<!--//

/*********************************************
		Scriptable Image Maps by Danny Goodman (www.dannyg.com)
		A bonus recipe for readers of O'Reilly's "JavaScript & DHTML Cookbook"
		This recipe first published at O'Reilly Network (www.oreillynet.com)
		For full implementation notes, read the article.
 *********************************************/
        var isWindowOpen = false;

	function initMaps() {
		if (document.getElementById) {
			var mapIds = initMaps.arguments;			// pass string IDs of containing map elements
			var i, j, area, areas;
			for (i = 0; i < mapIds.length; i++) {
				areas = document.getElementById(mapIds[i]).getElementsByTagName("area");
	
				for (j = 0; j < areas.length; j++) {	// loop thru img elements
					area = areas[j];
					area.onmousedown	= imgSwap;			// set event handlers
					area.onmouseout		= imgSwap;
					area.onmouseover	= imgSwap;
					area.onmouseup 		= imgSwap;
				}
			}
		}
	}

/*********************************************
	image swapping event handling
 *********************************************/
	function imgSwap(evt) {
            if (isWindowOpen == true)
            {
                return;
            }

            var imgStyle; var imgStyle2;
            evt = (evt) ? evt : event;
            var elem = (evt.target) ? evt.target : evt.srcElement;
            var imgClass = elem.parentNode.name;
            var coords = elem.coords.split(",");
            var clipVal = "rect(" + coords[1] + "px " +
                                    coords[2] + "px " +
                                    coords[3] + "px " +
                                    coords[0] + "px)";
            switch (evt.type) {
            case "mousedown" :

                    imgStyle = document.getElementById(imgClass + "Down").style;
                    imgStyle.clip = clipVal;
                    imgStyle.visibility = "visible";
                    break;

            case "mouseout" :

                    document.getElementById(imgClass + "Over").style.visibility  = "hidden";
                    document.getElementById(imgClass + "Down").style.visibility  = "hidden";
                    document.getElementById(imgClass + "Extra").style.visibility = "hidden";			
                    break;

            case "mouseover" :

                    imgStyle = document.getElementById(imgClass + "Over").style;
                    imgStyle.clip = clipVal;
                    imgStyle.visibility = "visible";

                    if ( elem.alt == "Courses" )
                    {
                        imgStyle = document.getElementById(imgClass + "Extra").style;
                        imgStyle.clip = clipVal;
                        imgStyle.visibility = "visible";

                    }
                    else if ( elem.alt == "Trackball" )
                    {
                        imgStyle = document.getElementById(imgClass + "Extra").style;
                        imgStyle.clip = clipVal;
                        imgStyle.visibility = "visible";

                    }
                    break;

            case "mouseup" :

                    document.getElementById(imgClass + "Down").style.visibility = "hidden";
                    if (elem.click) { elem.click(); } // guarantee click in IE
                    break;

            }

            evt.cancelBubble = true;
            return false;
	}

/*********************************************
	hide and display div
 *********************************************/


    function showWindow(divName) {
        if (isWindowOpen == false) {
            document.getElementById('floatingWindow').style.visibility='visible';
            document.getElementById(divName).style.visibility='visible';
            isWindowOpen = true;
        }
    }
            
    function closeWindow() {
        document.getElementById('floatingWindow').style.visibility='hidden';
        document.getElementById('player').style.visibility='hidden';
        document.getElementById('score').style.visibility='hidden';
        document.getElementById('trackball').style.visibility='hidden';
        document.getElementById('rotate').style.visibility='hidden';
        document.getElementById('courses').style.visibility='hidden';
        document.getElementById('hole').style.visibility='hidden';
        document.getElementById('start').style.visibility='hidden';
        isWindowOpen = false;
    }

    function clearWindow() {
        isWindowOpen = false;
    }

        
//-->
