

//check_ukprovider: validate dialogue is complete
function check_ukprovider(){


    var progress_bar_url=$F('progress_bar_url');
    
/* Business name and address */

//company
    if ($F('company').blank()){
         show_error_message("please enter the company name!",'error_message_panel');
        $('company').focus();
        return false;
    }
//contact
    if ($F('contact').blank()){
         show_error_message("please enter the contact name!",'error_message_panel');
        $('contact').focus();
        return false;
    }
//address1
    if ($F('address1').blank()){
         show_error_message("please enter the full postal address!",'error_message_panel');
        $('address1').focus();
        return false;
    }
//address2
    if ($F('address2').blank()){
         show_error_message("please enter the full postal address!",'error_message_panel');
        $('address2').focus();
        return false;
    }
//address3
    if ($F('address3').blank()){
         show_error_message("please enter the full postal address!",'error_message_panel');
        $('address3').focus();
        return false;
    }
//address4
    if ($F('address4').blank()){
         show_error_message("please enter the full postal address!",'error_message_panel');
        $('address4').focus();
        return false;
    }
//postcode
    if ($F('postcode').blank()){
         show_error_message("please enter the full postal address!",'error_message_panel');
        $('postcode').focus();
        return false;
    }
//lattitude
//longtitude
//template
    if ($F('templatekey').blank()){
         show_error_message("please select the template to use when presenting this service provider!",'error_message_panel');
        $('templatekey').focus();
        return false;
    }
/* END Business name and address */


/* Contact Details*/
//telephone
    var telephone=fix_telephone($F('telephone'));
    $('telephone').value=telephone;
    if ($F('telephone').blank()){
         show_error_message("please enter the telephone number!",'error_message_panel');
        $('telephone').focus();
        return false;
    }
//mobile
    var mobile=fix_telephone($F('mobile'));
    $('mobile').value=mobile;
    //fax
    var fax=fix_telephone($F('fax'));
    $('fax').value=fax;

//email
    if ($F('email').blank()){
         show_error_message("please enter the email address!",'error_message_panel');
        $('email').focus();
        return false;
    }
    var email=$F('email')
    if (!fixstring(email,true)){
        alert("Please check the email address as it does not seem to be valid!");
        $('email').focus();
        return false;
    }
    
//

/* END Contact Details*/


/* Search Optimisation */
//seo_title
//seo_keywords
//txt_seo_description

    if ($F('seo_title').blank()){
         show_error_message("please enter a search engine optimised title for the provider!",'error_message_panel');
        $('seo_title').focus();
        return false;
    }



/* END Search Optimisation */

/* Business Card */
//txt_strap_line

//txt_abstract
    if ($F('txt_abstract').blank()){
         show_error_message("please enter a summary of the business for use on the business card page!",'error_message_panel');
        $('txt_abstract').focus();
        return false;
    }



/* END Business Card */

/* Business Details */
    var el=get_el('FCKDATASOURCE');
    if (el){    
        var cEditor = FCKeditorAPI.GetInstance('txtHTML');
        var datasource_name = 'fd_description';
        var buffer=cEditor.GetXHTML(true);
        if (buffer.length!=0){
            $(datasource_name).value= buffer;
        }
         
    }       

/* END Business Details */

/* Picture*/

    var has_picture=parseInt($F('has_picture')) //does this record 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 provider!")){
                $('change_picture').value=0
            }
        }
    }


/* END Picture*/

/* Territories */
/* END Territories */

    $('save').target='keyhole'; 
// display a window indicating save progress 
    progress_window(progress_bar_url)         
    $('save').submit();

}


//refreshTerritory: react to user selecting a territory from the drop down listing
function refreshTerritory(){
    var t=$F('list_territories');
    alert(t);
    return false;
}





//check_ieprovider: validate dialogue is complete
function check_ieprovider(){


    var progress_bar_url=$F('progress_bar_url');
    
/* Business name and address */

//company
    if ($F('company').blank()){
         show_error_message("please enter the company name!",'error_message_panel');
        $('company').focus();
        return false;
    }
//contact
    if ($F('contact').blank()){
         show_error_message("please enter the contact name!",'error_message_panel');
        $('contact').focus();
        return false;
    }
//address1
    if ($F('address1').blank()){
         show_error_message("please enter the full postal address!",'error_message_panel');
        $('address1').focus();
        return false;
    }
//address2
//    if ($F('address2').blank()){
//         show_error_message("please enter the full postal address!",'error_message_panel');
//        $('address2').focus();
//        return false;
//    }
//address3
    if ($F('address3').blank()){
         show_error_message("please enter the full postal address!",'error_message_panel');
        $('address3').focus();
        return false;
    }
//address4
    if ($F('address4').blank()){
         show_error_message("please enter the full postal address!",'error_message_panel');
        $('address4').focus();
        return false;
    }

//lattitude
//longtitude
/* END Business name and address */


/* Contact Details*/
//telephone
    var telephone=fix_telephone($F('telephone'));
    $('telephone').value=telephone;
    if ($F('telephone').blank()){
         show_error_message("please enter the telephone number!",'error_message_panel');
        $('telephone').focus();
        return false;
    }
//mobile
    var mobile=fix_telephone($F('mobile'));
    $('mobile').value=mobile;
    //fax
    var fax=fix_telephone($F('fax'));
    $('fax').value=fax;

//email
    if ($F('email').blank()){
         show_error_message("please enter the email address!",'error_message_panel');
        $('email').focus();
        return false;
    }
    var email=$F('email')
    if (!fixstring(email,true)){
        alert("Please check the email address as it does not seem to be valid!");
        $('email').focus();
        return false;
    }
    
//

/* END Contact Details*/


/* Search Optimisation */
//seo_title
//seo_keywords
//txt_seo_description

    if ($F('seo_title').blank()){
         show_error_message("please enter a search engine optimised title for the provider!",'error_message_panel');
        $('seo_title').focus();
        return false;
    }



/* END Search Optimisation */

/* Business Card */
//txt_strap_line

//txt_abstract
    if ($F('txt_abstract').blank()){
         show_error_message("please enter a summary of the business for use on the business card page!",'error_message_panel');
        $('txt_abstract').focus();
        return false;
    }



/* END Business Card */

/* Business Details */
    var el=get_el('FCKDATASOURCE');
    if (el){    
        var cEditor = FCKeditorAPI.GetInstance('txtHTML');
        var datasource_name = 'fd_description';
        var buffer=cEditor.GetXHTML(true);
        if (buffer.length!=0){
            $(datasource_name).value= buffer;
        }
         
    }       

/* END Business Details */

/* Picture*/

    var has_picture=parseInt($F('has_picture')) //does this record 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 provider!")){
                $('change_picture').value=0
            }
        }
    }


/* END Picture*/

/* Territories */
/* END Territories */

    $('save').target='keyhole'; 
// display a window indicating save progress 
    progress_window(progress_bar_url)         
    $('save').submit();

}














