/*===============================*/
/*公共常用JS
/*===============================*/
String.prototype.Trim = function(){return this.replace(/^\s+|\s+$/g,"");} 
function $(obj){return document.getElementById(obj);}

//调整图片大小
function DownImage(ImgD,MaxWidth,MaxHeight)
{ 
    var image=new Image();
    image.src=ImgD.src;
    if(image.width>0 && image.height>0)
	{ 
		var rate = (MaxWidth/image.width < MaxHeight/image.height)?MaxWidth/image.width:MaxHeight/image.height;
		if(rate <= 1)
		{
			ImgD.width = image.width*rate;
			ImgD.height =image.height*rate;
		}
    }
}

//加载JS
function loadScript(scriptUrl)
{ 
	var h = document.getElementsByTagName("head")[0];
	var f = document.createElement("script"); 
	f.type ="text/Javascript"; 
	f.src = scriptUrl; 
	h.appendChild(f); 
}

//切换模块内容
function runtab(btn)
{
	var idname = new String(btn.id);
	var s = idname.indexOf("_");
	var e = idname.lastIndexOf("_")+1;
	var modId = idname.substr(0, s);
	var id = parseInt(idname.substr(e, 1));
	var tabNumber = btn.parentNode.childNodes.length;
	
	for(i=0;i<tabNumber;i++)
	{
		document.getElementById(modId+"_div_"+i).style.display = "none";
		document.getElementById(modId+"_btn_"+i).className = "";
	}
	document.getElementById(modId+"_div_"+id).style.display = "block";
	btn.className = "curr";
}

//复制当前文章标题和地址
function CopyURL()
{
	var myHerf=top.location.href;
	var title=document.title;
	if(window.clipboardData)
	{
		var tempCurLink=title + "\n" + myHerf;
		var ok=window.clipboardData.setData("Text",tempCurLink);
		if(ok)
			alert("按Ctrl + V ,粘贴到你所上的论坛或QQ好友群吧！");
	}
	else
	{
		alert("对不起，目前此功能只支持IE，请直接复制地址栏的地址！");
	}
}
loadScript("/js/main.js");

//获取在线用户
function refreh_Online()
{
	var Ajax = new oAjax("/inc/Online.asp",undo);
	var arrKey = new Array("Action");
	var arrValue = new Array("getOnline");
	Ajax.Post(arrKey,arrValue);
}
function undo(arrobj)
{
	//alert(arrobj[0]);
}
setInterval('refreh_Online()',5000);	//5秒检测次在线用户

function showMarqueeBox(id, lh, speed, delay)
{
	var o = document.getElementById(id);
	var p = false;
	var t;
	o.style.overflow = "hidden";
	o.style.height = o.style.lineHeight = lh + "px";
	//o.style.lineHeight = "18px";
	o.style.height = o.style.lineHeight;
	o.onmouseover = function() { p = true; }
	o.onmouseout = function() {	p = false; }
	function start()
	{
		t = setInterval(scrolling, speed);
		if (!p) o.scrollTop++;
	}
	function scrolling()
	{
		if ((o.scrollTop % lh) != 0)
		{
			o.scrollTop++;
			if (o.scrollTop >= o.scrollHeight - lh - 1) 
			{
			  o.scrollTop = 0;
			}
		}
		else
		{
			clearInterval(t);
			setTimeout(start, delay);
		}
	}
	setTimeout(start, delay);
}


