var disappeardelay=350  //menu disappear speed onMouseout (in miliseconds)
var enableanchorlink=0 //Enable or disable the anchor link when clicked on? (1=e, 0=d)
var hidemenu_onclick=1 //hide menu when user clicks within menu? (1=yes, 0=no)

var ie5=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function showhide(obj, e, visible, hidden){
if (ie5||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
{obj.visibility=visible
tabmenuobj.className='hover'}
else if (e.type=="click")
{obj.visibility=hidden
tabmenuobj.className=''
}
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie5 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie5 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie5 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function dropdownmenu(obj, e, dropmenuID, tabmenuID){
    if (window.event) event.cancelBubble=true
    else if (e.stopPropagation) e.stopPropagation()
    if (typeof dropmenuobj!="undefined") //hide previous menu
        {dropmenuobj.style.visibility="hidden"
        tabmenuobj.className=''}
    clearhidemenu()
    if (ie5||ns6){
        obj.onmouseout=delayhidemenu
        dropmenuobj=document.getElementById(dropmenuID)
        tabmenuobj=document.getElementById(tabmenuID)
        if (hidemenu_onclick) dropmenuobj.onclick=function(){dropmenuobj.style.visibility='hidden'}
        dropmenuobj.onmouseover=clearhidemenu
        dropmenuobj.onmouseout=ie5? function(){ dynamichide(event)} : function(event){ dynamichide(event)}
        showhide(dropmenuobj.style, e, "visible", "hidden")
        dropmenuobj.x=getposOffset(obj, "left")
        dropmenuobj.y=getposOffset(obj, "top")
        dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
        //dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
        //dropmenuobj.style.left="863px"
        dropmenuobj.style.top="236px"
        tabmenuobj.style.zIndex="103"
        
    }
return clickreturnvalue()
}

function clickreturnvalue(){
if ((ie5||ns6) && !enableanchorlink) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie5&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function delayhidemenu(){
delayhide=setTimeout("dropmenuobj.style.visibility='hidden',tabmenuobj.className='' ",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

function openWindow()
{
		var wgtWidth = 1012;
		var wgtHeight = 673;
		var screenX = screen.width;
		var screenY = screen.height;
		var leftX = parseInt((screenX - wgtWidth) / 2);
		var topY = parseInt((screenY - wgtHeight) / 2);
	
		var url = "http://pgacharitychallenge.worldgolftour.com/gameclient.aspx?utm_source=GGL&utm_medium=digital_games&utm_campaign=digital_games";
		
		// open the game client window
		// let the browser do the window management as the object reference remains even if child window is closed.
		// opera and ff being resizable by default, see http://developer.mozilla.org/en/docs/DOM:window.open		
		windowObjectReference = window.open(url, 'Worldgolftour_TM', 'width=' + wgtWidth + ',height=' + wgtHeight + ',left=' + leftX + ',top=' + topY + ',menubar=no,location=no,titlebar=no,toolbar=no,status=no,resizable=no,scrollbars=no');
		
		if((windowObjectReference != null)) {
			// focus the game client window
			// "assure" the object being accessible using timeout
			setTimeout("windowObjectReference.focus();", 42);
		}
}
