function check_email(email_address)
  {
  email = document.getElementById(email_address).value;
  var place = email.indexOf("@",1);
  var dot = email.indexOf(".",place+1);
  if ((place > -1)&&(email.length >2)&&(dot > 1))
    {
    return(true);
    }
  else
    {
    alert('The email address you typed is incorrect');
    return(false);
    }
}

function check_agree(){
	if(document.getElementById("agree").checked==false){
		alert("You have to agree to the guidelines to continue the procedure.");
		return false;
	}
	else
		return true;
}

function show_hide_states(){
	document.getElementById('states').style.display=document.getElementById('country').value=='USA' ? '' : 'none';
}

function check_get_a_quote_short(){
	if(document.getElementById('first_name').value=="first name")
		document.getElementById('first_name').value='';
	if(document.getElementById('last_name').value=="last name")
		document.getElementById('last_name').value='';
	if(document.getElementById('email').value=="email address")
		document.getElementById('email').value='';
    if(document.getElementById('phone').value=="phone #")
		document.getElementById('phone').value='';
	if(document.getElementById('departure_city').value=="departure city")
		document.getElementById('departure_city').value='';
	if(document.getElementById('destination_city').value=="destination city")
		document.getElementById('destination_city').value='';
	if(document.getElementById('passengers').value=="# of passengers"){
		document.getElementById('passengers').value='';
	}
	return true;
}



restoration_value=""
function restore(target){
	if(document.getElementById(target).value=="")
		document.getElementById(target).value=restoration_value;
}

function empty(target){
	 restoration_value= document.getElementById(target).value;
	 //document.getElementById(target).value="";
	 document.getElementById(target).focus();
	 document.getElementById(target).select();
}
  
function validate_survey(){
	validate=false;
	i=0;
	while(i<4 && validate==false){
	   if(document.survey.answer[i].checked)
	   		validate=true;
	   i++;
	}
	if(validate==false){
		alert("You didn't check any answer before validation");
		return false;
	}
	else
		return true;
}

/*  Show the cities for the departure cities */

function lookup(inputString) {
	if(inputString.length == 0) {
		// Hide the suggestion box.
		$('#suggestions').hide();
	} else {
		$.post("autocompletion/search_cities1.php", {queryString: ""+inputString+""}, function(data){
			if(data.length >0) {
				$('#suggestions').show();
				$('#autoSuggestionsList').html(data);
			}
		});
	}
} // lookup
function fill(thisValue) {
	$('#departure_city').val(thisValue);
	setTimeout("$('#suggestions').hide();", 200);
}


/*  Show the cities for the destination cities */
function lookup2(inputString) {
	if(inputString.length == 0) {
		// Hide the suggestion box.
		$('#suggestions2').hide();
	} else {
		$.post("autocompletion/search_cities2.php", {queryString: ""+inputString+""}, function(data){
			if(data.length >0) {
				$('#suggestions2').show();
				$('#autoSuggestionsList2').html(data);
			}
		});
	}
} // lookup
function fill2(thisValue) {
	$('#destination_city').val(thisValue);
	setTimeout("$('#suggestions2').hide();", 200);
}