/*
fix at 20070212
*/

function info(scriptID,url)
{
	this.scriptID = scriptID;
	this.url = url; 
}

info.prototype.show=function(){
	if (this.url)
	{
		var script = document.createElement("script");
		
		script.src=this.url;
		if (this.scriptID) 
		{		
			script.id=this.scriptID;
		}
		
		try
		{
		document.getElementsByTagName("head")[0].appendChild(script);
		}
		catch(e)
		{alert(e.message);}
	} 
};

function infoArr(){
	this.infoArr = new Array();
	this.showTime = 1000;
}
infoArr.prototype.add = function(scriptID,url){
	try
	{
		this.infoArr[this.infoArr.length] = [scriptID,url];		
	}
	catch(E)
	{}
};
infoArr.prototype.showAll = function(){
	for (i=0;i<this.infoArr.length;i++)
	{
		try
		{		
			var scriptID = this.infoArr[i][0] ; 
			var url = this.infoArr[i][1] ; 
			var infoparams = " \"" + scriptID + "\" " + " ,\"" + url + "\" " ;
			setTimeout("a=new info(" + infoparams + ");a.show();",this.showTime);	 	
		}
		catch(E)
		{}
	}
};
infoArrObj = new infoArr();

errorAlert = false;
function infoerr(msg,URL,lineno)
{
	try
	{
		var errMsg = "發生錯誤:\n" + msg + "\n於" + URL + "\n的第" + lineno + "行"; 
		if (errorAlert)
		{
			var errDiv = document.getElementById("errDiv");
			if (errDiv)
			{}
			else
			{
				errDiv = document.createElement("div");
				errDiv.id="errDiv";
				errDiv.style.border="solid 2px red";
				errDiv.style.width="100%";
				errDiv.style.zIndex="999";  
				errDiv.style.overflow="scroll";
			}
			errDiv.innerHTML += errMsg; 
			document.getElementsByTagName("body")[0].appendChild(errDiv);
		}
	}
	catch(E){}	
	return errorAlert;
}

window.onerror = infoerr;

/*

<script type="text/javascript">
//使用範例
var infoArrObj = new infoArr();
infoArrObj.add("aa","http://www.google.com?a=1&b=2");
infoArrObj.showAll();
errorAlert = true;
</script>
*/