<!--- Hide script from old browsers.

function subForm(to, task)
{
  // This function assumes there is only one form in the page
  document.forms[0].to.value = to;
  document.forms[0].task.value = task;
  document.forms[0].action = location.pathname;
  document.forms[0].submit();
}

function setValue(field, value)
{
  if(value == "null")
  {
    value = "";
  }
  
  document.forms[0].elements[field].value=value;
}



function openPopUpWindow() 
{
  var version = parseInt(navigator.appVersion);
  var popUpWindowName = null;

  if (version >= 4)
  {
    var popupUrl = location.pathname + "?task=POPUP";
    
    for (var i = 0; i < arguments.length; i+=2)
    {
      if(arguments[i] == "PopUpWindowName")
      {
        popUpWindowName=arguments[i+1];
      }
      else
      {
        popupUrl = popupUrl + "&" + arguments[i] + "=" + arguments[i+1];
      }
    }

    popupUrl = popupUrl + "&" + "Cygent.name" + "=" + window.name ;
    var showOfferWindow  = null;
    if(popUpWindowName == null)
    {
      showOfferWindow = window.open(popupUrl,'popUpWindow','height=500,width=540,scrollbars=yes');
    }
    else
    {
      showOfferWindow = window.open(popupUrl,popUpWindowName,'height=500,width=540,scrollbars=yes');
      showOfferWindow.moveBy(40,40);
    }
  }
}

/*



function openPopUpWindow() 
{
  var version = parseInt(navigator.appVersion);
  
  if (version >= 4)
  {
    var popupUrl = "/go?task=POPUP";
    
    for (var i = 0; i < arguments.length; i+=2)
    {
      popupUrl = popupUrl + "&" + arguments[i] + "=" + arguments[i+1];
    }

		popupUrl = popupUrl + "&" + "Cygent.name" + "=" + window.name ;
    var showOfferWindow = window.open(popupUrl,'popUpWindow','height=500,width=540,scrollbars=yes');
  }
}


*/



function closePopUpWindow() 
{
  var version = parseInt(navigator.appVersion);
  
  if (version >= 4)
  {
    var popupUrl = location.pathname + "?";		   
		var parentWindow ="";

    for (var i = 0; i < arguments.length; i+=2)
    {		     
		  if (arguments[i]==("ParentWindow.name"))
			{
			  parentWindow = arguments[i+1];
      }
			else if (i==0)
  		{
        popupUrl = popupUrl +  arguments[i] + "=" + arguments[i+1];
			}
			else
			{
				 popupUrl = popupUrl + "&" + arguments[i] + "=" + arguments[i+1];
			}
    }		
    
    var showOfferWindow = window.open(popupUrl, parentWindow);
  }
}






/*
** COOKIE FUNCTIONS
*/


function getCookieVal(offset) 
{  
  var endstr = document.cookie.indexOf (";", offset);  
  if (endstr == -1)
  {
    endstr = document.cookie.length;  
  }
  return unescape(document.cookie.substring(offset, endstr));
}


function getCookie(name) 
{  
  var arg = name + "=";  
  var alen = arg.length;  
  var clen = document.cookie.length;  
  var i = 0;  
  while (i < clen) 
  {
    var j = i + alen;    
    if (document.cookie.substring(i, j) == arg)
    {
      return getCookieVal (j);    
    }
    i = document.cookie.indexOf(" ", i) + 1;    
    if (i == 0)
    {
      break;   
    }
  }  
  return null;
}



function checkCookie(cookieName)
{
  var cookieValue = getCookie(cookieName);

  if (cookieValue == null)
  {
    return false;
  }
  else
  {
    return true;
  }
}



/*
** REDIRECT FUNCTIONS
*/

function redirectIfCookieNotFound(cookieName, portal)
{
  if (!checkCookie(cookieName))
  {
    // redirect to the CookiesDisabledError page
    subForm(portal + "_CookiesDisabledError", "viewError");
    return true;
  }
  else
  {
    // do nothing
    return false;
  }
  
}


function redirectIfNoCygentCookie(portal)
{
  redirectIfCookieNotFound("CygentSession", portal);
}

// End the hiding here. -->
 
