var $showindex = -1;
$(function(){
    //    $(".tabs").synload({
    //        btnclick:function(a){
    //            hislist = a.data;
    //            listtable = $(".newslist");
    //            listbody = listtable.find("li:gt(0)");
    //            listbody.remove();
    //            //遍历数据进行加载
    //            trsd = "";
    //            for(var i in hislist){
    //
    //                trsd += "<li style='list-style-type: disc; margin-left: 20px; line-height: 22px;'><a class='newsa' href='/Index/newstext/id/"+hislist[i].id+"'>"+hislist[i].title.substr(0, 20) +"</a></li>";
    //            }
    //
    //
    //            $(trsd).appendTo(listtable);
    //            $(".tabs").each(function(){
    //                $img = $(this).find("img");
    //                if($img.attr("tab") == $img.attr("src"))
    //                    $img.attr("src",$img.attr("tab1"));
    //                else
    //                    $img.attr("src",$img.attr("tab"));
    //            });
    //            return false;
    //        }
    //    });

    $('.tabs').on('click',function(){
       // $index = $('.tabs').index(this);

        $('.newslist').toggle();
        $(".tabs").each(function(){
            $img = $(this).find("img");
            if($img.attr("tab") == $img.attr("src"))
                $img.attr("src",$img.attr("tab1"));
            else
                $img.attr("src",$img.attr("tab"));
        });

        return false;
    });
    
    //预加载首页大图
    imgld = new Array();
    
    //    imgld[1] = new Image();
    //    imgld[1].src = "/image/ipic/2.jpg";
    //    imgld[2] = new Image();
    //    imgld[2].src = "/image/ipic/3.jpg";
    //    imgld[3] = new Image();
    //    imgld[3].src = "/image/ipic/4.jpg";


    $(".playsimg").each(function(i){
        imgld[i] = new Image();
        imgld[i].src = "/image/ipic/"+this.value;
        imgld[i].id = this.id;
        imgld[i].types = $(this).attr('typeid');
        imgld[i].titles = $(this).attr('ntitle');
    });
 

    //执行首页大图切换
    imgshow();
    $imglist = $("#listarray img");
    $showpanle = $("#showimg img");
    $imglist.mouseover(function(){
        $index = $imglist.index(this);
        $showpanle.hide();
        $imglist.eq($showindex).css("border","none");
        $showpanle.attr("src",imgld[$index].src);
        $showpanle.attr("alt",imgld[$index].titles);
        $(this).css("border","1px solid #f0f0f0");
        $showindex = $index;
        $showpanle.show(); 
        //切换首页大图链接
        if(imgld[$showindex].types == 0)
            $("#showimg a").attr("href","/Index/newstext/id/"+imgld[$showindex].id);
        else
            $("#showimg a").attr("href","/Index/casetext/id/"+imgld[$showindex].id);
    });
  
    
    
    
    $("#sform").submit(function(){
        if($.trim($("#numpanle").val()) == ""){
            alert("请输入想要验证的授权码");   
            return false;
        }
        if($.trim($("#numpanle").val()).length < 15 || $.trim($("#numpanle").val()).length > 20){
            alert("请输入正确的授权码");   
            return false;
        }
        
    });
    
});


function imgshow(){
    $imglist = $("#listarray img");
    $showpanle = $("#showimg img");
    //当前正显示的大图
    $showpanle.hide();
    $imglist.eq($showindex).css("border","none");
    $showindex++;
    if($showindex<$imglist.length)
        $showpanle.attr("src",imgld[$showindex].src);
    else{
        $showpanle.attr("src",imgld[0].src);
        $showindex = 0;
    }
    $imglist.eq($showindex).css("border","1px solid #f0f0f0");
    $showpanle.show();
    //切换首页大图链接
    $("#showimg a").attr("href","/Index/newstext/id/"+imgld[$showindex].id);

    setTimeout(imgshow,10000);
}


