//我已把原本框架的类selected换成了current，另外，把变量dep调取idTabs官网的jquery去掉了。
(function(){var dep;var init=function(){(function($){$.fn.idTabs=function(){var s={};for(var i=0;i<arguments.length;++i){var a=arguments[i];switch(a.constructor){case Object:$.extend(s,a);break;case Boolean:s.change=a;break;case Number:s.start=a;break;case Function:s.click=a;break;case String:if(a.charAt(0)=='.')s.current=a;else if(a.charAt(0)=='!')s.event=a;else s.start=a;break;}}
if(typeof s['return']=="function")
s.change=s['return'];return this.each(function(){$.idTabs(this,s);});}
$.idTabs=function(tabs,options){var meta=($.metadata)?$(tabs).metadata():{};var s=$.extend({},$.idTabs.settings,meta,options);if(s.current.charAt(0)=='.')s.current=s.current.substr(1);if(s.event.charAt(0)=='!')s.event=s.event.substr(1);if(s.start==null)s.start=-1;var showId=function(){if($(this).is('.'+s.current))
return s.change;var id="#"+this.href.split('#')[1];var aList=[];var idList=[];$("a",tabs).each(function(){if(this.href.match(/#/)){aList.push(this);idList.push("#"+this.href.split('#')[1]);}});if(s.click&&!s.click.apply(this,[id,idList,tabs,s]))return s.change;for(i in aList)$(aList[i]).removeClass(s.current);for(i in idList)$(idList[i]).hide();$(this).addClass(s.current);$(id).show();return s.change;}
var list=$("a[href*='#']",tabs).unbind(s.event,showId).bind(s.event,showId);list.each(function(){$("#"+this.href.split('#')[1]).hide();});var test=false;if((test=list.filter('.'+s.current)).length);else if(typeof s.start=="number"&&(test=list.eq(s.start)).length);else if(typeof s.start=="string"&&(test=list.filter("[href*='#"+s.start+"']")).length);if(test){test.removeClass(s.current);test.trigger(s.event);}
return s;}
$.idTabs.settings={start:0,change:false,click:null,current:".current",event:"!mouseover"};$.idTabs.version="2.2";$(function(){$(".idTabs").idTabs();});})(jQuery);}
	//mouseover& click 鼠标动作
var check=function(o,s){s=s.split('.');while(o&&s.length)o=o[s.shift()];return o;}
var head=document.getElementsByTagName("head")[0];var add=function(url){var s=document.createElement("script");s.type="text/javascript";s.src=url;head.appendChild(s);}
var s=document.getElementsByTagName('script');var src=s[s.length-1].src;var ok=true;for(d in dep){if(check(this,d))continue;ok=false;add(dep[d]);}if(ok)return init();add(src);})();

//以上为必须，以下是从http://zwbeta.com/wp-content/themes/ZwBeta/js/jquery.zwbeta.js摘的。

$(function() {
	//搜索框
	var keyWord = $("input#s");
	if (keyWord.val().length >= 1 ) keyWord.prev("label").hide();
	keyWord.focus(function(){ keyWord.prev("label").hide(); })
	keyWord.blur(function(){
		if (keyWord.val() == "") {
			keyWord.val("");
			keyWord.prev("label").show();
		}
	});

	//主菜单下拉
	$("#nav li").hover(
		function() {
			$(this).children("ul").slideDown(200);
		},
		function() {
			$(this).children("ul").slideUp(200);
		}
	);

	//列表隔行换色
	$(".list li:odd").addClass("odd");

	//初始化选项卡
	$("#choice ul:first").idTabs();
	$("#side-cmt ul:first").idTabs();
	$("#column-nav ul:first").idTabs();

	//首页相册文字
	$("#home-album li a").hover(
		function() {
			$(this).children("span").slideDown(200);
		},
		function() {
			$(this).children("span").slideUp(200);
		}
	);

	//鼠标经过tips效果
	$("#container a").not("#home-album li a, .social_share a").mouseover(function(tips){
		this.tipsTxt = this.title;
		this.tipsTxt = (this.tipsTxt.length>100?this.tipsTxt.toString().substring(0,100)+"...":this.tipsTxt);
			if (this.tipsTxt){
				this.tipsUrl = this.href;
				this.title = '';
				var tips = '<div id="tips"><p>' + this.tipsTxt + '</p><p><em>' + this.tipsUrl + '</em></p></div>';
				$('body').append(tips);
				$('#tips').css({"opacity":"0.8"})
			}
		}).mouseout(function(){
			this.title=this.tipsTxt;
			$('#tips').remove();
		}).mousemove(function(tip){ $('#tips').css({"top":(tip.pageY+22)+"px","left":(tip.pageX-10)+"px"});
	});
	//鼠标经过tips效果结束
	$(document).ready(function() {
	$('#resizer em').click(function() {
  	  var fontSize = 1.2;
  	  var name = $(this).attr('id');
  	  if (name == 'f_s') {
  	  	  fontSize -= 0.1
  	  	  } else if (name == 'f_l') {
  	  	  	  fontSize += 0.1
  	  	  } else if (name == 'f_m') {
  	  	  	  fontSize == 1.3
  	  	  }
  	 	$('.ZwBeta p').css('font-size', fontSize + 'em')    
  	 });
  	});

	//彩色tag云
	tagColor(".tags a");	

	//新窗口打开
	$(function() { $("a[rel*='external']").attr("target","_blank") });
	
	//云输入法
	$(".icon_ime").click(function(){$.getScript("http://ime.qq.com/fcgi-bin/getjs")});
	
	//滑动到顶部
	$('#to-top').click(function() { $("html,body,#wrap").animate({ scrollTop: 0 }, 1000); });
	$('.respond, .to-respond').click(function(){$('html,body').animate({scrollTop:$('#respond').offset().top}, 1000);});
	var showDistance = 50;//距离顶端多少距离开始显示to-top
	$(window).scroll(function(){
		if($(this).scrollTop() < showDistance){
			$("#to-top").fadeOut("fast");
		}else{
			$("#to-top").fadeIn("fast");
		}
	});
	//favicons
	$(".linkpage a").each(function(e){$(this).prepend("<img src=http://www.google.com/s2/favicons?domain="+this.href.replace(/^(http:\/\/[^\/]+).*$/, '$1').replace( 'http://', '' )+">");});
	//页面载入中...
	$('.wrap a:not(a[target*=_blank] , a[href*=javascript] , a[href*=#])').click(function(){
	$('#loading_').css({top:'180px',left:'45%'});
	$('#loading_').fadeIn(600);
	$('#loading_').fadeOut(6000)});
	
	$('#choice .list a ,.list li em a ,.st-related-posts li a').hover(function(){
	$(this).stop().animate({'left':'5px'},'fast')},function(){
	$(this).stop().animate({'left':'0px'},'fast')}); 
  	
	$('.list em a ,.list li a ,.st-related-posts li a ').click(function(){
	$(this).text('莫急,我给您老找文章去...');
	  window.location = $(this).attr('href');});
     
	//响应框输入字数统计
	var $comment = $('#comment');
	var $str  =  $('#str');
	var time;
	$comment.focus(function(){
		 time = window.setInterval( substring,100 );
	}); 
	function substring() {
		var val = $comment.val();
		var length = val.length;
		if( $str.html() != (length) ){
			 if(length==0){
				 $("#wordcount")[0].firstChild.nodeValue = "您已输入0";
				  $str.html(length);
				   }else{
				 $("#wordcount")[0].firstChild.nodeValue = "您已输入";
				 $str.html(length);
			}
		}
	}
	//欢迎词定位
	$(window).scroll(function() {
		var bodyTop = 0;
		if (typeof window.pageYOffset != 'undefined') {
			bodyTop = window.pageYOffset
		} else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') {
			bodyTop = document.documentElement.scrollTop
		} else if (typeof document.body != 'undefined') {
			bodyTop = document.body.scrollTop
		}
		$("#hellobaby").css("top", 500 + bodyTop)
	 });
	  $('#hellobaby').fadeOut(10000);
	  //滚动展示微博
	  $("#twitter li:not(:first)").css("display","none");
	    var B=$("#twitter li:last");
		var C=$("#twitter li:first");
		setInterval(function(){
			if(B.is(":visible")){
				C.fadeIn(500).addClass("in");B.hide()
			 }else{
				 $("#twitter li:visible").addClass("in");
				 $("#twitter li.in").next().fadeIn(500);
				 $("li.in").hide().removeClass("in")}
			 },3000) //每3秒钟切换一条，你可以根据需要更改
});

//图片渐显
function TsLazyload(templateUrl) {
	if(window.XMLHttpRequest){
		$(function() {
			$("img").not("#slide-pic img, #side-cmtli-2 img, .gallery img").lazyload({
				placeholder: templateUrl,
				effect: "fadeIn"
			});
		});
	}
}

//闪动联系我
function TsFlicker(getObject,times) {
	if (times == null) times = 5;
	for (i = 0; i<times; i++) {
		$("#" + getObject).fadeOut(200);
		$("#" + getObject).fadeIn(50);
	}
}
//插入贴图
function comment_image() {
  var URL = prompt('请您输入图片的 URL 位址:');
  if (URL) {
    document.getElementById('comment').value = document.getElementById('comment').value + '[img]' + URL + '[/img]';
  }
}
//彩色tag
function tagColor(getObject) {
	var colors = ["#0cf","#06f","#900","#990","#f36","#639","#60f","#0c0","#f90","#c66","#6cc","#f0f","#00f","#333"];
	var tags = $(getObject);
	var tagCount = tags.length;
	for ( i=0; i<tagCount; i++ ) {
		n = Math.floor( Math.random() * colors.length );
    	tags.eq(i).css({"color":colors[n]});
	}
}
