﻿//Global XMLHTTP Request object
var XmlHttp;
//Creating and setting the instance of appropriate XMLHTTP Request object to a “XmlHttp” variable  
function CreateXmlHttp()
{
  //Creating object of XMLHTTP in IE
  try
  {
    XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
  }
  catch(e)
  {
    try
    {
	    XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } 
    catch(oc)
    {
	    XmlHttp = null;
    }
  }
  //Creating object of XMLHTTP in Mozilla and Safari 
  if(!XmlHttp && typeof XMLHttpRequest != "undefined") 
  {
    XmlHttp = new XMLHttpRequest();
  }
}

//Called when response comes back from server
function HandleResponse()
{
  if(XmlHttp.readyState == 4)
  {
    if(XmlHttp.status == 200)
    {			
	    RefreshReview(XmlHttp.responseText);
    }
    else
    {
	    alert("There was a problem retrieving data from the server." );
    }
  }
}

//Send ajax request for refresh
function RequestReview(ID,BN,P,T,F)
{
  var requestUrl = "/property/icondo/ajaxsvr/svr_review_listing.aspx?bid=" + ID + "&bn=" + BN + "&p=" + P + "&t=" + T + "&f=" + F;
  CreateXmlHttp();
  if(XmlHttp)
  {
    XmlHttp.onreadystatechange = HandleResponse;
    XmlHttp.open("GET", requestUrl,  true);
    XmlHttp.send(null);	
  }
}

//Refresh page
function RefreshReview(response)
{
  document.getElementById("reviewTab").innerHTML = response;
}

//Called when response comes back from server
function HandleRating()
{
  if(XmlHttp.readyState == 4)
  {
    if(XmlHttp.status == 200)
    {			
	    RatingChanged(XmlHttp.responseText);
    }
    else
    {
	    alert("There was a problem retrieving data from the server.");
    }
  }
}

//Rating
function CRating(ID,Mode)
{
  var requestUrl = "/property/icondo/ajaxsvr/svr_rating_listing.aspx?id=" + ID + "&mode=" + Mode;
  CreateXmlHttp();
  if(XmlHttp)
  {
    XmlHttp.onreadystatechange = HandleRating;
    XmlHttp.open("GET", requestUrl,  true);
    XmlHttp.send(null);	
  }
}

//Refresh Rating
function RatingChanged(response)
{
  document.getElementById("DivB"+response).innerHTML = "<b>Done</b>";
  document.getElementById("DivA"+response).style.display = "none";
}