﻿// JScript File
function Ajax()
{
    this.url = "";
    this.method="POST"; //the default method to use
    this.async = true;
    this.xmlHttp = null;
    this.ajax_init  = ajax_init;
    this.ajax_send  = ajax_send;
    this.ajax_open = ajax_open;
    this.ajax_onreadystatechange = null;
    this.ajax_init();    
}

function ajax_open(url)
{
    if(this.xmlHttp)
    {
        this.xmlHttp.open(this.method,url);
    }
}

function ajax_send()
{
    try
    {
        if(this.xmlHttp)
        {
            // The sEmailAddress is defined in the getbook.asp 
            var oDate = new Date();
            var m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
            var curr_min = oDate.getMinutes();
            curr_min = curr_min + "";
            if (curr_min.length == 1)
                curr_min = "0" + curr_min;
            var sClientTime = "";
            var sClientDate = "";
            sClientDate = sClientDate.concat(m_names[oDate.getMonth()],"-",oDate.getDate(),"-",oDate.getFullYear());
            sClientTime = sClientTime.concat(oDate.getHours(),":",curr_min,":",oDate.getSeconds());
            var sStatsInfo = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
            sStatsInfo = sStatsInfo.concat("<OliveVariables>","<ClientDate>",encodeURIComponent(sClientDate),"</ClientDate>","<ClientTime>",encodeURIComponent(sClientTime),"</ClientTime>","<EmailAddress>",encodeURIComponent(sEmailAddrr),"</EmailAddress>","<URL>",encodeURIComponent(Olive_URL),"</URL>","<Issue>",encodeURIComponent(Olive_Issue),"</Issue>","<Section>",encodeURIComponent(Olive_Section),"</Section>","<Publication>",encodeURIComponent(Olive_Publication),"</Publication>","<PageLabel>",encodeURIComponent(Olive_PageLabel),"</PageLabel>","<ComponentType>",encodeURIComponent(Olive_ComponentType),"</ComponentType>","<BaseHref>",encodeURIComponent(Olive_BaseHref),"</BaseHref>","<Action>",encodeURIComponent(Olive_Action),"</Action>","<ComponentId>",encodeURIComponent(Olive_ComponentId),"</ComponentId>","<ComponentName>",encodeURIComponent(Olive_ComponentName),"</ComponentName>","<PageNumber>",encodeURIComponent(Olive_PageNumber),"</PageNumber>","<PageTitle>",encodeURIComponent(Olive_PageTitle),"</PageTitle>","<URLClick>",encodeURIComponent(Olive_URLClick),"</URLClick></OliveVariables>");
            this.xmlHttp.send(sStatsInfo);
        }
     }
     catch(e)
     {
     }
}

function ajax_init()
{ 
    try
    {    
        // Firefox, Opera 8.0+, Safari    
        this.xmlHttp = new XMLHttpRequest();    
    }
    catch (e)
    {    
      // Internet Explorer    
      try
      {      
        this.xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
      }
      catch (e)
      {      
          try
          {        
            this.xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
          }
          catch (e)
          {        
            //The browser does not support AJAX!;       
            this.xmlHttp = null;       
          }      
      }
      
   } 
  if(this.xmlHttp)
  {
    this.xmlHttp.onreadystatechange = function()
    {
        if(this.readyState==4)
        {
        }
    }
  } 
}  