﻿var t2 = n2 = count2 = 0;
var curPos = 0;
$(function(){
	initPic2();
	
	count2 = $("#piccontainer li").size();
	$("#switch_l .litem").each(function(i,n2){
	    $(this).data('index',i).children().each(function(){
	        $(this).data('index',i).children().data('index',i);
	    });
	    $(this).mouseover(function(event){
	        if($(event.target).data('index') != curPos){
	            n2 = i;
		        if (n2 >= count2) return;
		        $(this).addClass('litem_on').siblings().removeClass('litem_on');
		        $('#piccontainer li').filter(":visible").fadeOut(500).parent().children().eq(i).fadeIn(1000);
		        $(this).addClass('on').siblings().removeClass('on');
		        curPos = i;
		        $('#test').html($('#test').html()+'over|');
	        };	        
	    });
	});
	t2 = setInterval("showAuto2()", 3000);
	$("#switch").hover(function(){clearInterval(t2)}, function(){t2 = setInterval("showAuto2()", 3000);});
})

function showAuto2(){
	n2 = n2 >= (count2 - 1) ? 0 : n2 + 1;
	$("#switch_l .litem").eq(n2).trigger('mouseover');
}

function initPic2(){
    var imgs = $('#tmpPics').text();
    var links = $('#tmpPicLinks').text();
    var imghtml = '';
    var indexhtml = '';
    if(imgs != ''){
        var imgArry = imgs.split('|');
        var linkArry = links.split('|');
        $.each(imgArry,function(i,n2){
            imghtml += '<li><a href="' + linkArry[i] + '" target="_blank"><img src="' + n2 + '" alt="" /></a></li>';
        });
    };
    $('#piccontainer').html(imghtml);
};
