function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  }
}

function checkform(form)
{

if (form.name.value == "" || form.name.value == " Name:") {
   alert( "Please give us your name. \n Your information is safe with us - we won't share it without your permission." );
   form.name.focus();
   return false ;
}
if (form.budget.value == "" || form.budget.value == " Budget:") {
   alert( "Please give us a budget (buyer) or anticipated listing price (seller).\n Your information is safe with us - we won't share it without your permission." );
   form.budget.focus();
   return false ;
} 
    var Chars = "0123456789.,$"; 
    for (var i = 0; i < form.budget.value.length; i++) { 
      if (Chars.indexOf(form.budget.value.charAt(i)) == -1)  { 
         alert('Amount must be a number with or without the decimal & cents.'); 
         return false; 
      }             
    }   
if (form.phone.value == "" || form.phone.value == " Phone:") {
   alert( "Please give us your phone number - if you'd prefer we contact you via email, just specify that in the comment box. \n Your information is safe with us - we won't share it without your permission." );
   form.phone.focus();
   return false ;
}
if (form.email.value == "" || form.email.value == " Email:") {
   alert( "Please enter an email address -  if you'd prefer we contact you via phone, just specify that in the comment box. \n Your information is safe with us - we won't share it without your permission." );
   form.email.focus();
   return false ;
}
if (form.email.value.indexOf('@',0) == -1) {
   alert( "Please enter a VALID email address -  if you'd prefer we contact you via phone, just specify that in the comment box. \n Your information is safe with us - we won't share it without your permission." );
   form.email.focus();
   return false ;
}

  return true;
}

function checkform_friend(form)
{
	 if (form.name.value == "") {
	   alert( "Please give us your name." );
	   form.name.focus();
	   return false ;
	 }
	 if (form.friend_name.value == "") {
	   alert( "Please give us your friend's name." );
	   form.friend_name.focus();
	   return false ;
	 }
	 
	 if (form.friend_email.value == "") {
	   alert( "Please enter your friend's email address. \n Your information is safe with us - we won't share it without your permission." );
	   form.friend_email.focus();
	   return false ;
	}
	 if (form.friend_email.value.indexOf('@',0) == -1) {
	   alert( "Please enter a VALID email address. \n Your information is safe with us - we won't share it without your permission." );
	   form.friend_email.focus();
	   return false ;
	}	
  return true ;
}

function checkform_short(form)
{
	 if ( form.agree.checked == false )  {
        alert ( "Please check the box indicating you agree to the terms of service." );
        return false;	  
	}	
	 if (form.name.value == "") {
	   alert( "Please give us your name." );
	   form.name.focus();
	   return false ;
	 }
	 if (form.company_name.value == "") {
	   alert( "Please give us your company's name." );
	   form.company_name.focus();
	   return false ;
	 }

	 if (form.work_phone.value == "") {
	   alert( "Please give us your work phone number." );
	   form.work_phone.focus();
	   return false ;
	 }
	 if (form.address1.value == "") {
	   alert( "Please give us your street address." );
	   form.address1.focus();
	   return false ;
	 }
	 if (form.city.value == "") {
	   alert( "Please give us your city." );
	   form.city.focus();
	   return false ;
	 }
	 if (form.state.value == "") {
	   alert( "Please give us your state." );
	   form.state.focus();
	   return false ;
	 }	 
	 if (form.code.value == "") {
	   alert( "Please enter your zip code." );
	   form.code.focus();
	   return false ;
	 }	 
	 if (form.email.value == "") {
	   alert( "Please enter an email address -  if you'd prefer we contact you via phone, just specify that in the comment box. \n Your information is safe with us - we won't share it without your permission." );
	   form.email.focus();
	   return false ;
	}
	 if (form.email.value.indexOf('@',0) == -1) {
	   alert( "Please enter a VALID email address -  if you'd prefer we contact you via phone, just specify that in the comment box. \n Your information is safe with us - we won't share it without your permission." );
	   form.email.focus();
	   return false ;
	}	
  return true ;
}
