﻿// JavaScript Document
$(function() {
    /*******************车音网大记事***********************/
    $(".about_ol li:eq(0)").attr("id", "about_li");
    $(".about_ol").children("li").children("h2").mouseover(function() { $(this).parents("li").attr("id", "about_li").siblings().attr("id", ""); });

    /***********************合作招商************************/
    $(".agent3 ul li:first").attr("id", "agent3_li");
    $(".agent3_div table").eq(0).css("display", "block");
    $(".agent3 ul li").click(function() { var yi = $(".agent3 ul li").index(this); $(this).attr("id", "agent3_li").siblings().attr("id", ""); $(".agent3_div table").eq(yi).css("display", "block").siblings().css("display", "none"); });
    /*****************************产品套餐***********************/
    $(".taocan2_div ul li:first").attr("id", "taocan_bao");
    $(".taocan_bao table").eq(0).css("display", "block");
    //$(".taocan2_div ul li:first").click(function(){$(this).attr("id","taocan_bao").siblings().attr("id","");$(".taocan_bao table").css("display","none");$(".taocan_bao table").eq(0).css("display","block");});
    //$(".taocan2_div ul li:last").click(function(){$(this).attr("id","taocan_bao").siblings().attr("id","");$(".taocan_bao table").css("display","none");$(".taocan_bao table").eq(1).css("display","block");});
    $(".taocan_bao_s").hover(function() { $(this).children("div").css("display", "block"); }, function() { $(this).children("div").css("display", "none"); });
    /********************左导航**********************/
    $(".culture ul>li").has('ol').children("a").css("background", "url(images/left_bg.gif) no-repeat 130px center");
    $(".culture ul li").hover(function() { var i = $(".culture ul li").index(this); $(this).children("ol").css("display", "block").end().siblings().children("ol").css("display", "none"); }, function() { $(this).children("ol").removeAttr("style"); });
    /********************找回密码**********************/
    $(".getBackPassWord_tab ul li:first").attr("id", "PassWord_tab_li");
    $(".getBackPassWord_div").css("display", "none");
    $(".getBackPassWord_div1").css("display", "block");
    $(".getBackPassWord_tab ul li:first").click(function() { $(this).attr("id", "PassWord_tab_li").siblings().attr("id", ""); $(".getBackPassWord_div").css("display", "none"); $(".getBackPassWord_div1").css("display", "block"); });
    $(".getBackPassWord_tab ul li:last").click(function() { $(this).attr("id", "PassWord_tab_li").siblings().attr("id", ""); $(".getBackPassWord_div").css("display", "none"); $(".getBackPassWord_div2").css("display", "block"); });
    /********************首页*********************/
    var m = 1; var counto = $(".xwkx li").size();
    $(".xwkx li").eq(0).show();
    function showauto2() { $(".xwkx li").eq(m).css("display", "block").siblings().css("display", "none"); m = (m == (counto - 1) ? 0 : ++m); };
    bt = setInterval(showauto2, 5000);
    $(".xwkx").hover(function() { clearInterval(bt); }, function() { bt = setInterval(showauto2, 8000); });
    /**********************menu*******************************/
    setMenuStyle(); //用来设置导航选中样式
    setShortMenuStyle(); //设置快捷样式

    /************************v-map样式******************************/
    $("#map_click").click(function() { $(this).animate({ left: "890px" }, 300, function() { $(this).css("display", "none"); $("#map_click1").css({ "display": "block", "left": "890px" }); }); $(".map_seach").animate({ width: "0px", left: "902px" }, 300); });
    $("#map_click1").click(function() { $(this).animate({ left: "651px" }, 300, function() { $(this).css("display", "none"); $("#map_click").css({ "display": "block", "left": "651px" }); }); $(".map_seach").animate({ width: "253px", left: "646px" }, 300); });
    /**********************登录后选项卡样式*********************/
    $(".globle_tab_ul li:first").attr("id", "PassWord_tab_li");
    //$(".globle_tab").eq(0).css("display","block");
    $(".globle_tab_ul li").click(function() { var iy = $(".globle_tab_ul li").index(this); $(this).attr("id", "PassWord_tab_li").siblings().attr("id", ""); });
    /*********************通讯录************************/
    //$("._edter").click(function(){$(".user_contact_div1").hide('fast');$(".contact_edter").show('normal');});
    $(".txl_user").click(function() { $(".user_contact_div1").hide('fast'); $(".contact_cen").show('normal'); });
    $(".add_table ul li:first").attr("id", "add_li");
    //$(".user_contact_div20").css("display","block");
    $(".add_table ul li").click(function() { $(this).attr("id", "add_li").siblings().attr("id", ""); var ppi = $(".add_table ul li").index(this); $(".user_contact_div2" + ppi).css("display", "block").siblings().css("display", "none"); });
    $("._edter1").click(function() { $(".user_contact_div3").hide('fast'); $(".zu_gai").show('normal'); });

    /**********************下载专区选项卡样式*********************/
    $(".download_ul ul li:first").attr("id", "download_ul");
    $(".download_ul ul li").click(function() { $(this).attr("id", "download_ul").siblings().attr("id", ""); });

    /*********************首页图片转换*************************/
    $("#play_list ul li").eq(0).attr("id", "current_play");
    var t = i = 0, count = $("#play_list ul li").size() - 1;
    $("#play_list ul li").eq(0).find("img").css({ "border": "2px solid #c0ff00", "top": "-10px" }).end().find("p").css({ "color": "#c0ff00" });
    $("#play_img ul li").eq(0).fadeIn(500);
    function showAuto() { if (i >= count) { i = 0; } else { ++i; }; $("#play_list ul li").eq(i).trigger('click'); };
    t = setInterval(showAuto, 5000);
    $(".play").hover(function() { clearInterval(t); }, function() { t = setInterval(showAuto, 5000); });
    $("#play_list ul li").click(function() { var carvp = $("#play_list ul li").index(this); $(this).attr("id", "current_play").siblings().attr("id", ""); $("#play_list ul li div img").removeAttr("style").stop(true, true).animate({ "top": "8px" }, 200); $("#play_list ul li p").removeAttr("style"); $("#current_play div img").css({ "border": "2px solid #c0ff00" }).stop(true, true).animate({ "top": "-10px" }, 200); $("#current_play p").css({ "color": "#c0ff00" }); $("#play_img ul li").eq(carvp).fadeIn(600).siblings().fadeOut(200); i = carvp; });
    $("#play_list ul li").hover(function() { if ($(this).attr("id") != "current_play") { $(this).find("img").css({ "border": "2px solid #c0ff00" }); $(this).find("p").css({ "color": "#c0ff00" }); }; }, function() { if ($(this).attr("id") != "current_play") { $(this).find("img").removeAttr("style"); $(this).find("p").removeAttr("style"); $(this).find("img").stop(true, true).animate({ "top": "8px" }, 200); }; });
});

function setMenuStyle() {
    var locationUrl = window.location.href; //获取当前位置的地址
    var getString = locationUrl.substring(locationUrl.indexOf("http://") + 7, locationUrl.length); // 将http://  接去掉
    if (getString.indexOf("?") != -1) {
        getString = getString.substring(0, getString.indexOf("?"));  //将 ？ 后面的字符接去掉
    }

    var paraString = getString.split("/"); // 得到拆分数组
    var currentMark = paraString[1];  //当前栏目地址字符串
    //根据当前字符串判断加载样式
    //alert(paraString);
    switch (currentMark) {
        case 'Server':    //车音服务
            $(".header").find(".menu ul li:eq(0)").attr("id", "menu").siblings().attr("id", "");
            break;
        case 'NewProduct': //车音网产品
            $(".header").find(".menu ul li:eq(1)").attr("id", "menu").siblings().attr("id", "");
            break;
        case 'NewHelp':   //帮助中心
            $(".header").find(".menu ul li:eq(2)").attr("id", "menu").siblings().attr("id", "");
            break;
        case 'NewAgent':   //合作招商
            $(".header").find(".menu ul li:eq(3)").attr("id", "menu").siblings().attr("id", "");
            break;
        case 'NewCenter':   //媒体中心
            $(".header").find(".menu ul li:eq(4)").attr("id", "menu").siblings().attr("id", "");
            break;
        case 'About':  //关于我们
            $(".header").find(".menu ul li:eq(5)").attr("id", "menu").siblings().attr("id", "");
            break;
        default:  //默认没选中
            $(".header").find(".menu ul li").attr("id", "");
            break;
    }

}
function setShortMenuStyle() {
    var locationUrl = window.location.href; //获取当前位置的地址
    var getString = locationUrl.substring(locationUrl.indexOf("http://") + 7, locationUrl.length); // 将http://  接去掉
    if (getString.indexOf("?") != -1) {
        getString = getString.substring(0, getString.indexOf("?"));  //将 ？ 后面的字符接去掉
    }

    var paraString = getString.split("/"); // 得到拆分数组
    var currentMark = paraString[1];  //当前栏目地址字符串
    //根据当前字符串判断加载样式
    //alert(paraString);
    switch (currentMark) {
        case '': //首页
            $(".header").find(".top div a:eq(0)").attr("id", "shortmenu").siblings().attr("id", "");
            break;
        case 'UserReg':    //用户登录
            $(".header").find(".top div a:eq(1)").attr("id", "shortmenu").siblings().attr("id", "");
            break;
        case 'User':    //用户中心
            $(".header").find(".top div a:eq(1)").attr("id", "shortmenu").siblings().attr("id", "");
            break;
        case 'Connect': //联系我们
            $(".header").find(".top div a:eq(2)").attr("id", "shortmenu").siblings().attr("id", "");
            break;
        default:
            break;
    }
}


