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('startDateSearch_p');
toggleHelp('endDateSearch_p');
/*
toggleHelp('jobtypes_p');
*/
}

function sf(){document.form.realname.focus();} 


function validateform()
{
    
	//alert("test");
	
	var formobj;
	formobj = document.frmplanning;
	valid = true;
	//ref_no, site_postcode, site_address, agent_name,applicant,startDateSearch,endDateSearch
//fill in at least one field  && formobj.weeklylist.value == ""
    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 == "" && formobj.apptype.value == "" )
    {
        alert ( "Please fill in at least one of the search fields." );
		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;
	}
	*/
	
    return valid;

}


function ClearForm()
{
//ref_no, site_postcode, site_address,area,agent_name,applicant,startDateSearch,endDateSearch
//document.frmplanning.weeklylist.value = "";
document.genericform.apptype.value = "";
document.genericform.ref_no.value = "";
document.genericform.site_postcode.value = "";
document.genericform.site_address.value = "";
document.genericform.area.value = "";
//document.frmplanning.agent_name.value = "";
//document.frmplanning.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 = '';
	}
}
