
var	ss_blank_str			= "(Search word)",
		postcode_blank_str	= "(Postcode, Suburb, Town)"
		BusinessSS_blank_str	= "(Business Name)",
		emtpy_blank_str		= "";

function window_onload() 
{
	// Disable any fields which are redundant.
	if (document.SearchForm.CatID.value != emtpy_blank_str)
		document.SearchForm.ss.disabled = true;
		
	if (document.SearchForm.ss.value != emtpy_blank_str && document.SearchForm.ss.value != ss_blank_str)
		document.SearchForm.CatID.disabled = true;
		
	// Initialise any empty fields.
	if (document.SearchForm.ss.value == emtpy_blank_str)
		document.SearchForm.ss.value = ss_blank_str;
		
	if (document.SearchForm.postcode.value == emtpy_blank_str)
		document.SearchForm.postcode.value = postcode_blank_str;
		
	if (document.SearchForm.BusinessSS.value == emtpy_blank_str)
		document.SearchForm.BusinessSS.value = BusinessSS_blank_str;
}

function form_verify(form)
{
	if (form.BusinessSS.value == BusinessSS_blank_str && (form.postcode.value == emtpy_blank_str || form.postcode.value == postcode_blank_str))
	{
		alert("Please indicate your locality by Entering your postcode, Suburb or Town");

		if (form.postcode.disabled == false)
			form.postcode.focus();

		return false;
	}
	return true;
}

function Searchform_onsubmit(form)
{
	if (!form_verify(form)) 
		return false; 
		
	if (form.postcode.value == postcode_blank_str) 
		form.postcode.value = emtpy_blank_str; 
		
	if (form.ss.value== ss_blank_str) 
		form.ss.value = emtpy_blank_str; 
	
	if (form.BusinessSS.value == BusinessSS_blank_str) 
		form.BusinessSS.value = emtpy_blank_str; 
		
	return true;
}


function BusinessSS_onfocus(obj)
{
	if (obj.value == BusinessSS_blank_str) 
		obj.value = emtpy_blank_str; 
		
	obj.select(); 
	return true;
}

function BusinessSS_onblur(obj)
{
	if (obj.value == emtpy_blank_str) 
		obj.value = BusinessSS_blank_str; 
}

function RegionID_onchange(obj)
{
	if (obj.value == emtpy_blank_str) 
		document.SearchForm.postcode.disabled=false; 
	else 
		document.SearchForm.postcode.disabled=true;
}

function postcode_onfocus(obj)
{
	if (obj.value == postcode_blank_str) 
		obj.value = emtpy_blank_str; 
		
	obj.select();
	return true;
}

function postcode_onblur(obj)
{
	if (obj.value == emtpy_blank_str) 
		obj.value = postcode_blank_str; 
	else if (document.SearchForm.BusinessSS.value != BusinessSS_blank_str)
		document.SearchForm.BusinessSS.value = BusinessSS_blank_str;
}

function CatID_onchange(obj)
{
	if (obj.value == emtpy_blank_str) 
		document.SearchForm.ss.disabled=false; 
	else 
	{
		document.SearchForm.ss.disabled=true;
		if (document.SearchForm.BusinessSS.value != BusinessSS_blank_str)
			document.SearchForm.BusinessSS.value = BusinessSS_blank_str;
	}
}

function ss_onfocus(obj)
{
	if (obj.value == ss_blank_str) 
		obj.value = emtpy_blank_str;
	
	obj.select();
	return true;
}

function ss_onblur(obj)
{
	if (obj.value == emtpy_blank_str) 
	{ 
		obj.value = ss_blank_str; 
		document.SearchForm.CatID.disabled = false; 
	} 
	else 
	{
		document.SearchForm.CatID.disabled = true;

		if (document.SearchForm.BusinessSS.value != BusinessSS_blank_str)
			document.SearchForm.BusinessSS.value = BusinessSS_blank_str;
	}
}

