function fillCategory(){ 
 	// this function is used to fill the category list on load

	removeAllOptions(document.myform.Category);
	addOption(document.myform.Category, "", "Select the Property", "");

	addOption(document.myform.Category, "Residential", "Residential", "");
	addOption(document.myform.Category, "Commercial", "Commercial", "");
}

function testing(){
	//alert(document.myform.Category.value);
	if(document.myform.Category.value == 'Residential'){
		document.myform.bedrooms.disabled = false;
	}
	else if(document.myform.Category.value == 'Commercial'){
		document.myform.bedrooms.disabled = true;
	}
}

function SelectAreas(){
	// ON selection of category this function will work

	if(document.myform.searchStr[0].checked == true || document.myform.searchStr[1].checked == true)
	{
		removeAllOptions(document.myform.Areas);
		addOption(document.myform.Areas, "", "Select an area", "");
	
		removeAllOptions(document.myform.SubCat);
		addOption(document.myform.SubCat, "", "Select the Budget", "");
	
		removeAllOptions(document.myform.bedrooms);
		addOption(document.myform.bedrooms, "", "Bedrooms", "");

		if(document.myform.Category.value == 'Residential' && document.myform.searchStr[1].checked == true){
			addOption(document.myform.Areas,"Adyar", "Adyar");
			addOption(document.myform.Areas,"Alwarpet", "Alwarpet");
			addOption(document.myform.Areas,"Anna Nagar", "Anna Nagar");
			addOption(document.myform.Areas,"Ashok Nagar", "Ashok Nagar");
			addOption(document.myform.Areas,"Banglore", "Banglore");
			addOption(document.myform.Areas,"Besant Nagar", "Besant Nagar");
			addOption(document.myform.Areas,"East Tambaram", "East Tambaram");
			addOption(document.myform.Areas,"Guindy", "Guindy");
			addOption(document.myform.Areas,"Iyyappathangal", "Iyyappathangal");
			addOption(document.myform.Areas,"Kilkattalai", "Kilkattalai");
			addOption(document.myform.Areas,"Kodambakkam", "Kodambakkam");
			addOption(document.myform.Areas,"Kotturpuram", "Kotturpuram");
			addOption(document.myform.Areas,"Meenambakam", "Meenambakam");
			addOption(document.myform.Areas,"Pallikaranai", "Pallikaranai");
			addOption(document.myform.Areas,"Perungudi", "Perungudi");
			addOption(document.myform.Areas,"Porur", "Porur");
			addOption(document.myform.Areas,"R.A. Puram", "R.A. Puram");
			addOption(document.myform.Areas,"Saidapet", "Saidapet");
			addOption(document.myform.Areas,"Siruseri", "Siruseri");
			addOption(document.myform.Areas,"T Nagar", "T Nagar");
			addOption(document.myform.Areas,"Taramani", "Taramani");
			addOption(document.myform.Areas,"Thiruvanmiyur", "Thiruvanmiyur");
			addOption(document.myform.Areas,"Thoraipakkam", "Thoraipakkam");
			addOption(document.myform.Areas,"Velachery", "Velachery");
		
			addOption(document.myform.SubCat,"5000-10000", "5000-10000");
			addOption(document.myform.SubCat,"10000-15000", "10000-15000");
			addOption(document.myform.SubCat,"15000-20000", "15000-20000");
			addOption(document.myform.SubCat,"20000-25000", "20000-25000");
			addOption(document.myform.SubCat,"25000-30000", "25000-30000");
			addOption(document.myform.SubCat,"30000-35000", "30000-35000");
			addOption(document.myform.SubCat,"35000-40000", "35000-40000");
			addOption(document.myform.SubCat,"40000-45000", "40000-45000");
			addOption(document.myform.SubCat,"45000-50000", "45000-50000");

			addOption(document.myform.bedrooms, "1", "1");
			addOption(document.myform.bedrooms, "2", "2");
			addOption(document.myform.bedrooms, "3", "3");
			addOption(document.myform.bedrooms, "4", "4");
			addOption(document.myform.bedrooms, "4+", "4+");
		}
		else if(document.myform.Category.value == 'Commercial' && document.myform.searchStr[1].checked == true){
			addOption(document.myform.Areas,"Adyar", "Adyar");
			addOption(document.myform.Areas,"Besant Nagar", "Besant Nagar");
			addOption(document.myform.Areas,"Perungudi", "Perungudi");
			addOption(document.myform.Areas,"T. Nagar", "T. Nagar");
			addOption(document.myform.Areas,"Thiruvanmiyur", "Thiruvanmiyur");
	
			addOption(document.myform.SubCat,"10000-20000", "10000-20000");
			addOption(document.myform.SubCat,"20000-30000", "20000-30000");
			addOption(document.myform.SubCat,"30000-40000", "30000-40000");
			addOption(document.myform.SubCat,"40000-50000", "40000-50000");
			addOption(document.myform.SubCat,"50000-60000", "50000-60000");
			addOption(document.myform.SubCat,"60000-70000", "60000-70000");
			addOption(document.myform.SubCat,"70000-80000", "70000-80000");
			addOption(document.myform.SubCat,"80000-90000", "80000-90000");
			addOption(document.myform.SubCat,"90000-100000", "90000-100000");
		}
		else if(document.myform.Category.value == 'Commercial' && document.myform.searchStr[0].checked == true || document.myform.Category.value == 'Residential' && document.myform.searchStr[0].checked == true){
			addOption(document.myform.Areas,"Adyar", "Adyar");
			addOption(document.myform.Areas,"Besant Nagar", "Besant Nagar");
			addOption(document.myform.Areas,"Thriuvanmaiyur", "Thiruvanmaiyur");
			addOption(document.myform.Areas,"Velachery", "Velachery");
			addOption(document.myform.Areas,"Otherareas", "Otherareas");
	
			addOption(document.myform.SubCat,"5 lacs-25 lacs", "5 lacs-25 lacs");
			addOption(document.myform.SubCat,"25 lacs-40 lacs", "25 lacs-40 lacs");
			addOption(document.myform.SubCat,"40 lacs-60 lacs", "40 lacs-60 lacs");
			addOption(document.myform.SubCat,"60 lacs-1 crore", "60 lacs-1 crore");
			addOption(document.myform.SubCat,"1 crore-2 crore", "1 crore-2 crore");
			addOption(document.myform.SubCat,"2 crore-3 crore", "2 crore-3 crore");
			addOption(document.myform.SubCat,"2 crore-3 crore", "2 crore-3 crore");
			addOption(document.myform.SubCat,"any", "any");

			addOption(document.myform.bedrooms, "1", "1");
			addOption(document.myform.bedrooms, "2", "2");
			addOption(document.myform.bedrooms, "3", "3");
			addOption(document.myform.bedrooms, "4", "4");
			addOption(document.myform.bedrooms, "4+", "4+");
		}
	}
	else
	{
		alert("Choose Buy or Rent Option to Proceed.");
	}
}
///////////////// 

function removeAllOptions(selectbox)
{
	var i;
	for(i=selectbox.options.length-1;i>=0;i--)
	{
		//selectbox.options.remove(i);
		selectbox.remove(i);
	}
}

function addOption(selectbox, value, text )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;

	selectbox.options.add(optn);
}