jQuery(function($){
	var thumbBox = $("div#thumb-section");
	var styleLists = $("ul.change_style li a");
	var classTitle = $("div.title");
	var classThumb = $("div.thumb");
	var classFull = $("div.full");
	$(".slide_line").slider({
		animate:true ,
		max:100,
		min:0,
		value:96,
		range:"min" ,
		change:function(event,ui){
			if(ui.value < 33){
				event.preventDefault();
				changeTitle();
				styleLists.removeClass("current");
				$("ul.change_style li#title a").addClass("current");
			} else if ((ui.value > 33)&&(ui.value < 66)){
				event.preventDefault();
				changeThumb();
				styleLists.removeClass("current");
				$("ul.change_style li#thumb a").addClass("current");
			} else{
				event.preventDefault();
				changeFull();
				styleLists.removeClass("current");
				$("ul.change_style li#full a").addClass("current");
			}
		}
	});
	//标题
	$(".change_style li:eq(0) a").click(function(event){
		styleLists.removeClass("current");
		$(this).addClass("current");
		event.preventDefault();
		changeTitle();
	});
	function changeTitle(){
		if(!(thumbBox.className == "title")){
			thumbBox.fadeOut("fast", function() {
				thumbBox.addClass("title");
				$(this).removeClass("thumb");
				$(this).removeClass("full");
				$(this).fadeIn("fast"); 
				$(this).css("margin-bottom","25px");
				$(".ui-slider-handle").animate({left:"-2px"});
				$(this).find(".works_title").show();
				$(".thumb_box").click(function(){
					var titleLink = $(this).find("a").attr("href");
					location.href = titleLink;
				});
				return false;
				
			});
		}
	}
	//精简
	$(".change_style li:eq(1) a").click(function(event){
		event.preventDefault();
		styleLists.removeClass("current");
		$(this).addClass("current");
		changeThumb();
	});
	function changeThumb(){
		if(!(thumbBox.className == "thumb")){
			thumbBox.fadeOut("fast", function() {
				thumbBox.addClass("thumb");
				$(this).removeClass("title");
				$(this).removeClass("full");
				$(this).fadeIn("fast");
				$(this).css("margin-bottom","25px");
				$(".ui-slider-handle").animate({left:"58px"});
				$(this).find(".works_title").hide();
				//Hover caption
				$(function(){
					var u = navigator.userAgent;
					speed = 120;
					$(".thumb_box").hover(function(){
						if(!(u.indexOf("MSIE") != -1)){
							$(".caption", this).stop().animate({top:'0px' , opacity: '0.7'},{queue:false, duration:speed});
						} else {
							$(".caption", this).stop().animate({top:'0px' , opacity: '0.7'},{queue:false, duration:speed});
						}
					},function() {
						$(".caption", this).stop().animate({top:'0px' , opacity: '0'},{queue:false, duration:speed});
					});
				});
			});
		}
	}
	//全部
	$(".change_style li:eq(2) a").click(function(event){
		event.preventDefault();
		styleLists.removeClass("current");
		$(this).addClass("current");
		changeFull();
	});
	function changeFull(){
		if(!(thumbBox.className == "full")){
			thumbBox.fadeOut("fast", function() {
				thumbBox.addClass("full");
				$(this).removeClass("title");
				$(this).removeClass("thumb");
				$(this).fadeIn("fast");
				$(this).css("margin-bottom","0");
				$(".ui-slider-handle").animate({left:"114px"});
				$(this).find(".works_title").hide();
				$(".top_info").show();
				$(".thumb_box .photo").show();
			});
		}
	}
});
