jQuery(document).ready(function(){
	jQuery(".tx-wchotelseach-pi1 select").attr("onchange","javascript: DoHotelSearch()");
	
	jQuery(".tx-wchotelseach-pi1 a").click(function(e){
		e.preventDefault();
		changeForm(e,this);
	});
	
	jQuery(".tx-wchotelseach-pi1 form").submit(function(e){
		e.preventDefault();
		DoHotelSearch();
	});
});

function reloadSearchResults() {

var form = jQuery(".tx-wchotelseach-pi1 form");

if(jQuery("#content1_2").length>0) {
	jQuery("#content1_2").load("2.html?" + jQuery(form).serialize() + " #content1_2", function(){
		jQuery("#content1_2 #content1_2").attr("id","tmp");
	});
} else {
	jQuery("#content1_3").load("2.html?" + jQuery(form).serialize() + " #content1_2", function(){
		jQuery("#content1_3 #content1_2").attr("id","tmp");
		jQuery("#content1_3").attr("id","content1_2");
		jQuery("#content2_3").remove();
	});
} 

}

function changeForm(e, a) {
	e.preventDefault();
	jQuery.get(jQuery(a).attr("href") + '&eID=hotelsearch', function(data) {
		jQuery(".tx-wchotelseach-pi1").html(data);
	});
	
	reloadSearchResults();
}

function DoHotelSearch() {

var form = jQuery(".tx-wchotelseach-pi1 form");

jQuery.get('index.php?eID=hotelsearch', jQuery(form).serialize(), function(data) {
 jQuery(".tx-wchotelseach-pi1").html(data);
});
reloadSearchResults();
}

