/*
 * Airport -  Javascript
 *  
 * Copyright (c) 2008 ServerMX Online (servermxonline.com)
 *
 * $Date: 2008-05-27 00:00:00 -0500 (Tues, 27 May 2008) $
 * $Rev: 0001 $
 */
 
 var  from ='';
 var  to ='';
 
 var  fid=0;
 var  tid=0;
 var  car=1;
 
 var  gobook=0;
 
  
function SelPortChange(vAr) {
		$.ajax({
		  url: "ajax.port.php",
		  type:'GET', 
		  data: "para="+vAr,
		  cache: false,
		  beforeSend: function(html) {
			$("#portname").html('<img src="images/ajax.gif"> ');
		  },
		  success: function(html) {
			$("#portname").html(html);
		  }		  
		});					
}

function GetPrice() {

}

function SelCarChange(cAr) {	
		car = cAr;
		var carimg="<img src='images/car-"+cAr+".jpg' border=0>";
		$("#carBox").html(carimg);			
		FinalPara();
}

function Evaluate(eval) {
			
		if ( eval == "rfrom1") { 
		
			from = "airport";
			fid = $("#fairport").attr("value");
			
			document.getElementById("fcruiseport").value="";
			document.getElementById("fpostcode").value="";
			
		}
		
		if (  eval == "rfrom2" ) { 
		
			from = "postcode";
			fid = $("#fpostcode").attr("value");
			
			document.getElementById("fcruiseport").value="";
			document.getElementById("fairport").value="";			
			
		}	

		if (  eval == "rfrom3" ) { 
		
			from = "cruiseport";
			fid = $("#fcruiseport").attr("value");
			
			document.getElementById("fairport").value="";
			document.getElementById("fpostcode").value="";			
			
		}			
		
		if (  eval == "rto1") { 
		
			to = "airport";
			tid = $("#tairport").attr("value");
			
			document.getElementById("tcruiseport").value="";
			document.getElementById("tpostcode").value="";			
			
		}

		if (  eval == "rto2") { 
		
			to = "postcode";
			tid = $("#tpostcode").attr("value");
			document.getElementById("tcruiseport").value="";
			document.getElementById("tairport").value="";				
			
		}			
		
		if (  eval == "rto3") { 
		
			to = "cruiseport";
			tid = $("#tcruiseport").attr("value");
			document.getElementById("tairport").value="";
			document.getElementById("tpostcode").value="";			
			
		}
				
		FinalPara();
												
}


function FinalPara() {
	
	fpara = 'from='+from+'&fromid='+fid+'&to='+to+'&toid='+tid+'&car='+car;	
		
	//$("#debug").html(fpara);
	
	if ( from !='' || to !='' ) {
	
		$.ajax({
		  url: "get.price.php",
		  type:'GET', 
		  data: fpara,
		  cache: false,
		  beforeSend: function(html) {
			$("#price").html('<div style="font-size: 18px;"> loading... </div> ');
		  },
		  success: function(html) {
		  
		    if (html[0]!="<") { gobook=1; $("#price").html('£ '+html); }	else { gobook=0; $("#price").html(html);	}								 
			
			
		  }		  
		});			
	
	
	}
	
	
}

function checkbookingcomplete() {

	if ( from =='' || to =='' ) {
		alert('You must select your travel information!');
		return false;
	}
	
	if (gobook==0)  {
		alert('Preferred travel info is not yet available!');
		return false;
	}
	
	var fpara = 'from='+from+'&fromid='+fid+'&to='+to+'&toid='+tid+'&car='+car;		
	window.location='book.php?'+fpara;
	
	
	
}
	


