﻿var i = 0;
setInterval("ChangeImg()", 3000);
function ChangeImg() {
    var old = "";
    $(".highlight_tip span").each(function() {//图片自动变换
        //判断以前状态
        //old = $(this).find("a").html(); //以前的光标索引位置
        Valueindex = $(this).attr("valuetext");
        if (Valueindex == 1) {//如果在点击处的地方
            i = i + 1; ;
            if (i != 4) {
                $(this).parents("div.v_show").find("div.v_content_list").animate({ left: '+=-501px' }, "nomal");
                //                        alert($(this).parents("div.v_show").find(".v_content_list ul li").html());
            }
            else {
                $(this).parents("div.v_show").find("div.v_content_list").animate({ left: '+=1503px' }, "nomal");
                i = 0; //初始化
            }
        }
        //$(this).attr("valuetext", "1").siblings().attr("valuetext", "0")//变化里面的属性;
        //$(this).addClass("current").siblings().removeClass("current"); //点击上去的效果
    });
    //图标自动变换
    switch (i) {
        case 1: $(".list_title").html("标题2");
            break;
        case 2: $(".list_title").html("标题3");
            break;
        case 3: $(".list_title").html("标题4");
            break;
        case 0: $(".list_title").html("标题1");
            break;
    }
}
$(function() {
    $(".list_title").html("标题1"); //初始化标题
    $(".highlight_tip span").mouseover(function() {
        $(this).addClass("current"); //点击上去的效果
    });
    $(".highlight_tip span").mouseout(function() {
        if ($(this).attr("flact") != 1) {
            $(this).removeClass("current"); //点击上去的效果
        }
    });
    var old = ""; //以前位置
    var Valueindex = "";
    var num = ""; //两个差
    $(".highlight_tip span").each(function() {//找出点击的地方
        //判断以前状态
        Valueindex = $(this).attr("valuetext");
        if (Valueindex == 1) {//如果在点击处的地方
            old = $(this).find("a").html(); //以前的光标索引位置
        }
        $(this).click(function() {
            $(this).attr("flact", "1").siblings().attr("flact", "0");
            //点击以后再判断一次
            $(".highlight_tip span").each(function() {
                //判断以前在哪个地方
                Valueindex = $(this).attr("valuetext");
                if (Valueindex == 1) {//如果在点击处的地方
                    old = $(this).find("a").html(); //以前的光标索引位置
                }
            });
            $(this).attr("valuetext", "1").siblings().attr("valuetext", "0")//变化里面的属性;
            $(this).addClass("current").siblings().removeClass("current"); //点击上去的效果
            var index = $(this).find("a").html(); //现在位置
            num = old - index;
            var size = 504 * num;
            $(this).parents("div.v_show").find("div.v_content_list").animate({ left: '+=' + size + 'px' }, "fast");
        });
    });
})
