﻿
// 顶部Banner
(function() {
    var o = document.getElementById('dBanner');
    if (!o) return;
    loadflash('dBanner', 1003, 149, 'KDSkins/GX/swf/banner_idx2.swf');
})();

// 搜索
var doSearch= function(){
    var kw=$.trim($('#dTXTSearch').val());
    if(kw==''){
        alert('请输入搜索关键字');
        return;
    }
    
    window.location= 'IndexSearch.aspx?kw='+ escape(kw);
};

(function() {
    if (!document.getElementById('dBTNSearch')) return;
    $('#dBTNSearch').click(doSearch);
})();


// 下拉菜单
var allMenuIndex= [1,2,3,4,5,6];
var allMenuItems= ['dMenu_1','dMenu_2','dMenu_3','dMenu_4','dMenu_5','dMenu_6'];
var allSubMenuList = ['dSubMenu_1','dSubMenu_2','dSubMenu_3','dSubMenu_4','dSubMenu_5','dSubMenu_6'];
//        for (var i = 0; i < allMenuList.length; i++) {
//            var o = document.getElementById(allMenuList[i]);
//            if (!o) continue;
//            jQuery(o).css('opacity',0.8);
//        }
(function(){
    var itv= null;
    for( var i=0; i<allMenuItems.length; i++ ){
        (function(){
            var oItem= document.getElementById(allMenuItems[i]);
            var oSubMenu= document.getElementById(allSubMenuList[i]);
            if(!oSubMenu) return;
            if(!oItem) return;
            var hideItv= null;
            var showMenu= function(){
                clearTimeout(hideItv);
            };
            var hideMenu= function(){
                clearTimeout(hideItv);
                hideItv= setTimeout( function(){
                    if (oSubMenu) {
                        oSubMenu.style.display = 'none';
                    }
                }, 50);
            };
            oItem.onmouseover= function(){
                var pos = $(oItem).position(); 
                if (oSubMenu) {
                    oSubMenu.style.display = '';
                    oSubMenu.style.left = pos.left + Math.round((oItem.offsetWidth - oSubMenu.offsetWidth) / 2) + 'px';
                    oSubMenu.style.top = pos.top + 130 + 'px';
                }
            };
            oItem.onmouseout= function(){
                hideMenu();
            };
            oSubMenu.onmouseover= function(){
                clearTimeout(hideItv);
                oSubMenu.style.display = '';
            };
            oSubMenu.onmouseout= function(){
                clearTimeout(hideItv);
                oSubMenu.style.display = 'none';
            };
        })();
            
    }
})();
/*
jQuery.each($('#dNavBar .navItem'), function(i, el) {

    var itv = null;
    var sid = el.id.split('_')[1];
    var omenu = document.getElementById('dSubMenu_' + sid);

    var showMenu = function(idx) {
        
        if(!omenu) return;
        clearTimeout(itv);
        
        var cur_sub_menu_id= 'dSubMenu_' + idx;
        for (var i = 0; i < allSubMenuList.length; i++) {
            if (allSubMenuList[i] == cur_sub_menu_id) continue;
            var o = document.getElementById(allSubMenuList[i]);
            if (!o) continue;
            o.style.display = 'none';
        }


        var pos = $(el).position(); 
        if (omenu) {
            omenu.style.display = '';
            omenu.style.left = pos.left + Math.round((el.offsetWidth - omenu.offsetWidth) / 2) + 'px';
            omenu.style.top = pos.top + 130 + 'px';

        }

    };
    var hideMenu = function() {
        clearTimeout(itv);
        setTimeout(function() {
            for (var i = 0; i < allSubMenuList.length; i++) {
                var o = document.getElementById(allSubMenuList[i]);
                if (!o) continue;
                o.style.display = 'none';
            }
        }, 100);
    };
    el.onmouseover = function() { 
        var mid = el.id.split('_')[1];
        showMenu(mid);
    };
    el.onmousemove = function() {
        var mid = el.id.split('_')[1];
        showMenu(mid);
    };
    el.onmouseout = function() {
        if (omenu) omenu.style.display = 'none';
    };

    if (omenu) {
        omenu.onmouseover = function() {
            clearTimeout(itv);
        };
        omenu.onmouseout = function() {
            if (omenu) omenu.style.display = 'none';
        };
    }
});
*/