﻿var LotList = ['index','ssq','dlt','sd','pls','qxc','qlc','sfc'];

function addBookmark(title, url) {
    if (window.sidebar) { window.sidebar.addPanel(title, url, ""); } else if (document.all) { window.external.AddFavorite(url, title); } else if (window.opera && window.print) { return true; }
}
/*
by shuaishuai shuaishuai@foxmail.com
2009-10-12
*/
function setMenu() {
    var currentUrl = location.href;
    var endz = currentUrl.indexOf('.com/');
    if (endz > -1) {
        var temp = currentUrl.substring(endz + 5);
        var endz2 = temp.indexOf('/');
        var typeID = temp.substring(0, endz2);

        var lastdot = currentUrl.lastIndexOf('.');
        var lastg = currentUrl.lastIndexOf('/');
        var subID = currentUrl.substring(lastg + 1, lastdot);
        if (typeID.length > 0) {
            var t1 = currentUrl.indexOf(typeID);
            var sTemp = currentUrl.substring(t1 + typeID.length + 1);
            var t2 = sTemp.indexOf('/');
            if (t2 > 0) {
                subID = sTemp.substring(0, t2);
            }
        }
        if (!typeID || typeID=='all') {
            return;
        }
        else {
            document.getElementById('top_bar').style.display = 'none';
            
        }
        
        var haved = false;
        $('#top_menus > li').each(function(i) {//一级菜单选中
            if ($(this).attr('id') == 'topmenu_' + typeID) {
                haved = true;
                $(this).attr('class', 'current');
                document.getElementById('sub_menus_' + typeID).style.display = '';

                //二级菜单选中
                $('#sub_menus_' + typeID + ' > a').each(function(i) {
                    var currentSubMenuID = 'submenu_' + typeID + '_' + subID;
                    if ($(this).attr('id') == currentSubMenuID) {
                        $('#' + currentSubMenuID).attr('class', 'actived');
                        return;
                    }

                });

            }
            else {
                $(this).attr('class', '');
            }

        });
        if (!haved) {
            $('#topmenu_index').attr('class', 'current');
            document.getElementById('sub_menus_ssq').style.display = '';
        }
    }
}

var timeoutmilsecond = 100;
var overTime;
var outTime= new Date();;

function ShowSubMenu(typeID) {
//    var tempTime1 = outTime;
//    outTime = null;

//    overTime = new Date();
//    var tempTime2 = overTime;
//    overTime = null;

//    var _timespan = TimeSpan(tempTime2, tempTime1);

//    if (_timespan < 300) {
//        
//        return;
//    }
//    
    
    window.setTimeout(function() {
        var enabled = false;
        for (var i = 0; i < LotList.length; i++) {
            if (typeID == LotList[i]) {
                if (!enabled) {
                    document.getElementById('topmenu_' + typeID).className = 'current';
                    if (LotList[i] != 'index') {
                        document.getElementById('sub_menus_' + LotList[i]).style.display = '';
                        document.getElementById('top_bar').style.display = 'none';
                    }
                    else {
                        document.getElementById('top_bar').style.display = '';
                    }
                    enabled = true;
                }
            }
            else {
                document.getElementById('topmenu_' + LotList[i]).className = '';
                if (LotList[i] != 'index') {
                    document.getElementById('sub_menus_' + LotList[i]).style.display = 'none';
                    if (typeID == 'index') {
                        document.getElementById('top_bar').style.display = '';
                    }
                }
                else {
                    document.getElementById('top_bar').style.display = 'none';
                }
            }
        }
//        outTime = new Date();
    }, timeoutmilsecond);
}


function HideSubMenu() {
    
}


function TimeSpan(time1, time2) {
    return time1.getTime() - time2.getTime();
}
