<!--

//*********************************************************************
//Style Sheet Class Reference
function textFocus(tcTextField, p_required)  {
	//tcTextField.className = "formInputFocus_txt";
	this.focusRowTitle(tcTextField.name, p_required)
}

function textBlur(tcTextField, p_required) {
	//var className = (p_required) ? "formInputRequired_txt" : "formInput_txt";
	//tcTextField.className = className;
	this.blurRowTitle(tcTextField.name)
}

function focusRowTitle(p_name){
	switch(p_name){
		case "hearAbout_txt":
			p_name = "t_hearAbout";
			break;
		default:
			p_name = "t_" + p_name;
			break;
	
	}
	
	var divID = document.getElementById(p_name);
	divID.className = "fieldFocus";
}

function blurRowTitle(p_name){
	switch(p_name){
		case "hearAbout_txt":
			p_name = "t_hearAbout";
			break;
		default:
			p_name = "t_" + p_name;
			break;
	
	}

	var divID = document.getElementById(p_name);		
	divID.className = "fieldTitle";
}

function pageLoaded(){	
	document.forms[0].firstName.focus();
}

function verifyMainContact(){

	var formDoc = document.forms[0];
	var errorMsg = "";
		
	if(!checkValue(formDoc.firstName.value, 2)){
		errorMsg = "Please Enter Your First Name \r"
		throwErrorFocus("t_firstName");
	};

	if(!checkValue(formDoc.lastName.value, 2)){
		errorMsg += "Please Enter Your Last Name \r";
		throwErrorFocus("t_lastName");
	};
	
	if(!checkValue(formDoc.company.value, 2)){
		errorMsg += "Please Enter A Company Name \r";
		throwErrorFocus("t_company");
	};
	
	
	var tmpAddress = formDoc.addressOne.value.split(" ");
	if(tmpAddress[0].length < 1 || tmpAddress[0] == ""){
		errorMsg += "Please Enter A Valid Address \r";
		throwErrorFocus("t_addressOne");
	}else if(tmpAddress[1].length < 1 || tmpAddress[1] == ""){
		errorMsg += "Please Enter A Valid Address \r";
		throwErrorFocus("t_addressOne");
	}
	
	if(!checkValue(formDoc.city.value, 2)){
		errorMsg += "Please Enter A City \r";
		throwErrorFocus("t_city");
	};
	
	
	if(formDoc.state.selectedIndex == 0 && formDoc.country.selectedIndex != 1){
		errorMsg += "Please Select A State \r";
		throwErrorFocus("t_state");
	}
	
	if(!checkValue(formDoc.postalCode.value, 2)){
		errorMsg += "Please Enter A Valid Zip/Postal Code \r";
		throwErrorFocus("t_postalCode");
	};
	
	
	if(formDoc.country.selectedIndex == 0){
		errorMsg += "Please Select A Country \r";
		throwErrorFocus("t_country");
	}
	
	if(!checkValue(formDoc.phone.value, 10)){
		errorMsg += "Please Enter A Valid Phone Number \r";
		throwErrorFocus("t_phone");
	};
	
	if(!checkEmail(formDoc.email.value)){
		errorMsg += "Please Enter A Valid Email Address \r";
		throwErrorFocus("t_email");
	}
	
	if(!checkValue(formDoc.productName.value)){
		errorMsg += "Please Enter A Valid Product Name \r";
		throwErrorFocus("t_email");
	}
		
	if(errorMsg.length > 1){
		alert(errorMsg);
		return false;
	}else{
		return true;	
	}
}

function checkValue(p_value, p_length){
	
	if(p_value.length < p_length || p_value == ""){
		return false;
	}
	
	if(!checkEmptySpaces(p_value)){
		return false;
	}
	
	return true;
}

function checkEmptySpaces(p_value){
	
	if(p_value == null) return false;
	
	// Check Empty spaces In A Row
	var emptySpaces = 0;
	for(var counter = 0; counter < p_value.length; counter++){
		if(p_value.substr(counter,1) == " "){
			emptySpaces++;
		}else{
			emptySpaces = 0;
		}
	}

	if(emptySpaces > 1){		
		return false;
	}else{
		return true;
	}
}

function throwErrorFocus(p_name){
	var divID = document.getElementById(p_name);
	divID.className = "titleRowError_295 columnTitle_Font";
}


function displayHearAbout_txt(p_show, p_text){
	var showBox = (p_show == "true") ? "visible" : "hidden";
	document.forms[0].hearAbout_txt.style.visibility = showBox;
	
	if(showBox == "visible"){
		document.forms[0].hearAbout_txt.value = p_text;
		document.forms[0].hearAbout_txt.focus();
		document.forms[0].hearAbout_txt.select();
	}
}

function checkEmail(emailStr){
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	var matchArray=emailStr.match(emailPat)

	if (matchArray==null) {
	   //alert("Email address seems incorrect (check @ and .'s)");
	   return false;
	}

	var user=matchArray[1];
	var domain=matchArray[2];

	if (user.match(userPat)==null) {
		   // user is not valid
		   //alert("The username doesn't seem to be valid.")
		   return false;
	}

	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
		   // this is an IP address
	   for (var i=1;i<=4;i++) {
		  if (IPArray[i]>255) {
			 alert("The email address Destination IP address is invalid!")
		 return false;
		  }
		   }
		return true;
	}

	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
	   //alert("The email address domain name doesn't seem to be valid.")
		   return false;
	}

	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	
	if (domArr[domArr.length-1].length<2 ||
		   domArr[domArr.length-1].length>3) {
	   //alert("The email address must end in a three-letter domain, or two letter country.")
	   return false;
	}

	if (len<2) {
	   //alert("The email address is missing a hostname!")
	   return false;
	}
	return true;
}





//-->
