/*
 * 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=2;
 
 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;	
	if(document.getElementById("nopassenger"))
		fpara = fpara + '&passenger='+document.getElementById("nopassenger").value;
	
	$("#debug").html(fpara);
	
	if ( from !='' || to !='' ) {
	
		$.ajax({
		  url: "get.price.php",
		  type:'GET', 
		  data: fpara,
		  cache: false,
		  beforeSend: function(html) {
			if ( (tid != 0) && ( fid != 0) ) $("#priceText").html('<div style="font-size: 18px;"> loading... </div> ');
		  },
		  success: function(html) {
		  
		    if ( (tid != 0) && ( fid != 0) ) {
				
				document.getElementById("hd_saloon").value = "0.00";
				document.getElementById("hd_mpv5").value = "0.00";
				document.getElementById("hd_mpv8").value = "0.00";
				document.getElementById("hd_executive").value = "0.00";
			
				htmlArr = html.split(",");
				
				for(i=0;i<htmlArr.length;i++){
					
					if(i == 0){
						document.getElementById("saloon").innerHTML = "<h5 align='center' id='1'>&pound;" + htmlArr[i] + "</h5>";
						document.getElementById("hd_saloon").value = htmlArr[i];
					}else if(i == 1){
						document.getElementById("mpv").innerHTML = "<h5 align='center' id='2'>&pound;" + htmlArr[i] + "</h5>";
						document.getElementById("hd_mpv5").value = htmlArr[i];
					}else if(i == 2){
						document.getElementById("mpv8").innerHTML = "<h5 align='center' id='3'>&pound;" + htmlArr[i] + "</h5>";
						document.getElementById("hd_mpv8").value = htmlArr[i];
					}else{
						document.getElementById("executive").innerHTML = "<h5 align='center' id='4'>&pound;" + htmlArr[i] + "</h5>";
						document.getElementById("hd_executive").value = htmlArr[i];
					}
					
				}// end for
			
				gobook=1;
				//if (html!="<") { gobook=1; $("#priceText").html('£ '+html); }	else { gobook=0; $("#priceText").html(html);	}	
				
			}
			
		  }		  
		});			
	
	
	}
	
	
}

function checkbookingcomplete(carid,hdid){

	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;
	}
	
	if(document.getElementById(hdid).value == '0.00'){
		alert('Sorry Travel Information Submitted is not yet Available!');
		return false;	
	}
	
	fpara = 'from='+from+'&fromid='+fid+'&to='+to+'&toid='+tid+'&car='+carid;
	
	if(document.getElementById("nopassenger"))
		fpara = fpara + '&passenger='+document.getElementById("nopassenger").value;
	
	window.location='book.php?'+fpara;
	
}
