
var inited = false;

// Cookie Control

function getCookieVal (offset) 
{
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function FixCookieDate (date) {
  var base = new Date(0);
  var skew = base.getTime(); // dawn of (Unix) time - should be 0
  if (skew > 0)  // Except on the Mac - ahead of its time
    date.setTime (date.getTime() - skew);
}

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 SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}


// Mouse effects

var obj = new Object();
var tmp = new Object();
var tmpclass = "";
var ischild = false;

function mdown()
{
  tmp = window.event.srcElement;
  if (tmp.className=="") {tmp = tmp.parentElement;}
  if (tmp.className=="") {tmp = tmp.parentElement;}
  tmpclass = tmp.className;
  if (tmpclass=='item1b') {tmp.className='item1c';}
  if (tmpclass=='item2b') {tmp.className='item2c';}
  if (tmpclass=='menuitemb') {tmp.className='menuitemc';}
  if (tmpclass=='skinb') {tmp.className='skinc';}
  if (tmpclass=='frame1b') {tmp.className='frame1c';}
  if (tmpclass=='frame2b') {tmp.className='frame2c';}
  if (tmpclass=='backb') {tmp.className='backc';}
  if (tmpclass=='homeb') {tmp.className='homec';}
  if (tmpclass=='nextb') {tmp.className='nextc';}
}

function mup()
{
  tmp = window.event.srcElement;
  if (tmp.className=="") {tmp = tmp.parentElement;}
  if (tmp.className=="") {tmp = tmp.parentElement;}
  tmpclass = tmp.className;
  if (tmpclass=='item1c') {tmp.className='item1b';}
  if (tmpclass=='item2c') {tmp.className='item2b';}
  if (tmpclass=='menuitemc') {tmp.className='menuitemb';}
  if (tmpclass=='skinc') {tmp.className='skinb';}
  if (tmpclass=='frame1c') {tmp.className='frame1b';}
  if (tmpclass=='frame2c') {tmp.className='frame2b';}
  if (tmpclass=='backc') {tmp.className='backb';}
  if (tmpclass=='homec') {tmp.className='homeb';}
  if (tmpclass=='nextc') {tmp.className='nextb';}
}

function mover()
{
  tmp = window.event.srcElement;
  tmpclass = tmp.className;
  if (tmpclass=='item1a') {tmp.className='item1b';}
  if (tmpclass=='item2a') {tmp.className='item2b';}
  if (tmpclass=='menuitema') {tmp.className='menuitemb';}
  if (tmpclass=='skina') {tmp.className='skinb';}
  if (tmpclass=='frame1a') {tmp.className='frame1b';}
  if (tmpclass=='frame2a') {tmp.className='frame2b';}
  if (tmpclass=='backa') {tmp.className='backb';}
  if (tmpclass=='homea') {tmp.className='homeb';}
  if (tmpclass=='nexta') {tmp.className='nextb';}
}

function mout()
{
  tmp = window.event.srcElement;
  tmpclass = tmp.className;
  if (tmpclass=='item1b'||tmpclass=='item1c') {tmp.className='item1a';}
  if (tmpclass=='item2b'||tmpclass=='item2c') {tmp.className='item2a';}
  if (tmpclass=='menuitemb'||tmpclass=='menuitemc') {tmp.className='menuitema';}
  if (tmpclass=='skinb'||tmpclass=='skinc') {tmp.className='skina';}
  if (tmpclass=='frame1b'||tmpclass=='frame1c') {tmp.className='frame1a';}
  if (tmpclass=='frame2b'||tmpclass=='frame2b') {tmp.className='frame2a';}
  if (tmpclass=='backb'||tmpclass=='backb') {tmp.className='backa';}
  if (tmpclass=='homeb'||tmpclass=='homeb') {tmp.className='homea';}
  if (tmpclass=='nextb'||tmpclass=='nextb') {tmp.className='nexta';}
}

// Mouse over effect init & other Init

function init()
{
  inited = true;

  for(e=0; e<document.all.length; e++){
    if (document.all(e).tagName=="DIV"&&document.all(e).className!="")
    {
      document.all(e).onmouseenter = mover;
      document.all(e).onmouseleave = mout;
      document.all(e).onmousedown = mdown;
      document.all(e).onmouseup = mup;
    }
  }
}


// Loader manager

function ready()
{
  if(document.readyState=='complete') {

    document.getElementById('loader').className='loaderb';

  } else {

    document.getElementById('loader').className='loadera';

  }
}


function setready(state)
{
  if(state=='complete') {

    if (inited==false) {init();}
    document.getElementById('loader').className='loaderb';

  } else {

    document.getElementById('loader').className='loadera';

  }
}


function settitle(txt)
{
  if(document.readyState=='complete')
  {
    document.getElementById('doctitle').innerHTML=txt;
  }
}

// Skin manager

function setskin(cssurl)
{
  if (document.all)
  {
    var expdate = new Date ();
    FixCookieDate (expdate);
    expdate.setTime (expdate.getTime() + (31 * 24 * 60 * 60 * 1000));
    SetCookie("cssurl",cssurl,expdate);

    document.frames[0].setskin(cssurl);
    cssurl = cssurl + "/styles.css";
     //document.body.filters[0].Apply();
    document.styleSheets(0).href = cssurl;
     //document.body.filters[0].Play();
  }
}

if (document.all)
{
  var cssurl = ""
  cssurl = GetCookie("cssurl");
  if (cssurl!=null) {
    cssurl = cssurl + "/styles.css";
    document.styleSheets(0).href = cssurl;
  }
}



// mouse statistics

function mouseclick()
{
  var clicks = GetCookie("clicks");

  if (clicks==null) {clicks = 0;}
  clicks++;

  var expdate = new Date ();
  FixCookieDate (expdate);
  expdate.setTime (expdate.getTime() + (31 * 24 * 60 * 60 * 1000));
  SetCookie("clicks",clicks,expdate);
}



// events

document.onreadystatechange = ready;
document.onmousedown = mouseclick;



// statistics

var visited = GetCookie("visited");

if (visited==null) {visited = 0;}
visited++;

var expdate = new Date ();
FixCookieDate (expdate);
expdate.setTime (expdate.getTime() + (31 * 24 * 60 * 60 * 1000));
SetCookie("visited",visited,expdate);


