// JavaScript Document
// Example:
// simplePreload( '01.gif', '02.gif' ); 
function simplePreload()
{ 
  var args = simplePreload.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}
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 checkPhoneNumber(){
	var x=document.formA.phone.value;
	var anum=/^(\(\d{3}\)|\d{3})\s*\d{3}\s*-?\s*\d{4}$/;

	if (anum.test(x))
		testresult=true;
	else{
		testresult=false;
	}
	return (testresult);
	//return (true);
}

function validateRegistration(){
	valid = true;
	msg = "";
	if (document.formA.contactName.value == "") {
		valid = false;
		msg = "Please enter Your Name";
		fieldFocus = "document.formA.name.focus()";
	} 
	if (document.formA.cityState.value == "") {
		valid = false;
		msg = "Please enter Your City and State";
		fieldFocus = "document.formA.cityState.focus()";
	} 
	if (document.formA.materials.value == "") {
		valid = false;
		msg = "Please enter the Materials Desired";
		fieldFocus = "document.formA.materials.focus()";
	} 
	if (valid && document.formA.phone.value ==""){
		valid = false;
		msg = "Please enter Your Phone Number";
		fieldFocus = "document.formA.phone.focus()";
	} 
	if (valid && document.formA.phone.value !=""){
		valid = checkPhoneNumber();
		if (!valid) {
			msg = "Invalid Phone Number\nPlease enter a Valid Phone Number";
			fieldFocus = "document.formA.phone.focus()";
		}
	} 
	if (valid && document.formA.email.value ==""){
		valid = false;
		msg = "Please enter Your Email Address";
		fieldFocus = "document.formA.email.focus()";
	} 
	if (valid && document.formA.email.value !=""){
		valid = echeck(document.formA.email.value) ;
		if (!valid) {
			msg = "Invalid E-mail Address\nPlease enter a Valid Email Address";
			fieldFocus = "document.formA.email.focus()";
		}
	}
	if (!valid) {
		alert(msg);
		eval(fieldFocus);
	} else {
		document.formA.submit();
	}
}
function popupRetailSpecial(linkNum) { //v2.0
  newWin = window.open('popupRetailSpecial.php?linkNum='+linkNum,'viewImage','scrollbars=1,menubar=0,toolbar=0,location=0,resizable=1,status=0,width=700,height=400');
}
function popupResellerSpecial(linkNum) { //v2.0
  newWin = window.open('res_popupSpecial.php?linkNum='+linkNum,'viewImage','scrollbars=1,menubar=0,toolbar=0,location=0,resizable=1,status=0,width=700,height=400');
}

