// JavaScript Document

// slide  鼠标经过滑动
$(document).ready(function(){
	
	//workitem sliding
	$("ul.workitem > li").hover(function(){
		$(".cover",this).stop().animate({top:'0',left:'-250px'},{queue:false,duration:400});
	},function(){
		$(".cover",this).stop().animate({top:'0px',left:'0px'},{queue:false,duration:400});
		});
		
	//index text sliding
	$('.box1,.box3,.box4').hover(function(){
		$(".indeximg_text",this).stop().animate({bottom:'0px',right:'0'},{queue:false,duration:200});
	},function(){
		$(".indeximg_text",this).stop().animate({bottom:'-40px',right:'0px'},{queue:false,duration:200});
		});
		
	//nav sliding            
	$('ul.nav>li').hover(function(){
		$(".en",this).stop().animate({top:'-24px',left:'0'},{queue:false,duration:300});
	},function(){
		$(".en",this).stop().animate({top:'0px',left:'0px'},{queue:false,duration:300});
		 
		});	
			
	$('ul.nav>li').hover(function(){ 	 
		$(".cn",this).stop().animate({bottom:'0',left:'0'},{queue:false,duration:300});
	},function(){
		$(".cn",this).stop().animate({bottom:'-24px',left:'0px'},{queue:false,duration:300});
		});	
		
		//图片缓慢滚动
	$('.box4').hover(function(){
	 var  imgs= $(".box4 img").attr("height");
	 
		$("img",this).stop().animate({top:-imgs+205,left:'0'},{queue:false,duration:4200});
	},function(){
		$("img",this).stop().animate({top:'0px',left:'0px'},{queue:false,duration:400});
		});

	
});



//滚动插件
(function($){
$.fn.extend({
        Scroll:function(opt,callback){
                //参数初始化
                if(!opt) var opt={};
                var _this=this.eq(0).find("ul:first");
                var        lineH=_this.find("li:first").height(), //获取行高
                        line=opt.line?parseInt(opt.line,10):parseInt(this.height()/lineH,10), //每次滚动的行数，默认为一屏，即父容器高度
                        speed=opt.speed?parseInt(opt.speed,10):500, //卷动速度，数值越大，速度越慢（毫秒）
                        timer=opt.timer?parseInt(opt.timer,10):5000; //滚动的时间间隔（毫秒）
                if(line==0) line=1;
                var upHeight=0-line*lineH;
                //滚动函数
                scrollUp=function(){
                        _this.animate({
                                marginTop:upHeight
                        },speed,function(){
                                for(i=1;i<=line;i++){
                                        _this.find("li:first").appendTo(_this);
                                }
                                _this.css({marginTop:0});
                        });
                }
                //鼠标事件绑定
                _this.hover(function(){
                        clearInterval(timerID);
                },function(){
                        timerID=setInterval("scrollUp()",timer);
                }).mouseout();
        }       
})
})(jQuery);

$(document).ready(function(){
        $("#scrollDiv").Scroll({line:1,speed:500,timer:4000});
});


//显示更多作品
$(function(){
	var $category = $('ul.workitem li:gt(7)');
	$category.hide();
	
	var $toggleBtn=$('div.showmore');
	
	$toggleBtn.click(function(){ 
		$category.show("slow");
		$('div.showmore')
		.remove();
		})
	

})



//图片播放 大图
$(document).ready(function() {		 
	//Execute the slideShow, set 4 seconds for each images
	slideShow(4000);

}); 
function slideShow(speed) { 
	//append a LI item to the UL list for displaying caption
	$('ul.slideshow').append('<li id="slideshow-caption" class="caption"><div class="slideshow-caption-container"><h3></h3><p></p></div></li>');

	//Set the opacity of all images to 0
	$('ul.slideshow li').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('ul.slideshow li:first').css({opacity: 1.0}).addClass('show');
	
	//Get the caption of the first image from REL attribute and display it
	$('#slideshow-caption h3').html($('ul.slideshow li.show').find('img').attr('title'));
	$('#slideshow-caption p').html($('ul.slideshow li.show').find('img').attr('alt'));
		
	//Display the caption
	$('#slideshow-caption').css({opacity: 0.7, bottom:0});
	
	//Call the gallery function to run the slideshow	
	var timer = setInterval('gallery()',speed);
	
	//pause the slideshow on mouse over
	$('ul.slideshow').hover(
		function () {
			clearInterval(timer);	
		}, 	
		function () {
			timer = setInterval('gallery()',speed);			
		}); 
}

function gallery() {
 
	//if no IMGs have the show class, grab the first image
	var current = ($('ul.slideshow li.show')?  $('ul.slideshow li.show') : $('#ul.slideshow li:first'));
	
	//trying to avoid speed issue
	if(current.queue('fx').length == 0) {	
	
		//Get next image, if it reached the end of the slideshow, rotate it back to the first image
		var next = ((current.next().length) ? ((current.next().attr('id') == 'slideshow-caption')? $('ul.slideshow li:first') :current.next()) : $('ul.slideshow li:first'));
			
		//Get next image caption
		var title = next.find('img').attr('title');	
		var desc = next.find('img').attr('alt');	
	
		//Set the fade in effect for the next image, show class has higher z-index
		next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 1000);
		
		//Hide the caption first, and then set and display the caption
		$('#slideshow-caption').slideToggle(300, function () { 
			$('#slideshow-caption h3').html(title); 
			$('#slideshow-caption p').html(desc); 
			$('#slideshow-caption').slideToggle(500); 
		});		 
		//Hide the current image
		current.animate({opacity: 0.0}, 1000).removeClass('show');
	} 
}


//return to top
$(document).ready(function(){
$("#return_top").hide(); 

$(function(){
$(window).scroll(function(){
if ($(window).scrollTop()>100){
	$("#return_top").fadeIn(500);
	}
else{
$("#return_top").fadeOut(1500);
	}

	});
$("#return_top").click(function(){
$("body,html").animate({scrollTop:0},1000);
return false;
	});	
});
});

/* lightbox  */ 
  $(document).ready(function($){
   
    $(".lightbox").click(function() {
		$.lightbox( $(this).attr("value").split(",") );
    });

  });


//nav 导航指向栏目ID
$(document).ready(function($){
	
//index
	$body=(window.opera)?(document.compatMode=="CSS1Compat"?$('html'):$('body')):$('html,body');
	$('#nav_index').click(function(){
		$body.animate({scrollTop:($('#indexs').offset().top-100)},500);
		return false; 
		});	
		
//works		
	$body=(window.opera)?(document.compatMode=="CSS1Compat"?$('html'):$('body')):$('html,body');
	$('#nav_works').click(function(){
		$body.animate({scrollTop:($('#works').offset().top-100)},500);
		return false; 
		});
		
//service	
	$body=(window.opera)?(document.compatMode=="CSS1Compat"?$('html'):$('body')):$('html,body');
	$('#nav_service').click(function(){
		$body.animate({scrollTop:($('#service').offset().top-100)},500);
		return false; 
		});
		
//about	
	$body=(window.opera)?(document.compatMode=="CSS1Compat"?$('html'):$('body')):$('html,body');
	$('#nav_about').click(function(){
		$body.animate({scrollTop:($('#about').offset().top-100)},500);
		return false; 
		});		
//contact	
	$body=(window.opera)?(document.compatMode=="CSS1Compat"?$('html'):$('body')):$('html,body');
	$('#nav_contact').click(function(){
		$body.animate({scrollTop:($('#contact').offset().top-100)},500);
		return false; 
		});
		
 
})
 
 
//弹出knowedge
$(function(){
	$(".know li a").click(function () {
	    var key = $(this).attr("key");
		$(".bgpop[key='"+ key +"']").toggle(300);
	}); 
	
	$(".knowclose").click(function(){
	    $(this).parents("div.bgpop").toggle(300);
	});
});


//searvice 鼠标经过
$(function(){
	
$(".service_1 span").hover(function(){
	$(".service_1a").fadeToggle("fast","linear");
	});
 
$(".service_2 span").hover(function(){
	$(".service_2a").fadeToggle("fast","linear");
	});
  
$(".service_3 span").hover(function(){
	$(".service_3a").fadeToggle("fast","linear");
	});
  
$(".service_4 span").hover(function(){
	$(".service_4a").fadeToggle("fast","linear");
	});
  
$(".service_5 span").hover(function(){
	$(".service_5a").fadeToggle("fast","linear");
	});
  
$(".service_6 span").hover(function(){
	$(".service_6a").fadeToggle("fast","linear");
	});
  
$(".service_7 span").hover(function(){
	$(".service_7a").fadeToggle("fast","linear");
	});
 
 
 
});













