	$(function(){

	$("#ptype").change(function(){
					var a=$("#ptype").val();

	if(a!=""){		
	switch(a){
		
	case "1":
		$('#pr_feat, #c_area, #t_floor, #amenities, #balc, #unit_price, #f_no').hide();
		$('#facg').show();
		$('#distances').show();
		$("#form").attr("action", "process/residential_plot_process.php");
		break;
		
	case "2":
		$('#balc, #c_area, #pr_feat, #t_floor, #facg, #bed, #amenities').show();
		$('#unit_price,#f_no').hide();
		$('input:checkbox').attr("disabled", false);
		$("#form").attr("action", "process/residential_house_process.php");
		break;
		
	case "3":
		$('#balc, #pr_feat, #c_area, #t_floor, #amenities, #facg, #f_no, #bed, #bath').show();
		$('#unit_price').hide();
		$('input:checkbox').attr("disabled", false);
		$("#form").attr("action", "process/builder_floor_process1.php");

		break;
		
	case "5":
		$('#pr_feat, #c_area, #t_floor, #amenities, #facg, #f_no, #balc, #unit_price, #const').hide();
		$("#form").attr("action", "process/commercial_land_process.php");
		break;	
		
	case "6":
		$('#pr_feat, #c_area, #t_floor, #amenities, #facg, #f_no, #furnish, #const, #unit_price, #bath').show();
		$('#bed, #balc').hide();
		$('#ah1, #ah2, #ah3, #ah8').attr("disabled", true);
		$('#ah4, #ah6, #ah7').attr("disabled", false);
		$('#ea3,#ea4,#ea5,#ea6,#ea7,#ea13,#ea14,#ea15,#ea16,#ea17,#ea18').attr("disabled", true);
		$('#ea20').attr("disabled", false);
		$("#form").attr("action", "process/office_space_process.php");
		break;	
		
	case "7":
		$('#bed, #balc, #bath').hide();
		$('#c_area, #t_floor, #amenities, #facg, #f_no, #furnish, #const, #unit_price').show();
		$('#ah1, #ah2, #ah3, #ah8').attr("disabled", true);
		$('#ea3,#ea4,#ea5,#ea6,#ea7,#ea13,#ea14,#ea15,#ea16,#ea17,#ea18, #ea20').attr("disabled", true);
		$("#form").attr("action", "process/commercial_shop_process.php");
		break;	
		
	case "8":
		$('#bed, #balc').hide();
		$('#bath, #c_area, #t_floor, #amenities, #facg, #f_no, #furnish, #const, #unit_price').show();
		$('#ah1, #ah2, #ah3, #ah8').attr("disabled", true);
		$('#ea3,#ea4,#ea5,#ea6,#ea7,#ea13,#ea14,#ea15,#ea16,#ea17,#ea18, #ea20').attr("disabled", true);
		$("#form").attr("action", "process/commercial_showrooms_process.php");
		break;
		
	case "9":
	    $('#pr_feat, #balc, #bath, #f_no, #t_floor, #c_area, #amenities, #facg, #unit_price').hide();
		$("#form").attr("action", "process/hotel_sites_process.php");
		break;
		
	case "10":
		$(' #bed, #unit_price, #balc').hide();
		$(' #c_area, #bath, #t_floor, #amenities, #f_no, #furnish, #const, #facg').show();
		$('#ah1,#ah2,#ah3,#ea6,#ea4,#ea5,#ea6,#ea7,#ea13,#ea14,#ea15, #ea18').attr("disabled", true);
		$('#ea20,#ea16,#ea17,').attr("disabled", false);
		$("#form").attr("action", "process/business_center_process.php");

		break;
		
	case "11":
		$('#bath,#bed, #facg,#balc').hide();
		$(' #c_area, #t_floor, #amenities,  #f_no, #furnish, #const, #unit_price').show();
		$('#ah1,#ah2,#ah3, #ah6, #ah7, #ah8,#ea3,#ea4,#ea5,#ea6,#ea7,#ea12,#ea13,#ea14,#ea15,#ea16,#ea17, #ea18, #ea19,#ea20').attr("disabled", true);
		$("#form").attr("action", "process/warehouses_process.php");
		break;	
		
	case "12":
		$('#f_no, #unit_price, #bed, #balc, #bath, #c_area, #t_floor, #amenities').hide();
		$('#furnish, #facg, #const').show();
		$("#form").attr("action", "process/industrial_lands_process.php");
		break;	
		
		
	case "14":
		$('#pr_feat, #c_area, #t_floor, #amenities, #facg, #f_no, #balc, #unit_price, #const').hide();
		$("#form").attr("action", "process/agricultral_land_process.php");
		break;	
		
	case "4":
		$(' #f_no, #unit_price').hide();
		$('#c_area,#balc, #t_floor, #amenities, #facg, #furnish, #const, #bed, #bath').show();
		$('input:checkbox').attr("disabled", false);
		$("#form").attr("action", "process/farm_house_process.php");		
		break;	
		
	case "13":
		$('#balc, #bed, #unit_price').hide();
		$('#c_area, #bath, #t_floor, #amenities, #facg, #f_no, #furnish, #const,').show();
		$('#ah1, #ah2, #ah3, #ah4, #ah6, #ah7, #ah8').attr("disabled", true);
		$('input:checkbox').attr("disabled", false);
		$("#form").attr("action", "process/industrial_building_process.php");


		break;		

	default:

				alert("its default");
		
		}
}
	});
	
		$("#rptype").change(function(){
					var b=$("#rptype").val();

	if(b!=""){		
	switch(b){
		
	case "2":
		$('#balc, #c_area, #pr_feat, #t_floor, #facg, #bed, #amenities').show();
		$('#unit_price,#f_no').hide();
		$('input:checkbox').attr("disabled", false);
		$("#form").attr("action", "process/residential_house_process.php");
		break;
		
	case "3":
		$('#balc, #pr_feat, #c_area, #t_floor, #amenities, #facg, #f_no, #bed').show();
		$('#unit_price').hide();
		$('input:checkbox').attr("disabled", false);
		$("#form").attr("action", "process/builder_floor_process1.php");
		break;

	case "6":
		$('#pr_feat, #c_area, #t_floor, #amenities, #facg, #f_no, #furnish, #const, #unit_price, #bath').show();
		$('#bed, #balc').hide();
		$('#ah1, #ah2, #ah3, #ah8').attr("disabled", true);
		$('#ea3,#ea4,#ea5,#ea6,#ea7,#ea13,#ea14,#ea15,#ea16,#ea17,#ea18').attr("disabled", true);
		$('#ea20').attr("disabled", false);
		$("#form").attr("action", "process/office_space_process.php");
		break;	
		
	case "7":
		$('#bed, #balc, #bath').hide();
		$('#c_area, #t_floor, #amenities, #facg, #f_no, #furnish, #const, #unit_price').show();
		$('#ah1, #ah2, #ah3, #ah8').attr("disabled", true);
		$('#ea3,#ea4,#ea5,#ea6,#ea7,#ea13,#ea14,#ea15,#ea16,#ea17,#ea18, #ea20').attr("disabled", true);
		$("#form").attr("action", "process/commercial_shop_process.php");


		break;	
		
	case "8":
		$('#bed, #balc').hide();
		$('#bath, #c_area, #t_floor, #amenities, #facg, #f_no, #furnish, #const, #unit_price').show();
		$('#ah1, #ah2, #ah3, #ah8').attr("disabled", true);
		$('#ea3,#ea4,#ea5,#ea6,#ea7,#ea13,#ea14,#ea15,#ea16,#ea17,#ea18, #ea20').attr("disabled", true);
		$("#form").attr("action", "process/commercial_showrooms_process.php");
		break;
		
	case "10":
		$(' #bed, #unit_price, #balc').hide();
		$(' #c_area, #bath, #t_floor, #amenities, #f_no, #furnish, #const, #facg').show();
		$('#ah1,#ah2,#ah3,#ea6,#ea4,#ea5,#ea6,#ea7,#ea13,#ea14,#ea15, #ea18').attr("disabled", true);
		$('#ea20,#ea16,#ea17,').attr("disabled", false);
		$("#form").attr("action", "process/business_center_process.php");
		break;
		
	case "11":
		$('#bath,#bed, #facg,#balc').hide();
		$(' #c_area, #t_floor, #amenities,  #f_no, #furnish, #const, #unit_price').show();
		$('#ah1,#ah2,#ah3, #ah6, #ah7, #ah8,#ea3,#ea4,#ea5,#ea6,#ea7,#ea12,#ea13,#ea14,#ea15,#ea16,#ea17, #ea18, #ea19,#ea20').attr("disabled", true);
		$("#form").attr("action", "process/warehouses_process.php");
		break;	

	case "4":
		$('  #f_no, #unit_price').hide();
		$('#c_area, #amenities, #facg, #furnish, #const, #t_floor, #bed, #bath, #balc').show();
		$('input:checkbox').attr("disabled", false);
		$("#form").attr("action", "process/farm_house_process.php");	
		break;	
		
	case "13":
		$('#balc, #bed, #unit_price').hide();
		$('#c_area, #bath, #t_floor, #amenities, #facg, #f_no, #furnish, #const').show();
		$('input:checkbox').attr("disabled", false);
		$("#form").attr("action", "process/industrial_building_process.php");


		break;		

	default:

				alert("its default");

		
				}
}
	});


	
	$("input[name='ttype']").click(function(evt)
{
	var radio=$(this).val();
	if(radio=="rent")
	{
		$('#rproperty_type, #monthly').show()
		$('#sproperty_type, #total').hide()
	}
	else if(radio=="sell")
	{
		$('#rproperty_type, #monthly').hide()
		$('#sproperty_type, #total').show()
	}
});

	
	
	
	
		var j = $('[type="file"]').size() + 1;
		var cap=$("#imge input:text").size() + 1;
				 // check how many input exists on the document and add 1 for the add command to work

	$('#add').click(function() { // when you click the add link
		$('<p><input type="file" name="' + "img" +j + '" style="'+'margin-left:140px"'+'/> <input type="text" name="' + "cap" +cap + '" style="'+'margin-left:"'+'/></p>').appendTo('#imge'); // append (add) a new input to the document.
// if you have the input inside a form, change body to form in the appendTo
		j++; //after the click i will be i = 3 if you click again i will be i = 4
		cap++
	});

	$('a#remove').click(function() { // similar to the previous, when you click remove link
	if(j > 2) { // if you have at least 1 input on the form
		$('[type="file"]:last').remove(); //remove the last input
		$('#imge input:last').remove();
		cap--
		j--; //deduct 1 from i so if i = 3, after i--, i will be i = 2
	}
	});

	$('a#reset').click(function() {
	while(j > 2) { // while you have more than 1 input on the page
		$('input:last').remove(); // remove inputs
		j--;
	}
	});
	

	
	});
	
	function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		//Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		
	}
	return xmlHttp;
}

function populateloc(){
	xmlHttpsub=GetXmlHttpObject();
	if (xmlHttpsub==null)
	{
		alert ("Browser does not support HTTP Request");
		return false;
	}
	var city=document.getElementById("city").value;
	
	if(city!=''){
	var url="test2.php?city="+city;

	xmlHttpsub.open("GET",url,false);
	xmlHttpsub.send(null);
	document.getElementById('locality').innerHTML='<option value="" selected="selected">--Select Locality--</option>'+xmlHttpsub.responseText;
	}
//	strlengthSec=xmlHttpsub.responseText;
	return xmlHttpsub.responseText;
}

//NOTE: test() function is to be called on the website on "onchange"
	
	function set_seourl()
{
	seo_url = document.getElementById("seo_url");
	title = document.getElementById("ptitle");

	seo_url.value =  title.value.replace(/[ ]+/g,'-');
	seo_url.value =  seo_url.value.replace(/[--]+/g,'-');
	//alert(seo.value);
	seo_url.value =  seo_url.value.replace(/[^a-zA-Z-.,_0-9\/]+/g,'');
}


