﻿// JScript File
var ajaxxmlHttp=null;
var xmlHttpForBatchPrint=null;

//this function returns xmlHttp object
function GetXmlHttpObject()
{
    try
      {
      // Firefox, Opera 8.0+, Safari
      ajaxxmlHttp=new XMLHttpRequest();
      }
    catch (e)
      {
      // Internet Explorer
      try
        {
        ajaxxmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
      catch (e)
        {
        ajaxxmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      }
    return ajaxxmlHttp;
} 

function GetXmlHttpObjectforBatchPrint()
{
    try
      {
      // Firefox, Opera 8.0+, Safari
      xmlHttpForBatchPrint=new XMLHttpRequest();
      }
    catch (e)
      {
      // Internet Explorer
      try
        {
        xmlHttpForBatchPrint=new ActiveXObject("Msxml2.XMLHTTP");
        }
      catch (e)
        {
        xmlHttpForBatchPrint=new ActiveXObject("Microsoft.XMLHTTP");
        }
      }
    return xmlHttpForBatchPrint;
}

function GetDivFrameWindow()
{
        // Locate and return the window containing the frame named divframe.
	// use this code in place of top.* to prevent access errors when displaying the website in another domain's frameset (e.g. Lockheed).
	var indexWindow = window;
	while ((indexWindow != null) && (indexWindow.frames['divframe'] == null))
		indexWindow = indexWindow.parent;
	if ((indexWindow != null) && (indexWindow.frames['divframe'] != null))
		return indexWindow
	else
		return null;
}

function CreateXMLDoc() 
{
   var xmlDoc=null; 
try //Internet Explorer
  {
  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  }
catch(e)
  {
  try //Firefox, Mozilla, Opera, etc.
    {
    xmlDoc=document.implementation.createDocument("","",null);
    }
  catch(e) {alert(e.message)}
  }
try 
  {
  xmlDoc.async=false;
  return(xmlDoc);
  }
catch(e) {alert(e.message)}
return(null);
}

function ReplaceSpecialCharacters(inputString,replaceThis,replaceWith)
{
    var outputString;
    outputString=inputString.replace(replaceThis,replaceWith);
    if(outputString.indexOf(replaceThis)>0)
        outputString=ReplaceSpecialCharacters(outputString,replaceThis,replaceWith);
    return outputString;
}


//////////////// FUNCTION related to Cookies ///////////////////////

function fnCreateCookie(key, value, expire) 
{
  if (value==null) return;
  var v = value;
  if (v!="") v=escape(v);
  document.cookie = escape(key)+"="+ v + (expire?"; expires="+expire:"");
}

function fnGetCookieValue(key) 
{
  if (document.cookie) {
    var cp=document.cookie.split(";");
    var c=null;
    for (var i=0; i<cp.length; i++) {
      c=cp[i].split("=");
      if (unescape(c[0].replace(/\s*/gi,""))==key) { return (c.length>1?unescape(c[1]):""); }
    }
  }
  return ""; 
}

function fnRemoveCookie(key) 
{
  CreateCookie(key, "-1", "Fri, 31 Dec 1999 23:59:59 GMT;");
}

