

$(document).ready(function() {
	// ��ǰ��
	if ( $('.jq_userpost').length > 0 ) {
		$('.jq_userpost').each(function(index) {
			var _this = $(this);
			_this.find('ul > li > p > a:first-child').each(function(index1) {
				var item = $(this);
				item.click(function() {
					if(item.parent().parent().is('.on')){
						_this.find('ul > li').removeClass('on');
						return false;
					}
					_this.find('ul > li').removeClass('on');
					item.parent().parent().addClass('on');
					return false;
				});
			});
		});
	}
	if ( $('.jq_emoticon').length > 0 ) {
		$('.jq_emoticon').each(function(index) {
			var _this = $(this),
			_prev =_this.find('.prev'),
			_next =_this.find('.next'),
			_items=_this.find('ul');
			_prev.click(function(){_items.append(_items.find('li:first-child'));return false;});
			_next.click(function(){_items.find('li:last-child').prependTo(_items);return false;});
		});
	}
	if ( $('.img-paging').length > 0 ) {
		$('.img-paging').each(function(){
			var _this=$(this),_view= _this.parent().find('.viewport > ul'),len = _this.find(">a").length;
			_this.find('a').each(function(){ var item = $(this); item.data({'target': _view.find('li').eq(item.index())})})
				.bind({
					'click':function(){
						var item = $(this);
						_this.find("a.on").removeClass('on');
						item.addClass('on');
						if(item.data('target').index() > (_this.find(">a").length/2)){while(item.data('target').index() != 0){_view.find("> li").eq(len-1).prependTo(_view)}}
						else{while(item.data('target').index() != 0){_view.find('li').eq(0).appendTo(_view)}}
						return false;
					}
				})
				.mouseover(function(){
						var item = $(this);
						_this.find("a.on").removeClass('on');
						item.addClass('on');
						if(item.data('target').index() > (_this.find(">a").length/2)){while(item.data('target').index() != 0){_view.find("> li").eq(len-1).prependTo(_view)}}
						else{while(item.data('target').index() != 0){_view.find('li').eq(0).appendTo(_view)}}
						return false;
				})
		})
	}
});

$(document).ready(function() {

$('.jq_gift_bestrank5link > li > ul > li > a').click(function() {

		$('.gift_bestrank5_box').hide().filter($(this).attr('href')).show();
		$('.jq_gift_bestrank5link > li > ul > li > a').removeClass('on');
		$(this).addClass('on');
		
		return true;
	});
	$('.jq_gift_bestrank5link > li > a').click(function() {
				
		$('.gift_bestrank5_box').hide().filter($(this).attr('href')).show();
		$('.jq_gift_bestrank5link > li > a').removeClass('on');
		$(this).addClass('on');
		$('.jq_gift_bestrank5link > li > ul').hide();
		if ( $(this).next('ul').length ) {
			$(this).next('ul').show();
			$(this).next('ul').find('li:first-child > a').click();
		}
		return true;
	});
	
	
});
