﻿jQuery(document).ready(function(){
    jQuery("#siteMenu a").bind("focus", function() { this.blur() });
});
function objFlash(Src, Width, Height) {
    this.src = Src;
    this.width = Width;
    this.height = Height;
    this.quality = "";
    this.bgcolor = "";
    this.wmode = "";
    this.scale = "";
    this.menu = "";
    this.flashvars = "";

    this.Loading = LoadingFlash;

    function LoadingFlash() {
        this.src = this.src.toLowerCase();

        if (this.src.indexOf(".swf") < 0) {
            this.src = this.src + ".swf";
        }
        document.write("<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'   codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' WIDTH=" + this.width + " HEIGHT=" + this.height + " id=OBJECT2>");
        document.write("<PARAM NAME=movie VALUE='" + this.src + "'>");
        if (this.quality != "")
            document.write("<PARAM NAME=quality VALUE='" + this.quality + "'>");
        if (this.bgcolor != "")
            document.write("<PARAM NAME=bgcolor VALUE='" + this.bgcolor + "'>");
        if (this.wmode != "")
            document.write("<PARAM NAME='wmode' VALUE='" + this.wmode + "'>");
        if (this.scale != "")
            document.write("<PARAM NAME='scale' VALUE='" + this.scale + "'>");
        if (this.menu != "")
            document.write("<PARAM NAME='menu' VALUE='" + this.menu + "'>");
        if (this.flashvars != "")
            document.write("<PARAM NAME='flashvars' VALUE='" + this.flashvars + "'>");
        document.write("<EMBED src='" + this.src + "' quality='" + this.quality + "' bgcolor='" + this.bgcolor + "' WIDTH=" + this.width + " HEIGHT=" + this.height + " wmode='" + this.wmode + "'  TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'></EMBED> ");
        document.write("</OBJECT> ");
    }
}



/*
top menu object
*/

TopMenu = function() {
    this.subMenuType = "None"; //None, Vertical  ,Horizontal
    this.id = "";
    this.f_class = "";
    this.selectMenu = "";
    this.topHistory = new Array();
}
TopMenu.prototype = {
    init: function(menuId, firstMenuClassName, subMenuType) {
        this.subMenuType = subMenuType;
        this.id = menuId;
        this.f_class = firstMenuClassName;
        this.menuLeft = 0;
        this.menutRight = 0;
    },
    Bind: function() {
        jQuery("#" + this.id + " ." + this.f_class + " ul.m2nd").css("display", "none");
        if (this.subMenuType != "None") {
            jQuery("#" + this.id + " ." + this.f_class).bind("mouseover", { obj: this }, this.FirstMenu_Over);
            jQuery("#" + this.id + " ." + this.f_class).bind("mouseout", { obj: this }, this.FirstMenu_Out);
            var menus = jQuery("#" + this.id + " ." + this.f_class);
            for (var i = 0; i < menus.length; i++) {
                jQuery("#" + menus[i].id + " ul").bind("mouseover", { obj: this, parentId: menus[i].id }, this.SubMenu_Over);
                jQuery("#" + menus[i].id + " ul").bind("mouseout", { obj: this }, this.SubMenu_Out);
            }
            this.menuLeft = jQuery("#" + this.id).position().left;
            this.menuRight = jQuery("#" + this.id).width(); //+ this.menuLeft;
            if (this.subMenuType == "Horizontal") {
                jQuery("#" + this.id + " ." + this.f_class + " ul li").css("float", "left");
            }
        }
    },
    FirstMenu_Over: function(event) {
        var elementId = this.id;
        var obj = event.data.obj;
        jQuery(this).delay(100, function() {
            var blnHistory = false;
            jQuery("#" + elementId + "  ul.m2nd").css("display", "block");
            jQuery("#" + elementId + ">a").addClass("select1st");
            for (var i = 0; i < obj.topHistory.length; i++) {
                if (obj.topHistory[i] == elementId) {
                    blnHistory = true;
                    break;
                }
            }
            if (!blnHistory) {
                var height = jQuery("#" + elementId).height();
                var position = jQuery("#" + elementId).position();
                var x = position.left;
                var y = position.top;
                var subWidth = 0;
                if (obj.subMenuType == "Horizontal") {
                    jQuery("#" + elementId + " ul li").each(function(i) {
                        subWidth += jQuery(this).width();
                    });
                    if (navigator.userAgent.indexOf("MSIE 7") < 0 && navigator.userAgent.indexOf("MSIE 6.0") >= 0) {
                        jQuery("#" + elementId + " ul").css("width", subWidth);
                    }
                    if (x + subWidth >= obj.menuRight) {
                        x = obj.menuRight - subWidth - 20;
                    }
                }
                else if (obj.subMenuType == "Vertical") {
                    var maxwidth = 0;
                    jQuery("#" + elementId + " ul li a").each(function(i) {
                        if (maxwidth < jQuery(this).width()) {
                            maxwidth = jQuery(this).width();
                        }
                    });
                    if (maxwidth < 70) {
                        jQuery("#" + elementId + " ul li a").css({ display: "inline-block", width: 75 });
                    }
                    else {
                        jQuery("#" + elementId + " ul li a").css({ display: "inline-block", width: maxwidth + 10 });
                    }
                    x = x + 120;
                }
                jQuery("#" + elementId + " ul").css({ top: y, left: x });
                obj.topHistory.push(elementId);
            }
        });
    },
    FirstMenu_Out: function(event) {
        var elementId = this.id;
        jQuery(this).delay(100, function() {
            if (event.data.obj.selectMenu != elementId) {
                jQuery("#" + elementId + " ul.m2nd").css("display", "none");
                jQuery("#" + elementId + ">a").removeClass("select1st");
            }
        });
    },
    SubMenu_Over: function(event) {
        event.data.obj.selectMenu = event.data.parentId;
    },
    SubMenu_Out: function(event) {
        event.data.obj.selectMenu = "";
    }
}


