window.onload = function() {
toggleAllHelp();
//sf();
}

function toggleHelp(obj) {
var helptext = document.getElementById(obj);
helptext.style.display = 'none';
}

function toggleAllHelp () {
toggleHelp('ref_no_p');
toggleHelp('site_postcode_p');
toggleHelp('site_address_p');
toggleHelp('agent_name_p');
toggleHelp('applicant_p');

toggleHelp('startDateSearch_p');
toggleHelp('endDateSearch_p');







/*
toggleHelp('jobtypes_p');
*/
}


function sf(){document.form.realname.focus();}


function validateform()
{
    
	//alert("test");
	
	var formobj;
	formobj = document.genericform;
	valid = true;
	//ref_no, site_postcode, site_address, agent_name,applicant,startDateSearch,endDateSearch
//formobj.applicantfirstname.value == "" && formobj.applicantsurname.value == "" &&
//fill in at least one field
    if ( formobj.ref_no.value == "" && formobj.site_postcode.value == "" && formobj.site_address.value == "" && 
	formobj.agent_name.value == "" && formobj.applicant.value == "" &&  formobj.startDateSearch.value == "" && 
	formobj.endDateSearch.value == "" && formobj.area.value == "" && formobj.ward.value == "" && formobj.parish.value == "" )
    {
        alert ( "Please fill in at least one of the search fields." ); 
		valid = false;
    }
	
	/*if (formobj.weeklylist.value != "" && formobj.area.value == "")
	{
		alert ( "You have selected a weekly list date but have not specified an area.  Please specify a site area from the drop down." );
		formobj.area.focus();
        valid = false;
	}*/
	
	if (formobj.startDateSearch.value != "" && formobj.endDateSearch.value == "")
	{
		alert ( "Please fill in the 'to date'." );
		formobj.endDateSearch.focus();
        valid = false;
	}
	
	if (formobj.startDateSearch.value == "" && formobj.endDateSearch.value != "")
	{
		alert ( "Please fill in the 'from date'." );
		formobj.startDateSearch.focus();
        valid = false;
	}
	
	if (formobj.ref_no.value != "" && formobj.ref_no.value.length <= 3 )
	{
		alert ( "Please fill in the reference number with more than 3 characters." );
		formobj.ref_no.focus();
        valid = false;
	}
	
	if (formobj.site_postcode.value != "" && formobj.site_postcode.value.length <= 2 )
	{
		alert ( "Please fill in the site postcode with more than 2 characters." );
		formobj.site_postcode.focus();
        valid = false;
	}
	
	if (formobj.site_address.value != "" && formobj.site_address.value.length <= 2 )
	{
		alert ( "Please fill in the site address with more than 2 characters." );
		formobj.site_address.focus();
        valid = false;
	}
	
	if (formobj.agent_name.value != "" && formobj.agent_name.value.length <= 2 )
	{
		alert ( "Please fill in the agent name with more than 2 characters." );
		formobj.agent_name.focus();
        valid = false;
	}
	
	if (formobj.applicant.value != "" && formobj.applicant.value.length <= 2 )
	{
		alert ( "Please fill in the applicant with more than 2 characters." );
		formobj.applicant.focus();
        valid = false;
	}
	
	/*if (formobj.applicantfirstname.value != "" && formobj.applicantfirstname.value.length <= 2 )
	{
		alert ( "Please fill in the applicant firstname with more than 2 characters." );
		formobj.applicantfirstname.focus();
        valid = false;
	}
	
	if (formobj.applicantsurname.value != "" && formobj.applicantsurname.value.length <= 2 )
	{
		alert ( "Please fill in the applicant surname with more than 2 characters." );
		formobj.applicantsurname.focus();
        valid = false;
	}*/
	
    return valid;
 
}


function ClearForm()
{
//ref_no, site_postcode, site_address,area,agent_name,applicant,startDateSearch,endDateSearch
//document.frmplanning.weeklylist.value = "";
document.genericform.ref_no.value = "";
document.genericform.site_postcode.value = "";
document.genericform.site_address.value = "";
document.genericform.area.value = "";
document.genericform.agent_name.value = "";
//document.frmplanning.applicantfirstname.value = "";
//document.frmplanning.applicantsurname.value = "";
document.genericform.applicant.value = "";
document.genericform.startDateSearch.value = "";
document.genericform.endDateSearch.value = "";

document.genericform.ward.value = "";
document.genericform.parish.value = "";

}

function ClearFormWeekly()
{
	document.genericform.area.value = "";
	document.genericform.weeklylist.value = "";
}


function toggle(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}
