// JScript File

var currentHelpWindow = new ddHelpPopup();

function ddHelpPopup()
{
  this.helpDiv = document.getElementById("DdPopupHelpWindow");
  this.chkBox = document.getElementById("ClearWindowChk");
  this.cookieName = "ddPopupHelpCookie";
  
  if (getCookie(this.cookieName) != null)
    this.hasCookie = true;
  else
    this.hasCookie = false;
  
  // methods
  this.closeWindow = closeWindow;
  this.showWindow = showWindow;
  this.createCookie = createCookie;
  this.closeWindowAction = closeWindowAction;

  if (this.hasCookie)
    this.closeWindow();
  else
    this.showWindow();
}

function closeWindow()
{
  this.helpDiv.style.display = "none";  
}

function showWindow()
{
  this.helpDiv.style.display = "block";

}

function createCookie()
{
  SetCookie(this.cookieName, 1);
  this.closeWindow();
}

function closeWindowAction()
{  
  if (this.chkBox.checked)
    this.createCookie();
  else
    this.closeWindow();
}

function getCookie(name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  
  
  if (clen > 0)
    return 1;
  else
    return null;
}

function SetCookie (name, value) 
{
  var exp = new Date();
  exp.setTime(exp.getTime() + 7776000000);

  var argv = SetCookie.arguments;
  var argc = SetCookie.arguments.length;
  var expires = exp;
  
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : null;
  var secure = (argc > 5) ? argv[5] : false;
  document.cookie = name + "=" + escape (value) +
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
    ((path == null) ? "" : ("; path=" + path)) +
    ((domain == null) ? "" : ("; domain=" + domain)) +
    ((secure == true) ? "; secure" : "");
}


