/*===============================*/
/*公共常用JS
/*===============================*/
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;
		}
		else
		{
			ImgD.width = image.width;
			ImgD.height =image.height
		}
    }
}
//得到标准日期
function getDateTime(Y,M,D)
{
	document.write(Y+"-");
	document.write(M.length>1?M:"0"+M+"-");
	document.write(D.length>1?D:"0"+M);
}
function replenishHTML(string) {
    var list = [];
    var htmlPattern = /<(\/?)(?!(?:img|param|link|base|br)\b)([a-zA-Z]+)\b/g;
    
    while (htmlPattern.test(string)) {
        if (RegExp.$1) {
            var temp = '';
            for (var i = list.length, l = i ; i > -1 ; i --) {
                if (list[i] === RegExp.$2) {
                    temp = '<\/' + list.splice(i, list.length - i).reverse().join('><\/') + '>';
                    break;
                }
            }
            if (i == -1) temp = '<' + RegExp.$2 + '><\/' + RegExp.$2 + '>';
            string = RegExp.leftContext + temp + RegExp.rightContext.slice(1);
            htmlPattern.lastIndex = RegExp.leftContext.length + temp.length;
        } else {
            list.push(RegExp.$2);
        }
    }
    if (list.length) string = string + '<\/' + list.splice(0, list.length).reverse().join('><\/') + '>';
    return string;
};


//加载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()',30000);




