function flyMenu()
{ // initialize the flydown and flyup, content rich AJAX menus
    var i, shift, obj, props, flydown=$("a.flydown"), flyup=$("a.flyup");
    for (i=0; i < flydown.length; i++) { // content that will FLYDOWN
        shift = null;
        props = flydown[i].id.split("_");
        // setup hover effects if flyMenu ID is defined
        if (props && props.length > 1 && (props[1] == "fly" ||
         (props[1] == parseInt(props[1]) && props[2] == parseInt(props[2])))) {
            if (props[3] && props[3] == parseInt(props[3])) {
                shift = parseInt(props[3]); // shift left with dimensions
            }
            else if (props[1] == "fly" && props[2] && props[2] == parseInt(props[2])) {
                shift = parseInt(props[2]); // shift left with fly
            }
            obj = $(flydown[i]).parent();
            if (shift) {
                shift = ((props[2] && parseInt(props[2]) > obj.attr("offsetWidth") &&
                 parseInt($("#" + props[0]).css("width")) > obj.attr("offsetWidth"))?
                 (obj.attr("offsetWidth") - parseInt($("#" + props[0]).css("width"))) :
                 ((props[2] == parseInt(props[2]))? props[2] : 0));
            }
            if (props[1] && props[1] == parseInt(props[1]) &&
             props[2] && props[2] == parseInt(props[2])) { // AJAX content
                $(flydown[i]).after( // insert the flybox
                    "<span id=\"" + props[0] + "\" class=\"flybox flydown\" style=\"top:" +
                    obj.attr("offsetHeight") + "px; width:" + props[1] +
                    "px; height:" + props[2] + "px" + ((props[3] && props[3] == parseInt(props[3]))?
                    "; margin-left:-" + props[3] + "px" : "") + "\">" +
                    "<div class=\"flyload\" style=\"text-align:center; margin-top:50px\">" +
                    "<img src=\"/img/page_loading.gif\" width=\"187\"" +
                    " height=\"105\" alt=\"Loading\" /><br />Please Wait&hellip;<\/div><\/span>"
                );
            }
            else { // included content
                $("#" + props[0]).css({
                    top:obj.attr("offsetHeight") + "px",
                    margin:((shift)? "0px 0px 0px " + shift : 0) + "px"
                }); //.css({ opacity:"0.90" });
            }
            $(flydown[i]).hover( // primary cursor interraction
                function() { // mouseover, load/open flybox
                    $(this.parentNode).addClass("goFocus").removeClass("goBlur");
                },
                function() {} // mouseout, do nothing
            );
            /* NEEDS FURTHER WORK
            .click( // disable anchor click
                function() {
                    this.blur();
                    return false;
                    }
            )
            .focus( // primary keyboard interraction
                function() { // on focus, load/open flybox
                    props = this.id.split("_");
                    obj = $("#" + props[0]);
                    if ($("#" + props[0] + " div").hasClass("flyload")) { // load with AJAX
                        obj.load(
                            this.href,
                            null, // no post values
                            function() { // update on call-back, done
                                $("#" + props[0]).css({
                                    width:props[1] + "px", whiteSpace:"normal"
                                });
                            }
                        );
                    }
                    //$(this.parentNode).css({ opacity:"0.90" });
                    obj.css({ display:"block" }); // display the flybox
                }
            );
            */
            $(flydown[i].parentNode).hover( // secondary cursor interraction, on parent container
                function() { // mouseover, show the flybox / hide select boxes
                    // disable all dropdown box (except ones on the header) in IE6 to avoid layering issue
                    if (document.all && !window.XMLHttpRequest) {
                        $("select").css({ visibility:"hidden" });
                        $("#site_header select").css({ visibility:"visible" });
                }
                    props = $(this).find("a:first-child").attr("id").split("_");
                    obj = $("#" + props[0]);
                    if ($("#" + props[0] + " div").hasClass("flyload")) { // load with AJAX
                        obj.load(
                            this.href,
                            null, // no post values
                            function() { // update on call-back, done
                                $("#" + props[0]).css({ width:props[1] + "px", whiteSpace:"normal" });
                            }
                        );
                    }
                    //$(this.parentNode).css({ opacity:"0.90" });
                    obj.css({ display:"block" }); // display the flybox
                    $(this).addClass("goFocus").removeClass("goBlur");
                },
                function() { // mouseout, hide the flybox / display select boxes
                    // re-enable all dropdown box in IE6
                    if (document.all && !window.XMLHttpRequest) {
                        $("select").css({ visibility:"visible" });
                }
                    //$(this).css({ opacity:"1.0" });
                    props = $($(this).children("a")[0]).attr("id").split("_");
                    if (props) { $("#" + props[0]).css({ display:"none" }); }
                    $(this).addClass("goBlur").removeClass("goFocus");
                }
            );
            /* NEEDS FURTHER WORK
            .blur( // secondary keyboard interraction, on parent container
                function() { // on blur, hide the flybox
                    //$(this).css({ opacity:"1.0" });
                    props = $($(this).children("a")[0]).attr("id").split("_");
                    if (props) { $("#" + props[0]).css({ display:"none" }); }
                }
            );
            */
        }
    }
    for (i=0; i < flyup.length; i++) { // content that will FLYUP
        shift = null;
        props = flyup[i].id.split("_");
        if (props && props.length > 1 && (props[1] == "fly" ||
         (props[1] == parseInt(props[1]) && props[2] == parseInt(props[2])))) {
            if (props[3] && props[3] == parseInt(props[3])) {
                shift = parseInt(props[3]); // shift left with dimensions
            }
            else if (props[1] == "fly" && props[2] && props[2] == parseInt(props[2])) {
                shift = parseInt(props[2]); // shift left with fly
            }
            obj = $(flyup[i]).parent();
            if (shift) {
                shift = ((props[2] && parseInt(props[2]) > obj.attr("offsetWidth") &&
                 parseInt($("#" + props[0]).css("width")) > obj.attr("offsetWidth"))?
                 (obj.attr("offsetWidth") - parseInt($("#" + props[0]).css("width"))) :
                 ((props[2] == parseInt(props[2]))? props[2] : 0));
            }
            if (props[1] && props[1] == parseInt(props[1]) &&
             props[2] && props[2] == parseInt(props[2])) { // AJAX content
                $(flyup[i]).after( // insert the flybox
                    "<div id=\"" + props[0] + "\" class=\"flybox flyup\" style=\"bottom:" +
                    obj.attr("offsetHeight") + "px; width:" + props[1] +
                    "px; height:" + props[2] + "px" + ((props[3] && props[3] == parseInt(props[3]))?
                    "; margin-left:-" + props[3] + "px": "") + "\">" +
                    "<div class=\"flyload\" style=\"text-align:center; margin-top:50px\">" +
                    "<img src=\"/img/page_loading.gif\" width=\"187\"" +
                    " height=\"105\" alt=\"Loading\" /><br />Please Wait&hellip;<\/div><\/div>"
                );
            }
            else { // included content
                var ie = (document.all && !window.XMLHttpRequest)? -1 : 0; // position adjust for IE6
                $("#" + props[0]).css({
                    bottom:(obj.attr("offsetHeight") + ie) + "px",
                    margin:((shift)? "0px 0px 0px " + shift : 0) + "px"
                }); // .css({ opacity:"0.90" });
            }
            $(flyup[i]).hover( // primary cursor interraction
                function() { // mouseover, load/open flybox
                    $(this.parentNode).addClass("goFocus").removeClass("goBlur");
                },
                function() {} // mouseout, do nothing
            );
            /* NEEDS FURTHER WORK
            .click( // disable anchor click
                function() {
                    this.blur();
                    return false;
                }
            )
            .focus( // primary keyboard interraction
                function() { // on focus, load/open flybox
                    props = this.id.split("_");
                    obj = $("#" + props[0]);
                    if ($("#" + props[0] + " div").hasClass("flyload")) { // load with AJAX
                        obj.load(
                            this.href,
                            null, // no post values
                            function() { // update on call-back, done
                                $("#" + props[0]).css({
                                    width:props[1] + "px", whiteSpace:"normal"
                                });
                            }
                        );
                    }
                    //$(this.parentNode).css({ opacity:"0.90" });
                    obj.css({ display:"block" }); // display the flybox
                }
            );
            */
            $(flyup[i].parentNode).hover( // secondary cursor interraction, on parent container
                function() { // mouseover, show the flybox / hide select boxes
                    // disable all dropdown box (except ones on the header) in IE6 to avoid layering issue
                    if (document.all && !window.XMLHttpRequest) {
                        $("select").css({ visibility:"hidden" });
                        $("#site_header select").css({ visibility:"visible" });
                    }
                    props = $(this).find("a:first-child").attr("id").split("_");
                    obj = $("#" + props[0]);
                    if ($("#" + props[0] + " div").hasClass("flyload")) { // load with AJAX
                        obj.load(
                            this.href,
                            null, // no post values
                            function() { // update on call-back, done
                                $("#" + props[0]).css({ width:props[1] + "px", whiteSpace:"normal" });
                            }
                        );
                    }
                    //$(this.parentNode).css({ opacity:"0.90" });
                    obj.css({ display:"block" }); // display the flybox
                    $(this).addClass("goFocus").removeClass("goBlur");
                },
                function() { // mouseout, hide the flybox
                    // re-enable all dropdown box in IE6
                    if (document.all && !window.XMLHttpRequest) {
                        $("select").css({ visibility:"visible" });
                    }
                    //$(this).css({ opacity:"1.0" });
                    props = $($(this).children("a")[0]).attr("id").split("_");
                    if (props) { $("#" + props[0]).css({ display:"none" }); }
                    $(this).addClass("goBlur").removeClass("goFocus");
                }
            );
            /* NEEDS FURTHER WORK
            .blur( // secondary keyboard interraction, on parent container
                function() { // on blur, hide the flybox
                    props = $($(this).children("a")[0]).attr("id").split("_");
                    if (props) { $("#" + props[0]).css({ display:"none" }); }
                }
            );
            */
        }
    }
}

$(document).ready(function() {
    $("img").attr("title", function(){ return this.alt; }); // copy image alt to title for tooltip
    $("form.search").bind("submit", function() { // check for search entry before submitting
        if (this.text) { // form object exists
            this.text.value = this.text.value.replace(/\s*$/, "").replace(/^\s*/, ""); // trim white space
            if (this.text.value.match(/\w+/) && this.text.value.toLowerCase() != "search") {
                // has one or more words but is not 'search'
                this.attr1.value = this.text.value;
                return true; // submit form
            }
            else { alert("You must enter a search term."); }
        }
        return false;
    });
    $("form.search input#searchtxt").click(
        function() {
            if (this.value.toLowerCase() == "search") { this.value = ""; }
            this.className = "searchFocus";
        }
    ).focus(
        function() {
            if (this.value.toLowerCase() == "search") { this.value = ""; }
            this.className = "searchFocus";
        }
    ).blur(
        function() {
            if (this.value == "") { this.value = "Search"; }
            this.className = "searchBlur";
        }
    );
    flyMenu();
});
