function domail()
{
 var blValid=true;
 var strName='';
 var strEmail='';
 var strEnq='';
 strName=document.getElementById("txtName").value;
 if(strName=='')
 {
  alert('\n\nPlease enter your name.     \n\n');
  blValid=false;
  return;
 }
 strEmail=document.getElementById("txtEmail").value;
 if(strEmail=='')
 {
  alert('\n\nPlease enter your email address.     \n\n');
  blValid=false;
  return;
 } 
 if(checkmail(strEmail)==false)
 {
 	alert('\n\nPlease enter a valid email address.     \n\n');
  blValid=false;
  return;
 }
 strEnq=document.getElementById("txtEnq").value;
 if(strEnq=='')
 {
  alert('\n\nPlease enter your enquiry.     \n\n');
  blValid=false;
  return;
 } 
 if(blValid)
 {
  fetch('post.aspx?n='+strName+'&e='+strEmail+'&q='+strEnq,'contact');
 } 
}
function checkmail(strEmail)
{
 var strAt="@";
 var strDot=".";
 var intAt=strEmail.indexOf(strAt);
 var intStr=strEmail.length;
 var intStrDot=strEmail.indexOf(strDot);
 if(strEmail.indexOf(strAt)==-1)
 {
	return false;
 }
 if(strEmail.indexOf(strAt)==-1||strEmail.indexOf(strAt)==0||strEmail.indexOf(strAt)==intStr)
 {
	return false;
 }
 if(strEmail.indexOf(strDot)==-1||strEmail.indexOf(strDot)==0||strEmail.indexOf(strDot)==intStr)
 {
	return false;
 }
 if(strEmail.indexOf(strAt,(intAt+1))!=-1)
 {
	return false;
 }
 if(strEmail.substring(intAt-1,intAt)==strDot||strEmail.substring(intAt+1,intAt+2)==strDot)
 {
	return false;
 }
 if(strEmail.indexOf(strDot,(intAt+2))==-1)
 {
	return false;
 }
 if(strEmail.indexOf(" ")!=-1)
 {
	return false;
 }
 return true;				
}
function stat()
{
 window.status='Done';
 return true;
}
function domap(strBranch)
{
 var strPostcode=document.getElementById("txtPostcode").value;
 switch(strBranch)
 {
 	case'grays':
 	 window.open("http://maps.google.co.uk/maps?daddr=Thurrock+RM17+5XE+%4051.477613,0.307543&geocode=&dirflg=&saddr="+strPostcode+"&f=d&sll=51.477613,0.307543&sspn=0.001196,0.002403&ie=UTF8&t=h&z=11","map","toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=600,top=20,left=20");
 	 break;
 	default:
	 window.open("http://maps.google.co.uk/maps?f=d&source=s_d&saddr="+strPostcode+"&daddr=SX+Heating+%26+Plumbing+%4051.57710954255125,0.40285706520080566&geocode=%3BFRYBEwMdqSUGAA&hl=en&mra=ls&sll=51.57765,0.403453&sspn=0.002394,0.004807&ie=UTF8&t=h&z=12","map","toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=600,top=20,left=20");
	 break;
 }
}
function dolink(strLink)
{
	window.open("http://"+strLink,"link","toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=600,top=20,left=20");
}
function fetch(page,div)
{
 var objDiv=document.getElementById(div);
 objDiv.innerHTML='Loading...';
 var objZap=new zap(page,function(strContent)
 {
 	objDiv.innerHTML=strContent;
 });
 objZap.doGet();
}
function zap(URL,content)
{
 var objReq=go();
 objReq.onreadystatechange=snaffle;
 function go()
 {
  if(window.XMLHttpRequest)
  {
   return new XMLHttpRequest();
  }
  else if(window.ActiveXObject)
  {
   return new ActiveXObject("Microsoft.XMLHTTP");
  }
 }    
 function snaffle()
 {
  if(objReq.readyState==4)
  {
   if(objReq.status==200)
   {
    if(content)
    {
     content(objReq.responseText);
    }
   }
  }
 }
 this.doGet=function()
 {
  objReq.open("GET",URL,true);
  objReq.send(null);
 }
}
var kjlegg=
{
 input:"",
 clear:setTimeout('kjlegg.clear_input()',2000),
 load:function(link)
 {
 	window.document.onkeyup = function(e)
 	{
 	 kjlegg.input+= e?e.keyCode:event.keyCode;
   if(kjlegg.input=="3838404037393739666513")
   {
    kjlegg.code(link);
    clearTimeout(kjlegg.clear);
   }
   clearTimeout(kjlegg.clear);
   kjlegg.clear=setTimeout("kjlegg.clear_input()",2000);
  }
 },
 code:function(link)
 {
 	window.location=link
 },
 clear_input:function()
 {
  kjlegg.input="";
  clearTimeout(kjlegg.clear);
 }
}
