// JavaScript Document
var httpObj = false;
	try {
		  httpObj = new XMLHttpRequest();
		} catch (trymicrosoft) {
		  try {
				httpObj = new ActiveXObject("Msxml2.XMLHTTP");
		  } catch (othermicrosoft) {
			try {
			  httpObj = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (failed) {
			  httpObj = false;
			}
		}
	}
	
function viewDiv(element){

 	 if(document.getElementById(element).style.display = 'none')
      {
        document.getElementById(element).style.display = 'Block';
      }
      else if(document.getElementById(element).style.display = 'Block')
      {
        document.getElementById(element).style.display = 'none';
      }
}

function checkLogin(){
	if(document.getElementById("username").value==""){
		document.getElementById("loginError").innerHTML='<span class="error">Please Enter User Name</span>';
	return false;
	}else if(document.getElementById("password").value==""){
		document.getElementById("loginError").innerHTML='<span class="error">Please Enter Password</span>';
	return false;
	}else{
		var url = urlpath+"/ajax/login.php?username="+document.getElementById("username").value+"&password="+document.getElementById("password").value;
		
		httpObj.open("GET",url,true);
		httpObj.onreadystatechange = loginProcess;
		httpObj.send(null);
	}
}
function loginProcess(){
	
	if(httpObj.readyState==4){
		var strContent=(httpObj.responseText).replace(/^\s\s*/, "").replace(/\s\s*$/, "");
		
		if(strContent=="1"){	
			window.location.href=urlpath;
		}else{
			document.getElementById("loginError").innerHTML=strContent;
			
		}
		
	}
	
}

function saveProperty(id){
	var url = urlpath+"/ajax/saveProperty.php?id="+id;
		
		httpObj.open("GET",url,true);
		httpObj.onreadystatechange = saveProcess;
		httpObj.send(null);
	
}

function saveProcess(){
	if(httpObj.readyState==4){
		var strContent=(httpObj.responseText).replace(/^\s\s*/, "").replace(/\s\s*$/, "");
		if(strContent=="1"){	
			alert("Property has been saved in your profile");
		}else{
			alert("Property already saved in your profile");
		}
	}
}
String.prototype.trim = function() {
  return this.replace(/^\s\s*/, "").replace(/\s\s*$/, "");
};