/* 

NOTES:

brand_names: replace this word to tailor standard functionality such as validation, delete, posting



name_of_file: library of javascript to support brand_names
    david.kelly@fanore.com (http://www.fanore.com/website_design.htm)
    check_brand_names: validate the brand_names editing dialogue
    
    
*/


//check_brand_names: validate the brand_names editing dialogue
function check_brand_names(){
    var progress_bar_url=$F('progress_bar_url');
    
//brand_name
    if ($F('txt_title').blank()){
         show_error_message("please enter the brand name!",'error_message_panel');
        $('txt_title').focus();
        return false;
    }
//txt_seo_description
    if ($F('txt_seo_description').blank()){
         show_error_message("please enter a short narrative for this brand name!",'error_message_panel');
        $('txt_seo_description').focus();
        return false;
    }
//txt_keywords
 //   if ($F('txt_keywords').blank()){
 //        show_error_message("please enter keyword tags for this postcard!",'error_message_panel');
 //       $('txt_keywords').focus();
 //       return false;
 //   }
//  deal with image properties
    var has_picture=parseInt($F('has_picture')) //does this product already have an image ?
    var n_file=$F('picture') // has user selected an image
    
    //default value for replacing an image is NO
    $('change_picture').value='0'
    //if file not blank then reset replace image
    if (!n_file.blank()){
        //check that file is a JPG
        var m=n_file.toString().toLowerCase();
        var c=m.lastIndexOf(".")
        m=m.substr((c+1),4)
        if (m !='jpg'){
           show_error_message("please select a JPG for the picture !",'error_message_panel'); 
           $('picture').focus()
           return false;
        }
        $('change_picture').value='1'
        //double check that user wants to perform this action
        if (has_picture==1){
            if (!confirm("Please confirm that you wish to replace the picture currently being used!")){
                $('change_picture').value='0'
            }
        }
    }
    

    var el=get_el('FCKDATASOURCE');
    if (el){    
        var cEditor = FCKeditorAPI.GetInstance('txtHTML');
        var datasource_name = 'fd_description';
        //alert(datasource_name);
       $(datasource_name).value= cEditor.GetXHTML(true);
         
    }       
    $('url_payload').value=$F('url_params')
    //return false;
    $('save').target='keyhole'; 
// display a window indicating save progress 
    progress_window(progress_bar_url)         
    $('save').submit();

}
