/*******************************************************************
**--> Intro: For Lizus Customize WordPress Themes
**--> Author: lizus.com@gmail.com
**--> WebSite: http://www.lizus.com
*******************************************************************/

function slideSwitch() {
	var $current = $("#show div.current");
	var index_num=$('div.current').index($("#show"));
	$('#show_num a:eq('+index_num+')').addClass('current');
	// 判断div.current个数为0的时候 $current的取值
	if ( $current.length == 0 ) $current = $("#show div:last");
	
	// 判断div.current存在时则匹配$current.next(),否则转到第一个div
	var $next =  $current.next().length ? $current.next() : $("#show div:first");
	$current.addClass('prev');
	
	$next.css({opacity: 0.0}).addClass("current").animate({opacity: 1.0}, 1000, function() {
			//因为原理是层叠,删除类,让z-index的值只放在轮转到的div.current,从而最前端显示
			$current.removeClass("current prev");
		});
}

$(function() {
	var html='<div id="show_num">';
	var i=1;
	$("#show div").each(function(){
		html+='<li><a href=""><span>'+i+'</span></a></li>';
		i++;
	});
	html+='</div>';
	$('#header').before(html);
	$("#show div:first").addClass('current');
	$(".current").css("opacity","1.0");
	$('#show_num a').live('click',function(){
		$('#show div').removeClass('prev');
		$('#show div:eq('+($(this).html()-1)+')').addClass('prev');
		slideSwitch();
		return false;
	});
	
	// 设定时间为3秒(1000=1秒)
    setInterval( "slideSwitch()", 4000 ); 
});

$(function(){
	i=0;
	$('#home_left>ul>li>a').each(function(){
		$(this).addClass('pro'+i);
		i++;
	});
});

$(function ()
{
	var topAs=$('#topNav a').length;
	for (var i=0;i<topAs;i++)
	{
		$('#topNav a:eq('+i+')').addClass('topNav'+i);
	}
});

$(function ()
{
	var nowLocation=window.location;
	$('#nav a').each(function ()
	{
		var thisURL=$(this).attr('href').slice(0,-1);
		var verify=nowLocation.toString().search(thisURL);
		if (verify==0)
		{
			$(this).parent().addClass('nowLocations');
		}
	});
	$(".nowLocations:last").addClass('nowLocation');
});

$(function ()
{
	$('#sidebar li.cat-item').hover(function ()
	{
		$(this).children('ul').show().end().siblings().not($('.nowNav')).children('ul').hide();
		$(this).addClass('nowHover');
	},function ()
	{
		$(this).removeClass('nowHover');
		$(this).not($('.nowNav')).children('ul').hide();
	});
});

$(function ()
{
	var nowLocation=window.location;
	var url='http://blog.86mro.com/';
	if (nowLocation.toString().search(url)!=0)
	{
		return;
	}
	var thisURL=nowLocation.toString().slice(23);
	var ss=thisURL.search('/');
	thisURL=thisURL.slice(0,ss);
	thisURL=url+thisURL+'/';
	$('#sidebar li.cat-item').each(function ()
	{
		if ($(this).children('a:first').attr('href')==thisURL)
		{
			$(this).children('ul').show().end().siblings().not('.nowNav').children('ul').hide();
			$(this).addClass('nowNav');
		}
	});
	$('#sidebar li.categories>ul').prepend($('.nowNav'));
});

$(function ()
{
	$('#typeSe').bind('change',function ()
	{
		thisValue=this.value;
		switchValue(thisValue);
	});
});

function switchValue(thisValue)
{
		switch (thisValue)
		{
		case "ty1":
			$('.catSe').hide();
			$('#catSe2').show();
			break;
		case "ty2":
			$('.catSe').hide();
			$('#catSe1').show();
			break;
		default:
			$('.catSe').hide();
			$('#catSe0').show();
			break;
		}
}

$(function ()
{
	$("#sidebar h2:contains('导航菜单')").parent('li.categories').addClass('pagenav').removeClass('categories');
});

$(function ()
{
	if (!$('#listPages'))
	{
		return;
	}
	var num=parseInt($('#listPages .current').text());
	var total=parseInt($('#listPages option:last').text());
	var nowLocation=window.location;
	nowLocation=nowLocation.toString();
	var pageNum=nowLocation.indexOf('/page/');
	var homeURL='';
	var upURL='';
	var downURL='';
	var lastURL='';
	if (pageNum=='-1')
	{
		homeURL=nowLocation;
		upURL=nowLocation;
		if (total>1)
		{
			downURL=nowLocation+'page/2/';
			lastURL=nowLocation+'page/'+total+'/';
		}else{
			downURL=lastURL=nowLocation;
		}
	}else{
		nowLocation=nowLocation.substring(0,pageNum+1);
		homeURL=nowLocation;
		if (num<total)
		{
			upURL= num-1==1 ? nowLocation : nowLocation+'page/'+(num-1)+'/';
			downURL=nowLocation+'page/'+(num+1)+'/';
			lastURL=nowLocation+'page/'+total+'/';
		}else if (num==total)
		{
			upURL= num-1==1 ? nowLocation : nowLocation+'page/'+(num-1)+'/';
			downURL=lastURL=nowLocation+'page/'+num+'/';
		}else{
			downURL=upURL=upURL=homeURL;
		}
	}
	var html="<div id='navDiv'><span>[ <a href='"+homeURL+"' id='nav_index'>首页</a> <a href='"+upURL+"' id='nav_up'>上一页</a> <a href='"+downURL+"' id='nav_down'>下一页</a> <a href='"+lastURL+"' id='nav_last'>尾页</a> ]</span> <span>页次: "+num+"/"+total+" 页</span> <span>30条/页</span> <strong>转到:</strong> </div>";
	$('#listPages').prepend(html);
});


$(function(){
	$('#cat3 img').css({width:'120px',height:'92px'});
});