// JavaScript Document

 $(function(){
	 
	 function changeLocation(val)
 {
	 
  
  $.ajax({ 
		   cache:false,
		   async:true,
		   type: "POST",
		   url: "location.php",
		   data: "name="+val,
		   success: function(msg){
			 if(msg == 0){
				  window.location = 'index.php';	// change the URL according to ur path
			  }
			  $("#locations").html(msg);
		   }
		});
  
  
 
 }

	changeLocation($("#city").val());
		
		$("#city").change(function(){
				changeLocation($(this).val());
			});
			
	
	 });
	 

 $(function(){
	 
	 
	 
		 $("#submitBuyData").click(function(){
		 //alert($("#priceRange").val());
		
		  if ($("#category").val()=="") 
					
						{
						jAlert('Please Select Catagory')
						return (false); 	
						}
							
							
							else if($("#city").val()==""){
								
								jAlert('Please Select City')
								return (false); 
								
															
								}
							else if($("#location").val()=="Location"){
								
								jAlert('Please Select Location')
								return (false); 
								
								}
							else if($("#propertyType").val()==""){
								
								jAlert('Please Select Property Type')
								return (false); 
																							
								}
							else if(($("#subBHKSlabsBuy").val()=="")|| ($("#subBHKSlabsBuy").val()=="Size")){
								
								jAlert('Please Select Size')
								return (false); 
																							
								}
							else if(($("#subBHKPropertyBuy").val()=="")|| ($("#subBHKPropertyBuy").val()=="Size")){
								
								jAlert('Please Select Size')
								return (false); 
																							
								}	
							else if(($("#subBHKSizesBuy").val()=="")|| ($("#subBHKSizesBuy").val()=="Size")){
								
								jAlert('Please Select Size')
								return (false); 
																							
								}			
		 					else if(($("#subBHKLandBuy").val()=="")|| ($("#subBHKLandBuy").val()=="Size")){
								
								jAlert('Please Select Size')
								return (false); 
																							
								}			
		 					else if($("#priceRange").val()==""){
								
								jAlert('Please Select Price Range')
								return (false); 
																							
								}
		 
		 
		 
		 
		 
		 /*if(($("#buyname").val()=="" ) || ($("#buyname").val()=="Name" )){
					jAlert('Please enter Name!');
					return (false); 
					}
		else if(($("#buyEmail").val()=="" ) || ($("#buyEmail").val()=="Email ID" ))
			{
				jAlert('Please enter EmailID!');
					return (false); 
			}
			
			else if(($("#buyMobile").val()=="" ) || ($("#buyMobile").val()=="Mobile" ))
			{
				jAlert('Please enter Contact number!');
					return (false); 
			}
			
			else if($("#buyEmail").val()!="")
				{
					var uemail=$("#buyEmail").val();
					var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; 
					if(reg.test(uemail) == false) {
						jAlert('Please enter valid email address');
						return (false); 
					}
				}*/
				
		
		 
		
		$.post("outputData.php",{
					category:$("#category").val(),
					city:$("#city").val(),
					location:$("#location").val(),
					propertyType:$("#propertyType").val(),
					subBHKSlabs:$("#subBHKSlabsBuy").val(),
					subBHKProperty:$("#subBHKPropertyBuy").val(),
					subBHKSizes:$("#subBHKSizesBuy").val(),
					subBHKLand:$("#subBHKLandBuy").val(),
					priceRange:$("#priceRange").val(),
					/*buyName:$("#buyname").val(),
					buyEmail:$("#buyEmail").val(),
					buyMobile:$("#buyMobile").val(),*/
					
				},function(data){
					//alert (data);					
					
					if(data)
					{
					  
					  /*jConfirm('Thank you for submitting the details.Our representative will contact you with in 48 hours.', 'Confirmation Box', function(r){
						  //alert(r);//exit;
					   if(r){*/
					 window.location = 'searchResult_data.php';	
					   //}
					  //});
					}
					//tb_remove();
					});
		 });
	 
	 function changeProperty(val)
 {
	 
  
  $.ajax({ 
		   cache:false,
		   async:true,
		   type: "POST",
		   url: "property.php",
		   data: "name="+val,
		   success: function(msg){
			 if(msg == 0){
				  window.location = 'index.php';	// change the URL according to ur path
			  }
			  $("#property").html(msg);
			  changeSubProperty($("#propertyType").val());
		   }
		});
  
   
 
 }

	changeProperty($("#category").val());
		
		$("#category").change(function(){
				changeProperty($(this).val());
			});
			
	
	
	 function changeSubProperty(val)
 {
	 
  if(val==11 || val==5 || val==6 || val==14)
  {
  $.ajax({ 
		   cache:false,
		   async:true,
		   type: "POST",
		   url: "subProperty_buy.php",
		   data: "name="+val,
		   success: function(msg){
			 if(msg == 0){
				  window.location = 'index.php';	// change the URL according to ur path
			  }
			  $("#subBHKS").html(msg);
		   }
		});
  
  
 
  }
  else if(val==7 || val==8 || val==12 || val==13)
  {
	  
	  $.ajax({ 
		   cache:false,
		   async:true,
		   type: "POST",
		   url: "subSizes_buy.php",
		   data: "name="+val,
		   success: function(msg){
			 if(msg == 0){
				  window.location = 'index.php';	// change the URL according to ur path
			  }
			  $("#subBHKS").html(msg);
		   }
		});
  
	  
	  
  }
  
   else if(val==2)
  {
	  
	  $.ajax({ 
		   cache:false,
		   async:true,
		   type: "POST",
		   url: "subSlabs_buy.php",
		   data: "name="+val,
		   success: function(msg){
			 if(msg == 0){
				  window.location = 'index.php';	// change the URL according to ur path
			  }
			  $("#subBHKS").html(msg);
		   }
		});
  
	  
	  
  }
    else if(val==15 || val==16 || val ==4 || val ==3)
  {
	  
	  $.ajax({ 
		   cache:false,
		   async:true,
		   type: "POST",
		   url: "subLandSizes_buy.php",
		   data: "name="+val,
		   success: function(msg){
			 if(msg == 0){
				  window.location = 'index.php';	// change the URL according to ur path
			  }
			  $("#subBHKS").html(msg);
		   }
		});
  
	  
	  
  }
		
 }
 changeSubProperty($("#propertyType").val());
 
	$("#propertyType").live("change",function(){
		changeSubProperty($(this).val());
	 	});
		
		

	 		
		

});
	 

