/* 
 *http://thinkerpan.cn/
 *Copyright (c) 2010 thinkerpan v1.0
 *Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009)
 *Revision: 1.0
*/

jQuery(document).ready(function(){	
	
	//当前栏目添加current
	var thisID =$(".thisID").text(); 
	if(thisID==18){
	   $("#nav ul li").eq(5).children("a").addClass("current");
	}else if(thisID==5){
	   $("#nav ul li").eq(6).children("a").addClass("current");
	}else if(thisID==200){
	   $("#nav ul li").eq(7).children("a").addClass("current");
	}else if(thisID==6){
	}else if(thisID==""){ 
	}else{
		$("#nav ul li").eq(thisID).children("a").addClass("current");
	}
	
	//导航动画
	
	$("#nav li a").each(function(){
		if($(this).hasClass("current"))
		$(this).children("span.nav_zh").stop().css('backgroundPositionY','-102px');
	}).hover(function(){
		if(!$(this).hasClass("current")){
			//alert($(this).children("span.nav_zh").html());
			$(this).children("span.nav_zh").stop().animate({backgroundPositionY:'-112'},300);
			$(this).children("span.nav_zh").stop().animate({backgroundPositionY:'-102'},200);			
			$(this).children("span.nav_en").stop().animate({backgroundPositionY:'-56'},400);
		}
	},function(){
		if(!$(this).hasClass("current")){
			$(this).children("span.nav_zh").stop().animate({backgroundPositionY:'0'},300);
			$(this).children("span.nav_en").stop().animate({backgroundPositionY:'10'},300);
			$(this).children("span.nav_en").stop().animate({backgroundPositionY:'0'},200);
		}
	});
	

	//导航动画
	/*
	$("#nav li a").each(function(){
		//if($(this).hasClass("current"))
		//$(this).children("span.nav_zh").stop().css('backgroundPositionY','-102px');
	}).hover(function(){
		//if(!$(this).hasClass("current")){
			$(this).children("span.nav_zh").stop().animate({backgroundPosition:'left -112'},300);
			$(this).children("span.nav_zh").stop().animate({backgroundPosition:'left -102'},200);			
			$(this).children("span.nav_en").stop().animate({backgroundPosition:'left -56'},400);
		//}
	},function(){
		//if(!$(this).hasClass("current")){
			$(this).children("span.nav_zh").stop().animate({backgroundPosition:'0 0'},300);
			$(this).children("span.nav_en").stop().animate({backgroundPosition:'0 10'},300);
			$(this).children("span.nav_en").stop().animate({backgroundPosition:'0 0'},200);
		//}
	});
	 */

	//返回上部图标随滚动条动态滚动
    $('#go_top').scrollFollow({speed:900,offset:340});

	//链接动态效果
	$('.hover a').hover(function(){
	    $(this).animate({marginLeft:6},200);
	},function(){
	    $(this).animate({marginLeft:0},200);
	});

	//首页客户留言滚动
	$(function(){
		//多行应用@Mr.Think
		var _wrap=$('ul.mulitline');//定义滚动区域
		var _interval=3000;//定义滚动间隙时间
		var _moving;//需要清除的动画
		_wrap.hover(function(){
			clearInterval(_moving);//当鼠标在滚动区域中时,停止滚动
		},function(){
			_moving=setInterval(function(){
				var _field=_wrap.find('li:first');//此变量不可放置于函数起始处,li:first取值是变化的
				var _h=_field.height();//取得每次滚动高度
				_field.animate({marginTop:-_h+'px'},600,function(){//通过取负margin值,隐藏第一行
					_field.css('marginTop',0).appendTo(_wrap);//隐藏后,将该行的margin值置零,并插入到最后,实现无缝滚动
				})
			},_interval)//滚动间隔时间取决于_interval
		}).trigger('mouseleave');//函数载入时,模拟执行mouseleave,即自动滚动
	});


});

//动态返回顶部
jQuery(document).ready(function() {
	$("a.anchorLink").anchorAnimate()});
	
	jQuery.fn.anchorAnimate = function(settings) {
	
		settings = jQuery.extend({
			speed : 900
		}, settings);	
		
		return this.each(function(){
			var caller = this
			$(caller).click(function (event) {	
				event.preventDefault()
				var locationHref = window.location.href
				var elementClick = $(caller).attr("href")
				
				var destination = $(elementClick).offset().top;
				$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
					window.location.hash = elementClick
				});
				return false;
			})
		});
}
