/* ---------------------------- */
/* XMLHTTPRequest Enable */
/* ---------------------------- */
function createObject() {
var request_type;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_type = new ActiveXObject("Microsoft.XMLHTTP");
}else{
request_type = new XMLHttpRequest();
}
return request_type;
}

var http = createObject();






/* -------------------------- */
/* Add To Shortlist */
/* -------------------------- */
/* Required: var nocache is a random number to add to request. This value solve an Internet Explorer cache issue */
var nocache = 0;


function changepropertystatus(intPropertyId,intUserRating_UnkRAG_0123) {

// Set te random number to add to URL request

nocache = Math.random();

// Pass the login variables like URL variable

http.open('get', '/actions.cfm?action=changepropertystatus&intPropertyId='+intPropertyId+'&intUserRating_UnkRAG_0123='+intUserRating_UnkRAG_0123+'&nocache = '+nocache);

http.onreadystatechange = function() {

    propertylister(intPropertyId);
    
};

http.send(null);

}






function propertylister(intPropertyId){

if(http.readyState == 4){

 var stateresponse = http.responseText;
 var findzero = stateresponse.search(/0/);
 
 
 
 
 if (findzero < 1){
  propertylisting(intPropertyId);
}else{
  searchbar();
}
}
}



function propertylisting(intPropertyId){
 nocache1 = Math.random();
 http.open('get', '/ajax.cfm?ajaxpage=property_listing_inc&intPropertyId='+intPropertyId+'&nocache = '+nocache1);
 http.onreadystatechange = function() {
 	getpropertylisting(intPropertyId);
};
http.send(null);
}


function searchbar(){

nocache = Math.random();
 http.open('get', '/ajax.cfm?ajaxpage=search&nocache = '+nocache);
 
  http.onreadystatechange = function() {
 	showsearch();
  };

http.send(null);

 }


function getpropertylisting(intPropertyId) {
 if(http.readyState == 4){ 
 var propertylistingresponse = http.responseText;
 searchinc();
{
document.getElementById('propertylisting'+intPropertyId).innerHTML = propertylistingresponse;
}
}
}





function showsearch() {
 if(http.readyState == 4){ 
 var searchpage = http.responseText;
 	 searchinc();
{
document.getElementById('search').innerHTML = searchpage;
}
}
}





function searchinc(){
if(http.readyState == 4){ 
nocache = Math.random();
http.open('get', '/ajax.cfm?ajaxpage=search_inc&page=search&nocache = '+nocache);
http.onreadystatechange = function() {
	getsearchinc();
};
http.send(null);
}
}


function getsearchinc() {
 if(http.readyState == 4){ 
 var searchincresponse = http.responseText;
 	shortlistheader();
{
document.getElementById('searchinc').innerHTML = searchincresponse;
}
}
}


function shortlistheader(){
if(http.readyState == 4){ 
nocache = Math.random();
http.open('get', '/ajax.cfm?ajaxpage=shortlist_header&nocache = '+nocache);
http.onreadystatechange = function() {
	showshortlistheader();
};
http.send(null);
}
}


function showshortlistheader() {
 if(http.readyState == 4){ 
 var shortlistheaderresponse = http.responseText;
{
document.getElementById('shortlistheader').innerHTML = shortlistheaderresponse;
}
}
}





/*PropertyDetails.cfm*/

function PropertyDetails(intPropertyId) {

nocache = Math.random();

http.open('get', '/ajax.cfm?ajaxpage=PropertyDetails&intPropertyId='+intPropertyId+'&clickfrom=list&nocache = '+nocache);
http.onreadystatechange = function() {
    ViewPropertyDetails(intPropertyId);
};
http.send(null);
}


function ViewPropertyDetails(intPropertyId) {
 if(http.readyState == 4){ 
 var PropertyDetailresponse = http.responseText;
 pageTracker._trackPageview("/expanddetails" );
{
document.getElementById('propertylisting'+intPropertyId).innerHTML = PropertyDetailresponse;
}
}
}





function PostPropertyDetails(intPropertyId) {

nocache = Math.random();

http.open('get', '/actions.cfm?action=updatePropertyDetailRequest_action&intPropertyId='+intPropertyId+'&nocache = '+nocache);
http.onreadystatechange = function() {
    PropertyDetails1(intPropertyId);
};
http.send(null);
}


function PropertyDetails1(intPropertyId) {
 if(http.readyState == 4){ 
    PropertyDetails(intPropertyId);

}
}
