fadeColor = "#FF9A00";  // color to fade to fadeColor = "#0";
stepIn = 17; // delay when fading in
stepOut = 25; // delay when fading out
autoFade = true;
sloppyClass = true;
macCompat = false;
hexa = new makearray(16);
for(var i = 0; i < 10; i++)
{hexa[i] = i;}
hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
hexa[13]="d"; hexa[14]="e"; hexa[15]="f";
document.onmouseover = domouseover;
document.onmouseout = domouseout;
fadeColor = dehexize(fadeColor.toLowerCase());
var fadeId = new Array();

function dehexize(Color)
{var colorArr = new makearray(3);
for (i=1; i<7; i++)
{for (j=0; j<16; j++)
{if (Color.charAt(i) == hexa[j])
{if (i%2 !=0)
{colorArr[Math.floor((i-1)/2)]=eval(j)*16;}
else
{colorArr[Math.floor((i-1)/2)]+=eval(j);}}}}
return colorArr;}

function domouseover()
{if(document.all)
{var srcElement = event.srcElement;
if((srcElement.tagName == "A" && autoFade && srcElement.className != "nofade") || srcElement.className == "fade" || (sloppyClass && srcElement.className.indexOf("fade") != -1))
{if(!srcElement.startColor)
{srcElement.startColor = (srcElement.style.color)? srcElement.style.color: srcElement.currentStyle.color;
srcElement.startColor = dehexize(srcElement.startColor.toLowerCase());}
var link = (macCompat? srcElement.name: srcElement.uniqueID);
if(link)
{fade(srcElement.startColor,fadeColor,link,stepIn);}
else if (macCompat)
{alert("Error: Mac Compatility mode enabled, but link has no name.");}}}}

function domouseout()
{if(document.all)
{var srcElement = event.srcElement;
if((srcElement.tagName == "A" && autoFade && srcElement.className != "nofade") || srcElement.className == "fade" || (sloppyClass && srcElement.className.indexOf("fade") != -1))
{var link = (macCompat? srcElement.name: srcElement.uniqueID);
if(link)
{fade(fadeColor,srcElement.startColor, link,stepIn);}}}}
function makearray(n)
{this.length = n;
for(var i = 1; i <= n; i++)
{this[i] = 0;}
return this;}

function hex(i)
{if(i < 0)
{return "00";}
else if(i > 255)
{return "ff";}
else
{return "" + hexa[Math.floor(i/16)] + hexa[i%16];}}

function setColor(r, g, b, element)
{var hr = hex(r); var hg = hex(g); var hb = hex(b);
element.style.color = "#" + hr + hg + hb;}

function fade(s,e,element,step)
{var sr = s[0]; var sg = s[1]; var sb = s[2];
var er = e[0]; var eg = e[1]; var eb = e[2];
if(fadeId[0] != null && fade[0] != element && eval(fadeId[0]))
{var orig = eval(fadeId[0]);
setColor(orig.startColor[0],orig.startColor[1],orig.startColor[2],orig);
var i = 1;
while(i < fadeId.length)
{clearTimeout(fadeId[i]);
i++;}}
for(var i = 0; i <= step; i++)
{fadeId[i+1] = setTimeout("setColor(Math.floor(" + sr + " *(( " + step + " - " + i + " )/ " + step + " ) + " + er + " * (" + i + "/" + step + ")), Math.floor(" + sg + " * (( " + step + " - " + i + " )/ " + step + " ) + " + eg + " * (" + i + "/" + step + ")), Math.floor(" + sb + " * ((" + step + "-" + i + ")/" + step + ") + " + eb + " * (" + i + "/" + step + ")), " + element + ");", i * step);}
fadeId[0] = element;}

function rand(n){ return Math.round((Math.random()*(n-1))+1);}

function fadeimg(i){document.write('<img src="'+ i+ '" border=0 style="filter:alpha(opacity=50)" onMouseOut=Fade(this,50) onMouseOver=Fade(this,100) />');}
FadeObjects = new Object();FadeTimers = new Object();

function Fade(object, destOp, delta){if (object != "[object]"){setTimeout("Fade("+object+","+destOp+")",0);return}clearTimeout(FadeTimers[object.sourceIndex]);
diff = destOp-object.filters.alpha.opacity;dir = 1;if (object.filters.alpha.opacity > destOp){dir = -1;}
delta=Math.min(dir*diff,10);object.filters.alpha.opacity+=dir*5;if (object.filters.alpha.opacity != destOp){FadeObjects[object.sourceIndex]=object;
FadeTimers[object.sourceIndex]=setTimeout("Fade(FadeObjects["+object.sourceIndex+"],"+destOp+")",10);}}

function tableruler()
{
 if (document.getElementById && document.createTextNode)
  {
   var tables=document.getElementsByTagName('table');
   for (var i=0;i<tables.length;i++)
   {
    if(tables[i].className=='ruler')
    {
     var trs=tables[i].getElementsByTagName('tr');
     for(var j=0;j<trs.length;j++)
     {
      if(trs[j].parentNode.nodeName=='TBODY' && trs[j].parentNode.nodeName!='TFOOT')
       {
       trs[j].onmouseover=function(){this.className='ruled';return false}
       trs[j].onmouseout=function(){this.className='';return false}
     }
    }
   }
  }
 }
}



/*
* The Variable names have been compressed to achive a higher level of compression.
*/

// Prototype Method to get the element based on ID
function $(d){
	return document.getElementById(d);
}

// set or get the current display style of the div
function dsp(d,v){
	if(v==undefined){
		return d.style.display;
	}else{
		d.style.display=v;
	}
}

// set or get the height of a div.
function sh(d,v){
	// if you are getting the height then display must be block to return the absolute height
	if(v==undefined){
		if(dsp(d)!='none'&& dsp(d)!=''){
			return d.offsetHeight;
		}
		viz = d.style.visibility;
		d.style.visibility = 'hidden';
		o = dsp(d);
		dsp(d,'block');
		r = parseInt(d.offsetHeight);
		dsp(d,o);
		d.style.visibility = viz;
		return r;
	}else{
		d.style.height=v;
	}
}
/*
* Variable 'S' defines the speed of the accordian
* Variable 'T' defines the refresh rate of the accordian
*/
s=7;
t=10;

//Collapse Timer is triggered as a setInterval to reduce the height of the div exponentially.
function ct(d){
	d = $(d);
	if(sh(d)>1){
		v = Math.round(sh(d)/d.s);
		v = (v<1) ? 1 :v ;
		v = (sh(d)-v);
		sh(d,v+'px');
		d.style.opacity = (v/d.maxh);
		d.style.filter= 'alpha(opacity='+(v*100/d.maxh)+');';
	}else{
		sh(d,0);
		dsp(d,'none');
		d.style.opacity = 100;
		d.style.filter= 'alpha(opacity=100);';
		clearInterval(d.t);
	}
}

//Expand Timer is triggered as a setInterval to increase the height of the div exponentially.
function et(d){
	d = $(d);
	if(sh(d)<d.maxh){
		v = Math.round((d.maxh-sh(d))/d.s);
		v = (v<1) ? 1 :v ;
		v = (sh(d)+v);
		sh(d,v+'px');
		d.style.opacity = (v/d.maxh);
		d.style.filter= 'alpha(opacity='+(v*100/d.maxh)+');';
	}else{
		sh(d,d.maxh);
		clearInterval(d.t);
	}
}

// Collapse Initializer
function cl(d){
	if(dsp(d)=='block'){
		clearInterval(d.t);
		d.t=setInterval('ct("'+d.id+'")',t);
	}
}

//Expand Initializer
function ex(d){
	if(dsp(d)=='none'){
		dsp(d,'block');
		d.style.height='0px';
		clearInterval(d.t);
		d.t=setInterval('et("'+d.id+'")',t);
	}
}

// Removes Classname from the given div.
function cc(n,v){
	s=n.className.split(/\s+/);
	for(p=0;p<s.length;p++){
		if(s[p]==v+n.tc){
			s.splice(p,1);
			n.className=s.join(' ');
			break;
		}
	}
}
//Accordian Initializer
function Accordian(d,s,tc){
	// get all the elements that have id as content
	l=$(d).getElementsByTagName('div');
	c=[];
	for(i=0;i<l.length;i++){
		h=l[i].id;
		if(h.substr(h.indexOf('-')+1,h.length)=='content'){c.push(h);}
	}
	sel=null;
	//then search through headers
	for(i=0;i<l.length;i++){
		h=l[i].id;
		if(h.substr(h.indexOf('-')+1,h.length)=='header'){
			d=$(h.substr(0,h.indexOf('-'))+'-content');
			d.style.display='none';
			d.style.overflow='hidden';
			d.maxh =sh(d);
			d.s=(s==undefined)? 7 : s;
			h=$(h);
			h.tc=tc;
			h.c=c;
			// set the onclick function for each header.
			h.onclick = function(){
				for(i=0;i<this.c.length;i++){
					cn=this.c[i];
					n=cn.substr(0,cn.indexOf('-'));
					if((n+'-header')==this.id){
						ex($(n+'-content'));
						n=$(n+'-header');
						cc(n,'__');
						n.className=n.className+' '+n.tc;
					}else{
						cl($(n+'-content'));
						cc($(n+'-header'),'');
					}
				}
			}
			if(h.className.match(/selected+/)!=undefined){ sel=h;}
		}
	}
	if(sel!=undefined){sel.onclick();}
}

function ExpOrCollAll(d,vis){
	l=$(d).getElementsByTagName('div');
	c=[];
	for(i=0;i<l.length;i++){
		h=l[i].id;
		if(h.substr(h.indexOf('-')+1,h.length)=='content'){c.push(h);}
	}
	for(i=0;i<l.length;i++){
		h=l[i].id;
		if(h.substr(h.indexOf('-')+1,h.length)=='header'){
			d=$(h.substr(0,h.indexOf('-'))+'-content');
			d.style.display=(vis?'':'none');
			d.style.overflow=(vis?'':'hidden');
		}
	}
}
