﻿var scrollingObj;
var scrollingStr;
var scrollingPos;
var th;
var scrollingLen;

function showGreatRank2()
{
	great_rank_title_2.style.display = '';
	great_rank_title_1.style.display = 'none';
	great_rank_1.style.display = 'none';
	great_rank_2.style.display = '';
}

function showGreatRank1()
{
	great_rank_title_1.style.display = '';
	great_rank_title_2.style.display = 'none';
	great_rank_2.style.display = 'none';
	great_rank_1.style.display = '';
}

function startScrolling(obj, str, scrLen)
{
	if (str.length > scrLen)
	{
		scrollingObj = obj;
		scrollingStr = str.replace(/_/g, " ");
		scrollingPos = -1;
		scrollingLen = scrLen;
		th = window.setInterval(scrollHead, 300);
	}
}

function scrollHead()
{
	scrollingObj.innerHTML = scrollingStr.substr(++scrollingPos, scrollingLen);
	if (scrollingPos >= scrollingStr.length - 1)
	{
		scrollingPos = -1;
	}
}

function stopScrolling(obj, str)
{
	clearInterval(th);
	obj.innerHTML = str.replace(/_/g, " ");;
}

function initScr(url, str, scrLen)
{
	startTitle = str.replace(/ /g, "_"); //正则中g表示替换多个，i只替换第一个
	if (str.length > scrLen)
	{
		str = str.substr(0, scrLen) + '..';
	}
	stopTitle = str.replace(/ /g, "_");
	if (url == '#')
	{
		document.write('<span onmouseover=startScrolling(this,"' + startTitle + '",' + scrLen + ') onmouseout=stopScrolling(this,"' + stopTitle + '")>' + str + '</span>'); 
	}
	else
	{
		document.write('<a href=' + url + ' target=_blank class=b onmouseover=startScrolling(this,"' + startTitle + '",' + scrLen + ') onmouseout=stopScrolling(this,"' + stopTitle + '")>' + str + '</a><br/>'); //HTML标签属性如果不用引号分隔，就会自动按空格分隔。如果脚本函数的字符串参数中含有空格，就会出现“未结束的字符串变量”错误
	}
}

function changeRank(rankId, rankNum)
{
	url = "../inc/load_rank.php" + "?rank_number=" + rankNum + "&rank_id=" + rankId + "&x=" + Math.random();
	Request("GET",url,null,callBack,null, rankId);
}

function openPlayer(title, url)
{
	window.open("player.php?title=" + title + "&url=" + url, null, "height=256,width=320,status=no,toolbar=no,menubar=no,location=no,resizable=no");
}

