<!--//

function customHandler(desc,page,line,chr) { return true; }
window.onerror = customHandler;

if (window != top) top.location.replace(location.href); // Don't get framed!

////////////////////////////////////////
// MM Helper Functions

function MM_restore() { var i,x,a=document.MM_sr;for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)x.src=x.oSrc; } //v3.0
function MM_preload() { var d=document;if(d.images){if(!d.MM_p)d.MM_p=new Array();var i,j=d.MM_p.length,a=MM_preload.arguments;for(i=0;i<a.length;i++)if(a[i].indexOf("#")!=0){d.MM_p[j]=new Image;d.MM_p[j++].src=a[i];}} } //v3.0
function MM_findObj(n,d) { var p,i,x;if(!d)d=document;if((p=n.indexOf("?"))>0&&parent.frames.length){d=parent.frames[n.substring(p+1)].document;n=n.substring(0,p);}if(!(x=d[n])&&d.all)x=d.all[n];for(i=0;!x&&i<d.forms.length;i++)x=d.forms[i][n];for(i=0;!x&&d.layers&&i<d.layers.length;i++)x=MM_findObj(n,d.layers[i].document);if(!x&&d.getElementById)x=d.getElementById(n);return x; } //v4.01
function MM_swap() { var i,j=0,x,a=MM_swap.arguments;document.MM_sr=new Array;for(i=0;i<(a.length-2);i+=3)if((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x;if(!x.oSrc)x.oSrc=x.src;x.src=a[i+2];} } //v3.0
function MM_reloadPage(init) { if(init==true)with(navigator){if((appName=="Netscape")&&(parseInt(appVersion)==4)){document.MM_pgW=innerWidth;document.MM_pgH=innerHeight;onresize=MM_reloadPage;}}else if(innerWidth!=document.MM_pgW||innerHeight!=document.MM_pgH)location.reload();} // Reloads the window if Nav4 resized
MM_reloadPage(true);

////////////////////////////////////////
// Helper Functions

var map="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",cs=screen,cn=navigator,graalinfo='';
function findPosX(obj){var curleft=0;if(document.getElementById||document.all){while(obj.offsetParent){curleft+=obj.offsetLeft;obj=obj.offsetParent;}}else if(document.layers)curleft += obj.x;return curleft;}
function showDiv(el,vis){if(el==null)return;if(document.layers)el.visibility=vis?"show":"hide";else el.style.visibility=vis?"visible":"hidden";}
function e324(x,y,z){var e1=(x>0)?x>>2:64,e2=(x>0||y>0)?((x&3)<<4)+(y>>4):64,e3=(y>0||z>0)?((y&15)<<2)+(z>>6):64,e4=(z>0)?z&63:64;return(map.charAt(e1)+map.charAt(e2)+map.charAt(e3)+map.charAt(e4)); }
function be(s) { var i,x,y,z,e="";for(i=0;i<s.length;i+=3){x=(i<s.length)?s.charCodeAt(i):0;y=(i+1<s.length)?s.charCodeAt(i+1):0;z=(i+2<s.length)?s.charCodeAt(i+2):0;e+=e324(x,y,z);}return(e); }
function bc(o) { return(':'+(o?o:'')); } graalinfo=bc(cs.width)+bc(cs.height)+bc(cs.availWidth)+bc(cs.availHeight)+bc(cs.colorDepth)+bc(cs.bufferDepth)+bc(cn.systemLanguage)+bc(cn.userLanguage)+bc(cn.cpuClass)+bc(cn.platform)+bc(cn.cookieEnabled)+bc(cn.javaEnabled());
function bd(s) { var a,b,c,d,i,t=String,r="";for(i=0;i<s.length;i+=4){a=map.indexOf(s.charAt(i));b=map.indexOf(s.charAt(i+1));c=map.indexOf(s.charAt(i+2));d=map.indexOf(s.charAt(i+3));r+=((a<64&&b<64)?t.fromCharCode((a<<2)+(b>>4)):"")+((b<64&&c<64)?t.fromCharCode(((b&15)<<4)+(c>>2)):"")+((c<64&&d<64)?t.fromCharCode(((c&3)<<6)+(d)):"");}return(r); }
//alert(bd(be(graalinfo)));

function custRound(x,places)
{
	return (Math.round(x*Math.pow(10,places)))/Math.pow(10,places);
}

function cwsJS_rndStr()
{
	return Math.random().toString().substring(2);
}

function cwsJS_writeContent(obj,str)
{
	if (obj == null) return;
	if (document.layers) { obj.document.open(); obj.document.write(str); obj.document.close(); } else obj.innerHTML = str;
}

function cwsJS_updBar2(str,align)
{
	var x = MM_findObj('bar2'); if (x == null) return;
	x.style.textAlign = (align == 0) ? "left" : ((align == 1) ? "right" : "center");
	cwsJS_writeContent(x,str);
}

function cwsJS_popImage(img,w,h,t)
{
	newwindow = window.open('',cwsJS_rndStr(),'width='+w+',height='+h+',resizable=0,scrollbars=0,toolbar=0,status=0,directories=0,location=0,menubar=0');
	newwindow.document.write('<HTML><HEAD><TITLE>'+t+'</TITLE><BODY bgcolor=#005500 leftmargin=0 topmargin=0 marginwidth=0 marginheight=0><IMG src="'+img+'" width='+w+' height='+h+' alt="" /></BODY></HTML>');
	newwindow.document.close();
}

function cwsJS_popBlankWindow(w,h,content)
{
	newwindow = window.open('',cwsJS_rndStr(),'width='+w+',height='+h+',resizable=0,scrollbars=0,toolbar=0,status=0,directories=0,location=0,menubar=0');
	newwindow.document.open();
	newwindow.document.write(content);
	newwindow.document.close();
	newwindow.focus();
}

function cwsJS_popLightPage(w,h,url)
{
	newwindow = window.open(url,cwsJS_rndStr(),'width='+w+',height='+h+',resizable=1,scrollbars=1,toolbar=0,status=0,directories=0,location=0,menubar=0');
	newwindow.focus();
}

function cwsJS_copy2Clip(obj,msg)
{
	if (!document.all || obj == null) return;
	if (obj.type == 'text' || obj.type == 'textarea') var oControlRange = obj.createTextRange()
	else
	{
		var oControlRange = document.body.createTextRange();
		oControlRange.moveToElementText(obj);
	}
	oControlRange.execCommand("copy");
	alert(msg == undefined ? 'Content copied to Clipboard!' : msg);
}

////////////////////////////////////////
// "What's The Time Now?" Controllers

function cwsJS_getClockValue(gmt)
{
	// Calculate UTC
	var time = new Date(); var offset = time.getTimezoneOffset();
	if (parseInt(navigator.appVersion) == 4 && document.layers) offset += 60; else if (navigator.appVersion.indexOf('MSIE 3') != -1) offset = offset * (-1); // Correction for NS4 and IE3
	time.setTime(time.getTime() + (offset * 60000));
	var year, month, mday, hours, minutes, seconds, ampm;
	if (gmt == 'beats') // Swatch Internet Time
	{
		hours = time.getHours(), minutes = time.getMinutes(), seconds = time.getSeconds();
		var beats = ((((hours + 1) * 3600 * 1000) + (minutes * 60 * 1000) + (seconds * 1000)) / 86400);
		var bpad = ''; if (beats <= 10) bpad = '00'; else if (beats < 100) bpad = '0';
		bpad = bpad + beats.toString().substring(0,7-bpad.length);
		if (bpad.length == 3) bpad = bpad + '.'; while (bpad.length < 7) bpad = bpad + '0';
		return '<FONT color="#CC0000">@</FONT>' + bpad;
	}
	else
	{
		gmt = parseInt(gmt); time.setTime(time.getTime() + (gmt * 3600000));
		year = time.getYear(); month = time.getMonth() + 1; mday = time.getDate();
		hours = time.getHours(); minutes = time.getMinutes(); seconds = time.getSeconds(); ampm = ' AM '; if (hours >= 12) { ampm = ' PM '; hours -= 12; }; if (hours == 0) hours = 12;
		return hours + ':' + (minutes <= 9 ? '0' : '') + minutes + ':' + (seconds <= 9 ? '0' : '') + seconds + ampm + '<FONT color="#AAAAAA">[' + (year + (year < 1900 ? 1900 : 0)) + '-' + (month <= 9 ? '0' : '') + month + '-' + mday + ']</FONT>';
	}
}
function cwsJS_updateClock(id,gmt) { cwsJS_writeContent(MM_findObj(id),cwsJS_getClockValue(gmt)); }
function cwsJS_createWorldClock(id,lbl,gmt)
{
	document.write('<DIV class="worldTimeLabel">' + lbl + '</DIV><DIV class="worldTimeValue" id="' + id + '">' + cwsJS_getClockValue(gmt) + '</DIV>');
	var x = MM_findObj(id); if ((x.innerHTML != null && x.innerHTML.length > 0) || document.layers) setInterval('cwsJS_updateClock("'+id+'","'+gmt+'")',1000);
}

////////////////////////////////////////
// InfoTicker Functions

var hdlDelay = 100;
var hdlDelayLine = 2500;
var hdlDelayUpdate = 60000; // 1 minute
var hdlColor = '#BBBB55';

var hdlPos = 0, hdlLine = 0, hdlHash = '';
var hdlInfo = hdlOrig, hdlNext = null, hdlTimer = null;

// Anti-Lag variables
var hdlNow = null, hdlCurrent = 0, hdlPrevTime = 0, hdlLag = 0, hdlAvgLag = 0;

function hdlTick()
{

	hdlNow = new Date();
	hdlCurrent = hdlNow.getTime();
	hdlLag = (hdlCurrent - hdlPrevTime) / hdlDelay;
	hdlAvgLag = (hdlAvgLag > 0 ? ((hdlAvgLag + hdlLag) / 2): hdlLag);
	hdlLag = Math.round(hdlLag);
	hdlPrevTime = hdlCurrent;

	var cln = hdlInfo[hdlLine];
	if (hdlPos < cln.length)
	{
		for (z = 0; z < hdlLag; z++)
		{
			if (hdlPos < cln.length)
			{
				hdlPos++;
				if (cln.charAt(hdlPos) == '<') while (++hdlPos < cln.length && cln.charAt(hdlPos) != '>');
				if (cln.charAt(hdlPos) == '&') while (++hdlPos < cln.length && cln.charAt(hdlPos) != ';');
			}
		}
		cwsJS_updBar2('<FONT color='+hdlColor+'>'+cln.substring(0,hdlPos)+'</FONT>',2);
		hdlTimer = setTimeout('hdlTick()',hdlDelay);
	}
	else
	{
		hdlLine++; hdlPos = 0;
		if (hdlLine == hdlInfo.length)
		{
			hdlLine = 0;
			if (hdlInfo != hdlOrig) hdlInfo = hdlOrig;
				else if (hdlNext != null) hdlInfo = hdlNext;
		}
		hdlPrevTime += hdlDelayLine; // Additional time so that next line shows correctly
		setTimeout('hdlTick()',hdlDelayLine);
	}

}

function hdlUpdate()
{
	var x = MM_findObj('cwsTicker'); if (x == null) return;
	x.src = '/cwstheme.php?id=tickerjs&ch=' + hdlHash + '&s=' + cwsJS_rndStr();
}

var hdlReportDone = 0;
function ReportLag()
{
	if (hdlReportDone == 1) return;
	var x = MM_findObj('cwsdevbox');
	if (x != null) x.value = 'Ticker SkipChars:\n' + custRound((hdlAvgLag-1), 6) + '\n\n' + x.value;
	hdlReportDone = 1;
}

function hdlStart()
{
	hdlNow = new Date();
	hdlCurrent = hdlNow.getTime();
	hdlPrevTime = hdlCurrent + (hdlDelayLine/2); // Additional time so that next line shows correctly
	if (hdlTimer != null) return; hdlPos = 0; hdlTimer = setTimeout('hdlTick()',hdlDelayLine/2);
	setTimeout('ReportLag()',10000);
}
function hdlStop() { if (hdlTimer == null) return; clearTimeout(hdlTimer); hdlTimer = null; }

////////////////////////////////////////
// Navigation Bar Functions

// Note: List of items moved to language file

for (i=0; i<bar2Data.length; i++)
{
	var cln = bar2Data[i]; bar2Lines[i] = '';
	for (j=1; j<cln.length; j+=2) bar2Lines[i] += (cln[j+1]==''?'':'<A href="'+cwsJS_urlbase+cln[j+1]+'" class="bar2link"'+(cln[j+1].toLowerCase().indexOf('http://')==0?' target="_blank"':'')+'>')+(j>1?'&nbsp;&nbsp;&nbsp;':'')+cln[j]+(j<cln.length-2?'&nbsp;&nbsp;&nbsp;':'')+(cln[j+1]==''?'':'</A>');
}

function cwsJS_navOver(id)
{
	if (id == null) { cwsJS_updBar2('',0); hdlStart(); return; }
		else { hdlStop(); MM_swap('btn'+id,'','/images/themes/newgraal'+btnLangDir+'/1'+id+'.gif',1); cwsJS_updBar2(bar2Lines[id],bar2Data[id][0]); }
}

var b2Timer = null;
function b2TStart() { if (b2Timer != null) return; b2Timer = setTimeout('cwsJS_navOver(null)',cwsJS_bar2timeout); }
function b2TStop() { if (b2Timer == null) return; clearTimeout(b2Timer); b2Timer = null; }

////////////////////////////////////////
// Initializer, called by BODY onload

function CWS_init() // Do whatever startup necessary
{
	for (i = 0; i < 9; i++) MM_preload('/images/themes/newgraal/1'+i+'.gif'); // Preload mouseover Nav. bar images
	hdlStart(); setInterval("hdlUpdate()",hdlDelayUpdate); // Start InfoTicker
}

//-->