/********************************************************************/
/* ActiveX Object("Microsoft.XMLHTTP") is not supported in FireFox  */
/* Hence a Synchronous HttpRequest has been made to server          */
/* to fill the control values dynamically                           */
/********************************************************************/
function GetURLContent(strURL)
{ 
    // 
    // Changes made for browser compatibity as ActiveX Object("Microsoft.XMLHTTP") is not supporting firefox 
    //
	
   if(window.ActiveXObject){
    objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
    objXMLHttp.open("GET", strURL, false);
    objXMLHttp.send();
    strContent = objXMLHttp.responseText;
    return getContent(strContent);
   }
   else
   {    
    objXMLHttp = null;
    objXMLHttp = new XMLHttpRequest();    
    objXMLHttp.open("GET", strURL, false);	 
	  objXMLHttp.send(null);
    

    if (objXMLHttp.readyState == 4 && objXMLHttp.status == 200) {
      strContent = objXMLHttp.responseText; 
    }
     return getContent(strContent);      
   }
  
}

//
// Function breakdown from GetURLContent
// Retun the Parsed String 
//

function getContent( strContent )
{  
   nIndex = strContent.indexOf("</script>");   
   if (nIndex != -1)
      strContent = strContent.substring(nIndex + 10, strContent.length);   
   return strContent;
}


function Trim(strBuffer) 
{ 
   while (strBuffer.substring(0, 1) == ' ') 
      strBuffer = strBuffer.substring(1, strBuffer.length);

   while (strBuffer.substring(strBuffer.length - 1, strBuffer.length) == ' ')
      strBuffer = strBuffer.substring(0, strBuffer.length - 1);

   return strBuffer
} 

function ClearListbox(objListbox)
{
   if (objListbox.options)
      while (objListbox.options.length > 0)
         objListbox.options[0] = null;
}

function AddListboxItem(objListbox, value, text)
{
   option = document.createElement('OPTION');
   option.text = text;
   option.value = value;

  //
  // Based on browser the compatibilty the parameter is passed to the function 'add'
  //
   if(window.ActiveXObject)
    objListbox.add(option);
   else
    objListbox.add(option,null);
}

function ListBoxSelectByValue(objListBox, strValue)
{
   for (i = 0; i < objListBox.length; i++)
   {
      if (objListBox.options[i].value == strValue)
      {
         eval("objListBox.options[" + i + "].selected = true");
         return true;
         break;
      }
   }
   
   return false;
}

function AutoTab(objField, event, objDestination)
{
   reg = /^(0|8|9|16|17|18|37|38|39|40|46)$/;
   if (reg.test(event.keyCode))
      return;

   if (objField.getAttribute && objField.value.length == objField.getAttribute("maxlength"))
      objDestination.focus();
}

function SetCookie(strCookie, strValue)
{
   var dateExpire = new Date();
   dateExpire.setTime(dateExpire.getTime() + 365 * 24 * 3600 * 1000);
   document.cookie = strCookie + "=" + escape(strValue) + ";expires=" + dateExpire.toGMTString();
}

function ReadCookie(strCookie)
{
   var nStart = document.cookie.indexOf(strCookie);
   if (nStart == -1)
      return "";
 
   var nEnd = document.cookie.indexOf(';', nStart);
   if (nEnd == -1) 
      nEnd = document.cookie.length; 

   return unescape(document.cookie.substring(nStart + strCookie.length + 1, nEnd));
}



/*

Functions added for EDiscrepancy


*/

function SetRowNumber( rNumber, strDocType ) 
	{
	  SetCookie( "DocOrdered", "Detailed Transaction History");
	  SetCookie( "HistoryDocType", strDocType );
	  SetCookie( "RowNumber", rNumber );
	}

function SetDocOrdered( doc ) 
	{
	  SetCookie( "DocOrdered", doc );
	}