﻿// JScript File


var callObj = null;
var callCount = 0;

var is_ie = (navigator.userAgent.indexOf('MSIE') >= 0) ? 1 : 0; 
var is_ie5 = (navigator.appVersion.indexOf("MSIE 5.5")!=-1) ? 1 : 0; 
var is_opera = ((navigator.userAgent.indexOf("Opera 6")!=-1)||(navigator.userAgent.indexOf("Opera/6")!=-1)) ? 1 : 0; 
var is_netscape = (navigator.userAgent.indexOf('Netscape') >= 0) ? 1 : 0; 

function CallServer(pCalling,pId,pSearching)
{
  if (is_ie)
  {       
    var strObjName = (is_ie5) ? 'Microsoft.XMLHTTP' : 'Msxml2.XMLHTTP'; 
           
    try
    { 
      callCount++;
  	
      objXmlHttp = new ActiveXObject(strObjName); 
      objXmlHttp.onreadystatechange = function()
      {
        if (objXmlHttp.readyState == 4 || objXmlHttp.readyState == "complete") 
        {
          if (objXmlHttp.responseText != "")
          {
            document.getElementById(pId).style.display = "block";
            document.getElementById(pId).innerHTML = objXmlHttp.responseText;
          }
          else
            document.getElementById(pId).style.display = "none";
        }
        else
        {
          document.getElementById(pId).style.display = "block";
          document.getElementById(pId).innerHTML = pSearching;
        }
      }
      objXmlHttp.open('GET', pCalling, true); 
      objXmlHttp.send(null); 		 
    } 
    catch(e)
    { 
  //		alert('IE detected, but object could not be created. Verify that active scripting and activeX controls are enabled'); 
      return; 
    } 
  }
  else if (is_opera)
  { 
    //Opera has some issues with xmlHttp object functionality 
    //alert('Opera detected. The page may not behave as expected.');
    return; 
  } 
  else
  { 
    // Mozilla | Netscape | Safari 
    objXmlHttp = new XMLHttpRequest(); 
    objXmlHttp.onload = function()
    {
      if (objXmlHttp.readyState == 4 || objXmlHttp.readyState == "complete") 
      {
        if (objXmlHttp.responseText != "")
        {
          document.getElementById(pId).style.display = "block";
          document.getElementById(pId).innerHTML = objXmlHttp.responseText;
        }
        else
          document.getElementById(pId).style.display = "none";
      }
      else
      {
        document.getElementById(pId).style.display = "block";
        document.getElementById(pId).innerHTML = pSearching;
      }
    }
    
    objXmlHttp.onerror = function()
    {
      if (objXmlHttp.readyState == 4 || objXmlHttp.readyState == "complete") 
      {
        if (objXmlHttp.responseText != "")
        {
          document.getElementById(pId).style.display = "block";
          document.getElementById(pId).innerHTML = objXmlHttp.responseText;
        }
        else
          document.getElementById(pId).style.display = "none";
      }
      else
      {
        document.getElementById(pId).style.display = "block";
        document.getElementById(pId).innerHTML = pSearching;
      }
    }
                    
    objXmlHttp.open('GET', pCalling, true); 
    objXmlHttp.send(null); 		 
  }               
}



function ElementUri(pIdentity,pUri,pHeight,pWidth,pScroll)
{
  if (pScroll == "")
    pScroll = "no";
  
  if (pIdentity == "")
    pIdentity = "ElementUri";
  
  if (pUri != "")
  {
 
    pSize = "";
    if (pWidth > 0 && pHeight > 0)
      pSize = "height="+ pHeight +",width="+ pWidth +",";

    dialog = window.open(pUri, pIdentity, pSize + "resizable=yes,scrollbars=" + pScroll + ",status=no,location=no,toolbar=no,menubar=no",true);
    dialog.moveTo(((screen.width-pWidth)/2),((screen.height-pHeight)/2));
    dialog.focus();

  }
}

function WindowReloader(pQuery)
{
  window.location.href = pQuery;
}

function SwitchDiv(pdiv)
{
  if (document.getElementById(pdiv).style.display == "block")
    document.getElementById(pdiv).style.display = "none";	
  else
    document.getElementById(pdiv).style.display = "block";
}

function SwitchDivOff(pdiv)
{
  document.getElementById(pdiv).style.display = "none";	
}

function ReloadWindow()
{
  window.location.href = window.location.href;
}

function SwitchIcon(pId,pOn,pOff)
{
  if (document.getElementById(pId).src.indexOf(pOn) != -1)
    document.getElementById(pId).src = pOff;	
  else
    document.getElementById(pId).src = pOn;
}

function SwitchIconOff(pId,pIcon)
{
  document.getElementById(pId).src = pIcon;
}

function ConfirmLink(pWarning,pLink)
{
  if (window.confirm(pWarning))
  {
    window.location.href = pLink;
  }
}

