var iWinWidth = screen.width / 8 * 7;

function OpenFunc(a)
{
	window.focus();
	window.open(a,'','width=200,height=200,status=yes,toolbar=yes,menubar=no,location=no,resizable=yes,scrollbars=yes');
	return false;
}

function OpenHref(a)
{
	window.focus();
	window.open(a,'','width='+iWinWidth+',status=yes,toolbar=yes,menubar=no,location=no,resizable=yes,scrollbars=yes');
	return false;
}

function ShowMyLoading(doc)
{
	var img,x,y;
	with (doc)
	{
		img = createElement('IMG');
		img.style.position = "absolute";
		img.style.display = 'block';
		img.src = '/club/images/loading.asp';
		img.style.zOrder = 99;
		x = body.scrollLeft + (body.clientWidth - 64) / 2;
		y = body.scrollTop + (body.clientHeight - 64) / 2;
		img.style.pixelLeft = x;
		img.style.pixelTop  = y;
		body.insertBefore(img);
	}
}
//需要此两函数处理输入的汉字，Program By Aoeiuv.Com
function GetAString(s){
	var c,n,i;
	c = '';
	n = s.length;
	for (i=0;i<n;i++)
	{
		if (s.charCodeAt(i) == 0) return c;
		c += s.charAt(i);
	}
	return c;
}

function GetInput(info,d){
	var s
	s = prompt(info,d);
	if (s)
		return GetAString(s);
	else
		return '';
}
//处理汉字输入，Program By Aoeiuv.Com

/*--------------小-------亮-------晓-------之-------亮--------------------------
作者：密码
主页：<a href="http://www.aoeiuv.com">宝贝悟语(aoeiuv.com)</a>
说明：显示滚动公告以及显示提示信息
申明：如果您使用了以下的代码，请保留头注释。
历史：2003年03月18日 创建
1.0版：2003年03月18日
1.目前该功能只支持IE4以上版本。
------------------------------------------------－请－保－留－以－上－信－息－*/
var isNS = (document.layers);
var isIE = (document.all);

function js(obj, obj_name) { 
	var result = '', i = '';
	for (i in obj)
//	if (obj[i] != '' && obj[i] != '[object]' && obj[i] != null)
		result += obj_name + '.' + i + ' = ' + obj[i] + '\n';
	return result;
}

//<div id="dyLLB" onmouseover="this._MoveStop=true;" onmouseout="this._MoveStop=false;" title="<b>鼠标移到上面将暂停滚动，移开后恢复。</b>"></div>
//ScrollText('dyLLB')

function ScrollTextFun(d){
	var s = 'ScrollTextFun("'+d+'")';
	with (eval(d)){
		if (_MoveStop){
			_Timeout = setTimeout(s,100);
			return;
		}
		var n = scrollTop;
		scrollTop += _Step;
		if (n == scrollTop) scrollTop = _Step;
		if (scrollTop == 0 || scrollTop == scrollHeight - 18)
			_Timeout = setTimeout(s,_TimerScroll);
		else
			if (Math.round(scrollTop / _LineHeight) * _LineHeight == scrollTop)
				_Timeout = setTimeout(s,_TimerStop);
			else
				_Timeout = setTimeout(s,_TimerScroll);
	}
}

function ScrollText(d){
	var ff = eval(d);
	if (ff._Timeout != null) clearTimeout(ff._Timeout);
	with (ff.style){
		overflow = 'auto';
		overflowX = 'hidden';
		overflowY = 'hidden';
		paddingRight = 4; 
		paddingLeft = 4;
		paddingTop = 2;
		paddingBottom = 2;
		fontSize = '12px';
		lineHeight = "14px";
		height = 16;
	}
	ff.scrollTop = 0;
	ff._Step = 2;
	ff._TimerScroll = 100;
	ff._TimerStop = 3000;
	ff._LineHeight = 14;
	ff._MoveStop = false;
	ScrollTextFun(d);
}

document.write('<div id="dyHint" style="left:0;top:0;visibility:hidden; position:absolute;z-index:777;background-color: #F4F7FB; border: 1px #000000 solid; font-size: 12px; padding-right: 4px; padding-left: 4px; padding-top: 4px; padding-bottom: 4px;overflow-x:hidden;overflow-y:hidden; text-align:left"></div>');
dyHint._Type = 0;
dyHint._tWait = 200;
dyHint._tStep = 50;
dyHint._tStop = 5000
dyHint._tOver = 100;
dyHint._CurH = 0;
dyHint._StepOpen = 8;
dyHint._StepClose = 8;
dyHint._ScrollOpen = false;
dyHint._ScrollClose = true;
dyHint._TimeOut = 0;
dyHint._From = null;

function ToShowTitle(t){
	if ((t == null) || (t == '')) return;
	t = t.replace(/\n/ig,'<br>');
	with (dyHint){
		innerHTML = t;
		_From = event.srcElement;
		_From.title = '';
		var l = event.clientX+document.body.scrollLeft+12;
		var t = event.clientY+document.body.scrollTop+15;
		var l1 = document.body.clientWidth + document.body.scrollLeft - 10;
		var t1 = document.body.clientHeight + document.body.scrollTop - 10;
		if (l + scrollWidth > l1) l = l1 - scrollWidth;
		if (t + scrollHeight > t1) t = t1 - scrollHeight;
		_CurH = 0;
		_Type = 1;
		with (style){
			height = 0;
			pixelLeft = l;
			pixelTop = t;
		}
		_TimeOut =	window.setTimeout('ShowTitle()',_tWait);
	}
}

function GetTitle(){
	var t = event.srcElement;
	if ((t == null) || (t == '')) return true;
	t = t.title;
	if (!((t == null) || (t == '')))
		ToShowTitle(t);
	if (ghOldOnMouseOver != null) 
		return ghOldOnMouseOver;
	else
		return true;
}

function ShowTitle(){
	with (dyHint){
		var n = scrollHeight;
		switch (_Type){
			case 1:
				style.visibility = 'visible';
				_Type = 2;
			case 2:
				if ((_CurH += _StepOpen) > n) _CurH = n;
				if (_ScrollOpen) scrollTop = n - _CurH;
				if ((style.height = _CurH) == n) 
				{
					_Type = 3;
					_TimeOut = window.setTimeout('ShowTitle()',_tStop);
				}else
					_TimeOut = window.setTimeout('ShowTitle()',_tStep);
				break;
			case 3:
				if ((_CurH -= _StepClose) < 0) _CurH = 0;
				if (_ScrollClose) scrollTop = n - _CurH;
				if ((style.height = _CurH) == 0)
					StopTitle();
				else
					_TimeOut = window.setTimeout('ShowTitle()',_tOver);
				break;
		}
	}
}

function StopTitle(){
	with (dyHint)
	{
		clearTimeout(_TimeOut);
		_TimeOut = 0;
		_Type = 0;
		style.visibility = 'hidden';
		if (_From == null) return;
		_From.title = innerHTML;
		_From = null
	}
	if (ghOldOnMouseUp != null) 
		return ghOldOnMouseUp;
	else
		return true;
}

/*--------------小-------亮-------晓-------之-------亮--------------------------
作者：密码
主页：<a href="http://www.aoeiuv.com">宝贝悟语(aoeiuv.com)</a>
说明：建立浮动且可拖动的发贴专用章
申明：如果您使用了以下的代码，请保留头注释。
历史：2001-9-15 创建
      1.0版：
	       1.目前该功能只支持IE4以上版本。
			<div style="position:absolute;" onmousedown="Drag(this)">
------------------------------------------------－请－保－留－以－上－信－息－*/
var aDivCount = 10;
var aDivFloater = new Array(10);//(null,null,null,null,null,null,null,null,null,null);
for (var aN=0;aN<10 ;aN++ ) aDivFloater[aN] = null;

var OldMouseX,OldMouseY,OldDivX,OldDivY;
var DragDiv = null;
var floaterLeft = 0 , floaterTop = 0 ;
var FloatImgNum = 0;
var iStep = 7;
var IntervalID = 0;

var OldMouseOver = document.onmouseover;
var OldMouseUp = document.onmouseup;

function divMouseMove()
{
	if (null == DragDiv) return;
	var mouseX = event.clientX - OldMouseX + OldDivX + document.body.scrollLeft;
	var mouseY = event.clientY - OldMouseY + OldDivY + document.body.scrollTop;
	DragDiv.style.pixelLeft = mouseX;
	DragDiv.style.pixelTop = mouseY;

	return;
}

function UnDrag()
{
	event.srcElement.style.position = '';
}

function Drag(div)
{
	if (event.button==2) 
	{
		if (1 == div._IsFloater)
		{
			if (confirm('按确定取消浮动功能^_^ ')) DelFloater(div);
		}
		else
		{
			if (confirm('按确定打开浮动功能：） '))	AddFloater(div,1);
		}
		return false;
	}

	div._IsDrag = 1;
	div.ondblclick = UnDrag;
	DragDiv = div;

	if (div.style.position != "absolute"){
		OldMouseX = event.clientX + document.body.scrollLeft;
		OldMouseY = event.clientY + document.body.scrollTop;
		div.style.position = "absolute";
		div.style.pixelLeft = OldMouseX;
		div.style.pixelTop  = OldMouseY;
		OldDivX = OldMouseX - 2;
		OldDivY = OldMouseY - 2;
	}
	else
	{
		OldMouseX = event.clientX + document.body.scrollLeft;
		OldMouseY = event.clientY + document.body.scrollTop;
		OldDivX = OldMouseX - event.offsetX - 2;
		OldDivY = OldMouseY - event.offsetY - 2;
	}

	OldMouseOver = document.onmouseover;
	OldMouseUp = document.onmouseup;
	document.onmousemove = divMouseMove;
	document.onmouseup   = divMouseUp;

	return false;
}

function divMouseUp()
{
	var l,t;

	if (event.button==2) 
	{
		window.event.cancelBubble = true;
		return;
	}

	if (null == DragDiv) return;

	l = document.body.scrollLeft + document.body.clientWidth - DragDiv.scrollWidth;
	t = document.body.scrollTop + document.body.clientHeight - DragDiv.scrollHeight;

	if (DragDiv.style.pixelLeft > l) DragDiv.style.pixelLeft = l;
	if (DragDiv.style.pixelTop  > t) DragDiv.style.pixelTop  = t;

	l = document.body.scrollLeft;
	t = document.body.scrollTop;

	if (DragDiv.style.pixelLeft < l) DragDiv.style.pixelLeft = l;
	if (DragDiv.style.pixelTop  < t) DragDiv.style.pixelTop  = t;


	DragDiv._floaterLeft = DragDiv.style.pixelLeft - document.body.scrollLeft;
	DragDiv._floaterTop = DragDiv.style.pixelTop - document.body.scrollTop;
	DragDiv._IsDrag = 0;
	DragDiv = null;
	
	document.onmousemove = OldMouseOver;
	document.onmouseup   = OldMouseUp;

	return;
}

function AddFloater(div,step){
	var i;
	if (1 == div._IsFloater) return;
	for (i=0;i<aDivCount ;i++ )
	{
		if (aDivFloater[i] == null)
		{
			div._Step = step;
			div._IsFloater = 1;
			div._floaterLeft = div.style.pixelLeft - document.body.scrollLeft;
			div._floaterTop = div.style.pixelTop - document.body.scrollTop;
			aDivFloater[i] = div;
			if (IntervalID == 0) 
				IntervalID = window.setInterval("SetFloater()",1);
			return;
		}
	}
}

function DelFloater(div){
	var i,n = 0;
	if (1 != div._IsFloater) return;
	for (i=0;i<aDivCount ;i++ )
	{
		if (aDivFloater[i] == null)
			n++;
		else if (aDivFloater[i] == div)
		{
			aDivFloater[i] = null;
			div._floaterLeft = div.style.pixelLeft;
			div._floaterTop = div.style.pixelTop;
			div._IsFloater = 0;
			n++;
		}
	}
	if (n == aDivCount)
	{
		if (IntervalID)
		{
			window.clearInterval(IntervalID);
			IntervalID = 0;
		}
	}
}

function SetFloater(){
	var i,div,newLeft,newTop;
	
	for (i=0;i<aDivCount ;i++)
	{
		if ((div = aDivFloater[i]) == null) continue;
		{
			if (1 == div._IsDrag) continue;
			newLeft = div._floaterLeft + document.body.scrollLeft;
			newTop = div._floaterTop + document.body.scrollTop;
			if (div._Step)
			{
				newLeft -= div.style.pixelLeft;
				newTop  -= div.style.pixelTop;
				newLeft /= iStep;
				newTop  /= iStep; 
				if (Math.abs(newLeft) >= 1)
					div.style.pixelLeft += newLeft;
				else
					div.style.pixelLeft = div._floaterLeft + document.body.scrollLeft;
				if (Math.abs(newTop) >= 1)
					div.style.pixelTop += newTop;
				else
					div.style.pixelTop = div._floaterTop + document.body.scrollTop;
			}
			else
			{
				div.style.pixelLeft = newLeft;
				div.style.pixelTop = newTop;
			}
		}
	}

}
//IntervalID = window.setInterval("SetFloater()",1);


/*--------------小-------亮-------晓-------之-------亮--------------------------
作者：密码
主页：<a href="http://www.aoeiuv.com">宝贝悟语(aoeiuv.com)</a>
说明：一些页面结束后的设置
申明：如果您使用了以下的代码，请保留头注释。
------------------------------------------------－请－保－留－以－上－信－息－*/
function ShowLoading()
{
//	return;
//	alert('tt');
	ShowMyLoading(document);
}

var gbFirstSubmit = true;
function FormSubmit(t){
	if (gbFirstSubmit)
	{
		if (confirm(t))
		{
			ShowLoading();
			gbFirstSubmit = false;
			return true;
		}
	}
	return false;
}

function FirstSubmit(){
	if (gbFirstSubmit)
	{
		ShowLoading();
		gbFirstSubmit = false;
		return true;
	}
	return false;
}

function MyAClick() {
	var t
	if ('A' == event.srcElement.tagName)
	{
		t = event.srcElement.target;
		if ('_self' == t)
			ShowLoading();
		if (!gbTargetBlank)
		{
			if (t == null) ShowLoading();
		}
	}
	else
		SetTextFocus();

	if (ghOldOnClick != null) 
		return ghOldOnClick;
	else
		return;
}

var gLastElement = null;

function SetTextFocus(){
	var v = event.srcElement;
	if (v == gLastElement) return;
	with (gLastElement = v){
		var s = v.type;
		if (s == "text" || s == "password")
		{
			if (!readOnly && !disabled){
				select();
				focus();
			}
		}
	}
}


function TrOver(t){
//	t.style.backgroundColor = '#e8f4ff';
	t.style.backgroundColor = '#EEEEEE';
}
function TrOut(t){
	t.style.backgroundColor = '';
}

function EL(s,t){
	var i,n,c,k;
	n = s.length;
	c = '';
	k = 0;
	for (i=0;i<n;i++)
	{
		k ++;
		if (k>29) k = 1;
		c += String.fromCharCode(s.charCodeAt(i)-k);
	}
	document.write(c.toLowerCase() + t + '</a>');
}