/* 协议弹出框 */
$(document).ready(function(){	   
$(".regconfer").click(function(){
    $(".regshow").animate({ opacity: 'show' }, "fast");
});

$(".regagree").click(function(){
	$(".regshow").animate({ opacity: 'hide' }, "fast");
});
});

/* 提示消息框显示隐藏 */
$(document).ready(function(){
						   
$(".message").click(function(){
    $(".messagetip").animate({ opacity: 'show' }, "fast");
});

$(".messageclose").click(function(){
	$(".messagetip").animate({ opacity: 'hide' }, "fast");
});
});

/* 回到顶部 */
jQuery(document).ready(function($){
$('#roll_top').click(function(){$('html,body').animate({scrollTop: '0px'}, 800);});
$('#roll_bottom').click(function(){$('html,body').animate({scrollTop:$('#footer').offset().top}, 800);});
});


/* 大厅微博滚动 */
$(function(){
msgmove(); 
$(".topiclist1").hover(function(){
$(this).attr("name","hovered"); 
},function(){
$(this).removeAttr("name");
});
});
function msgmove(){ var isIE=!!window.ActiveXObject;
var isIE6=isIE&&!window.XMLHttpRequest;
if($(".topiclist1").attr("name") != "hovered"){
var height = $(".topiclist1 li:last").height();
if(isIE6){
$(".topiclist1 li:last").css({"height":0});
}else{ $(".topiclist1 li:last").css({"opacity":0,"height":0});
}
$(".topiclist1 li:first").before($(".topiclist1 li:last"));
$(".topiclist1 li:first").animate({"height":height},300);
if(!isIE6){
$(".topiclist1 li:first").animate({"opacity":"1"},300);
}
}
setTimeout("msgmove()",5000);
}


// 广场随机用户推荐列表 切换	
(function($){
	$.fn.extend({
		"jScroll":function(o){
			o = $.extend({
				auto: 2000, //延迟时间（毫秒）
				speed: 800, //单次滚动时长（毫秒）
				vertical: false, //是否向上滚动(默认向左)
				scroll: 1 //每次滚动的元素数量
			},o);
			var running = false, sizeCss = o.vertical ? "height" : "width", ulSize = 0;
			var scrollTimer, scrollLen, itemSize, animCss, i;
			var div = $(this), ul = div.find("ul"), li = ul.children("li");
			
			div.css({overflow: "hidden"});
			ul.css({margin: "0", padding: "0", display: "inline-block"});
			li.css({"list-style-type": "none", float: o.vertical ? "none" : "left"});
			
			for(i=0; i<=li.size()-1; i++){
				itemSize = o.vertical ? li.eq(i).outerHeight() : li.eq(i).outerWidth();
				ulSize+=itemSize;
			}
			var divSize = o.vertical ? div.height() : div.width(); //容器宽(高)
			ul.css(sizeCss, (ulSize*2)+"px");
			if(ulSize > divSize) running = true; //UL的宽(高)大于容的器宽(高)时才滚动
		
			div.hover(function(){
				clearInterval(scrollTimer);
			},function(){
				if(running){
					scrollTimer = setInterval(function(){
						scrollLen = 0;
						itemSize = 0;
						li = ul.children("li");
						for(i=0; i<=o.scroll-1; i++){
							itemSize = o.vertical ? li.eq(i).outerHeight() : li.eq(i).outerWidth();
							scrollLen+=itemSize;
						}
						animCss = o.vertical ? {marginTop:-scrollLen +"px"} : {marginLeft:-scrollLen +"px"};
						ul.animate(animCss, o.speed, function(){
							ul.css(o.vertical ? "margin-top" : "margin-left", "0");
							li.slice(0,o.scroll).appendTo(ul); //将前面的元素移至末尾
						})
					}, parseInt(o.auto+o.speed));
				}
			}).trigger("mouseleave"); //DOM加载完毕后自动执行hover(fn1, fn2)的fn2
		}
	});
})(jQuery);


						
// 广场随机用户推荐列表 切换	
$(document).ready(function(){
  var currentPosition = 0;
  var slideWidth = 520;
  var slides = $('.slide');
  var numberOfSlides = slides.length;

  $('#slidesContainer').css('overflow', 'hidden');

  slides
    .wrapAll('<div id="slideInner"></div>')
	.css({
      'float' : 'left',
      'width' : slideWidth
    });

  $('#slideInner').css('width', slideWidth * numberOfSlides);

  $('#slideshow')
    .prepend('<span class="control" id="leftControl">Clicking moves left</span>')
    .append('<span class="control" id="rightControl">Clicking moves right</span>');

  manageControls(currentPosition);

  $('.control')
    .bind('click', function(){
	currentPosition = ($(this).attr('id')=='rightControl') ? currentPosition+1 : currentPosition-1;
    
    manageControls(currentPosition);
    $('#slideInner').animate({
      'marginLeft' : slideWidth*(-currentPosition)
    });
  });

  function manageControls(position){
	if(position==0){ $('#leftControl').hide() } else{ $('#leftControl').show() }
    if(position==numberOfSlides-1){ $('#rightControl').hide() } else{ $('#rightControl').show() }
  }	
});


// 广场热门话题选项卡切换效果
function nTabs(thisObj,Num){
if(thisObj.className == "active")return;
var tabObj = thisObj.parentNode.id;
var tabList = document.getElementById(tabObj).getElementsByTagName("li");
for(i=0; i <tabList.length; i++)
{
  if (i == Num)
  {
   thisObj.className = "active"; 
      document.getElementById(tabObj+"_Content"+i).style.display = "block";
  }else{
   tabList[i].className = "normal"; 
   document.getElementById(tabObj+"_Content"+i).style.display = "none";
  }
} 
}

