$(document).ready(function() {
		$("input:submit").button();
		$("a", ".tac", ".edit").button();
		
});

$(document).ready(function(){

	var sd ="";
	var ed="";
			 $('#rangeInlinePicker').hide();
			$("#calendar1").live("click",function(){$('#rangeInlinePicker').show('slow');
			$('#rangeInlinePicker').datepick({dateFormat: 'yyyy-mm-dd',onSelect: showDate,     minDate:new Date(),maxDate: '2012-05-14',rangeSelect: true, monthsToShow: [1, 3]});
			$('#calendar1').click(function() { $('#rangeInlinePicker').toggle('fast'); return false;  });
		});
function showDate(date) {
	
	year = date[0].getFullYear();
	month = date[0].getMonth()+1;
	day = date[0].getDate();
	sd = year+"-"+month+"-"+day;
	year = date[1].getFullYear();
	month = date[1].getMonth()+1;
	day = date[1].getDate();
	ed = year+"-"+month+"-"+day;
	
	var beach = $("#beachfront").attr("checked")== true ? 1 : 0;
	var nearbeach = $("#nearbeach").attr("checked")== true ? 1 : 0;
	var lake = $("#lake").attr("checked")== true ? 1 : 0;
	var marina = $("#marina").attr("checked")== true ? 1 : 0;
	var mountain = $("#mountain").attr("checked")== true ? 1 : 0;
	var city = $("#city").attr("checked")== true ? 1 : 0;
	var resort = $("#resort").attr("checked")== true ? 1 : 0;
	var rural = $("#rural").attr("checked")== true ? 1 : 0;
	var townloc = $("#town").attr("checked")== true ? 1 : 0;
	var village = $("#village").attr("checked")== true ? 1 : 0;
	var golf = $("#neargolf").attr("checked")== true ? 1 : 0;
	var ongolf = $("#ongolf").attr("checked")==true ? 1 : 0;
	var wash = $("#washmachine").attr("checked")==true ? 1 : 0;
	var dish = $("#dishwasher").attr("checked")==true ? 1 : 0;
	var ppool = $("#privatepool").attr("checked")==true ? 1 : 0;
	var aircon = $("#air-con").attr("checked")==true ? 1 : 0;
	var heat = $("#heating").attr("checked")==true ? 1 : 0;
	var sat = $("#sattv").attr("checked")==true ? 1 : 0;
	var bbq = $("#bbq").attr("checked")==true ? 1 : 0;
	var bband = $("#internet").attr("checked")==true ? 1 : 0;
	var wheel = $("#wheelchair").attr("checked")==true ? 1 : 0;
	var disable = $("#disability").attr("checked")==true ? 1 : 0
	var smoking = $("#smoking").attr("checked")==true ? 1 : 0;
	var pets = $("#pets").attr("checked")==true ? 1 : 0;
	var cpool = $("#communalpool").attr("checked")==true ? 1 : 0;
	var child = $("#children").attr("checked")==true ? 1 : 0
	var dvd = $("#dvd").attr("checked")==true ? 1 : 0;
	var parking = $("#parking").attr("checked")==true ? 1 : 0;


		



	//var sd = 

	//var ed = 
			
	$.ajax({
		  url: 'http://www.visitdevonandcornwall.com/getdata.php',
		  dataType : "html",
		  data : ({type : $("#type1 >option:selected").val(),town1 : $("#town1").val(),area1 : $("#area1 option:selected").val(),beds : $("#beds1 option:selected").val(),sleeps : $("#sleeps1 option:selected").val(),
			  beach : beach,nearbeach : nearbeach,lake : lake,marina : marina,mountain : mountain,city : city,resort : resort,rural : rural,townloc : townloc,village : village,golf : golf,ongolf:ongolf,wash : wash, dish:dish,ppool :ppool , aircon : aircon, heat : heat,sat: sat, bbq : bbq,bband : bband,wheel:wheel,disable: disable,smoke :smoking ,pets :pets,child : child,dvd : dvd, parking : parking , cpool: cpool,sd:sd,ed:ed}),
		  success: function(data) {
		    $(".center").html(data);
			$("input:submit").button();
			$("a", ".tac").button();
		  }
		});
}

	$(".change").bind("change",function(){
		//if ($(this).val() != ""
		var beach = $("#beachfront").attr("checked")== true ? 1 : 0;
		var nearbeach = $("#nearbeach").attr("checked")== true ? 1 : 0;
		var lake = $("#lake").attr("checked")== true ? 1 : 0;
		var marina = $("#marina").attr("checked")== true ? 1 : 0;
		var mountain = $("#mountain").attr("checked")== true ? 1 : 0;
		var city = $("#city").attr("checked")== true ? 1 : 0;
		var resort = $("#resort").attr("checked")== true ? 1 : 0;
		var rural = $("#rural").attr("checked")== true ? 1 : 0;
		var townloc = $("#town").attr("checked")== true ? 1 : 0;
		var village = $("#village").attr("checked")== true ? 1 : 0;
		var golf = $("#neargolf").attr("checked")== true ? 1 : 0;
		var ongolf = $("#ongolf").attr("checked")==true ? 1 : 0;
		var wash = $("#washmachine").attr("checked")==true ? 1 : 0;
		var dish = $("#dishwasher").attr("checked")==true ? 1 : 0;
		var ppool = $("#privatepool").attr("checked")==true ? 1 : 0;
		var aircon = $("#air-con").attr("checked")==true ? 1 : 0;
		var heat = $("#heating").attr("checked")==true ? 1 : 0;
		var sat = $("#sattv").attr("checked")==true ? 1 : 0;
		var bbq = $("#bbq").attr("checked")==true ? 1 : 0;
		var bband = $("#internet").attr("checked")==true ? 1 : 0;
		var wheel = $("#wheelchair").attr("checked")==true ? 1 : 0;
		var disable = $("#disability").attr("checked")==true ? 1 : 0
		var smoking = $("#smoking").attr("checked")==true ? 1 : 0;
		var pets = $("#pets").attr("checked")==true ? 1 : 0;
		var cpool = $("#communalpool").attr("checked")==true ? 1 : 0;
		var child = $("#children").attr("checked")==true ? 1 : 0
		var dvd = $("#dvd").attr("checked")==true ? 1 : 0;
		var parking = $("#parking").attr("checked")==true ? 1 : 0;


			


	
		//var sd = 

		//var ed = 
				
		$.ajax({
			  url: 'http://www.visitdevonandcornwall.com/getdata.php',
			  dataType : "html",
			  data : ({type : $("#type1 >option:selected").val(),town1 : $("#town1").val(),area1 : $("#area1 option:selected").val(),beds : $("#beds1 option:selected").val(),sleeps : $("#sleeps1 option:selected").val(),
				  beach : beach,nearbeach : nearbeach,lake : lake,marina : marina,mountain : mountain,city : city,resort : resort,rural : rural,townloc : townloc,village : village,golf : golf,ongolf:ongolf,
						  wash : wash,
								  dish:dish,
										  ppool :ppool , aircon : aircon, heat : heat,
												   sat: sat, bbq : bbq,
														   bband : bband,wheel:wheel,
																   disable: disable,smoke :smoking ,
																		   pets :pets,child : child,
																				   dvd : dvd, parking : parking , 
																						   cpool: cpool,sd:sd,ed:ed}),
			  success: function(data) {
			    $(".center").html(data);
				$("input:submit").button();
				$("a", ".tac").button();
			  }
			});



	})




});
