// SMCrunch2 Version 2.0.1, Copyright (C) Smart Media Ltd 2001-2005. All Rights Reserved.
//
// !!! Note: JScript by default
//
var textSize = "Normal";
function getSize()
{
var sRE = "(?:; )?" + "TextSize" + "=([^;]*);?";
var oRE = new RegExp(sRE);
if(oRE.test(document.cookie))
{
textSize = decodeURIComponent(RegExp["$1"]);
}
}
function increaseSize()
{
getSize();
if(textSize == "Large") textSize="Largest";
if(textSize == "Normal" ) textSize="Large";
activeCSS();
setCookie();
}
function dicreaseSize()
{
getSize();
if(textSize == "Large") textSize="Normal";
if(textSize == "Largest") textSize="Large";
activeCSS();
setCookie();
}
function setCookie()
{
var date = new Date();
date.setTime(date.getTime()+24*60*60*1000);
document.cookie = "TextSize="+textSize+"; expires="+date.toGMTString();
}
function activeCSS()
{
var i, oneLink;
for( i = 0; (oneLink = document.getElementsByTagName("link")[i]); i++)
{
if(oneLink.getAttribute("title") && findWord("stylesheet", oneLink.getAttribute("rel")))
{
if (oneLink.getAttribute("title") == textSize) oneLink.disabled = false;
else oneLink.disabled = true;
}
}
}
function findWord(needle, haystack)
{
return haystack.match(needle + "\\b");
}
function checkSearchForm()
{
if( document.searchform.qu.value == null || document.searchform.qu.value.length == 0 )
{
alert("Please enter a search term.");
document.searchform.qu.focus();
return false;
}
else return true;
}
window.onload = function(e)
{
}

function NewWindow(mypage, myname, w, h, scroll)
{
  winprops = 'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars='+scroll+',resizable=yes,width='+w+',height='+h
  win = window.open(mypage, myname, winprops)
}

function ep(e)
{
  if( e != null )
  {
    var x = 0;
    var y = 0;
    var t = e;
    while( t != null && t.offsetParent != t )
    {
      if( t.offsetLeft != null )
        x += t.offsetLeft;
      if( t.offsetTop != null )
        y += t.offsetTop;
      t = t.offsetParent;
    }	
    var o = new Object();
    o.x = x;
    o.y = y;
    return o;
  }
  return null;
}


function go()
{
  reposition();
  setTimeout("fadein('splash_logo',0)",100);
  setTimeout("fadein('splash_entersite',0)",400);
// as of 071220 logo  was300, entersite 1500
//  setTimeout("fadein('splash_news_0',0)",1500);
//  setTimeout("ticker(1,0)",1900);
}

function reposition()
{
  position('splash_logo');
  position('splash_entersite');
  position_news_0();
}

if( window.addEventListener )
  window.addEventListener('resize',reposition,false);
else if( window.attachEvent )
  window.attachEvent('onresize',reposition);
else
  window.onresize = reposition;

function position(name)
{
  var e = document.getElementById('splash_content');
  var e2 = document.getElementById(name);
  if( e != null && e2 != null )
  {
    e2.className = name+'class';
    var o = ep(e);
    
    if( o != null && window.event )
    {
      e2.style.position = 'absolute';
      var l = (e.offsetWidth-e2.offsetWidth)/2;
      e2.style.left = (o.x)+'px';
      
      var t = 0;
      if( name == 'splash_entersite' )
      {
        var e3 = document.getElementById('splash_logo');
        t += e3.offsetHeight;
      }
      
      e2.style.top = (o.y+t)+'px';
    }
    e2.style.display = 'block';
  }
}

function position_news_0()
{
  var e = document.getElementById('splash_news_b');
  var e2 = document.getElementById('splash_news_0');
  if( e != null && e2 != null )
  {
    var o = ep(e);
    if( o != null )
    {
      e2.style.position = 'absolute';
      //alert('x='+o.x+' y='+o.y);
      e2.style.left = (o.x)+'px';
      e2.style.top = (o.y)+'px';
    }
  }
}

function ticker(n,m)
{
  var e = document.getElementById('splash_news_0l');
  var e2 = document.getElementById('splash_news_'+n);
  var e3 = document.getElementById('splash_news_'+n+'l');
  if( e != null && e2 != null && e3 != null)
  {
    var d = 100;
    // if at beginning of this news item, get the link
    if( m == 0 )
    {
      e.href = e3.href;
      e.innerHTML = e3.innerHTML.charAt(0);
      m++;
    }
    else if( m < e3.innerHTML.length )
    {
      // If in the middle of a news item, get the next character
      e.innerHTML += e3.innerHTML.charAt(m);
      m++;
    }
    else
    {
      // If at the end of a news item, go back to the beginning, and try to go to the next news item
      m=0;
      n++;
      e3 = document.getElementById('splash_news_'+n+'l');
      if( e3 == null )
        n = 1;
      d = 2500;
    }
    setTimeout("ticker("+n+","+m+")",d);
  }
}


function fadein(name,n)
{
  if( n > 255 )
    n = 255;
  var e = document.getElementById(name);
  e.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity='+n+');';
  e.style.opacity = n/255;
  if( n < 255 )
  {
    n += 3;
    setTimeout("fadein('"+name+"',"+n+")",120);
  }
}
onload = go;
