/* 

NOTES:

promotional_panels: replace this word to tailor standard functionality such as validation, delete, posting



name_of_file: library of javascript to support promotional_panels
    david.kelly@fanore.com (http://www.fanore.com/website_design.htm)
    check_promotional_panels: validate the promotional_panels editing dialogue
    
    
*/


//check_promotional_panels: validate the promotional_panels editing dialogue
function check_promotional_panels(){
    var progress_bar_url=$F('progress_bar_url');
    
//site_id: which website for the panel?
    if ($F('site_id').blank()){
         show_error_message("please select the website!",'error_message_panel');
        $('site_id').focus();
        return false;
    }
//panel_context: where will the panel appear?
    if ($F('context').blank()){
         show_error_message("please select the type of promotional panel!",'error_message_panel');
        $('context').focus();
        return false;
    }

//panel_link_type: what will it link to?
    if ($F('panel_link_type').blank()){
         show_error_message("please select the destination (link) for this promotional panel!",'error_message_panel');
        $('panel_link_type').focus();
        return false;
    }

//panel_link_id: valid id selected ?
/*
    if ($F('panel_link_id').blank()){
         show_error_message("please select the destination (link) for this promotional panel!",'error_message_panel');
        $('panel_link_type').focus();
        return false;
    }
*/
//caption: required

//    if ($F('caption').blank()){
//         show_error_message("please enter a caption for this promotional panel!",'error_message_panel');
//        $('caption').focus();
//        return false;
//    }



//strap_line
    if ($F('strap_line').blank()){
         show_error_message("please enter a strap line for this promotional panel!",'error_message_panel');
        $('strap_line').focus();
        return false;
    }
//panel_type
 //   if ($F('txt_keywords').blank()){
 //        show_error_message("please enter keyword tags for this promotional panel!",'error_message_panel');
 //       $('txt_keywords').focus();
 //       return false;
 //   }
//  deal with image properties
    var has_picture=parseInt($F('has_picture')) //does this promotional panel 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 used for this promotional panel!")){
                $('change_picture').value='0'
            }
        }
    }
    
    $('url_payload').value=$F('url_params')
    //return false;
    $('save').target='keyhole'; 
// display a window indicating save progress 
    progress_window(progress_bar_url)         
    $('save').submit();

}
