$(document).ready(function(){
		
		if(navigator.userAgent.search(/msie/i)!= -1) { 
		} else { 
		// Non-IE Code 
			$('ul#filter a').click(function() {
			$(this).css('outline','none');
			$('ul#filter .current').removeClass('current');
			$(this).parent().addClass('current');

			var filterVal = $(this).text();

			if(filterVal == 'All') {
			$('#portfolio .projectThumbnail.hidden').stop().animate({"opacity": "1"}, 1000).removeClass('hidden');
			} else {
			$('#portfolio .projectThumbnail').each(function() {
				if(!$(this).hasClass(filterVal)) {
					$(this).stop().animate({"opacity": "0.1"}, 1000).addClass('hidden');
				} else {
					$(this).stop().animate({"opacity": "1"}, 1000).removeClass('hidden');
				}
			});
			}
			return false;
			});
		}
	
		$('#site-generator').before('</span><div id="backtotop"><span id="beam"></span><span id="totop">从头再来!</span></div>'); 
		
		$('.projectThumbnail a.nojquery').removeClass('nojquery');
		$('.projectThumbnail img').mouseover(function () {
			$(this).stop().animate({"opacity": "0"}, 700);
		});
		$('.projectThumbnail img').mouseout(function () {
			$(this).stop().animate({"opacity": "1"}, 700);
		});
		
		if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
			$('.projectThumbnail img').bind('touchstart', function(){
				$(this).stop().animate({"opacity": "0"}, 700);
			});
			$('.projectThumbnail img').bind('touchend', function(){
				$(this).stop().animate({"opacity": "1"}, 700);
			});	
		}
		
		$('#backtotop').click(function() {
			$('body,html').animate({scrollTop:0},1000);
		});
		
		$("#menu-service").click(function() {
			$('html,body').animate({scrollTop: $("#cm-services").offset().top}, 1000);
		});

		var fadeDuration = 150; //time in milliseconds
				
		$('.more').hover(function() {
			$(this).animate({ paddingRight: '10px' }, fadeDuration);
		  }, function() {
			$(this).animate({ paddingRight: '0px' }, fadeDuration);
		});
	
		if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
			$('.more').bind('touchstart', function(){
				$(this).animate({ paddingRight: '10px' }, fadeDuration);
			});
			$('.more').bind('touchend', function(){
				$(this).animate({ paddingRight: '0px' }, fadeDuration);
			});	
		}
		
		$('.sendbutton').hover(function() {
			$(this).animate({ marginRight: '15px' }, fadeDuration);
		  }, function() {
			$(this).animate({ marginRight: '0px' }, fadeDuration);
		});
		
		if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
			$('.sendbutton').bind('touchstart', function(){
				$(this).animate({ marginRight: '15px' }, fadeDuration);
			});
			$('.sendbutton').bind('touchend', function(){
				$(this).animate({ marginRight: '0px' }, fadeDuration);
			});	
		}
		
		$('.nav-previous').hover(function() {
			$(this).animate({ paddingLeft: '5px'}, fadeDuration);
		  }, function() {
			$(this).animate({ paddingLeft: '0px'}, fadeDuration);    
		});
		
		if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
			$('.nav-previous').bind('touchstart', function(){
				$(this).animate({ paddingLeft: '5px'}, fadeDuration);
			});
			$('.nav-previous').bind('touchend', function(){
				$(this).animate({ paddingLeft: '0px'}, fadeDuration);    
			});	
		}
		
		$('.nav-next').hover(function() {
			$(this).animate({ paddingRight: '10px' }, fadeDuration);
		  }, function() {
			$(this).animate({ paddingRight: '0px' }, fadeDuration);
		});


		

		if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
			$('.nav-next').bind('touchstart', function(){
				$(this).animate({ paddingRight: '10px' }, fadeDuration);
			});
			$('.nav-next').bind('touchend', function(){
				$(this).animate({ paddingRight: '0px' }, fadeDuration);   
			});	
		}
		
		$(function() {
		$("a[href*='http://']:not([href*='"+location.hostname.replace
           ("www.","")+"'])").each(function() {
				$(this).click(function(event) {
				event.preventDefault();
				event.stopPropagation();
				window.open(this.href, '_blank');
				}).addClass('externalLink');
			});
		});

		//菜单鼠标事件
		$("#access img").mouseover(function() {
			var imgsrc = this.src.split("/");
			var imgname = imgsrc[imgsrc.length-1].split(".");
			this.src = "./images/" + imgname[0]+"_on."+imgname[1];
		});
		$("#access img").mouseout(function() {
			var imgsrc = this.src.split("/");
			var imgname = imgsrc[imgsrc.length-1].split(".");
			var img = imgname[0].split("_");
			this.src = "./images/" + img[0]+"."+imgname[1];
		});

});
	
