function changeFrontTab(obj){
	if(obj.id == "box_btn_rn" && obj.className == "box_btn_link_unslct"){
		document.getElementById("box_btn_cs").className = "box_btn_link_unslct";
		document.getElementById("box_btn_gq").className = "box_btn_link_unslct";
		obj.className = "box_btn_link_slct";
		document.getElementById("reserve_now_cntr").style.display = "";
		document.getElementById("get_quote_cntr").style.display = "none";
		document.getElementById("check_status_cntr").style.display = "none";

	}else if(obj.id == "box_btn_gq" && obj.className == "box_btn_link_unslct"){
		document.getElementById("box_btn_cs").className = "box_btn_link_unslct";
		document.getElementById("box_btn_rn").className = "box_btn_link_unslct";
		obj.className = "box_btn_link_slct";
		document.getElementById("reserve_now_cntr").style.display = "none";
		document.getElementById("get_quote_cntr").style.display = "";
		document.getElementById("check_status_cntr").style.display = "none";
		
	}else if(obj.id == "box_btn_cs" && obj.className == "box_btn_link_unslct"){
		document.getElementById("box_btn_gq").className = "box_btn_link_unslct";
		document.getElementById("box_btn_rn").className = "box_btn_link_unslct";
		obj.className = "box_btn_link_slct";
		document.getElementById("reserve_now_cntr").style.display = "none";
		document.getElementById("get_quote_cntr").style.display = "none";
		document.getElementById("check_status_cntr").style.display = "";		
	}
}

function login(){
	user = document.getElementById("login").value;
	pass = document.getElementById("password").value;
	
	url = "includes/ajax/auth_login.php?login=" + user + "&pass="+pass;
	message = "<div id=\"verify\">verifying...</div>";
	ajaxRequest(url,'reserve_now_cntr',message);
	
	setTimeout('loadLogin();',1000);
}

function loadLogin(){
	if(document.getElementById("verified").innerHTML == "Approved"){
		url = "includes/ajax/page_header_right_top.php";
		ajaxRequest(url,'page_header_right_top',"loading...");

		url2 = "includes/ajax/reserve_now_cntr.php";
		makerequest(url2,'reserve_now_cntr');

		document.getElementById("box_btn_rn").innerHTML = "Welcome";
		
	}
}
function encodeMyHtml(id) {
	encodedHtml = escape(id);
	encodedHtml = encodedHtml.replace(/\//g,"%2F");
	encodedHtml = encodedHtml.replace(/\?/g,"%3F");
	encodedHtml = encodedHtml.replace(/=/g,"%3D");
	encodedHtml = encodedHtml.replace(/&/g,"%26");
	encodedHtml = encodedHtml.replace(/@/g,"%40");
	return encodedHtml;
} 
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
	
function submitQuote(){
	quoteName = document.getElementById("quote_name").value;
	quotePickup = document.getElementById("quote_pickup").value;
	quoteDestination = document.getElementById("quote_destination").value;
	quoteRequests = document.getElementById("quote_requests").value;
	quoteEmail = document.getElementById("quote_email").value;
	
	if(!quoteName){
		alert("Please enter a name.");
		return false;
	}
	if(!quotePickup){
		alert("Please enter a Pickup.");
		return false;
	} 
	if(!quoteDestination){
		alert("Please enter a Destination.");
		return false;
	}
	if(quoteEmail){
		if(!echeck(quoteEmail)){
			//alert("Please enter a valid eMail.");
			return false;
		}
	}else if(!quoteEmail){
		alert("Please enter an eMail Address.");
		return false;		
	}	
	
		url = "includes/ajax/submit_quote.php?name="+quoteName+"&pickup="+quotePickup+"&dest="+quoteDestination+"&requests="+quoteRequests+"&email="+quoteEmail;
		makerequest(url,'get_quote_cntr');	

}

function checkStatus(){

	confNo = document.getElementById("conf_no").value;
	confEmail = document.getElementById("conf_email").value;

	if(isNaN(confNo)){
		alert("Please enter a valid confirmation number.");
		return false;
	}
	if(!confNo){
		alert("Please enter a confirmation number.");
		return false;
	}
	if(!confEmail){
		alert("Please enter the eMail address used to book this trip.");
		return false;
	}
	url = "includes/ajax/check_status.php?id="+confNo+"&email="+confEmail;
	new makerequest(url,'check_status_cntr');	
}