// JavaScript Document
$(document).ready(function(){
	<!--FROM DESTINATION START-->
	<!--On Select box change-->
	$("#from_destination").change(function (){
		var from_destination=$("#from_destination").val();
		var from_dest='Fromdestination';
		var getAction;
		if(from_destination=="airport")
		{	
			$("#search_panel").html('<div style="padding-top:80px;"><img src="images/ajax-loader.gif"></div>');
			$("#selected_text_from").hide();
			$("#postalcode").hide();
			getAction='airport';
		}
		else if(from_destination=="town")
		{
			$("#search_panel").html('<div style="padding-top:80px;"><img src="images/ajax-loader.gif"></div>');
			$("#selected_text_from").hide();
			$("#postalcode").hide();
			getAction='town';//define drop down value here
		}
		else if(from_destination=="postalcode")
		{
			$("#search_panel").html('<div style="padding-top:80px;"><img src="images/ajax-loader.gif"></div>');
			$("#postalcode").show();//on front_search.php for reference 
			$("#txt_search_post").val('');//on generated textbox for postcode searching
			$("#selected_text_from").hide();//use for selected span hide on index.php
			$("#search_panel").hide();//use for index.php main searching panel
			$("#replce_post_code").replaceWith('<div id="postalcode"><table width="100%"><tbody><tr><td style="color:#FFF;font-weight:bold;">Enter Postcode Or Street Name</td></tr><tr><td height="5"></td></tr><tr><td><input type="text" size="34" placeholder="Postcode Or Street Name" id="txt_search_post" name="txt_search_post" style="text-transform:uppercase;"></td></tr></tbody></table></div>');
			return false;
		}
		else if(from_destination=="hotel")
		{
			$("#search_panel").html('<div style="padding-top:80px;"><img src="images/ajax-loader.gif"></div>');
			$("#selected_text_from").hide();
			$("#postalcode").hide();
			getAction='hotel';//define drop down value here
		}
		else if(from_destination=="station")
		{
			$("#search_panel").html('<div style="padding-top:80px;"><img src="images/ajax-loader.gif"></div>');
			$("#selected_text_from").hide();
			$("#postalcode").hide();
			getAction='station';//define drop down value here
		}
	else if(from_destination=="-- Select --")
		{	return false;	}
		$.ajax({
			type:'POST',
			url:'front_search.php?action='+ getAction +'&destination='+from_dest,
			success:function(res){
				$("#search_panel").replaceWith('<div id="search_panel" style="height:250px;overflow:auto;">'+res+'</div>');		
				}		
			});
		});
		<!--On Select box change-->
		<!--Searching on text change for from  destination-->
		$("#txt_search_post").live('keyup',function() {
			var word=$("#txt_search_post").val();
			var postalcode='postalcode';
			var from_dest='Fromdestination';
			$.ajax({
			type:'POST',
			url:'front_search.php?action='+postalcode+'&word='+word+'&destination='+from_dest,
			success:function(res){
					$("#selected_text_from").show();
					$("#search_panel").html('<div style="padding-top:80px;"><img src="images/ajax-loader.gif"></div>');
					$("#search_panel").replaceWith('<div id="search_panel" style="height:250px;overflow:auto;">'+res+'</div>');
				}		
			});
	});
		<!--Searching on text change for from  destination-->
		<!--FROM DESTINATION CLOSE-->	
		<!--TO DESTINATION START-->
		$("#to_destination").change(function(){
			var to_destination=$("#to_destination").val();
			var to_dest='Todestination';
			var getAction;
			if(to_destination=="airport")
			{	
				$("#search_panel").html('<div style="padding-top:80px;"><img src="images/ajax-loader.gif"></div>');
				$("#selected_text_to").hide();
				$("#postalcode_to").hide();
				getAction='airport';//define drop down value here
			}
			else if(to_destination=="town")
			{	
				$("#search_panel").html('<div style="padding-top:80px;"><img src="images/ajax-loader.gif"></div>');
				$("#selected_text_to").hide();
				$("#postalcode_to").hide();
				getAction='town';//define drop down value here
			}
			else if(to_destination=="postalcode")
			{
				$("#postalcode_to").show();//on front_search.php for reference 
				$("#selected_text_to").hide();
				$("#replce_post_code_to").replaceWith('<div id="postalcode_to"><table width="100%"><tbody><tr><td style="color:#FFF;font-weight:bold;">Enter Postcode Or Street Name</td></tr><tr><td height="5"></td></tr><tr><td><input type="text" size="34" placeholder="Postcode Or Street Name" id="txt_search_post_to" name="txt_search_post_to" style="text-transform:uppercase;"></td></tr></tbody></table></div>');
			return false;
			}
			else if(to_destination=="hotel")
			{
				$("#search_panel").html('<div style="padding-top:80px;"><img src="images/ajax-loader.gif"></div>');
				$("#selected_text_to").hide();
				$("#postalcode_to").hide();
				getAction='hotel';//define drop down value here
			}
			else if(to_destination=="station")
			{
				$("#search_panel").html('<div style="padding-top:80px;"><img src="images/ajax-loader.gif"></div>');
				$("#selected_text_to").hide();
				$("#postalcode_to").hide();
				getAction='station';//define drop down value here
			}
			else if(to_destination=="-- Select --")
			{	return false;	}
			$.ajax({
			type:'POST',
			url:'front_search.php?action='+ getAction +'&destination='+to_dest,
			success:function(res){
				$("#search_panel").replaceWith('<div id="search_panel" style="height:250px;overflow:auto;">'+res+'</div>');		
				}		
			});
	});
		<!--TO DESTINATION CLOSE-->
		<!--Searching on text change for to destination-->
		$("#txt_search_post_to").live('keyup',function() {
			var word=$("#txt_search_post_to").val();
			var postalcode='postalcode';
			var to_dest='Todestination';
			$.ajax({
			type:'POST',
			url:'front_search.php?action='+postalcode+'&word='+word+'&destination='+to_dest,
			success:function(res){
					$("#search_panel").replaceWith('<div id="search_panel" style="height:250px;overflow:auto;">'+res+'</div>');
				}		
			});
	});
		<!--Searching on text change for to destination-->
});
<!-- Only for from destination-->	
function GetValFrom(valueFrom){
	//alert('hello');
	document.getElementById("selected_text_from").style.display='block';
	document.getElementById("selected_text_from").innerHTML=valueFrom;
	<!--document.getElementById("journey_from").value=valueFrom;-->
	document.getElementById("ret_jrny_from").value=valueFrom;
	document.getElementById("search_panel").style.display='none';
	document.getElementById("postalcode").style.display='none';
	}
<!-- Only for from destination-->	
<!-- Only for to destination-->	
function GetValTo(valueto){
	document.getElementById("selected_text_to").style.display='block';
	document.getElementById("selected_text_to").innerHTML=valueto;
<!--	document.getElementById("journey_to").value=valueto;-->
	document.getElementById("ret_jrny_to").value=valueto;
	document.getElementById("search_panel").style.display='none';
	document.getElementById("postalcode_to").style.display='none';
	}
<!-- Only for to destination-->			
function keyChange(o)
{ o.value=o.value.toUpperCase();}
