jQuery(document).ready(function(){
	onloadcall();
	homepage();
});
jQuery(document).ready(function () {
    runOnDOMready()
});
function runOnDOMready() {
    setUpClasses()
}
function setUpClasses() {
    jQuery("li:nth-child(even)").addClass("even");
    jQuery("li:first-child").addClass("first");
    jQuery("li:last-child").addClass("last");
    jQuery("input[type=submit]").hover(function () {
        jQuery(this).addClass("submitHover")
    },

    function () {
        jQuery(this).removeClass("submitHover")
    });
}
function replaceAll(str, searchTerm, replaceWith, ignoreCase) {
    var regex = "/" + searchTerm + "/g";
    if (ignoreCase) {
        regex += "i"
    }
    return str.replace(eval(regex), replaceWith)
}

function filterClasses(a) {
    a = replaceAll(a, "first", "");
    a = replaceAll(a, "last", "");
    a = replaceAll(a, "even", "");
    a = replaceAll(a, "current", "");
    a = replaceAll(a, "dropdown", "");
    a = replaceAll(a, " ", "");
    return a
}

function dropdowns() {
    var e = microtime(true);
    var c = "";
    jQuery("#nav div.dropdown h2").hide();
    var a = false;
    var b = "";
    jQuery("#nav > ul li a._nav").each(function (f, g) {
        jQuery(this).click(function (k) {
            if (!a) {
                a = true;
                var j = jQuery(this);
                var h = j.parent("li").attr("class");
                h = filterClasses(h);
                if (h != "") {
                    dd_Klass = ".dropdown-" + h;
                    if (jQuery(dd_Klass).length > 0) {
                        k.preventDefault();
                        if (jQuery("#nav > ul li.dropdown").length > 0) {
                            if (!j.parent("li").hasClass("dropdown")) {
                                jQuery("#nav > ul li.dropdown").removeClass("dropdown");
                                j.parent("li").addClass("dropdown");
                                jQuery("#nav").addClass("heightFix");
                                jQuery(".dropdown-open").fadeOut("normal", function () {
                                    jQuery(".dropdown-open").removeClass("dropdown-open");
                                    jQuery(dd_Klass).fadeIn("normal", function () {
                                        jQuery(dd_Klass).addClass("dropdown-open");
                                        a = false
                                    })
                                })
                            } else {
                                jQuery("#nav > ul li.dropdown").removeClass("dropdown");
                                jQuery("#nav").removeClass("heightFix");
                                jQuery(".dropdown-open").slideUp("normal", function () {
                                    jQuery(".dropdown-open").removeClass("dropdown-open");
                                    jQuery("#nav").removeClass("dd-open");
                                    if (b != "") {
                                        jQuery("#nav > ul li." + b).addClass("current");
                                        ieNavClasses();
                                        b = ""
                                    }
                                    a = false
                                })
                            }
                        } else {
                            j.parent("li").addClass("dropdown");
                            jQuery("#nav").addClass("dd-open");
                            if (j.parent().parent().find("li.current").length > 0) {
                                b = filterClasses(j.parent().parent().find("li.current").attr("class"));
                                j.parent().parent().find("li.current").removeClass("current");
                                ieNavClasses()
                            }
                            jQuery(dd_Klass).slideDown("normal", function () {
                                jQuery(dd_Klass).addClass("dropdown-open");
                                a = false
                            })
                        }
                    }
                }
            }
        })
    });
    jQuery("#nav").find(".a_close_nav").click(function (f) {
        f.preventDefault();
        jQuery("#nav > ul li.dropdown").removeClass("dropdown");
        jQuery("#nav").removeClass("heightFix");
        jQuery(".dropdown-open").slideUp("normal", function () {
            jQuery(".dropdown-open").removeClass("dropdown-open");
            jQuery("#nav").removeClass("dd-open");
            if (b != "") {
                jQuery("#nav > ul li." + b).addClass("current");
                ieNavClasses();
                b = "";
                b = ""
            }
        })
    });
    var d = microtime(true);
    totalTimer.dropdow = (d - e)
}
// This could be the end //

// Keep - but remove redundant bits //
function indispensableFunctions() {
    dropdowns();
}
function homepage() {
    indispensableFunctions();
}

// Might be able to ditch this later //
var totalTimer = new Array();

function microtime(b) {
    var a = new Date().getTime() / 1000;
    var c = parseInt(a, 10);
    return (b) ? a : (Math.round((a - c) * 1000) / 1000) + " " + c
}
// Keep this onLoadcall() //
function onloadcall() {
}
