/*
function tab_over(tabid,tabview,type) {
  if(document.getElementById(tabid).className==type+"tab-down") {
	  document.getElementById(tabid).className=type+"tab";
    document.getElementById(tabid+"_content").style.display="block";
    for(var i=0;i<tabview.length;i++) {
      if(tabid!=tabview[i]) {
        document.getElementById(tabview[i]+"_content").style.display="none";
        document.getElementById(tabview[i]).className=type+"tab-down";
      }
    }
  }
}
*/

function tab_over(tabid, tabview, type) {

	tab_over_jquery(tabid, tabview, type);

}

function tab_over_jquery(tabid, tabview, type) {

  if($j('#' + tabid).attr('className') == (type + "tab-down")) {

		$j('#' + tabid).attr('className', (type + "tab"));
		$j('#' + tabid + "_content").show();

    for(var i = 0; i < tabview.length; i++) {
      if(tabid!=tabview[i]) {
				$j('#' + tabview[i] + "_content").hide();
				$j('#' + tabview[i]).attr('className', (type + "tab-down"));
      }
    }
  }

}

$j(function(){
	// 先取得 .abgne-news-scroll ul, 並設定淡入及輪播時間
	var $news = $j('.news-scroll ul'), 
		fadeInSpeed = 1000, 
		timer, speed = 3000;
 
	// 用來控制輪播用
	function newsScroll(){
		// 先找出最後一個 li
		var $last = $news.find('li:last');
		// 複製一份並先隱藏起來
		// 接著把它加到 .abgne-news-scroll ul 中的第一個項目
		// 最後用淡入的方式顯示, 當顯示完後繼續輪播
		$last.clone().hide().prependTo($news).fadeIn(fadeInSpeed, function(){
			timer = setTimeout(newsScroll, speed);
		});
		// 把 $last 移除掉
		$last.remove();
	}
 
	// 啟動輪播計時器
	timer = setTimeout(newsScroll, speed);
});

