function choose_copts(div) {
	var obj = document.getElementById(div);
	obj.style.display = 'inline';
	obj = document.getElementById('x_' + div);
	obj.style.display = 'none';
}

function close_copts(div) {
	var obj = document.getElementById(div);
	obj.style.display = 'none';
	obj = document.getElementById('x_' + div);
	obj.style.display = 'inline';
}

function clickViewET(div) {
	var obj = document.getElementById('divET');
	obj.style.display = 'none';
	obj = document.getElementById('divLDR');
	obj.style.display = 'none';
	obj = document.getElementById(div);
	obj.style.display = 'inline';
}

var nTime;
var nTarget = js_date; 

function drawCountdown(layer,text) {
	if (document.getElementById(layer)) {
		document.getElementById(layer).innerHTML = text;
	} 
}

function Tick() {
	var dNow = new Date();
	nTime = nTarget - dNow.valueOf();
	if (nTime < 0) nTime = 0;
	nTime = Math.floor(nTime / 1000);
	Display("ctdwn_d1", "ctdwn_d2", "ctdwn_d3", 86400);
	Display(null, "ctdwn_h1", "ctdwn_h2", 3600);
	Display(null, "ctdwn_m1", "ctdwn_m2", 60); 
	Display(null, "ctdwn_s1", "ctdwn_s2", 1); 
}

function Display(el2, el1, el0, nDivisor) {
	var nValue = (nTime - (nTime %= nDivisor)) / nDivisor;
	drawCountdown(el0,(nValue % 10));
	nValue = Math.floor(nValue / 10);
	drawCountdown(el1,(nValue % 10));
	if (el2) {
		nValue = Math.floor(nValue / 10);
		if(nValue > 0) {
			drawCountdown(el2,(nValue % 10));
		}
	}
}

function startScroll() {
	frontPart = scrollMsg.substring(scrollCtr,scrollMsg.length);
	backPart = scrollMsg.substring(0,scrollCtr);
	document.scrollForm.thisbanner.value = frontPart + backPart;
	if (scrollCtr < scrollMsg.length) {scrollCtr++;}
	else {scrollCtr = 0;}
	setTimeout("startScroll()", scrollSpd);
	if(scrollCtr%100<1) {
		document.cookie = "scroll=" +scrollCtr + ";path=" + '/';
	}
}

function deleteSheet(serial, entryname) {
	if(confirm('Are you sure that you want to permanently delete the bracket "'+entryname+'"?')) {
		var url = '/?viewer=bracket_d&serial=' + serial;
		document.location = url;
	}
}

function replyTo(msg_id) {
	var cWin = open('/?viewer=print&p=admin_replyto&msgid='+msg_id, 'replyWin'+msg_id, 'directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no,scrollbars=yes,width=600,height=400,resizable=yes');
	cWin.document.close();
	cWin.focus();
}

function openPrint(page,pageqry,extrastuff) {
	var url = '/?viewer=print&p='+page+pageqry+extrastuff;
	var myPBars = 'directories=no,location=no,menubar=yes,status=no';
	myPBars += ',titlebar=no,toolbar=yes';
	var myPOptions = 'scrollbars=yes,width=800,height=500,resizable=yes';
	var myPFeatures = myPBars + ',' + myPOptions;
	var printWin = open(url, 'myPrintDoc', myPFeatures);
	printWin.document.close();
	printWin.focus();
}

function openHelp(in_url) {
	var url = js_srcdir+in_url+'.html';
	var myPBars = 'directories=no,location=no,menubar=yes,status=no';
	myPBars += ',titlebar=no,toolbar=yes';
	var myPOptions = 'scrollbars=yes,width=440,height=480,resizable=yes';
	var myPFeatures = myPBars + ',' + myPOptions;
	var printWin = open(url, 'myPrintDoc', myPFeatures);
	printWin.document.close();
	printWin.focus();
}

function openXls(page,pageqry,extrastuff) {
	var url = '/?viewer='+page+pageqry+extrastuff+'&excel=true';
	document.location = url;
}

function glance(ltrt, iframe) {
	var obj;
	if(iframe == 'scr') {
		obj = document.getElementById(ltrt + 'glance_scr');
		obj.style.display = 'inline';
		obj = document.getElementById(ltrt + 'glance_ldr');
		obj.style.display = 'none';
	} else {
		obj = document.getElementById(ltrt + 'glance_scr');
		obj.style.display = 'none';
		obj = document.getElementById(ltrt + 'glance_ldr');
		obj.style.display = 'inline';
	}
}

function cMsgCounter(field) {
	if (field.value.length > 750) {
		field.value = field.value.substring(0, 750);
	} 
}

function sMsgCounter(field) {
	if (field.value.length > 2000) {
		field.value = field.value.substring(0, 2000);
	} 
}

function editMsg() {
	var obj=document.getElementById('editComMsg');
	obj.style.display='inline';
	obj=document.getElementById('viewComMsg');
	obj.style.display='none';
}

function cancelMsg() {
	var obj=document.getElementById('viewComMsg');
	obj.style.display='inline';
	obj=document.getElementById('editComMsg');
	obj.style.display='none';
}

function editRtMsg() {
	var obj=document.getElementById('editRtComMsg');
	obj.style.display='inline';
	obj=document.getElementById('viewRtComMsg');
	obj.style.display='none';
}

function cancelRtMsg() {
	var obj=document.getElementById('viewRtComMsg');
	obj.style.display='inline';
	obj=document.getElementById('editRtComMsg');
	obj.style.display='none';
}

function editScroll() {
	var obj=document.getElementById('editScroll');
	obj.style.display='inline';
}

function cancelScroll() {
	var obj=document.getElementById('editScroll');
	obj.style.display='none';
}

// START POPIT MENU
var defaultMenuWidth="250px" //set default menu width.
var linkset=new Array()

var ie5=document.all && !window.opera
var ns6=document.getElementById

if (ie5||ns6)
document.write('<div id="popitmenu" onMouseover="clearhidemenu2();" onMouseout="dynamichide2(event)"></div>')

function iecompattest(){
return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement : document.body
}

function showmenu(e, which, optWidth){
if (!document.all&&!document.getElementById)
return
clearhidemenu2()
menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu")
menuobj.innerHTML=which
menuobj.style.width=(typeof optWidth!="undefined")? optWidth : defaultMenuWidth
menuobj.contentwidth=menuobj.offsetWidth
menuobj.contentheight=menuobj.offsetHeight
eventX=ie5? event.clientX : e.clientX
eventY=ie5? event.clientY : e.clientY
//Find out how close the mouse is to the corner of the window
var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX
var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY
//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<menuobj.contentwidth)
//move the horizontal position of the menu to the left by it's width
menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px"
else
//position the horizontal position of the menu where the mouse was clicked
menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px"
//same concept with the vertical position
if (bottomedge<menuobj.contentheight)
menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+"px" : window.pageYOffset+eventY-menuobj.contentheight+"px"
else
menuobj.style.top=ie5? iecompattest().scrollTop+event.clientY+"px" : window.pageYOffset+eventY+"px"
menuobj.style.visibility="visible"
return false
}

function contains_ns6(a, b) {
//Determines if 1 element in contained in another- by Brainjar.com
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function hidemenu2(){
if (window.menuobj)
menuobj.style.visibility="hidden"
}

function dynamichide2(e){
if (ie5&&!menuobj.contains(e.toElement))
hidemenu2()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
hidemenu2()
}

function delayhidemenu2(){
delayhide2=setTimeout("hidemenu2()",500)
}

function clearhidemenu2(){
if (window.delayhide2)
clearTimeout(delayhide2)
}

if (ie5||ns6)
document.onclick=hidemenu2
// END POPIT MENU