/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

function echeck(str) {
		//alert(str);
		at="@";
		dot=".";
		lat=str.indexOf(at);
		lstr=str.length;
		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 checkContactForm(){
	var errorString = "There is an error with the data you enetered.  Please check the following items:\n\n";
	var emailCheck = false;
	var nameCheck = false;
	var catCheck = false;
	var msgCheck = false;
	var subCheck = false;
	
	if(document.getElementById('name').value!=""){
		nameCheck=true;
	} else {
		errorString+="-Name\n";
	}
	
	if(document.getElementById('email').value!=""&&echeck(document.getElementById('email').value)){
		emailCheck=true;
	} else {
		errorString+="-Email Address\n";
	}
	
	if(document.getElementById('subject').value!=""){
		subCheck=true;
	} else {
		errorString+="-Subject Line\n";
	}
	
	if(document.getElementById('category').selectedIndex.value!=""){
		catCheck=true;
	} else {
		errorString+="-Category\n";
	}
	
	if(document.getElementById('message').value!=""){
		msgCheck=true;
	} else {
		errorString+="-Message\n";
	}
	errorString+="\nPlease correct the above and try again.";
	
	if(!(emailCheck&&nameCheck&&catCheck&&msgCheck&&subCheck)){
		alert(errorString);
		return false;
	}else{
		return true;
	}
	
}
function checkWTL(){
	var errorString = "<ul>";
	var emailCheck = false;
	var fnameCheck = false;
	var lnameCheck = false;
	var phoneCheck = false;
	var compCheck = false;
	var hearCheck = false;
	
	if(document.getElementById('fname').value!=""){
		fnameCheck=true;
	} else {
		errorString+="<li>First Name is required</li>";
	}
	
	if(document.getElementById('lname').value!=""){
		lnameCheck=true;
	} else {
		errorString+="<li>Last Name is required</li>";
	}
	
	if(document.getElementById('email').value!=""&&echeck(document.getElementById('email').value)){
		emailCheck=true;
	} else {
		errorString+="<li>Email Address is required</li>";
	}
	
	if(document.getElementById('phone').value!=""){
		phoneCheck=true;
	} else {
		errorString+="<li>Phone Number Line</li>";
	}
	
	if(document.getElementById('comp').value!=""){
		compCheck=true;
	} else {
		errorString+="<li>Company Name is required\n";
	}
	if(document.getElementById('hearAboutUs').value!=""){
		hearCheck=true;
	} else {
		errorString+="<li>How did you hear about us required\n";
	}
	
	errorString+="</ul>";
	
	if(!(emailCheck && fnameCheck && lnameCheck && compCheck && phoneCheck && hearCheck)){
		//alert(errorString);
		document.getElementById('errorRow').style.display="block";
		document.getElementById('errorDiv').innerHTML=errorString;
		document.getElementById('showErrorMsg').style.display="inline";
		return false;
	}else{
		return true;
	}
	
}		
			
			
			
			
			