    // Preload Mouseover Images
    var image1 = new Image(); image1.src = "/images/middle_linkbar_golf_course-over.gif"; 
    var image2 = new Image(); image2.src = "/images/middle_linkbar_book_an_event-over.gif"; 
    var image3 = new Image(); image3.src = "/images/middle_linkbar_golf_shop-over.gif"; 
    var image4 = new Image(); image4.src = "/images/middle_linkbar_go_karts-over.gif"; 
    var image5 = new Image(); image5.src = "/images/middle_linkbar_mini_putt-over.gif"; 
    var image6 = new Image(); image6.src = "/images/middle_linkbar_driving_range-over.gif"; 
    var image7 = new Image(); image7.src = "/images/middle_linkbar_tee_times-over.gif"; 

    // Switch between all hidden, staticpage dropdown hidden and external url hidden
    function showFields (visible) {
        // Netscape 6+, Mozilla/Firefox, IE 5
        if(document.forms.form) {

            var form = document.forms.form;

            // We can pass a "visible" to the showFields function. If we don't then we need to
            // grab one from the form
            if (visible == null) {
                visible = form.menu_link_type.value;
            }

            // If it was a spacer, but now is not, clear the menu_name value
            if (visible != "spacer" && form.menu_name.value == "(spacer)") {
                form.menu_name.value = "";
            }

            // Hide everything by default
            form.menu_link_staticpage.style.display   = "none";
            form.menu_link_externalurl.style.display  = "none";

            // What to hide and what to show?
            switch (visible) {
                case "staticpage":
                    form.menu_link_staticpage.style.display   = "inline";
                    break;
                case "externalurl":
                    form.menu_link_externalurl.style.display  = "inline";
                    break;
                case "spacer":
                    form.menu_name.value="(spacer)";
                    break;
                case "title":
                    break;
            }
        }
    }

   function confirmation(operation, get_plugin, item_name, yesurl, nourl) {

        response = confirm("Are you sure you want to " + operation + " the " + get_plugin + " \"" + item_name + "\"?");

        if (response == true) {
            window.location.href = yesurl;
        }
    };

    // Store the current page in javascript for rollovers
    var thisPage = location.pathname;
    thisPage = thisPage.substring(1);

    function in_string(haystack, needle) {
        var string = new String();
        var testString = new String();

        if (haystack.length > 0 && thisPage.length > 0) {

            // Load the string variable with our haystack
            string = haystack;

            // Grab the needle.length last characters from the string
            testString = string.substr(string.length - needle.length, needle.length);

            if (testString == needle) return true;
            else return false;
        } else {
            return false;
        }
    }


    function mouseover(image_name) {
        if (in_string(image_name, thisPage)) return;

        if (document.images) {
            document.images[image_name].src = '/images/' + image_name + '-over.gif';
        }
    }

    function mouseout(image_name) {
        if (in_string(image_name, thisPage)) return;

        if (document.images) {
            document.images[image_name].src = '/images/' + image_name + '.gif';
        }
    }

    function sidebar_mouseover(sidebar_item_name) {
        if (in_string(sidebar_item_name, thisPage)) return;

        if (document.images) {
            document.getElementById(sidebar_item_name).style.background = 'url(/images/sidebar_mouseover.gif) bottom right no-repeat';
        }
    }

    function sidebar_mouseout(sidebar_item_name) {
        if (in_string(sidebar_item_name, thisPage)) return;

        if (document.images) {
            document.getElementById(sidebar_item_name).style.background = 'url(/images/sidebar_seperator.gif) bottom right no-repeat';
        }
    }

    function validate(input_name) {

        inputs = document.getElementById("form");
        if (inputs != null) {
            num_inputs = input_name.length;

            // Go through each of the specified elements and check for
            // elements that have'nt been filled out
            for (i=0; i<num_inputs; i++) {

                if (!input_name[i]) {
                    continue;
                }

                if (input_name[i].value == '') {
                    alert ('The ' + input_name[i].name + ' field is required.');
                    if (input_name[i].type != "radio") {
                        input_name[i].focus();
                        input_name[i].focus();
                    }
                    return false;
                }
            }
        }

        return true;
    }

    function setExternalLinks() {
        if ( !document.getElementsByTagName ) {
            return null;
        }

        var anchors = document.getElementsByTagName( "a" );
        for ( var i = 0; i < anchors.length; i++ ) {
            var anchor = anchors[i];
            if ( anchor.getAttribute( "href" ) && anchor.getAttribute( "rel" ) == "external" ) {
                anchor.setAttribute( "target", "_blank" );
            }
        }

        return true;
    }

    window.onload = setExternalLinks;

    function show_help (text) {
        alert("Are you sure you want to " + operation + " the " + get_plugin + " \"" + item_name + "\"?");
    }

    //Call with: <span class="link" onclick="openITT();">CLICK HERE TO BOOK YOUR TEE-TIME</span>
    function openITT() {
        var dw=405, dh=200;
        var dt=((window.screen.availHeight - dh)/2)-25;
        var dl=(window.screen.availWidth - dw)/2;
        var itt=window.open("http://142.59.93.129/leapfrog.itt/default.aspx" ,null,"top=" + dt + ",left=" + dl + ", height=" + dh + ",width=" + dw + ",status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no,channelmode=no");
        itt.focus();
    }

    function addLoadEvent(func) {
        var oldonload = window.onload;
        if (typeof window.onload != 'function') {
            window.onload = func;
        }
        else {
            window.onload = function() {
                oldonload();
                func();
            }
        }
    }

    function isTextOverflowing() {
        // Take a look at the height of the main text div on the main page
        var main_text = document.getElementById("main_text");
        var isOverflow = false;

        if (main_text) {
            // Grab the supposed and actual heights of the main text element
            var supposed = main_text.style.height;
            var actual = main_text.offsetHeight;

            // Strip "px" off of the height
            supposed = supposed.replace(/px/, "");

            if (actual - supposed < 2) return;

            // If the actual height is greater than the supposed height, fix the layout
            // so it overflows properly
            if (actual > supposed) {
                document.getElementById("bottom_border").innerHTML = "<img style=\"width: 499px; height: 9px;\" src=\"images/main_text_bottom_overflow.gif\" alt=\"spacer\" />";
                document.getElementById("bottom_border").style.paddingLeft = "195px";
                document.getElementById("bottom_border").style.background = "#F8F6F6";
                document.getElementById("main_text_left").innerHTML = "<img style=\"width: 195px; height: 9px;\" src=\"images/bottom_block_bottom.gif\" alt=\"spacer\" />";
            }
        }
    }

    addLoadEvent(isTextOverflowing);

    function calculateCost() {
        thisForm = document.getElementById("form");

        numPeople     = thisForm.Total_Number_of_People.value;
        costPerPerson = thisForm.Total_Cost_Per_Person.value;

        if (numPeople > 0 && costPerPerson > 0) {
            calculatedCost = '$' + numPeople * costPerPerson;

            // Trim off any more than 2 decimal places
            decimalIndex = calculatedCost.indexOf(".");
            if (decimalIndex > 0) {
                calculatedCost  = calculatedCost.substr(0, decimalIndex) + '.' + calculatedCost.substr(decimalIndex + 1, 2);
            }

            thisForm.Calculated_Total_Cost.value = calculatedCost;
        }
    }
