// JavaScript Document
// Add trim functionality to String prototype
String.prototype.trim = function () { return this.replace(/^\s+|\s+$/g,''); };

// validate that the form controls have the correct value
function Validate()
{
	var isValid = true;
	var errorText = "Please amend the following errors:\r\n";
	
	var s = String( document.frmSearch.txtLocation.value );
	
	if ( s.trim().length == 0 )
	{				
		errorText = AddBreakToTextBlock(errorText, "\r\n" ) + "Enter a city town or postcode";
		isValid = false;
	}
	else
	{
		var loc = document.getElementById("txtLocation").value;
		var mapstyle = "mtGoogle";
		var searchAddr = dotdotpath + "SessionSearcher/ShowResults.aspx?Location=" + loc + "&MapStyle=" + mapstyle;
		document.frmSearch.action = searchAddr;
		//document.frmSearch.submit();
	}
	
  }

function SetStatus( checkControl )
{
	if ( checkControl != null )
	{
		if ( checkControl.id == "chkDateOn" )
		{
			document.frmSearch.chkDateAfter.checked = false;
			document.frmSearch.chkDateBefore.checked = false;
		}
		else
		{
			document.frmSearch.chkDateOn.checked = false;
		}
	}
}

function AddBreakToTextBlock( s, breaker )
{
	var s1 = String(s);
	
	if ( s1.length > 0 ) { s1 = s1+breaker; }
	
	return s1;
}
