// JavaScript Document
$(function(){
  
	var fh=$("#featuresContainer li").height()+21;
	$("#featuresContainer").css("overflow","hidden").toggleHeight(fh*3,fh*11,"查看更多功能介绍","隐藏更多功能介绍","#viewMore");
	$viewMore=$("<a href='#features' id='viewMore' style='float:right;margin-top:10px;'>查看更多功能介绍</a>").click(function(){$("#featuresContainer").toggleHeight(fh*3,fh*11,"查看更多功能介绍","隐藏更多功能介绍","#viewMore");$(this).blur();return false;});
	$("#featuresContainer").after($viewMore);
	$("#featuresContainer li:even").addClass("even");
	
	$("#awardsContainer").css("overflow","hidden").toggleHeight(88,687,"查看更多奖项","隐藏更多奖项","#viewAwards");
	$viewAwards=$("<a href='#awards' id='viewAwards' style='float:right;margin-top:10px;'>查看更多奖项</a>").click(function(){$("#awardsContainer").toggleHeight(88,687,"查看更多奖项","隐藏更多奖项","#viewAwards");$(this).blur();return false;});
	$("#awardsContainer").after($viewAwards);
	
	
	$(".tabs a").isTab();

});

jQuery.fn.extend({

	toggleHeight:function(hMin,hMax,ts,th,btn){
		$btn=$(btn);
		if($(this).height()>hMin){
			$(this).animate({height:hMin},function(){$btn.text(ts)});
		}else{
			$(this).animate({height:hMax},function(){$btn.text(th)});
		}
		return $(this);
	}
	,isTab:function(s,c){
		s?s=s:s=0;
		c?c=c:c="current";
		var vc=c+Math.round(Math.random()*100000);
		$(this).each(function(i){
							  if(i==s){
								  $(this).addClass(c);
								  $("#"+$(this).attr("href").split("#")[1]).addClass(vc);
							  }else{
								  $("#"+$(this).attr("href").split("#")[1]).hide();
							  }
							  }).click(function(){
								  	$("."+vc).hide().removeClass(vc);
									$(this).blur().addClass(c).parent().parent().find("."+c).not($(this)).removeClass(c);
									$("#"+$(this).attr("href").split("#")[1]).show().addClass(vc);
									return false;
								  });
		return $(this);
	}

});
