// Checking browser compatabile
function GetXmlHttpObject()
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
		objXMLHttp = new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}

function getSessionValue(){
	xmlHttpSession = GetXmlHttpObject();
	
	if( xmlHttpSession == null) { 
		alert("Browser does not support HTTP Request");
		return;
	}
	
	url = "index.php?page=getSession"
	url = url
	xmlHttpSession.onreadystatechange = stateChangedSession
	xmlHttpSession.open("get",url,true)
	xmlHttpSession.send(null)	
}


function propShortlist(thisObj){
	xmlHttp = GetXmlHttpObject();
	propIdArr = new Array();
	
	if( xmlHttp == null) { 
		alert("Browser does not support HTTP Request");
		return;
	}

	for(i=0; i<document.propList.propCheck.length; i++){
		if(document.propList.propCheck[i].checked){
			propIdArr[i]=document.propList.propCheck[i].value
		}
	}
	
	var url = "index.php?page=shortlist";
	var params = "propCheck="+propIdArr
	xmlHttp.open("POST", url, true);

	//Send the proper header information along with the request
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");

	xmlHttp.onreadystatechange = stateChangedPropShortlist
	xmlHttp.send(params)	
	return false;
}

// State Changed 
function stateChangedSession() 
{ 
	if ( xmlHttpSession.readyState == 4 || xmlHttpSession.readyState == "complete")
	{ 
		sessionData = xmlHttpSession.responseText;
		sessionDataArr = sessionData.split("^^");
		name = sessionDataArr[1];
		if(name == ""){
			document.getElementById("welcomeDiv").innerHTML = "Welcome Guest";					
		}
		else{
			document.getElementById("welcomeDiv").innerHTML = "Welcome "+name+" <a href='/?page=postProperty'> Myaccount </a> | <a href='/?page=signout'> Signout</a>";
			}
	}
}


function stateChangedPropShortlist() 
{ 
	if ( xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
	{ 
		response = xmlHttp.responseText;
		//alert(response);
		if(response == "Error"){
			displayMessage('http://www.shubhniwas.com/a2.html')
		}	
		else{
			alert(response);	
		}	
	}
}