function GenWriteCookie(name, value, days)
{
//********************************************************************************************
// Description: This function writes the cookie to a file and maintains it for xx number of
//              days.
//
// Input: Name -- name of cookie to write
//        Value -- cookie value
//        Days -- Cookie expires if inactive after 'x' number of days.
//
// Output: None
//
// Return Codes: None
//********************************************************************************************
  if (days)
  {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}
function GenReadCookie(CookieName)
//*********************************************************************************
// Description: Reads the cookie list and returns the value of the cookie
//
// Input: CookieName -- name of cookie to look for and return
//      
// Output: None
//
// Return Codes: the value of cookie if found, otherwise value is empty string
//*********************************************************************************
{
    var AllCookies;
    var Pos;
    var Start;
    var End;
    var Value;
  
    Value = "";
    AllCookies = document.cookie;
    Pos = AllCookies.indexOf(CookieName);
    if(Pos != -1)
    {
        Start = Pos + CookieName.length + 1;    //Add 1 char for the '=' that follows the CookieName
        End = AllCookies.indexOf(";", Start);
        if(End == -1)
            End = AllCookies.length;
      
        Value = AllCookies.substring(Start,End);
        Value = unescape(Value);
            
    }//end if
    
    return Value;  
}
function ShowDivWindow(InName)
{
  //***************************************************************************************
  //* Description:display a div
  //*              
  //* Input: None
  //*
  //* Output: None
  //*
  //* Return Codes: None
  //*************************************************************************************** 
  var WaitWin=document.getElementById(InName);
  var WaitWinIFrame;
  
  if (WaitWin != null)
  {
		WaitWin.style.left=document.body.clientWidth/2-(parseInt(WaitWin.style.width)/2);
		WaitWin.style.top=document.body.clientHeight/2;
		WaitWin.style.display="block";
		WaitWin.style.visibility="visible";
		WaitWin.style.zIndex=100;
		WaitWin.insertAdjacentHTML("afterEnd",'<IFRAME id=WaitWinIFrame style="DISPLAY: none; LEFT: 0px; POSITION: absolute; TOP: 0px" src="javascript:false;" frameBorder="0" scrolling="no"></IFRAME>');
		WaitWinIFrame=document.getElementById("WaitWinIFrame");
		WaitWinIFrame.style.left=WaitWin.style.left;
		WaitWinIFrame.style.top=WaitWin.style.top;
		WaitWinIFrame.style.display="block";
		WaitWinIFrame.style.width=WaitWin.style.width;
		WaitWinIFrame.style.height=WaitWin.style.height;
		WaitWinIFrame.style.zIndex=99;  
  }
}
function HideDivWindow(InName)
{
  //***************************************************************************************
  //* Description:hide the please wait dialog. assumes the existence of an HTML control
  //*             with an ID of "PleaseWait"
  //*
  //* Input: None
  //*
  //* Output: None
  //*
  //* Return Codes: None
  //*************************************************************************************** 
  var WaitWin=document.getElementById(InName);
  var WaitWinIFrame;
  if (WaitWin != null)
  {
		WaitWin.style.display="none";
		WaitWin.style.visibility="hidden";
		WaitWinIFrame=document.getElementById("WaitWinIFrame");
		if (WaitWinIFrame != null)
			WaitWinIFrame.style.display="none";
  }
}
