﻿taiSonAjax = function(ajaxMethod,contentObj,values,loadImg)
{
    this.ajaxMethod = ajaxMethod;
    this.contentObj = contentObj;
    this.values = (values&&values.trim().length>0) ? values.split("|") : undefined;
	this.loadImg = loadImg;
	this.runAjax();
};
taiSonAjax.prototype.runAjax = function()
{
	var me = this;	
	var top = (parseInt(this.contentObj.offsetHeight) - 30)/2;
	var loadInfo = this.loadImg ? "<div style=\"margin:" + top + "px auto;padding:0px; text-align:center;\"><img src=\"" + this.loadImg + "\" style=\"height:16px;line-height:16px;\" border=\"0\">" : "<div style=\"margin:" + top + "px auto;height:25px;line-height:25px; text-align:center;\">載入中．．．</div>";
	get_Ajax_CallBack = function(rs)
	{
		if(rs.value != null)
	    {
		    me.contentObj.innerHTML = rs.value.toString();
	    }
	    else
	    {
	        me.contentObj.innerHTML = loadInfo;
	    }
	};
	
	var varValues="";
	if(this.values)
	{
		for(var i = 0; i < this.values.length; i++)
		{
			varValues += "\"" + this.values[i] + "\",";
		}
	}
	eval(this.ajaxMethod + "(" + varValues  + "get_Ajax_CallBack)");
};

String.prototype.trim = function()
{
	return this.replace(/(^\s*)|(\s*$)/g, "");
};
function childNodes(Obj) 
{ 
    var objChilds=Obj.childNodes 
    var newObjs=new Array(); 
    var j=0; 
    for(var i=0;i<objChilds.length;i++) 
    { 
          if(objChilds[i].nodeType==1) 
          { 
               newObjs[j]=objChilds[i]; 
               j++; 
          } 
    } 
    return newObjs; 
}  
function $(id){
  if (typeof(id) != "string" || id == "") return null;
  if (document.getElementById) return document.getElementById(id);
  if (document.all) return document.all(id);  
  try {return eval(id);} catch(e){ return null;}
}