function goto(pagename)	{
	var rootURL = '';
	var filename = pagename;
	window.location=rootURL + pagename;
}

function rolloverLNav (id,obj)	{
	document.getElementById(id).style.backgroundImage = 'none';
	document.getElementById(id).style.color = '#FFFFFF';	
	obj.style.cursor = 'hand';
	obj.style.cursor = 'pointer';
}

function rolloutLNav (id,bgimage)	{
	var bgimg = bgimage;
	document.getElementById(id).style.backgroundImage = "url("+bgimg+")";
	document.getElementById(id).style.color = '#666666';
}



email_msg = 'Please enter a valid e-mail address';

function checkFormFields() {
	checkCommonField('title');
	checkCommonField('firstname');
	checkCommonField('lastname');
	checkCommonField('street');
	checkCommonField('city');
	checkCommonField('postcode');
	checkCommonField('test');
}

function checkCommonField(fid) {
	var fieldVal = document.getElementById(fid).value;
  	if (fieldVal == '' || fieldVal == null) {
  		completeFields = false;
  	}
	// validate email
	else if (fid=='test'){
  		if (echeck(fieldVal)==false)	{			
			emailField = false;
		}			
  	}
}

function sendDetails() {
	completeFields = true;
	emailField = true;
	checkFormFields();
	 if(completeFields == true &&  emailField == true) {
	 	document.getElementById('webform').submit();
	 }
 	 else {
		if (completeFields == false)	{
  			alert('Please complete all fields');
		}
		else {
			alert(email_msg);
		}
 	}				
}

function echeck(str) {
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	if (str.indexOf(at)==-1){		   
	   return false;
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){		 
	   return false;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		return false;
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		return false;
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return false;
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		return false;
	 }
	
	 if (str.indexOf(" ")!=-1){
		return false;
	 }
	 return true;				
}






