var iTimerID = 0;
var mousex = 0;
var mousey = 0;
var mrcurdivName = ""


function submitform(frm, btn, val, sw, cls){
	var old_value = btn.value
	
	swtichbutton(btn, val, sw, cls)
	if (validatefrm(frm)){
		frm.submit()
	} else {
		swtichbutton(btn, old_value, true, "button")
	}
}

function openwchild(url, wd){
	hkSource = window.open("","hkSource","toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width="+wd+",height=500");
	if (hkSource == null) {
		alert("The function requires that a new window must be opened.\nBut a popup blocker/ or other active process is enabled and so this function can not run.\n\nTo use this function, please allow our site to run popups.")
	}else{
		hkSource.location = url
		hkSource.focus()	
	}
}

function swtichbutton(btn, val, sw, cls){
	if (sw == true){
		btn.className = cls
		if (btn.disabled == true){
			btn.disabled = false
		}else{
			btn.disabled = true
		}
	}
	btn.value = val
}

function gotourl(url){
	window.location = url
}


function whataboutfooter(){
	document.getElementById("divfooter").style.top =  Math.max(document.getElementById("divmainbody").offsetHeight, document.getElementById("divnavigation").offsetHeight) + 90
	document.getElementById("divfooter").style.width = 850
	document.getElementById("divfooter").style.visibility  = "visible" 
	
}

function showsubmenu(divName,effect, o){
	x =  eval('document.getElementById("mainbody").offsetLeft') - 3
	y = eval('document.getElementById("menu'+divName+'").offsetTop') + document.getElementById("divheader").offsetHeight
	//window.status = x + " " + y + " OffsetHeight " + eval('document.all.item("menu'+divName+'").offsetHeight') + "MouseX: " + mousex + " Mousey:" + mousey
	// if effect==1 then do the effect thing
	if (mrcurdivName != ""){
		var force = 1
		mrhide(mrcurdivName, 1, force)
	}
	
	// ie bug fix.
	if (eval('document.getElementById("'+divName+'").style.visibility')=="") eval('document.getElementById("'+divName+'").style.visibility="hidden"');
	// make win appear.
	test = eval('document.getElementById("'+divName+'").style.visibility')
	if (test == "hidden") {	
		
		eval('document.getElementById("'+divName+'").style.filter="revealTrans(duration=0.5, transition=6)"')
		eval('document.getElementById("'+divName+'").filters.revealTrans.apply()')
		eval('document.getElementById("'+divName+'").style.pixelLeft=x')
		eval('document.getElementById("'+divName+'").style.pixelTop=y')
		eval('document.getElementById("'+divName+'").style.visibility="visible"')
		eval('document.getElementById("'+divName+'").filters.revealTrans.play()')
		
		mrcurdivName = divName		
		imrTimerID = setInterval("mrdohidediv()", 2000) 
	}
}


function mrhide(divName, effect, force){// hides a popup

	eval('document.getElementById("'+mrcurdivName+'").style.visibility="hidden"')
	mrcurdivName = ""
	clearInterval(imrTimerID)
}

function mrdohidediv(){
	if (mrcurdivName != ""){
		msg = ""
		ileft = eval('document.all.item("'+mrcurdivName+'").offsetLeft') + eval('document.all.item("'+mrcurdivName+'").offsetParent.offsetLeft') 
		iwth = eval('document.all.item("'+mrcurdivName+'").offsetWidth')
		itop = eval('document.all.item("'+mrcurdivName+'").offsetTop') + eval('document.all.item("'+mrcurdivName+'").offsetParent.offsetTop') 
		ihgt = eval('document.all.item("'+mrcurdivName+'").offsetHeight')
		force = 0 
		if (mousex < ileft || mousex > ileft + iwth){
			force = 1
			}
		if (mousey < itop || mousey > itop + ihgt){ 
			force = 1 }
		if (force == 1){ 
			mrhide(mrcurdivName, 1, force) }	
	}	
}

function microsoftMouseMove() {

    if (document.layers) {
        mousex = event.pageX;
        mousey = event.pageY;
    }
    else if (document.all) {
        mousex = window.event.x;
        mousey = window.event.y;
    }
        
}
