window.onload = function(){
	//Rollover Preload
	rollover = new Image(); 
	rollover.src="../images/button-over.png"; 

	//Photographer Driven Join Rollover
	if (document.getElementById("signupbutton")) {
		var signupButton = document.getElementById("signupbutton");	
		signupButton.onmouseover = function(){
			this.setAttribute("src", "../images/sign-up-over.png");
		}
		signupButton.onmouseout = function(){
			this.setAttribute("src", "../images/sign-up.png");
		}
	}
	
	//Managed Join Rollover
	if (document.getElementById("inquire-button")) {
		var signupButton = document.getElementById("signupbutton");	
		signupButton.onmouseover = function(){
			this.setAttribute("src", "../images/inquire-button-over.png");
		}
		signupButton.onmouseout = function(){
			this.setAttribute("src", "../images/inquire-button.png");
		}
	}
	
	//Fundraisers Join Rollover
	if (document.getElementById("joinfundraisers")) {
		var signupButton = document.getElementById("joinfundraisers");	
		signupButton.onmouseover = function(){
			this.setAttribute("src", "../images/join-fundraisers-over.png");
		}
		signupButton.onmouseout = function(){
			this.setAttribute("src", "../images/join-fundraisers.png");
		}
	}
	
	//Sign In Button
	if(document.getElementById("join")){
		var joinButton = document.getElementById("join");
		joinButton.onmouseover = function(){
			this.setAttribute("src", "http://sales.simplephoto.com/images/joinbutton-over.png");
		}
		joinButton.onmouseout = function(){
			this.setAttribute("src", "http://sales.simplephoto.com/images/joinbutton.png");
		}
	}
	if(document.getElementById("signin")){
		var signinButton = document.getElementById("signin");
		signinButton.onmouseover = function(){
			this.setAttribute("src", "http://sales.simplephoto.com/images/signinbutton-over.png");
		}
		signinButton.onmouseout = function(){
			this.setAttribute("src", "http://sales.simplephoto.com/images/signinbutton.png");
		}
	}
	if(document.getElementById("inquire")){
		var inquireButton = document.getElementById("inquire");
		inquireButton.onmouseover = function(){
			this.setAttribute("src", "http://sales.simplephoto.com/images/inquirebuttonover.png");
		}
		inquireButton.onmouseout = function(){
			this.setAttribute("src", "http://sales.simplephoto.com/images/inquirebutton.png");
		}
	}
	
	//Services Rollover
	if (document.getElementById("services-table")) {
		var joinButton = document.getElementById("services-table").getElementsByTagName("img");
		for (i = 0; i < 3; i++) {
			joinButton[i].onmouseover = function(){
				this.setAttribute("src", "images/join-small-over.png");
			}
			joinButton[i].onmouseout = function(){
				this.setAttribute("src", "images/join-small.png");
			}
		}
	}
	
	//Sign In Form Cookie
	if(spcookie.cookieExists() && document.getElementById("loginForm")){
		var loginForm = document.getElementById("loginForm");
		loginForm.username.value = spcookie.getSubValue("uname");
		loginForm.pw.value = spcookie.getSubValue("pword");
		loginForm.rememberbox.checked = true;
	}
	
	//Pricing
	if (document.getElementById("markup")){
		var radio 	= document.getElementById("markup").getElementsByTagName("input");
		var td 		= document.getElementById("prices").getElementsByTagName("td");
		
		for (i = 0; i < 3; i++) {
			radio[i].onclick = function(){
				var factor = this.getAttribute("value");
				
				for (j = 0; j < td.length; j++) {
					if (td[j].getAttribute("class") == "number" || td[j].getAttribute("className") == "number") {
						var newValue = ((td[j].getAttribute("title") / 2) * factor) + (parseFloat(td[j].getAttribute("title") / 2));
						td[j].innerHTML = "$" + newValue.toFixed(2);
						td[j + 1].innerHTML = "$" + (newValue - (td[j].getAttribute("title") / 2)).toFixed(2);
						new Effect.Highlight(td[j],{startcolor:'#ffff99', endcolor:'#ffffff',duration: 0.75});
						new Effect.Highlight(td[j+1],{startcolor:'#ffff99', endcolor:'#ffffff',duration: 0.75});
					}
				}
			}
		}
	}
	
	//Toggle Program Explainers
	if(document.getElementById("joinoptions")){
		var linkAdvantage	= document.getElementById("advantagelink");
		var linkPremium		= document.getElementById("premiumlink");
		var linkFree		= document.getElementById("freelink");
		var closeAdvantage 	= document.getElementById("joinoptions").getElementsByTagName("h2")[0].getElementsByTagName("span")[0];
		var closePremium 	= document.getElementById("joinoptions").getElementsByTagName("h2")[1].getElementsByTagName("span")[0];
		var closeFree 		= document.getElementById("joinoptions").getElementsByTagName("h2")[2].getElementsByTagName("span")[0];
		
		linkAdvantage.onclick = function(){
			Effect.toggle('advantageexplainer','blind');
			return false;
		}
		linkPremium.onclick = function(){
			Effect.toggle('premiumexplainer','blind');
			return false;
		}
		linkFree.onclick = function(){
			Effect.toggle('freeexplainer','blind');
			return false;
		}
		
		closeAdvantage.onclick = function(){
			Effect.toggle('advantageexplainer','blind');
		}
		closePremium.onclick = function(){
			Effect.toggle('premiumexplainer','blind');
		}
		closeFree.onclick = function(){
			Effect.toggle('freeexplainer','blind');
		}
	}
	
	//Forgot Form Toggle
	if(document.getElementById("forgotpassword")){
		document.getElementById("forgotpassword").onclick=function(){
			//AutoFill Username If Exists
			document.getElementById("passwordForm").password_forgot.value = document.getElementById("loginForm").username.value;
			Effect.toggle('forgotformpassword','blind');
		}
	}
}

//Sign In Form Cookie
var spcookie = new CJL_CookieUtil("remembersplogin",100000);

function setRemember(){
	var loginForm = document.getElementById("loginForm");
		
	if(loginForm.rememberbox.checked){
		spcookie.setSubValue("uname", loginForm.username.value);
		spcookie.setSubValue("pword", loginForm.pw.value);
	}else{
		if(spcookie.cookieExists()){
			spcookie.expire();
		}
	}
}

function submitinquireform(){
	validateInquiry();
	document.forms[0].action = 'http://sales.simplephoto.com/photographer-driven/inquiry.php';
	document.forms[0].submit();
}

/**
 * Copyright (C) 2002-2003, CodeHouse.com. All rights reserved.
 * CodeHouse(TM) is a registered trademark.
 *
 * THIS SOURCE CODE MAY BE USED FREELY PROVIDED THAT
 * IT IS NOT MODIFIED OR DISTRIBUTED, AND IT IS USED
 * ON A PUBLICLY ACCESSIBLE INTERNET WEB SITE.
 * 
 * CodeHouse.com JavaScript Library Module: Cookie Utility Class
 *
 * You can obtain this script at http://www.codehouse.com
 */
function CJL_CookieUtil(name, duration, path, domain, secure){
   this.affix = "";
   if( duration ){   	  
      var date = new Date();
	  var curTime = new Date().getTime();
	  date.setTime(curTime + (1000 * 60 * duration));
	  this.affix = "; expires=" + date.toGMTString();
   }
   if( path ){
      this.affix += "; path=" + path;
   }
   if( domain ){
      this.affix += "; domain=" + domain;
   }
   if( secure ){
      this.affix += "; secure=" + secure;
   }
   function getValue(){
      var m = document.cookie.match(new RegExp("(" + name + "=[^;]*)(;|$)"));
      return m ? m[1] : null;   
   }
   this.cookieExists = function(){
      return getValue() ? true : false;
   }
   this.expire = function(){
      var date = new Date();
	  date.setFullYear(date.getYear() - 1);
	  document.cookie=name + "=noop; expires=" + date.toGMTString(); 
   }       
   this.setSubValue = function(key, value){
      var ck = getValue();
      if( /[;, ]/.test(value) ){
         //Mac IE doesn't support encodeURI
		 value = window.encodeURI ? encodeURI(value) : escape(value);
      }
      if( value ){
         var attrPair = "@" + key + value;
         if( ck ){
             if( new RegExp("@" + key).test(ck) ){
		        document.cookie =
				   ck.replace(new RegExp("@" + key + "[^@;]*"), attrPair) + this.affix;
	         }else{
		        document.cookie =
				   ck.replace(new RegExp("(" + name + "=[^;]*)(;|$)"), "$1" + attrPair) + this.affix;
	         }
         }else{
		 	document.cookie = name + "=" + attrPair + this.affix;
         }
      }else{      
	     if( new RegExp("@" + key).test(ck) ){
	        document.cookie = ck.replace(new RegExp("@" + key + "[^@;]*"), "") + this.affix;
	     }
      }
   }
	this.getSubValue = function(key){
      	var ck = getValue();
		if( ck ){
         var m = ck.match(new RegExp("@" + key + "([^@;]*)"));
		if( m ){
	        var value = m[1];
			if( value ){ 
	           //Mac IE doesn't support decodeURI
			   return window.decodeURI ? decodeURI(value) : unescape(value);
	        }
	     }
      }
   }
}

//Validation
function validate(){
	var error 			= document.getElementById("error");
	var input 			= document.getElementsByTagName("input");
	var select 			= document.getElementsByTagName("select");
	var errorMessage 	= "<strong>Oops. There was an error:</strong>";
	var numberOnly		= /\D/;
	var validEmail  	= /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	for (i = 0; i < input.length; i++) {
		var inputName 	= input[i].getAttribute("name");
		var inputLength	= input[i].value.length;
		
		if (inputName == "FirstName" && inputLength < 1) {
			errorMessage += "&#187; Please Enter Your First Name" + "<br />";
			input[i].setAttribute("class", "box errorbox");
			input[i].setAttribute("className", "box errorbox");
		}else if(inputName == "FirstName" && inputLength > 0){
			input[i].setAttribute("class", "box");
			input[i].setAttribute("className", "box");
		}
		if (inputName == "LastName" && inputLength < 1) {
			errorMessage += "&#187; Please Enter Your Last Name" + "<br />";
			input[i].setAttribute("class", "box errorbox");
			input[i].setAttribute("className", "box errorbox");
		}else if(inputName == "LastName" && inputLength > 0){
			input[i].setAttribute("class", "box");
			input[i].setAttribute("className", "box");
		}
		if (inputName == "CompanyName" && inputLength < 1) {
			errorMessage += "&#187; Please Enter Your First Name" + "<br />";
			input[i].setAttribute("class", "box errorbox");
			input[i].setAttribute("className", "box errorbox");
		}else if(inputName == "CompanyName" && inputLength > 0){
			input[i].setAttribute("class", "box");
			input[i].setAttribute("className", "box");
		}
		if (inputName == "Address" && inputLength < 1) {
			errorMessage += "&#187; Please Enter Your Address" + "<br />";
			input[i].setAttribute("class", "box errorbox");
			input[i].setAttribute("className", "box errorbox");
		}else if(inputName == "Address" && inputLength > 0){
			input[i].setAttribute("class", "box");
			input[i].setAttribute("className", "box");
		}
		if (inputName == "City" && inputLength < 1) {
			errorMessage += "&#187; Please Enter Your City" + "<br />";
			input[i].setAttribute("class", "box errorbox");
			input[i].setAttribute("className", "box errorbox");
		}else if(inputName == "City" && inputLength > 0){
			input[i].setAttribute("class", "box");
			input[i].setAttribute("className", "box");
		}
		if(select[0].selectedIndex == 0 && i==8) {
			errorMessage += "&#187; Please Enter Your State" + "<br />";
			select[0].setAttribute("class", "state errorbox");
			select[0].setAttribute("className", "state errorbox");			
		}else if(select[0].selectedIndex != 0 && i==8){
			select[0].setAttribute("class", "state");
			select[0].setAttribute("className", "state");
		}
		if (inputName == "PostalCode" && inputLength < 5) {
			errorMessage += "&#187; Please Enter A Zip or Postal Code" + "<br />";
			input[i].setAttribute("class", "box zip errorbox");
			input[i].setAttribute("className", "box zip errorbox");
		}else if (inputName == "PostalCode" && inputLength > 4) {
			input[i].setAttribute("class", "box zip");
			input[i].setAttribute("className", "box zip");
		}
		if (inputName == "PhoneNumber" && inputLength < 1) {
			errorMessage += "&#187; Please Enter Your Phone Number" + "<br />";
			input[i].setAttribute("class", "box errorbox");
			input[i].setAttribute("className", "box errorbox");
		}else if(inputName == "PhoneNumber" && inputLength > 0){
			input[i].setAttribute("class", "box");
			input[i].setAttribute("className", "box");
		}
		if ((inputName == "EmailAddress" && inputLength < 6) || (inputName == "EmailAddress" && !validEmail.test(input[i].value))) {
			errorMessage += "&#187; Please Enter Your Primary Email Address" + "<br />";
			input[i].setAttribute("class", "box errorbox");
			input[i].setAttribute("className", "box errorbox");
		}else if ((inputName == "EmailAddress" && inputLength > 5) || (inputName == "EmailAddress" && validEmail.test(input[i].value))) {
			input[i].setAttribute("class", "box");
			input[i].setAttribute("className", "box");
		}
		if (inputName == "userid" && inputLength < 1) {
			errorMessage += "&#187; Please Enter Your Desired User Name" + "<br />";
			input[i].setAttribute("class", "box errorbox");
			input[i].setAttribute("className", "box errorbox");
		}else if(inputName == "userid" && inputLength > 0){
			input[i].setAttribute("class", "box");
			input[i].setAttribute("className", "box");
		}
		if (inputName == "pw" && inputLength < 1) {
			errorMessage += "&#187; Please Enter Your Desired Password" + "<br />";
			input[i].setAttribute("class", "box errorbox");
			input[i].setAttribute("className", "box errorbox");
		}else if(inputName == "pw" && inputLength > 0){
			input[i].setAttribute("class", "box");
			input[i].setAttribute("className", "box");
		}
		if (inputName == "bCardholderName" && inputLength < 1) {
			errorMessage += "&#187; Please Enter the Name on Card" + "<br />";
			input[i].setAttribute("class", "box errorbox");
			input[i].setAttribute("className", "box errorbox");
		}else if(inputName == "bCardholderName" && inputLength > 0){
			input[i].setAttribute("class", "box");
			input[i].setAttribute("className", "box");
		}
		if(inputName == "CCNum"){
			var ccValue =(input[i].value).replace(/\s+/g,'');
		}
		if ((inputName == "CCNum" && inputLength < 13) || (inputName == "CCNum" && inputLength > 19) || (inputName == "CCNum" && numberOnly.test(ccValue))) {
			errorMessage += "&#187; Please Enter a Number Only Credit Card Number" + "<br />";
			input[i].setAttribute("class", "box errorbox");
			input[i].setAttribute("className", "box errorbox");
		}else if ((inputName == "CCNum" && inputLength > 12) || (inputName == "CCNum" && inputLength < 20) || (inputName == "CCNum" && !numberOnly.test(ccValue))) {
			input[i].setAttribute("class", "box");
		}
		if (inputName == "bAddress" && inputLength < 1) {
			errorMessage += "&#187; Please Enter the Credit Card Address" + "<br />";
			input[i].setAttribute("class", "box errorbox");
			input[i].setAttribute("className", "box errorbox");
		}else if(inputName == "bAddress" && inputLength > 0){
			input[i].setAttribute("class", "box");
			input[i].setAttribute("className", "box");
		}
		if (inputName == "bCity" && inputLength < 1) {
			errorMessage += "&#187; Please Enter the Credit Card City" + "<br />";
			input[i].setAttribute("class", "box errorbox");
			input[i].setAttribute("className", "box errorbox");
		}else if(inputName == "bCity" && inputLength > 0){
			input[i].setAttribute("class", "box");
			input[i].setAttribute("className", "box");
		}
		if(select[5].selectedIndex == 0 && i==22) {
			errorMessage += "&#187; Please Enter the Credit Card State" + "<br />";
			select[5].setAttribute("class", "state errorbox");
			select[5].setAttribute("className", "state errorbox");
		}else if(select[5].selectedIndex != 0 && i==22){
			select[5].setAttribute("class", "state");
			select[5].setAttribute("className", "state");
		}
		if (inputName == "bPostalCode" && inputLength < 5) {
			errorMessage += "&#187; Please Enter A Zip or Postal Code" + "<br />";
			input[i].setAttribute("class", "box zip errorbox");
			input[i].setAttribute("className", "box zip errorbox");
		}else if (inputName == "bPostalCode" && inputLength > 4) {
			input[i].setAttribute("class", "box zip");
			input[i].setAttribute("className", "box zip");
		}
		if ((inputName == "bEmailAddress" && inputLength < 6) || (inputName == "bEmailAddress" && !validEmail.test(input[i].value))) {
			errorMessage += "&#187; Please Enter Your Billing Email Address" + "<br />";
			input[i].setAttribute("class", "box errorbox");
			input[i].setAttribute("className", "box errorbox");
		}else if ((inputName == "bEmailAddress" && inputLength > 5) || (inputName == "bEmailAddress" && validEmail.test(input[i].value))) {
			input[i].setAttribute("class", "box");
			input[i].setAttribute("className", "box");
		}
		if (inputName == "terms" && input[i].checked == false) {
			errorMessage += "&#187; Please Check the Terms &amp; Conditions Checkbox" + "<br />";
		}else if (inputName == "terms" && input[i].checked == true) {
			errorMessage += "";
		}
	}
	
	self.scrollTo(0,0);
	if(errorMessage.length!=42){
		error.innerHTML = errorMessage;
		error.style.display = "block";
	}else{
		error.style.display = "none";
		document.getElementById("VendorForm").submit();
	}
}

function validateInquiry(){
	var error = document.getElementById("error");
	var input = document.getElementsByTagName("input");
	var select = document.getElementsByTagName("select");
	var errorMessage = "<strong>Oops. There was an error:</strong>";
	var numberOnly = /\D/;
	var validEmail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	for (i = 0; i < input.length; i++) {
		var inputName = input[i].getAttribute("name");
		var inputLength = input[i].value.length;
		
		if (inputName == "realname" && inputLength < 1) {
			errorMessage += "&#187; Please Enter Your Name" + "<br />";
			input[i].setAttribute("class", "box errorbox");
			input[i].setAttribute("className", "box errorbox");
		}
		else 
			if (inputName == "realname" && inputLength > 0) {
				input[i].setAttribute("class", "box");
				input[i].setAttribute("className", "box");
			}
		if ((inputName == "email" && inputLength < 6) || (inputName == "email" && !validEmail.test(input[i].value))) {
			errorMessage += "&#187; Please Enter Your E-mail Address" + "<br />";
			input[i].setAttribute("class", "box errorbox");
			input[i].setAttribute("className", "box errorbox");
		}
		else 
			if ((inputName == "email" && inputLength > 5) || (inputName == "email" && validEmail.test(input[i].value))) {
				input[i].setAttribute("class", "box");
				input[i].setAttribute("className", "box");
			}
		if (inputName == "phone" && inputLength < 1) {
			errorMessage += "&#187; Please Enter Your Phone Number" + "<br />";
			input[i].setAttribute("class", "box errorbox");
			input[i].setAttribute("className", "box errorbox");
		}
		else 
			if (inputName == "phone" && inputLength > 0) {
				input[i].setAttribute("class", "box");
				input[i].setAttribute("className", "box");
			}
	}
	
	self.scrollTo(0, 0);
	if (errorMessage.length != 42) {
		error.innerHTML = errorMessage;
		error.style.display = "block";
	}
	else {
		error.style.display = "none";
		document.getElementById("inquiry").submit();
	}
}
	
function validateSupport(){
	var error = document.getElementById("error");
	var input = document.getElementsByTagName("input");
	var select = document.getElementsByTagName("select");
	var errorMessage = "<strong>Oops. There was an error:</strong>";
	var numberOnly = /\D/;
	var validEmail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	for (i = 0; i < input.length; i++) {
		var inputName = input[i].getAttribute("name");
		var inputLength = input[i].value.length;
		
		if (inputName == "fullname" && inputLength < 1) {
			errorMessage += "&#187; Please Enter Your Name" + "<br />";
			input[i].setAttribute("class", "box errorbox");
			input[i].setAttribute("className", "box errorbox");
		}
		else 
			if (inputName == "fullname" && inputLength > 0) {
				input[i].setAttribute("class", "box");
				input[i].setAttribute("className", "box");
			}
		if ((inputName == "email" && inputLength < 6) || (inputName == "email" && !validEmail.test(input[i].value))) {
			errorMessage += "&#187; Please Enter Your E-mail Address" + "<br />";
			input[i].setAttribute("class", "box errorbox");
			input[i].setAttribute("className", "box errorbox");
		}
		else 
			if ((inputName == "email" && inputLength > 5) || (inputName == "email" && validEmail.test(input[i].value))) {
				input[i].setAttribute("class", "box");
				input[i].setAttribute("className", "box");
			}
	}
	
	self.scrollTo(0, 0);
	if (errorMessage.length != 42) {
		error.innerHTML = errorMessage;
		error.style.display = "block";
	}
	else {
		error.style.display = "none";
		document.getElementById("supportform").submit();
	}
}

function validatePasswordRequest(){
	var error 			= document.getElementById("error");
	var passwordForm 	= document.getElementById("passwordForm");
	
	if (passwordForm.password_forgot.value==""){
		error.innerHTML = "Please Enter Your E-mail or Username";
		error.style.display = "block";
	}
	else {
		error.style.display = "none";
		passwordForm.submit();
	}
}

function openTOC(which){
	if(document.getElementById("open").innerHTML == "Open Full Size"){
		document.getElementById("toc").style.height= "400px";
		document.getElementById("open").innerHTML = "Close";
	}else{
		document.getElementById("toc").style.height= "70px";
		document.getElementById("open").innerHTML = "Open Full Size";
	}
}

function validateJoin(){
	var error = document.getElementById("error");
	var input = document.getElementsByTagName("input");
	var select = document.getElementsByTagName("select");
	var errorMessage = "<strong>Oops. There was an error:</strong>";
	var numberOnly = /\D/;
	var validEmail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	for (i = 0; i < input.length; i++) {
		var inputName = input[i].getAttribute("name");
		var inputLength = input[i].value.length;
		
		if (inputName == "realname" && inputLength < 1) {
			errorMessage += "&#187; Please Enter Your First Name" + "<br />";
			input[i].setAttribute("class", "box errorbox");
			input[i].setAttribute("className", "box errorbox");
		}
		else 
			if (inputName == "realname" && inputLength > 0) {
				input[i].setAttribute("class", "box");
				input[i].setAttribute("className", "box");
			}
		if (inputName == "LastName" && inputLength < 1) {
			errorMessage += "&#187; Please Enter Your Last Name" + "<br />";
			input[i].setAttribute("class", "box errorbox");
			input[i].setAttribute("className", "box errorbox");
		}
		else 
			if (inputName == "LastName" && inputLength > 0) {
				input[i].setAttribute("class", "box");
				input[i].setAttribute("className", "box");
			}
		if (inputName == "CompanyName" && inputLength < 1) {
			errorMessage += "&#187; Please Enter Your Company Name" + "<br />";
			input[i].setAttribute("class", "box errorbox");
			input[i].setAttribute("className", "box errorbox");
		}
		else 
			if (inputName == "CompanyName" && inputLength > 0) {
				input[i].setAttribute("class", "box");
				input[i].setAttribute("className", "box");
			}
		if (inputName == "Address" && inputLength < 1) {
			errorMessage += "&#187; Please Enter Your Address" + "<br />";
			input[i].setAttribute("class", "box errorbox");
			input[i].setAttribute("className", "box errorbox");
		}
		else 
			if (inputName == "Address" && inputLength > 0) {
				input[i].setAttribute("class", "box");
				input[i].setAttribute("className", "box");
			}
		if (inputName == "City" && inputLength < 1) {
			errorMessage += "&#187; Please Enter Your City" + "<br />";
			input[i].setAttribute("class", "box errorbox");
			input[i].setAttribute("className", "box errorbox");
		}else if(inputName == "City" && inputLength > 0){
			input[i].setAttribute("class", "box");
			input[i].setAttribute("className", "box");
		}
		if(select[0].selectedIndex == 0 && i==6) {
			errorMessage += "&#187; Please Enter Your State" + "<br />";
			select[0].setAttribute("class", "state errorbox");
			select[0].setAttribute("className", "state errorbox");			
		}else if(select[0].selectedIndex != 0 && i==8){
			select[0].setAttribute("class", "state");
			select[0].setAttribute("className", "state");
		}
		if (inputName == "PostalCode" && inputLength < 5) {
			errorMessage += "&#187; Please Enter A Zip or Postal Code" + "<br />";
			input[i].setAttribute("class", "box zip errorbox");
			input[i].setAttribute("className", "box zip errorbox");
		}else if (inputName == "PostalCode" && inputLength > 4) {
			input[i].setAttribute("class", "box zip");
			input[i].setAttribute("className", "box zip");
		}	
		
		if (inputName == "PhoneNumber" && inputLength < 1) {
			errorMessage += "&#187; Please Enter Your Phone Number" + "<br />";
			input[i].setAttribute("class", "box errorbox");
			input[i].setAttribute("className", "box errorbox");
		}else if(inputName == "PhoneNumber" && inputLength > 0){
			input[i].setAttribute("class", "box");
			input[i].setAttribute("className", "box");
		}
		if ((inputName == "email" && inputLength < 6) || (inputName == "email" && !validEmail.test(input[i].value))) {
			errorMessage += "&#187; Please Enter Your Primary Email Address" + "<br />";
			input[i].setAttribute("class", "box errorbox");
			input[i].setAttribute("className", "box errorbox");
		}else if ((inputName == "email" && inputLength > 5) || (inputName == "EmailAddress" && validEmail.test(input[i].value))) {
			input[i].setAttribute("class", "box");
			input[i].setAttribute("className", "box");
		}
		if (inputName == "date_requested" && inputLength < 1) {
			errorMessage += "&#187; Please Enter Your Date Requested" + "<br />";
			input[i].setAttribute("class", "datebox errorbox");
			input[i].setAttribute("className", "datebox errorbox");
		}
		else 
			if (inputName == "date_requested" && inputLength > 0) {
				input[i].setAttribute("class", "datebox");
				input[i].setAttribute("className", "datebox");
			}	
		if (inputName == "terms" && input[i].checked == false) {
			errorMessage += "&#187; Please Check the Terms of Service Checkbox" + "<br />";
		}else if (inputName == "terms" && input[i].checked == true) {
			errorMessage += "";
		}
	}
	
	self.scrollTo(0, 0);
	if (errorMessage.length != 42) {
		error.innerHTML = errorMessage;
		error.style.display = "block";
	}
	else {
		error.style.display = "none";
		document.forms[0].submit();
	}
}
