 function MM_openBrWindow(theURL,winName,features) { //v2.0
	 window.open(theURL,winName,features);
  }
  function Show_Map(city,country,city_id,Longitude,Latitude){
  	  document.frm_search.city.value=city;
	  document.frm_search.country.value=country;
	  document.frm_search.city_id.value=city_id;
	  document.frm_search.Longitude.value=Longitude;
	  document.frm_search.Latitude.value=Latitude;
	  document.frm_search.method="post";
	  document.frm_search.action="show_map.html";
	  //document.frm_search.action="show_map.php";
	  document.frm_search.submit();
  }
   function Go_Search1(city_id){
  	  document.frm_search.method="post";
	  document.frm_search.action="search.html";
	   //document.frm_search.action="search.php";
	  document.frm_search.city_id.value=city_id;
	  document.frm_search.submit();
  }
  function Go_Spl_Feat_Spots(){
  	  document.frm_search.method="post";
	  document.frm_search.action="spl_feat_spots.html";
	  document.frm_search.submit();
  }
  function Go_View_Index(store_room_id){
	  document.frm_search.method="post";
	  document.frm_search.action="view.html";
	  document.frm_search.store_room_id.value=store_room_id;
	  document.frm_search.submit();
  }

 

  function Check_Post_Code(){
  	var sid=document.frm_search.state_id.value;
	var pcode=document.frm_search.post_code.value;
	//alert(pcode);
	if(pcode!=''){
		//alert(isNumeric(document.frm_search.post_code.value));
		if(isNumeric(document.frm_search.post_code.value) == true){
			var len=pcode.length;
			var first_char=pcode.substring(0, 1);
			var bool=false;
			if(sid=='2'){ 
				if(first_char=='2'){
					bool=true;
				}
			}
			if(sid=='7'){
				if(first_char=='3'){ 
					bool=true;
				}
			}
			if(sid=='4'){
				if(first_char=='4'){ 
					bool=true;
				}
			}
			if(sid=='1'){
				if(first_char=='2'){ 
					bool=true;
				}
			}
			if(sid=='3'){
				if(first_char=='0'){ 
					bool=true;
				}
			}
			if(sid=='8'){
				if(first_char=='6'){ 
					bool=true;
				}	
			}
			if(sid=='5'){
				if(first_char=='5'){ 
					bool=true;
				}	
			}
			if(sid=='6'){
				if(first_char=='7'){ 
					bool=true;
				}
			}
			if(bool==true){
				document.frm_search.method="post";
				document.frm_search.action="search.html";
				document.frm_search.submit();
				return true;
				
			}else{
				if(sid == '') {
					alert("Please enter a State");
					return false;
				}
				alert("Invalid Postcode\nNew South Wales starts with 2\nVictoria starts with 3\nQueensland starts with 4\nACT starts with 2\nNorthern Territories starts with 0\nWestern Australia starts with 6\nSouthern Australia starts with 5\nTasmania starts with 7");
				return false;
			}
		} // end of isNumeric
		else {
			document.frm_search.method="post";
			document.frm_search.action="search.html";
			document.frm_search.submit();
			return true;
		}
	}
	else {
		document.frm_search.method="post";
		document.frm_search.action="search.html";
		document.frm_search.submit();
		return true;
	}
		
		
  }

  function isNumeric(strString) 
   { 
		// check for valid numeric strings 
		var strValidChars = "0123456789"; // these are alloable chars
		var strChar; 
		var blnResult = true; 
		if (strString.length == 0) return false; 
		
		// test strString consists of valid characters listed above 
		for (i = 0; i<strString.length && blnResult == true; i++) 
		{ 
			strChar = strString.charAt(i); 
			if (strValidChars.indexOf(strChar) == -1) 
			{ 
				blnResult = false; 
			} 
		} 
		return blnResult; 
  }

function check(){
	
	if(document.frm_add_email.user_name.value==""){
			alert("Please enter your name.");
			document.frm_add_email.user_name.focus();
			return false;
	}
	if(document.frm_add_email.user_email.value==""){
			alert("Please enter your email.");
			document.frm_add_email.user_email.focus();
			return false;
	}
	var str=document.frm_add_email.user_email.value;

	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str)) {
		testresults=true;
	}
	else {
		alert("Please enter valid email");
		document.frm_add_email.user_email.focus();
		return false;
	}
	if(document.frm_add_email.post_code.value=="" && document.frm_add_email.suburb.value==""){
			alert("Please enter post code / suburb.");
			document.frm_add_email.post_code.focus();
			return false;
	}
	if(document.frm_add_email.post_code.value!="" && document.frm_add_email.post_code.value.length != 4){
			alert("Please enter 4 digit post code.");
			document.frm_add_email.post_code.focus();
			return false;
	}
	if(document.frm_add_email.rent_from.value==""){
			alert("Please enter Minimum monthly Rent Amount.");
			document.frm_add_email.rent_from.focus();
			return false;
	}
	if(isNaN(document.frm_add_email.rent_from.value)||(document.frm_add_email.rent_from.value<=0)) {
		alert("Please Enter Minimum montly Rent Amount");
		document.frm_add_email.rent_from.focus();
		return false;
	}
	if(document.frm_add_email.rent_to.value==""){
			alert("Please enter Maximum Rent Amount.");
			document.frm_add_email.rent_to.focus();
			return false;
	}
	if(isNaN(document.frm_add_email.rent_to.value)||(document.frm_add_email.rent_to.value<=0)) {
		alert("Please Enter a Rent To amount");
		document.frm_add_email.rent_to.focus();
		return false;
	}
		/*alert("Minimum Monthly Rent cannot be greater than Maximum Rent amount");
		document.frm_add_email.rent_from.focus();
		return false;
	}*/
	
	var ischk = false;
	var issellchk = false;
	if(document.frm_add_email.is_rent.checked==true){
		ischk = true;
	}
	if(document.frm_add_email.is_sell.checked==true){
		issellchk = true;
	}
	
	if(!ischk && !issellchk) {
		alert("Please Tick the Search For Storerooms To Rent/ Sell/ both box.");
		return false;
	}
	document.frm_add_email.method="post";
	document.frm_add_email.submit();
	
}

function CheckNumeric(e) {   
    var key = (window.event) ? event.keyCode : e.which;   
	if (window.event)     
	    key = event.keyCode   
	else     key = e.which   // Was key that was pressed a numeric character (0-9) or backspace (8)?   
	if ( key > 47 && key < 58 || key == 8 || key == 46 )    
	 return; // if so, do nothing   
	else // otherwise, discard character     
	if (window.event) //IE      
	// window.event.returnValue = null;    
	window.event.keyCode=0;
	  else //Firefox       
	  e.preventDefault(); 
  }


  
  function Go_Search2(show_for){
		//alert(show_for);
		document.frm_email.method="post";
		document.frm_email.show_for.value=show_for;
		document.frm_email.action="search.html";
		document.frm_email.submit();
	}
	function update(){
		document.frm_email_update.method="post";
		document.frm_email_update.submit();
	}
	function Delete_Selected(){
		document.frm_email.method="post";
		document.frm_email.submit();
	}
  
  function CheckDigit(e) {   
		var key = (window.event) ? event.keyCode : e.which;   
		if (window.event)     
			key = event.keyCode   
		else     key = e.which   // Was key that was pressed a numeric character (0-9) or backspace (8)?   
		if ( key > 47 && key < 58 || key == 8 )    
		 return; // if so, do nothing   
		else // otherwise, discard character     
		if (window.event) //IE      
		// window.event.returnValue = null;    
		window.event.keyCode=0;
		  else //Firefox       
		  e.preventDefault(); 
   	}
