// JavaScript Document
/*
Content: Common components;
Remark: remenhuati;
Version: v0.1;
Author: guanxin.com JF.Z;
Date: 2010-04-06
*/
var int;
var times = 5000;
var Width = 266;
$.fn.topics=function(){
 int=setInterval("move('left')",times)
 $(".btn").click(function(){
  move(this.id);
 });
 $(".list").css({"width":($(".list .item").length) * Width})
}
function move(sign)
{
	var left;
	left = parseInt($(".list").css("left"));
	var tleft = left;
	switch(sign)
	{
	case "left":
	{
	  var len = ($(".list .item").length+1) * Width;
	  if((len - Math.abs(left)) > Width*2)
	  {
	   tleft -= Width;
	  }
	  else
	  {
	   tleft = 0;
	  }
	  break;
		}
	case "right":
	{
	  if (left == 0)
	  {
		  tleft = -parseInt($(".list").css("width")) + Width;
	  }
	  else
	  {
	   tleft += Width;
	  }
	  break;
		}
	}
	if ((tleft - left) != 0)
	{
	$(".list").animate({
	  left:tleft + "px"
	},30,function(){
	  left = tleft;
	  int=setInterval("move('"+sign+"')",times)
	});
	}
	int = clearInterval(int);
}
	
