// JScript File
function newWindow(theUrl){
	window.open(theUrl,"_blank","toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=1024,height=768");
}

function submitEnquiry() {
	   var errorMsg = "";
	   
	   if (document.getElementById("name").value == '')
	   {
		   errorMsg += "You must enter your name.\n"
	   }
	   if (document.getElementById("phone").value == '')
	   {
		   errorMsg += "You must enter your phone number.\n"
	   }
	   else if (!document.getElementById("phone").value == '')
	   {
		   if (IsNumeric(document.getElementById("phone").value) == false)
		   {
			   errorMsg += "Your phone number must only contain numbers.\n"
		   }
	   }
	   if (document.getElementById("email").value == '')
	   {
		   errorMsg += "You must enter your email address.\n"
	   }
	   else if (echeck(document.getElementById("email").value) == false)
	   {
		   errorMsg += "Your email address is invalid.\n"
	   }
	if (!errorMsg == '')
	{
		alert (errorMsg)
		return false
	}
	else
	{
		return true
	}
}

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					
}
	
function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }
