/* 
Eastcoast Technology Javascripts 
Modified 09262006

*/
// function check to see if object is null

function validateRequired(theField,theFieldName){
var result;
	if (theField.value==""){
		result=false;
		alert(theFieldName + ' is a Required field');
		theField.focus();}
	else{result=true;}
return result;
}




// function validates the contact us form
function validateform(theForm){
theForm.psubmit.disabled=true;

if (!validateRequired(theForm.pname,'Your Name')){theForm.psubmit.disabled=false; return false};
if (!validateRequired(theForm.paddress,'Address')){theForm.psubmit.disabled=false;return false};
if (!validateRequired(theForm.pcity,'City')){theForm.psubmit.disabled=false;return false};
if (!validateRequired(theForm.pzip,'Zip')){theForm.psubmit.disabled=false;return false};
if (!validateRequired(theForm.pcountry,'Country')){theForm.psubmit.disabled=false;return false};
if (!validateRequired(theForm.pphone,'Phone')){theForm.psubmit.disabled=false;return false};

theForm.psubmit.value='Processing...';
return true;
}



function activate(theField){
theField.style.background="#FFFFCC";
}

function inactivate(theField){
theField.style.background="#FFFFFF";
}



var xmlHttp


function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}


function validateCode(randno)
{
str = document.checker.txt1.value;


if (str.length==0)
  { 
	 
 document.checker.txt1.value="";
 alert("Please enter the letters/numbers in the box provided.");
 document.checker.txt1.focus();
  return false;
  }



if (document.checker.txt1.value == document.getElementById("c").innerHTML)
{
document.checker.submit_btn.disabled=true;
document.checker.action="/cgi-bin/ect/confirm.pl/do.finalize";
document.checker.submit(); return true;
}else{
alert("Invalid Code");
return false;
}


















xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 

var url="/cgi-bin/ect/confirm.pl/do.check";


url=url+"?q="+str;
url=url+"&pname="+document.checker.pname.value;

url=url+"&pcompanyname="+document.checker.pcompanyname.value;
url=url+"&pcompanysize="+document.checker.pcompanysize.value;
url=url+"&pcompanywebsite="+document.checker.pcompanywebsite.value;

url=url+"&pcompanycategory="+document.checker.pcompanycategory.value;
url=url+"&paddress="+document.checker.paddress.value;
url=url+"&pcity="+document.checker.pcity.value;
url=url+"&pprovince="+document.checker.pprovince.value;
url=url+"&pstate="+document.checker.pstate.value;
url=url+"&pzip="+document.checker.pzip.value;
url=url+"&pcountry="+document.checker.pcountry.value;
url=url+"&pemail="+document.checker.pemail.value;
url=url+"&pphone="+document.checker.pphone.value;
url=url+"&pfax="+document.checker.pfax.value;

url=url+"&pcomments="+document.checker.pcomments.value;

url=url+"&pcontactmethod="+document.checker.pcontactmethod.value;
url=url+"&rand_no="+randno;


url=url+"&sid="+Math.random();

xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} 

function stateChanged() 
{ 

if (xmlHttp.readyState==4)
{ 


if (xmlHttp.responseText.match("MATCH"))
{document.checker.submit_btn.disabled=true;
document.checker.action="/cgi-bin/ect/confirm.pl/do.finalize";
document.checker.submit(); return true;
}else{
document.getElementById("response").innerHTML=xmlHttp.responseText;
document.getElementById("response").style.display="inline";
}}

return false;
}


function roll(img_name, img_src)
   {
   document[img_name].src = img_src;
   }
function newwin(url,name){
winname=name;
if (!winname)
{winname='Window';
}
window.open(url,winname,"top=50 left=50 scrollbars=yes height=480  width=680  location=no menubar=yes resizable");
}
