
$(document).ready(function() {
	// put all your jQuery goodness in here.


	$('#contactus').click(
			function() {
			
				
				dataString = $("#enquiryform").serialize();
				$.post("/index/requestinfo", dataString);
				var d = new Date();
				$('#inforequestmessage')
						.html(
								"Info has been requested "
										+ d.toLocaleString());
			});
	
	
	$('#btn_propertyenquiry').click(
			function() {
				
				
				
				$("#enquiry-form").validate({
					  rules: {
						mobilephone: {
					      required: true,
					      digits: true
					    },
					    firstname: {
					    	required: true,
					    	minlength: 3

					    	
					    	
					    },
					    
					    surname: {
					    	required: true,
					    	minlength: 3
					    	
					    	
					    },

					    
					    email: {
					    	required: true,
					    	email: true

					    	
					    	
					    },
					    
					    query: {
					    	required: true,
					    	minlength: 10
					    	
					    	
					    }
					    
					    
					    
					  }
					});
				
	if (!$("#enquiry-form").validate().form() ) {
					
					return;
					
					
				} 
			
				dataString = $("#enquiry-form").serialize();
				$.post("/index/requestinfo", dataString);
				var d = new Date();
				
				$("#enquiry-form").fadeOut('slow',function(){});
				$('#inforequestmessage')
						.html(
								"<em>Thank you. Your enquiry has been sent "
										+ d.toLocaleString() + ". One of our team will contact you shortly to arrange an appointment to view this property. " + "</em>");
									
			});
	
	
	$('#btnRequestValuation').click(
			function() {
				
				$("#sidebar-form").validate({
					  rules: {
					  phoneValuation: {
					      required: true,
					      digits: true,
					      minlength: 6
					    },
					    
					    cemail: {
					    	required: true,
					    	email: true,
					    	

					    	
					    	
					    },
					    
					    cname: {
					    	required: true,
					    	minlength: 2

					    	
					    	
					    }
					    
					    
					  }
					});

				
				

				
			
				if (!$("#sidebar-form").validate().form() ) {
					
					return;
					
					
				} 
			
				dataString = $("#sidebar-form").serialize();
				
				$.post("/index/requestval", dataString);
				var d = new Date();
				
				$("#sidebar-form").fadeOut('slow',function(){});
				$('#valuation_request_message')
						.html(
								"<em>Thank you. Your enquiry has been sent "
										+ d.toLocaleString() + ". We will be in touch shortly</em>");
									
			});
	
	

	
	
	$('#gallery a').lightBox({fixedNavigation:true});
	
	
	$('#homesalestype').change(function(){
		
		var chosenValue = $('#homesalestype').val();
		
		var salePrices = Array("Any Price","0-100K","100-150K","150-250K","250-350K","350-450K","450-550k","550-650k","650-750k","750-850K","950+");
		var salePricesVal = Array(0,100,150,250,350,450,550,650,750,850,950);
		var rentPrices = Array("Any Price","0k-1k monthly","1k-2k monthly","2k-3k monthly","3k-4k monthly","4k-5k monthly","5k-6k monthly","7k-8k monthly","9k-10k monthly","10k-11k monthly");
		var rentPricesVal = Array(0,1,2,3,4,5,6,7,8,9,10);
		
		//console.log(chosenValue);
		
		$('#pricepoint-max').empty();
		
		var len = chosenValue == 1 ? salePrices.length : rentPrices.length;
		
		var chosenArray = chosenValue == 1 ? salePrices : rentPrices;
		
		var chosenArrayOptions = chosenValue == 1 ? salePricesVal : rentPricesVal;
		
		for(i=0; i <len; i++) {
			
			$('#pricepoint-max').append($("<option>").val(chosenArrayOptions[i]).text(chosenArray[i]));
		
		}
		
		
		
	}) ;
	


}); // close document ready







