/*This file and its contents are (c) Angus Turnbull, 2004. All Rights Reserved.*/

var isDOM=document.getElementById?1:0,isIE=document.all?1:0,isNS4=navigator.appName=='Netscape'&&!isDOM?1:0,isOp=self.opera?1:0,isDyn=isDOM||isIE||isNS4;function getRef(i,p){p=!p?document:p.navigator?p.document:p;return isIE?p.all[i]:isDOM?(p.getElementById?p:p.ownerDocument).getElementById(i):isNS4?p.layers[i]:null};function getSty(i,p){var r=getRef(i,p);return r?isNS4?r:r.style:null};if(!self.LayerObj)var LayerObj=new Function('i','p','this.ref=getRef(i,p);this.sty=getSty(i,p);return this');function getLyr(i,p){return new LayerObj(i,p)};function LyrFn(n,f){LayerObj.prototype[n]=new Function('var a=arguments,p=a[0],px=isNS4||isOp?0:"px";with(this){'+f+'}')};LyrFn('x','if(!isNaN(p))sty.left=p+px;else return parseInt(sty.left)');LyrFn('y','if(!isNaN(p))sty.top=p+px;else return parseInt(sty.top)');function FSMenu(myName,nested,cssProp,cssVis,cssHid){this.myName=myName;this.nested=nested;this.cssProp=cssProp;this.cssVis=cssVis;this.cssHid=cssHid;this.cssLitClass='';this.menus={root:new FSMenuNode('root',this)};this.menuToShow=[];this.mtsTimer=null;this.showDelay=0;this.hideDelay=500};FSMenu.prototype.show=function(mN){with(this){menuToShow=arguments;clearTimeout(mtsTimer);mtsTimer=setTimeout(myName+'.menus.root.over()',10)}};FSMenu.prototype.hide=function(mN){with(this){clearTimeout(mtsTimer);if(menus[mN])menus[mN].out()}};function FSMenuNode(id,obj){this.id=id;this.obj=obj;this.lyr=this.child=this.args=this.par=this.timer=null;var node=this;this.over=function(evt){with(node)with(obj){if(isNS4&&evt&&lyr.ref)lyr.ref.routeEvent(evt);clearTimeout(timer);if(menuToShow){clearTimeout(mtsTimer);var a=menuToShow,m=a[0];menuToShow=null;if(!menus[m]||!menus[m].lyr.ref)menus[m]=new FSMenuNode(m,obj);var c=menus[m];if(c==node)return;clearTimeout(c.timer);if(c!=child&&c.lyr.ref){c.args=a;c.par=node;if(showDelay)c.timer=setTimeout(myName+'.menus["'+c.id+'"].show()',showDelay);else c.show()}}if(!nested&&par)par.over()}};this.out=function(evt){with(node)with(obj){if(isNS4&&evt&&lyr&&lyr.ref)lyr.ref.routeEvent(evt);clearTimeout(timer);timer=setTimeout(myName+'.menus["'+id+'"].hide()',hideDelay);if(!nested&&par)par.out()}};if(id!='root')with(this)with(lyr=getLyr(id))if(ref){if(ref.addEventListener){ref.addEventListener('mouseover',this.over,false);ref.addEventListener('mouseout',this.out,false)}else{ref.onmouseover=this.over;ref.onmouseout=this.out}}};FSMenuNode.prototype.show=function(){with(this)with(obj){if(!par)return;if(par.child&&par.child!=this)par.child.hide();par.child=this;var offR=args[1];if(offR&&cssLitClass&&!isNS4)offR.className+=(offR.className?' ':'')+cssLitClass;lyrVis(1)}};FSMenuNode.prototype.hide=function(){with(this)with(obj){if(!par)return;if(args[1]&&cssLitClass&&!isNS4)args[1].className=args[1].className.replace(new RegExp('\\s*'+cssLitClass+'$'),'');if(lyr)lyrVis(0);if(child)child.hide();if(par&&par.child==this)par.child=null;par=null}};FSMenuNode.prototype.lyrVis=function(sh){with(this)with(obj){lyr.timer|=0;lyr.counter|=0;with(lyr){clearTimeout(timer);if(sh)sty[cssProp]=cssVis;sty.zIndex=1000+sh;lyr.alpha(counter==100?null:counter);counter+=10*(sh?1:-1);counter+=10*(sh?1:-1);if(counter>100){counter=100}else if(counter<0){counter=0;sty[cssProp]=cssHid}else timer=setTimeout(myName+'.menus["'+id+'"].lyrVis('+sh+')',50)}}};LyrFn('alpha','var f=ref.filters,d=(p==null),o=d?"inherit":p/100;if(f){if(!d&&sty.filter.indexOf("alpha")==-1)sty.filter+=" alpha(opacity="+p+")";else if(f.length&&f.alpha)with(f.alpha){if(d)enabled=false;else{opacity=p;enabled=true}}}else if(isDOM)sty.opacity=sty.MozOpacity=o;');

function setEvent(obj, evt, fn)
{
	if (obj.addEventListener) obj.addEventListener(evt, fn, false);
	else obj['on' + evt] = fn;
}

function loadHandler()
{
	if (!isDOM) return;

// IE5+/Win,Moz,Safari,Op>6,etc... only past this point.
	if (!document.documentElement || (isIE && !isOp && (navigator.userAgent.indexOf('Mac') > -1))) return;

// H1 Animation hook.
 	h1Setup();
};


setEvent(window, 'load', loadHandler);

// <h1> fading effect :).
var h1Arr = [];
function h1Setup()
{
 h1Arr = document.getElementsByTagName('h1');
 for (var h = 0; h < h1Arr.length; h++)
 {
  var h1 = h1Arr[h], text = h1.firstChild.nodeValue;
  h1.removeChild(h1.firstChild);
  h1.animNodes = [];
  for (var i = 0; i < text.length; i++)
  {
   var span = document.createElement('span');
   span.appendChild(document.createTextNode(text.substring(i, i+1)));
   h1.appendChild(span);
   h1.animNodes[h1.animNodes.length] = span;
  }
  h1.animCount = 0;
  h1.animTimer = setInterval('h1Anim(' + h + ')', 50);
 }
};
function h1Anim(h)
{
 var h1 = h1Arr[h], c = h1.animCount++, noAnim = 1;
 for (var i = 0; i < h1.animNodes.length; i++)
 {
  var s = h1.animNodes[i];
  var frac = Math.max(0, Math.min(1, (c-i)/10));
  if (s.animDone) continue;
  noAnim = 0;
  s.style.color = 'rgb(' + parseInt(255-255*frac) + ',' +
   parseInt(255-153*frac) + ',' + parseInt(255-51*frac) + ')';
  if (frac == 1)
  {
   s.style.marginLeft = 'auto';
   s.animDone = 1;
  }
  else if (frac > 0) s.style.marginLeft = 0.6*(1-frac) + 'em';
 }
 if (noAnim) clearInterval(h1.animTimer);
 h1.style.visibility = 'visible';
};

if (isDOM && document.documentElement)
{
 // Hide H1 elements for animation. Yeah, I know document.write sucks.
 document.write('<style type="text/css"> h1 { visibility: hidden } </style>');
}
