function fixEmailAddress(){
document.getElementById("Email Address").value = document.getElementById("emailaddr").value;
}

function validate() {
  if(!document.getElementById) return;

  // get form variables
  var FirstName = document.getElementById("FirstName").value;
  var LastName = document.getElementById("LastName").value;
  var Email = document.getElementById("emailaddr").value;
  var Zip = document.getElementById("Zip").value;
  //var wantsGuide = document.getElementById("RentalGuideRequest").checked
  
 	document.getElementById("SubmitMe").value='Please Wait...';
 
  var incorrect = new Array();
  var regExp = /[A-Za-z]{2,6}/;
  var no = 0;

  regExp = /[A-Za-z]{3,}-?[A-Za-z]?/;
  if(regExp.test(FirstName)) {
   	FirstName = FirstName.charAt(0).toUpperCase() + FirstName.substring(1,FirstName.length).toLowerCase();
  } else {
   	incorrect[no] = "1";
  	 no++;
   	FirstName = "";
  }

  regExp = /[A-Za-z]{3,}-?[A-Za-z]?/;
  if(regExp.test(LastName)) {
   	LastName = LastName.charAt(0).toUpperCase() + LastName.substring(1,LastName.length).toLowerCase();
  } else {
   	incorrect[no] = "2";
  	 no++;
   	LastName= "";
  }
  
  if(Email.length < 5) {
   	incorrect[no] = "3";
   	no++;
   	Email= "";
  }

  if(Zip.length < 3) {
   	incorrect[no] = "4";
   	no++;
   	Zip= "";
  }
 
  for(i=1;i<5;i++) {
  		document.getElementById(i).style.border="0px solid #000000";
  }

  for(j=0;j<no;j++) {
  		document.getElementById(incorrect[j]).style.border="2px solid #FF0000";
  }

  if(no > 0) {
   	scroll(0,0);
   	document.getElementById("SubmitMe").value = 'Submit';
   	document.getElementById("errors").innerHTML = "<span class=\"error\">There was an error with your form submission. Please fill in the necessary fields.</span><br />";
  }else{

		if (document.getElementById("RentalGuideRequest").checked == false) 
		{
			document.subscribeForm.submit();
			//alert ("sign up only")
			
		} else { 	
	
			xmlhttpPost("SendRentalRequest.asp");
			//alert ("guide")
			//document.subscribeForm.submit();
		}

  	}
  document.getElementById("FirstName").value = FirstName;
  document.getElementById("LastName").value = LastName;
  document.getElementById("Zip").value = Zip;

  }


function xmlhttpPost(strURL) {
    var xmlHttpReq = false;
    var self = this;
    
	// Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    
	self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
           submitTheForm(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send(getquerystring());
 }

function getquerystring() {
    var form     = document.forms['subscribeForm'];
    var word = form.FirstName.value;
    var word2 = form.LastName.value;
    var word3 = form.MailingAddress.value;
    var word4 = form.City.value;
    var word5 = form.State.value;
    var word6 = form.Zip.value;   
    
    qstr = 'firstName=' + escape(word) + '&LastName=' + escape(word2) + '&MailingAddress=' + escape(word3) + '&City=' + escape(word4) + '&State=' + escape(word5) + '&Zip=' + escape(word6) ;
    return qstr;
}

function submitTheForm(str){

if (document.getElementById("NewsLetter").checked == true){
   document.subscribeForm.submit();
   }else{
	window.location = "sucess.asp?r=guide"
   
   }
}





