﻿//newslist
$(function(){
	$(".news_list li:last-child").addClass("noborder");
});

//tab
$(function(){
	$(".itab a:first-child").addClass("active");
	$(".itab a").mouseover(function(){
		$(this).siblings().removeClass("imp");
		$(this).prev().addClass("imp");
		$(this).addClass("active").siblings().removeClass("active");
	});	
});

$(function(){
	$("#timer").dyTimer();
});

//newslist
$(function(){
	$(".ifriend a").each(function(i){
   		$(this).addClass("ifr"+i);
	});
});

$.fn.dyTimer=function(){
	var t=$(this);
	window.setInterval(time,1000);
	function time(){
		var MA=new Date(2011,7,12);//深圳大运会举办日期：2011年8月12日
		var now=new Date();
		var m=MA.getTime()-now.getTime();
		var esec=parseInt(m/1000)%60;
		var emin=parseInt(m/(60*1000))%60;
		var ehour=parseInt(m/(3600*1000))%24;
		var eday=parseInt((MA.getTime()-now.getTime())/(3600*1000*24));
		var url="<a href=\"http://www.sz2011.org/\" target=\"_blank\">"+eday+"天&nbsp;"+ehour+"时&nbsp;"+emin+"分&nbsp;"+esec+"秒"+"</a>";
		t.html(url);
		//t.html(eday+"天&nbsp;&nbsp;"+ehour+"时&nbsp;&nbsp;"+emin+"分&nbsp;&nbsp;"+esec+"秒");
	}
}

$(function(){
var timer = null;
var offset = 4000;
var index = 0;

	$(".big_pic > li").hover(function(){
		clearTimeout(timer);
	},function(){
		timer = window.setTimeout(auto, offset);
	});

	
//大图交替轮换
function slideImage(i){
    $('.big_pic > li').eq(i).siblings().hide();
	$('.big_pic > li').eq(i).fadeIn(600);
	$(".pic_news_title").html($('.big_pic li').eq(i).children("a").attr("title"));
	
}

//改变小图焦点
function rechange(loop){
    $('.small_pic li').removeClass('hot');
    $(".small_pic li").eq(loop).addClass('hot');
}

		
//自动播放函数
function auto(){
    if (index >= $('.big_pic > li').length){
        index = 0;
    }
    rechange(index);
    slideImage(index);
	index++;
    timer = window.setTimeout(auto, offset);
	
}

function initsmallpic(){
	var j;
	for(j=0; j<$('.big_pic > li').length; j++){
		$(".small_pic ul").append("<li class='smallpic"+j+"'>"+(j+1)+"</li>");
	}

}

		
//初始调用
    initsmallpic();
    auto(); 
		
//绑定小图
    $('.small_pic li').each(function(i){
		var c=i;
		$('.smallpic'+c,'.small_pic').live("click", function(){
            if (timer) {clearTimeout(timer);}                
            index=i;
						rechange(index);
            slideImage(index); 
						timer = window.setTimeout(auto, offset); 
            $(this).siblings().removeClass("hot"); 
						$(this).addClass("hot");            
            return false;
    	});
	}); 
});



//主页BAN切换
$(function () {
	$("#change_3 .a_bigImg img").soChange({
		thumbObj:'#change_3 .ul_change_a2 span',
		thumbNowClass:'on',//自定义导航对象当前class为on
		changeTime:4000//自定义切换时间为4000ms
	});
})

