// This function checks if the page is called from the default frameset
// If not, it redirects the parent screen to the Default HomePage of the site
// Optionally, it sets the title for the parent window
// The function PageInit should be called as OnLoad event in the BODY tag.
// Other standard functions are: 
// - SwapVisible (object)          Alters display from '' to none and back
// - SetVisible (object)           Alters display to ''
// - UnsetVisible (object)         Alters display to 'none'
// - OpenHelp (ID)                 Pops up helpdisplay (not implemented in ASP yet)

sitehome = '/index.html';


function SetVisible (objIn)
{
  if (objIn.length) 
  {
    for (counter=0; counter<objIn.length; counter++)
    {
      objIn[counter].style.display = '';
    }    
  }
  else
  {
    objIn.style.display = '';
  }
}

function UnsetVisible (objIn)
{
  if (objIn.length) 
  {
    for (counter=0; counter<objIn.length; counter++)
    {
      objIn[counter].style.display = 'none';
    }    
  }
  else
  {
    objIn.style.display = 'none';
  }
}

function SwapVisible (objIn)
{
  if (objIn.length) 
  {
    for (counter=0; counter<objIn.length; counter++)
    {
      if (objIn[counter].style.display == 'none')
      {
        objIn[counter].style.display = '';
      }
      else
      {
        objIn[counter].style.display = 'none';
      }
    }    
  }
  else
  {
    if (objIn.style.display == 'none')
    {
      objIn.style.display = '';
    }
    else
    { 
      objIn.style.display = 'none';
    }
  }
}


var bites = document.cookie.split("; "); 

function getCookie(name) { // use: getCookie("name");
  for (var i=0; i < bites.length; i++) 
  {
    nextbite = bites[i].split("="); // break into name and value
    if (nextbite[0] == name) // if name matches
      return unescape(nextbite[1]); // return value
  }
  return null;
}

var today = new Date();
var expiry = new Date(today.getTime() + 28 * 24 * 60 * 60 * 1000); // plus 28 days

function setCookie(name, value) 
{ 

  if (value != null && value != "")
    document.cookie=name + "=" + escape(value) + "; expires=" + expiry.toGMTString();
  bites = document.cookie.split("; ");
}


function PageInit(title)
{
//  if (parent.parent.frames.length == 2)
//  {
//    if (parent.parent.frames(0).name != 'GGtopnav')
//    {
//      parent.parent.navigate(sitehome)
//    }
//  }
//  else
//  {
//    parent.parent.navigate(sitehome)
//  }
  
  if (title != '')
  {
    parent.parent.document.title = title;
  }  
}

function enter2submit(formobject)
{
  if (event.keyCode == 13)
  {
    formobject.submit();
  }
}

function OpenHelp(ID)
{ 
window.open('/PopupHelp.asp?ID=' + ID,'helpwindow',
'toolbar=no, location=no,status=no,menubar=no,scrollbars=yes, resizable=no,width=320,height=300,top=65,left=400');
}
