﻿
function setTab(name,cursel,n){
 for(i=1;i<=n;i++){
  var menu=document.getElementById(name+i);
  var con=document.getElementById("jsweb_"+name+"_"+i);
  menu.className=i==cursel?"hover":"";
  con.style.display=i==cursel?"block":"none";
}
//for (i = 1; i <= n; i++) {
//    $("#jsweb_" + name + "_" + i).hide();
//    $("#" + name + i + "").attr("class", "");
//}
//    $("#jsweb_" + name + "_" + cursel).show();
//    $("#" + name + cursel + "").attr("class", "hover");
}



$(document).ready(function () {
    var dl = document.getElementsByTagName("dl");
    if (dl.length < 1) return false;
    for (var i = 0; i < dl.length; i++) {
        //初始化，让第一个类为over
        if (dl[i].className.indexOf("over") == -1) {
            dl[0].className = "over";
        }
        //遍历循环，模拟:hover伪类
        dl[i].onmouseover = function () {
            for (var j = 0; j < dl.length; j++) {
                dl[j].className = "";
            }
            this.className = "over";
        }
    }
}
);

var Index = {
    YearPirvClick: function () {
        var stryear = $("#div_year").text();
        var strmonth = $("#div_month").text();
        this.YearClick(parseInt(stryear) - 1, strmonth);
    }, YearNextClick: function () {
        var stryear = $("#div_year").text();
        var strmonth = $("#div_month").text();
        this.YearClick(parseInt(stryear) + 1, strmonth);
    }, YearClick: function (year, month) {
        $("expo_content_div").load("/aspx/expo.aspx?year=" + year + "&month=" + month);
        $("#div_year").text(year);
        $("#div_month").text(month);

        //        $.ajax({
        //            type: "POST",
        //            url: "/aspx/ajax.aspx",
        //            data: "type=getexpolist&year=" + year + "&month=" + month,
        //            success: function (data) {
        //                if (data == "0") {
        //                    alert("加载数据失败,请稍候再试!");
        //                    return;
        //                } else if (data == "1") {
        //                    alert("对不起，您所选择的时间段中无信息！");
        //                    return;
        //                }
        //                $("#div_year").text(year);
        //                $("#div_month").text(month);
        //                $("#expo_content_div").html(data);
        //            }
        //        });
    }, MonthPirvClick: function () {
        var stryear = $("#div_year").text();
        var strmonth = $("#div_month").text();
        this.YearClick(stryear, parseInt(strmonth) - 1);
    }, MonthNextClick: function () {
        var stryear = $("#div_year").text();
        var strmonth = $("#div_month").text();
        this.YearClick(stryear, parseInt(strmonth) + 1);
    }
}
function MarketSearch() {
    var keyword = $("#key_market").val();
    if ($.trim(keyword) == "") { alert("请输入关键字。"); return false; }
    var url = "http://so.puworld.com/results_comments_" + keyword + "_title_1.html";
    window.open(url);
}

function NewsSearch() {
    var keyword = $("#key_news").val();
    if ($.trim(keyword) == "") { alert("请输入关键字。"); return false; }
    var url = "http://so.puworld.com/results_news_" + keyword + "_title_1.html";
    window.open(url);
}

function B2BSearch() {
    var keyword = $("#key_b2b").val();
    var types = $("#type_b2b").val();
    var url = "http://b2b.puworld.com/";
    if ($.trim(keyword) == "") { alert("请输入关键字。"); return false; }
    if (types != "30") {
        url += "search.aspx?parent=0&industryid=20000&city=0&keyword=" + escape(keyword) + "&type=" + types + "&comtype=0&date=0";
    }
    else {
        url += "shoplist.aspx?parent=0&city=0&keyword=" + escape(keyword) + "&comtype=0&date=0";
    }
    window.open(url);
}

function ExpoSearch() {
    var keyword = $("#key_expo").val();
    if ($.trim(keyword) == "") { alert("请输入关键字。"); return false; }
    var url = "http://so.puworld.com/results_expo_" + keyword + "_title_1.html";
    window.open(url);
}

function JobSearch() {
    var keyword = $("#key_job").val();
    var types = $("#type_job").val();
    var url = "http://job2010.puworld.com/";
    if ($.trim(keyword) == "") { alert("请输入关键字。"); return false; }
    if (types == "0") {
        url += "job/search.aspx?kind=1&keyword=" + escape(keyword);
    }
    else {
        url += "talent/search.aspx?keyword=" + escape(keyword);
    }
    window.open(url);
}
function SetHome(obj) {
    try {
        obj.style.behavior = 'url(#default#homepage)';
        obj.setHomePage(document.URL);
    } catch (e) {
        if (window.netscape) {
            try {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            } catch (e) {
                alert("抱歉，此操作被浏览器拒绝！\n\n请在浏览器地址栏输入“about:config”并回车然后将[signed.applets.codebase_principal_support]设置为'true'");
            };
        } else {
            alert("抱歉，您所使用的浏览器无法完成此操作。\n\n您需要手动将" + document.URL + "设置为首页。");
        };
    };
}

//  添加收藏夹
function myAddPanel(title, url, desc) {
    if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function'))//Gecko 
        window.sidebar.addPanel(title, url, desc);
    else//IE 
        window.external.AddFavorite(url, title);
}
function showTalent(index) {
    $(".zpq_gg2").find("dt").each(function () { $(this).hide(); })
    $(".zpq_gg2").find("dd").each(function () { $(this).hide(); })

    $("#dt_" + index).show();
    $("#dd_" + index).show();
    $("#dt_" + index).css({ float: "right", "margin-top": "-25px" });
}
function YearChange(types) {
    var year = parseInt($("#div_year").text());
    var month = parseInt($("#div_month").text());
    year = types == "1" ? year + 1 : year - 1;
    LoadHtml(year, month);
}

function MonthChange(types) {
    var year = parseInt($("#div_year").text());
    var month = parseInt($("#div_month").text());
    month = types == "1" ? month + 1 : month - 1;
    if (month > 12) {
        year = year + 1;
        month = 1;
    }
    if (month < 1) {
        year = year - 1;
        month = 12;
    }
    LoadHtml(year, month);
}

function LoadHtml(year, month) {
    $("#expo_content_div").load("/aspx/expo.aspx?year=" + year + "&month=" + month);
    $("#div_year").text(year);
    $("#div_month").text(month);
}
function ChangeTheme(obj) {
    $(".shangjilm").find("li").each(function () { $(this).css("background-color", ""); });
    $(obj).css("background-color", "#FFF9E6");
}
function SetExpoCalendar(obj) {
    var expo_date = $(obj).val();
    if ($.trim(expo_date) != "") {
        var arydate = expo_date.split("-");
        var url = "http://exhibition.puworld.com/searchexhibitionlist-" + arydate[0] + "-" + arydate[1] + "-0.html";
        window.open(url);
    }
}
