function LimitAttach(file)
{
  extArray = new Array(".jpeg", ".jpg");
  allowSubmit = false;
  if (!file) 
  {
  alert("Please Upload Your Image");
  return true;
  }
     while (file.indexOf("\\") != -1)
    file = file.slice(file.indexOf("\\") + 1);
    ext = file.slice(file.indexOf(".")).toLowerCase();
    for (var i = 0; i < extArray.length; i++)
      {
        if (extArray[i] == ext)
        {
          allowSubmit = true;
          break;
         }
    }
    
    if (allowSubmit==false)
       {
        alert("Please only upload files that end in types: "+ (extArray.join(" ")) + "\nPlease select a new "+ "file to upload and submit again.");
        return true; 
        }
    return false; 
}

/*
Strip whitespace from the beginning and end of a string
Input : a string
*/
function trim(str)
{
	return str.replace(/^\s+|\s+$/g,'');
}

/*
Make sure that textBox only contain number
*/
function checkNumber(textBox)
{
	while (textBox.value.length > 0 && isNaN(textBox.value)) {
		textBox.value = textBox.value.substring(0, textBox.value.length - 1)
	}
	
	textBox.value = trim(textBox.value);
/*	if (textBox.value.length == 0) {
		textBox.value = 0;		
	} else {
		textBox.value = parseInt(textBox.value);
	}*/
}

/*
	Check if a form element is empty.
	If it is display an alert box and focus
	on the element
*/




function isEmpty(formElement, message) {
	formElement.value = trim(formElement.value);
	
	_isEmpty = false;
	if (formElement.value == '') {
		_isEmpty = true;
		alert(message);
		formElement.focus();
	}
	
	return _isEmpty;
}
function check_it(formElement, message)
 {
      formElement.value = trim(formElement.value);
     var tomatch= /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/
     if (tomatch.test(formElement.value))
     {
      _check_it = false;
		 
     }
     else
     {
     _check_it = true;
     alert(message);
		  formElement.focus();
     }
    return _check_it; 
}
function checkEmail(formElement, message) {
	formElement.value = trim(formElement.value);
		
    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(formElement.value))
		{
    _isValid = false;
		}else{
		_isValid = true;
		alert(message);
		formElement.focus();
	}
	
	return _isValid;
}
function isNumberKey(evt)
{
         var charCode = (evt.which) ? evt.which : evt.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;
         else
         return true;
}
var defkey = '';
var defgeo = '';

function submitFilter(id, value) {
  if(id) {
    document.getElementById(id).value = value;
  }
  document.getElementById('filter_form').submit();
}

function showGeoFilter(enable) {
  obj = document.getElementById('geo_filter');
  box = document.getElementById('geo_box');
  val = document.getElementById('sel_geo');
  if(enable) {
    obj.style.display = '';
    box.checked = true;
  } else {
    obj.style.display = 'none';
    box.checked = false;

    if(val.value == 'x' && !defgeo) {
      //don't refresh
    } else {
      submitFilter('sel_geo', 'x');
    }
  }
}

function showKeywordFilter(enable) {
  obj = document.getElementById('keyword_filter');
  box = document.getElementById('keyword_box');
  val = document.getElementById('sel_keyword');
  if(enable) {
    obj.style.display = '';
    box.checked = true;
    //focus on the keyword box.
    document.getElementById('sel_keyword').focus();
  } else {
    obj.style.display = 'none';
    box.checked = false;
    if(!val.value && !defkey) {
      //don't refresh
    } else {
      submitFilter('sel_keyword' , '');
    }
  }
}

      function changeStatus(id, sts)
      {
        var pars1 = "process="+sts+"&id="+ id;
        //alert(pars1);
        new Ajax.Request('userupdate.php?' + pars1, {
        method: 'get',
        onSuccess: function(transport) {
          var notice = $('errmsg');
          //alert(transport.responseText);
          if (transport.responseText.match(/yes/)){
              alert("Status Updated...");
              //notice.update('Status Updated');
             }
          if (transport.responseText.match(/no/))
          {
                alert("Error while update the status");
              //notice.update('Unable to update the status');
          }
         }
        });
     }

function changeEmail(id){
  var param1="process=";

}
function ShowContent(d) {
document.getElementById(d).style.display = "block";
}
// Radio Button Validation
// copyright Stephen Chapman, 15th Nov 2004,14th Sep 2005
// you may copy this function but please keep the copyright notice with it

function gosearch(){
 window.location.href="searchproperty.html";

}
