// JavaScript Document
/*
# Copyright © 2007 起凡数字.All rights reserved
# Author: vanshion 
*/
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-19456278-6']);
_gaq.push(['_setDomainName', '.5211game.com']);
_gaq.push(['_addOrganic', 'baidu', 'word']);
_gaq.push(['_addOrganic', 'sogou', 'query']);
_gaq.push(['_addOrganic', 'soso', 'w']);
_gaq.push(['_addOrganic', 'yodao', 'q']);
_gaq.push(['_setAllowHash', false]);
_gaq.push(['_trackPageLoadTime']);
_gaq.push(['_trackPageview']);

(function () {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();


$(document).ready(function() {
	/*滑动门模块*/
	$("[class*='tab_con_']").each(function(i){
		$("ul#tab_nav_"+i+" li:first").addClass("active").show();
		if($(this).is(':visible')){ 
			$(".tab_con_"+i+":first").show();									   
			$(this).next().hide();
			}
		else{
			$(this).next().hide();}
		$("ul#tab_nav_"+i+" li").mouseover(function() {
			$("ul#tab_nav_"+i+" li").removeClass("active");
			$(this).addClass("active");
			$(".tab_con_"+i).hide();
			var activeTab = $(this).find("a").attr("href"); 
			$(activeTab).show();
			return false;
		});
	 });
     
	 /*下拉菜单*/
	 $("[class*='select']").each(function(j){			
			$(".select"+j+":first").click(function() { 
				if($(this).next(".selectlist").is(':visible')){ 
					$(this).next(".selectlist").hide();
					$(".select"+j+":first").removeClass("active");
				}
				else {
					$(".selectlist").hide();
					$(".select"+j).addClass("active");
					$(this).next("#ss"+j).slideToggle();
				}
				return false;
			});
		$(document).click(function(event){
			$("#ss"+j).hide();
			$(".select"+j+":first").removeClass("active");});
		$("#ss"+j).mouseover(function(event){
			$("#ss"+j).show();});
		$("#ss"+j).mouseout(function(event){
			$("#ss"+j).hide();
			$(".select"+j+":first").removeClass("active");
			});
	});
});


//auto play slide
var currentImage;
var currentIndex = -1;
function showImage(index) {
    if (index < $('#bigPic img').length) {
        var indexImage = $('#bigPic img')[index]
        if (currentImage) {
            if (currentImage != indexImage) {
                $(currentImage).css('z-index', 2);
                clearTimeout(myTimer);
                $(currentImage).fadeOut(200, function() {
                    myTimer = setTimeout("showNext()", 3000);
                    $(this).css({ 'display': 'none', 'z-index': 1 })
                });
            }
        }
        $(indexImage).css({ 'display': 'block', 'opacity': 1 });
        currentImage = indexImage;
        currentIndex = index;
        $('#thumbs li').removeClass('active');
        $($('#thumbs li')[index]).addClass('active');
    }
}

function showNext() {
    var len = $('#bigPic img').length;
    var next = currentIndex < (len - 1) ? currentIndex + 1 : 0;
    showImage(next);
}

/**/  var myTimer;

$(document).ready(function() {
    myTimer = setTimeout("showNext()", 1000);
    showNext(); //loads first image
    $('#thumbs li').bind('click', function(e) {
        var count = $(this).attr('rel');
        showImage(parseInt(count) - 1);
    });
});

/* news slide */
function Rotate(){
	var current = $('#rotator ul li:visible');
	var next = current.next().length ? current.next() : current.parent().children(':first'); 
	current.slideUp(300).hide();
	next.slideDown(300);
	setTimeout(Rotate, 5000);
}
