

function validateAlertForm() {
		
		for(i=1;i<document.theForm.cat.length;i=i+1)
		{
			if(document.theForm.cat[i].checked)
			{
				cat_ok = true;
				break;
			}
			else
			{
				cat_ok = false;
			}
		}
		if(!cat_ok)
		{
			alert('Please select an area.');
			return;	
		}
		var minp=document.theForm.min_price.options.value;
		var maxp=document.theForm.max_price.options.value;
		if (Number(minp) > Number(maxp)){			
			alert('Please select less min price than max price.');
			document.theForm.min_price.focus();
			return;
		}
		
		
		if(document.theForm.email.value == '')
		{
			alert('Please enter your email.');
			document.theForm.email.focus();
		}
		document.theForm.submit();
	
	}
	
	function ifAll(){
		if(document.theForm.allareas.checked == true){
		
			for (loop=0; loop < document.theForm.cat.options.length; loop++)
  			{
				document.theForm.cat.options[loop].selected = true;
			}
		}else{
			for (loop=0; loop < document.theForm.cat.options.length; loop++)
  			{
				document.theForm.cat.options[loop].selected = false;
			}
		}
	}
	
	function selectField(value) {
				
					document.theForm.searchType.value = value;
				
					if (value==2) {
						document.theForm.aType[1].checked=0;
						document.theForm.aType[0].checked=1;
						document.theForm.aType[2].checked=0;	
			
						document.theForm.min_price.options[0] = new Option("$0","0");
						document.theForm.max_price.options[0] = new Option("No Limit","99999999");
						l = document.theForm.max_price.options.length;
						for (i=1;i<=l;i++) {
							document.theForm.min_price.options[1] = null;
							document.theForm.max_price.options[1] = null;
						}
						document.theForm.min_price.options[1] = new Option("$1000",1000);
						document.theForm.max_price.options[1] = new Option("$1000",1000);
						document.theForm.min_price.options[2] = new Option("$1500",1500);
						document.theForm.max_price.options[2] = new Option("$1500",1500);
						document.theForm.min_price.options[3] = new Option("$2000",2000);
						document.theForm.max_price.options[3] = new Option("$2000",2000);
						document.theForm.min_price.options[4] = new Option("$3000",3000);
						document.theForm.max_price.options[4] = new Option("$3000",3000);
						document.theForm.min_price.options[5] = new Option("$4000",4000);
						document.theForm.max_price.options[5] = new Option("$4000",4000);
						document.theForm.min_price.options[6] = new Option("$5000",5000);
						document.theForm.max_price.options[6] = new Option("$5000",5000);
						document.theForm.min_price.options[7] = new Option("$6000",6000);
						document.theForm.max_price.options[7] = new Option("$6000",6000);
						document.theForm.min_price.options[8] = new Option("$7000",7000);
						document.theForm.max_price.options[8] = new Option("$7000",7000);
						document.theForm.min_price.options[9] = new Option("$8000",8000);
						document.theForm.max_price.options[9] = new Option("$8000",8000);
						document.theForm.min_price.options[10] = new Option("$10000",10000);
						document.theForm.max_price.options[10] = new Option("$10000",10000);
						/*document.theForm.search_Type.checked = true;*/
					} else {
						if(value == 1)
						{
							document.theForm.aType[0].checked=0;
							document.theForm.aType[1].checked=1;
							document.theForm.aType[2].checked=0;							
						}
						else if(value == 3)
						{
							document.theForm.aType[0].checked=0;
							document.theForm.aType[1].checked=0;
							document.theForm.aType[2].checked=1;							
						}
						l = document.theForm.max_price.options.length;
						for (i=1;i<=l;i++) {
							document.theForm.min_price.options[1] = null;
							document.theForm.max_price.options[1] = null;
						}
						document.theForm.min_price.options[0] = new Option("$0","0");
						document.theForm.max_price.options[0] = new Option("No Limit","99999999");
						j=0;
						for (i=100000;i<=350000;i+=25000) {
							j++;
							document.theForm.min_price.options[j] = new Option("$"+i,i);
							document.theForm.max_price.options[j] = new Option("$"+i,i);
						}
						for (i=400000;i<=900000;i+=50000) {
							j++;
							document.theForm.min_price.options[j] = new Option("$"+i,i);
							document.theForm.max_price.options[j] = new Option("$"+i,i);
						}
						for (i=1000000;i<=1600000;i+=100000) {
							j++;
							document.theForm.min_price.options[j] = new Option("$"+i,i);
							document.theForm.max_price.options[j] = new Option("$"+i,i);
						}
						j++;
						document.theForm.min_price.options[j] = new Option("$1750000",1750000);
						document.theForm.max_price.options[j] = new Option("$1750000",1750000);
						for (i=2000000;i<=5000000;i+=500000) {
							j++;
							document.theForm.min_price.options[j] = new Option("$"+i,i);
							document.theForm.max_price.options[j] = new Option("$"+i,i);
						}
						
						j++;
						document.theForm.min_price.options[j] = new Option("$6000000",6000000);
						document.theForm.max_price.options[j] = new Option("$6000000",6000000);
						j++;
						document.theForm.min_price.options[j] = new Option("$8000000",8000000);
						document.theForm.max_price.options[j] = new Option("$8000000",8000000);
					}
				}




function selectRooms(value){
	if(value == 1){
		DWRUtil.removeAllOptions("beds");
		DWRUtil.addOptions("beds", {1:'1 Family+',2:'2 Family+',3:'3 Family+',4:'4 Family+',99:'5 Family and UP'});
	}else{
		DWRUtil.removeAllOptions("beds");
		DWRUtil.addOptions("beds", {0:'Studio',1:'1 BR+',2:'2 BR+',99:'3 BR and UP'	});
	}
}
