<!--- Hide script from old browsers
//  scart --  Auxiliary Javascript functions for the shopping
//            cart
// Author:  Saturnino Luz &#60;luz@hovslund.nis.sdu.dk&#62;

// We'll call this "mainWindow" so that the notepad window
// knows where to send its pages; must be overridden in
// header_aux.updt
var  mainWindow = "";
var  expWin=self;
var focusallowed = 0;

if ( window.name == "" )
  window.name="mainWindow";

if ( mainWindow == "" )
  mainWindow=top;


// =====
function expinit() {
  expWin=self;
  expWin.focus();
  // hack to find out if browser allows focus
  // will throw an error before reching this point
  // if not (try...catch handle this in newer browsers)
  focusallowed = 1;

}

// =====
function exp(pageURL) {
  if ( expWin == self || expWin.closed )
    expWin=window.open(pageURL,
                       "popupwindow",
                       "toolbar=0,scrollbars=1,titlebar=0,"+
                       "width=600,height=340,dependent=1");
  else
    expWin.location.href=pageURL;
  if ( focusallowed )
          expWin.focus();
  return false;
}

// =====
function exp1(pageURL, width, height) {
  if ( expWin == self || expWin.closed )
    expWin=window.open(pageURL,
                       "subtlecart",
                       "toolbar=0,scrollbars=1,titlebar=0,width="+
                       width+",height="+height+",dependent=0");
  else
    expWin.location.href=pageURL;
        expWin.focus();
}

// =====
function noexp() {
        if (expWin != self)
                expWin.close();
}

// =====
function WriteCookie (cookieName, cookieValue, expiry)
{
  var expDate = new Date();

  if(expiry)
    {
            expDate.setTime (expDate.getTime() + expiry);
            document.cookie =
        cookieName + "=" + cookieValue
        + "; expires=" + expDate.toGMTString()
        + "; path=/" ;
    }
  else
    {
            document.cookie = cookieName + "=" + cookieValue
        + "; path=/" ;
    }
}

// =====
function setUIDCookie ( userID )
{
  var name = "SubtleUID";

  var value = userID;
  if ( ! value )
    value = Math.random();
  var months = 2;
  WriteCookie(name, value, 1000 * 60 * 60 * 24 * months * 31);
}

// =====
function UpdateUIDCookie () {
  var CookieString = document.cookie;
  var CookieSet = CookieString.split (';');
  var SetSize = CookieSet.length;
  var CookiePieces;
  var ReturnValue = "";
  var x = 0;

  for (x = 0; ((x < SetSize) && (ReturnValue == "")); x++)
    {
            CookiePieces = CookieSet[x].split ('=');

            if (CookiePieces[0].substring (0,1) == ' ') {
        CookiePieces[0] =
          CookiePieces[0].substring (1, CookiePieces[0].length);
            }

            if (CookiePieces[0] == "SubtleUID") {
        ReturnValue =  CookiePieces[1] ;
            }
        }
  if ( ReturnValue == "" ){
    setUIDCookie( );
  }
  else {
    setUIDCookie( ReturnValue );
  }
}

// =====
UpdateUIDCookie();
expinit();
// end script hiding from old browsers -->
