/*******************************************************************
**--> Intro: For Lizus Customize WordPress Themes
**--> Author: lizus.com@gmail.com
**--> WebSite: http://www.lizus.com
*******************************************************************/

$(function ()
{
	$('#nav li').hover(function(){
		$(this).children('ul').show();
		$(this).children('a:first').addClass('current');
	},function(){
		$(this).children('ul').hide();
		$(this).children('a:first').removeClass('current');
	});
});


$(function(){
	var s_h=$('#sidebar').height();
	var m_h=$('.main:first').height();
	if (s_h>m_h){
		$('.main:first').height($('#sidebar').height());
	}else{
		$('#sidebar').height($('.main:first').height());
	}
});

$(function(){
	$('#up_a').bind('click',function(){
		history.go(-1)
		return false;
	});
});

$(function(){	
	if ($('#home_1_pic_news div:last')!=$('#home_1_pic_news div:first')){
		show_init();
		setInterval('right_show()',5000);
	}
});

function show_init(){
	$('#home_1_pic_news div').css({position:'absolute',left:0,top:0,width:'220px',height:'200px',overflow:'hidden'});
	$('#home_1_pic_news div img').css({width:'auto',height:'200px'});
}

function right_show(){
	$('#home_1_pic_news div:last').addClass('now_show');
	$('#home_1_pic_news div:last').prev().addClass('next_show');
	$('#home_1_pic_news .next_show:first').css({left:'-220px',top:'0'});
	$('#home_1_pic_news .next_show:first').animate({left:0},1000);
	$('#home_1_pic_news .now_show:first').animate({left:'220px'},1000);
	$('#home_1_pic_news div:last').removeClass('now_show');
	$('#home_1_pic_news div:last').prev().removeClass('next_show');
	$('#home_1_pic_news').prepend($('#home_1_pic_news div:last'));
}


//用于使某些jQuery对象产生相同的高度
function equalHeight(group) {    
	tallest = 0;   
	if (group.length){
		group.each(function() {    
			thisHeight = jQuery(this).height();    
			if(thisHeight > tallest) {    
				tallest = thisHeight;    
			}    
		});    
		group.height(tallest);    
	}	
}

//reheight main and sidebar
jQuery(document).ready(function(){
	equalHeight(jQuery('#sidebar').add(jQuery('.main')));
});


jQuery(document).ready(function (){
	var wrapper=jQuery('#nav>div');
	var ul=wrapper.children('ul');
	var lis=ul.children('li');
	ul.width(lis.size()*80);
	ul.css({
		'margin-left':(wrapper.width()-ul.width())/2
	});
});
