//button rollover affect + css style
function classChange(styleChange,item){
	item.className = styleChange;
}
//preload images
function preloader() 

{
     // counter
     var i = 0;
     // create object
     imageObj = new Image();
     // set image list
     images = new Array();
     images[0]="signupBtnRl.gif"
     images[1]="LoginBtn_8531roll.gif"
     //images[2]="image3.jpg"
     //images[3]="image4.jpg"
     // start preloading
     for(i=0; i<=3; i++) 
     {
          imageObj.src=images[i];
     }

} 


//this adjusts window to pictures width/height--need change all pages to use this
function openWin3(pic,w,h) {
  var features = "scrollbars=yes," + "width="+ w + ",height=" + h + ",left=" + ((screen.width - w)/2) + ",top=" + ((screen.height - h)/2) + ",screenX=" + ((screen.width - w)/2) + ",screenY=" +((screen.height - h)/2);
 myWin = window.open(pic,"",features);
}


//Form check and general purpose functions
     function checkPhone(phone){
		//phone numbers are accepted in the forms: (xxx)xxx-xxxx | xxx-xxx-xxxx | xxx xxx xxxx
		re = /^(\(\d{3})\)\d{3}-\d{4}$|^\d{3}-\d{3}-\d{4}$|^\d{3}\s\d{3}\s\d{4}$/;
		return re.test(phone);
	}

    function checkEmail(email){
	    //email = document.getElementById("email");
		email = email.toLowerCase();
		re = /^.+@[^\.].*\.[a-z]{2,}$/;
		return re.test(email);
	}
    function verifyEmail(){
	   var email = document.getElementById("email").value;
	   var emCheck = document.getElementById("emCheck").value;
	   //alert("emCheck" + document.getElementById("emCheck").value);
	   if (email != emCheck){
		 return false;
	   }else{
		 return true;
	   }
    }


    function checkZip(zip) {
	     re = /^\d{5}(-\d{4})?$|^ &/;
	     return re.test(zip);
	}

    //for contact form only
  	function checkForm(){
		var name = document.getElementById("name");
		var email = document.getElementById("email");
		//emCheck = document.getElementById("emCheck");
		phone = document.getElementById("phone");
		contact = document.getElementById("contact");

		if (name.value.length == 0){
			alert("You must enter a name");
			return false;
		}
		//check principal address
		if (document.forms[0].principalAddressCountry.value =="United States"){
			if ((document.forms[0].principalAddress.value == "") || (document.forms[0].principalAddressCity.value == "") || (document.forms[0].principalAddressState.selectedIndex == "") || (document.forms[0].principalAddressZip.value == "") )	{
				alert("business address");
				return false;
		   }
		}
		if (document.forms[0].principalAddressCountry.value !="United States"){
			if ((document.forms[0].principalAddress.value == "") || (document.forms[0].principalAddressCity.value == "") ){
				alert("business address");
				return false;
			}
		}
		if (checkPhone(phone.value) != true){	
			alert("Incorrect phone number format.");
			return false;
		}
		if (checkEmail(email.value) != true){
			alert("You must enter a valid email.");
			return false;
		}
		
		if (verifyEmail() != true){
			alert("Enter the same email ");
			return false;
		}
		if (document.forms[0].service[0].checked != true && document.forms[0].service[1].checked != true && document.forms[0].service[2].checked != true){
			alert("select a service");
			return false;
		}
	}
	
	//end contact form code

	
	///////////////// External  Links
	//no link display Does not include www
	function showLink(part1,part2,part3){
		var Link = part1+part2+part3;
		LinkDisplay = Link.split("?")[0];
		LinkDisplay= LinkDisplay.split("/")[0];
		document.write("<div class='resourcesLink'><a href='http://" + Link+  "' rel='nofollow' target='_blank' >http://" + LinkDisplay +"</a></div>" );
		
	}
	//no link display and https Secure Does not include www. 
		function showLinkSecure(part1,part2,part3){
		var Link = part1+part2+part3;
		LinkDisplay = Link.split("?")[0];
		LinkDisplay= LinkDisplay.split("/")[0];
		document.write("<div class='resourcesLink'><a href='https://" + Link+  "' rel='nofollow' target='_blank' >https://" + LinkDisplay +"</a></div>" );
		
	}

	function showL(part1,part2,part3){
		var Link = part1+part2+part3;
		LinkDisplay = Link.split("?")[0];
		LinkDisplay= LinkDisplay.split("/")[0];
		document.write("<div class='resourcesLink'><a href='http://www." + Link+  "' rel='nofollow' target='_blank' class='resourcesLink'>http://www." + LinkDisplay +"</a></div>" );
	}
		//no link display and https Secure. includes www
	function showLSecure(part1,part2,part3){
		var Link = part1+part2+part3;
		LinkDisplay = Link.split("?")[0];
		LinkDisplay= LinkDisplay.split("/")[0];
		document.write("<div class='resourcesLink'><a href='https://www." + Link+  "' rel='nofollow' target='_blank' class='resourcesLink'>https://www." + LinkDisplay +"</a></div>" );
		
	}
//////////////

         //link to NW database. no link display and https Secure. includes www
	function showNWLSecure(){
		parent.location='https://www.llcagent.com/affiliate/login.asp'
		
	}


	//no email display, different name to not conflict with showRA() hardcoded on pages
	function showRAemail(){
		var Name="fo@northw";
		var Server="estregiste";
		var Link = Name+Server;
		document.write("<a href='mailto:in" + Link+  "redagent.com'>"  );
		document.write("in" + Link + "redagent.com");
		document.write("</a>");
	}

	//no email display
	function showEm(Name,Server){
		var Link = Name+Server;
		document.write("<a href='mailto:" + Link +  "'>"  );
		document.write(Link);
		document.write("</a>");
	}



