function $extend(a)
{
	try{for(var c=1;c<arguments.length;c++){var d=arguments[c];for(var f in d){if ( f != 'event'){try{a[f]=d[f];}catch(e){alert(f);}}}}return a;}
	catch (e){alert('$extend:'+e.message);}finally{a = null;d = null;c = null;f = null;}
}
function $addMethod(_object,name,fn)
{
	try
	{
		var old = _object[name];
		_object[name] =function()
		{
			if ( fn.length  == arguments.length ){return fn.apply(this,arguments);fn = null;}
			else if ( typeof old == 'function' )old.apply(this,arguments);
		};
	}catch (e){alert('$addMethod:'+e.message);}finally{_object = null;name = null;}
};
if(typeof HTMLElement !="undefined" && !window.opera)
{
	HTMLElement.prototype.__defineGetter__("outerHTML",function()
	{
		var a=this.attributes, str="<"+this.tagName.toLowerCase(), i=0;for(;i<a.length;i++)
		if(a[i].specified)
		str+=" "+a[i].name+'="'+a[i].value+'"';
		if(!this.canHaveChildren)
		return str+">";
		return str+">"+this.innerHTML+"</"+this.tagName+">";
	});
	HTMLElement.prototype.__defineSetter__("outerHTML",function(s)
	{
		var r = this.ownerDocument.createRange();
		r.setStartBefore(this);
		var df = r.createContextualFragment(s);
		this.parentNode.replaceChild(df, this);
		return s;
	});
	HTMLElement.prototype.__defineGetter__("canHaveChildren",function()
	{
		return !/^(area|base|basefont|col|frame|hr|img|br|input|isindex|link|meta|param)$/.test(this.tagName.toLowerCase());
	});
	HTMLElement.prototype.__defineGetter__("children",function()
	{ 
		var returnValue = new Object(); 
		var number = 0; 
		for (var i=0; i<this.childNodes.length; i++)
		{ 
			if (this.childNodes[i].nodeType == 1) 
			{ 
				returnValue[number] = this.childNodes[i]; 
				number++; 
			}
		}
		returnValue.length = number;
		returnValue.item = function(idx)
		{
			return this[idx] || null;
		};
		return returnValue; 
     });
}
// 將內容從函數中刪除
Function.prototype.reject = function(_fRemoveFun) 
{
	try
	{
		var preSen = this.toString();
		_fRemoveFun = _fRemoveFun.toString();
		preSen=preSen.replace(/^(function *[\w|\$|\.| ]*\([\w|\$|\,|\_| ]*\)*([\r\n\t ])*\{)([\W|\w]*)([\r\t]*\})$/ig,"$3");
		_fRemoveFun=_fRemoveFun.replace(/^(function *[\w|\$|\.| ]*\([\w|\$|\,|\_| ]*\)*([\r\n\t ])*\{)([\W|\w]*)([\r\t]*\})$/ig,"$3");
		return new Function(preSen.replace(_fRemoveFun,""));
	}catch (e){alert('Function.reject:'+e.message);}finally{preSen = null;_fRemoveFun = null;}
};
// 追加內容到函數時
Function.prototype.inject = function(_fAppendFun) 
{
	try
	{
		var preSen = this.toString();
		var preBody= preSen.replace(/^(function *[\w|\$|\.| ]*\([\w|\$|\,|\_| ]*\)*([\r\n\t ])*\{)([\W|\w]*)([\r\t]*\})$/ig,"$3");
		var preArgs = preSen.replace(/^(function *[\w|\$|\.| ]*\([\w|\$|\,|\_| ]*\)*([\r\n\t ])*\{)([\W|\w]*)([\r\t]*\})$/ig,"$1");
		preArgs = preArgs.replace(/([\r\t]*\{)*/ig,"");
		preArgs = String(preArgs.replace(/^(function *[\w|\$|\.| ]*\()*([\w|\$|\,|\_| ]*)\)*/ig,"$2")).trim();
		_fAppendFun = _fAppendFun.toString();
		_fAppendFun=_fAppendFun.replace(/^(function *[\w|\$|\.| ]*\([\w|\$|\,|\_| ]*\)*([\r\n\t ])*\{)([\W|\w]*)([\r\t]*\})$/ig,"$3");
		if ( preArgs.length )
		{
			return new Function(preArgs,preBody+_fAppendFun);
		}
		else return new Function(preBody+_fAppendFun);
	}catch (e){alert('Function.inject:'+e.message);}finally{preSen = null;preBody = null;preArgs = null;_fAppendFun = null;}
};
Function.prototype.method = function (name, func)
{
	try
	{
		this.prototype[name] = func;
		return this;
	}catch (e){alert('Function.method:'+e.message);}finally{name = null;func = null;}
    
};
// 綁定函數事件
Function.prototype.bind = function() 
{
	var __method = this, args = $A(arguments),object = args.shift();
	return function() {return __method.apply(object, args.concat($A(arguments)));}
};
Function.prototype.bindAsEventListener = function() 
{
	var __method = this, args = $A(arguments), object = args.shift();
	return function(event) 
	{
		return __method.apply(object, [( event || window.event)].concat(args).concat($A(arguments)));
	}
};
/*firefox*/ 
function __firefox()
{ 
	HTMLElement.prototype.__defineGetter__("runtimeStyle", __element_style); 
	window.constructor.prototype.__defineGetter__("event", __window_event); 
	Event.prototype.__defineGetter__("srcElement", __event_srcElement);
	HTMLElement.prototype.__defineGetter__("innerText",function(s)
	{
		this.textContent=s;
	});
	HTMLElement.prototype.__defineGetter__("innerText",function()
	{
		return this.textContent;
	});
}
function __element_style(){ return this.style; } 
function __window_event(){ return __window_event_constructor(); } 
function __event_srcElement(){ return this.target;}
function __window_event_constructor()
{
	if(document.all)return window.event;
	var _caller = __window_event_constructor.caller;
	var maxidx = 100;
	while(_caller!=null && _caller && maxidx > 0)
	{ 
		var _argument = _caller.arguments[0]; 
		if(_argument)
		{ 
			var _temp = _argument.constructor; 
			if(_temp.toString().indexOf("Event")!=-1)return _argument; 
		}
		_caller = _caller.caller;
		maxidx = ~-maxidx;
	}
	return null; 
}
if(window.addEventListener){ __firefox(); }
/*end firefox*/ 
function $A(iterable,filter) 
{
	if (!iterable) return [];
	if (iterable.toArray) return iterable.toArray(filter);
	else 
	{
		var results = [];
		for (var i = 0, length = iterable.length; i < length; i++)
		{
			results.push(iterable[i]);
		}
		return results;
	}
};
function $empty(){}
// 引用的try catch語句
function $try(fn,args,errfn,_win)
{
	try
	{
		if ( typeof fn == 'function' ) {return fn(args);}
	}
	catch(e)
	{
		if ( typeof errfn  == 'function' ) {return errfn(args,e);}
		else if ( typeof args == 'string' ){$alert(( !errfn ? '' : e.message+ '\nError Source:'+errfn) + '\n' + args);return false;}
		else{$alert(e.name+":"+e.message + (errfn ? '\nError Source:'+errfn : ''));return false;}
	}
};
function $trys()
{
	try
	{
		var length,i,lambda,returnValue;
		for (i = 0, length = arguments.length; i < length; i++) 
		{
			lambda = arguments[i];
			try 
			{
				returnValue = lambda();
				break;
			} catch (e) {}
		}
		return returnValue;
	}catch (e){alert('$trys:'+e.message);}finally{i = null;lambda = null;returnValue = null;length = null;}
};
// 生成數組對象
function $splat(obj){if ($type(obj) != 'array') {obj = [obj];}return obj;};
function $err(obj,_sContent)
{
	try
	{
		if ( Browser.isIE )obj.focus();
		else
		{
			var _xy = WF.getElementCoordinate(obj);
			_xy[1] = _xy[1] > 10 ? _xy[1]- 10 : 0;
			if ( Browser.isFirefox )document.documentElement.scrollTop = _xy[1];else document.body.scrollTop = _xy[1];
			_xy = null;
		}
		$alert(_sContent || obj.innerHTML);
	}catch (e){alert('$err:'+e.message);}finally{obj = null;_sContent = null;}
}
function $alert(_sAlarm,_sTitle,_fCallBack)
{
	try
	{
		if ( typeof Panel == 'function')
		{
			_sTitle = _sTitle || '錯誤信息';
			Panel.setCaption(_sTitle);
			Panel.setColor('#FF0000');
			Panel.open($alertformat(_sAlarm),_fCallBack);
		}
		else alert($alertformat(_sAlarm));
	}catch (e){alert('$alert:'+e.message);}finally{_sAlarm = null;_sTitle = null;_fCallBack = null;}
};
function $prompt(_sPrompt,_fID,_fCallBack)
{
	try
	{
		_fID = $(_fID);
		if ( _fID.elementExists() )
		{
			_fID.style.display = 'block';
			_fID.prompt = true;
			_fID.innerHTML = _sPrompt;
		}
		else $alert(_sPrompt,'信息提示',_fCallBack);
	}catch (e){alert('$prompt:'+e.message);}finally{_sPrompt = null;_fID = null;_fCallBack = null;}
}
function $msg(_sTitle,_sContent)
{
	try
	{
		Panel.setCaption((_sTitle || '無標題'));
		Panel.open(_sContent,null,0);
	}catch (e){alert('$msg'+e.message);}finally{_sTitle = null;_sContent = null;}
}
function $alertformat(_str){return typeof _str == 'string' && _str.trim().length > 0 ? _str.replace(/<br([ ]*)\/>/g,'\n') : _str;};

$extend(Array.prototype,new function()
{
	this._each = function(iterator)
	{
		for (var i = 0, length = this.length; i < length; i++)iterator(this[i]);
	};
	this.each = function(iterator)
	{
		try {var index = 0;this._each(function(value){try {iterator(value, index++);} catch (e) { throw e;}});return this;}
		catch (e){throw e;}finally{index = null;value = null;iterator = null;}
	};
	this.exists = function(iterator)
	{
		for (var i = 0, length = this.length; i < length; i++) if ( iterator == this[i] ) return true;
		return false;
	};
	this.getIndex = function(iterator)
	{
		try{var idx = -1;var i = 0;for (i; i < this.length; i++){if ( iterator == this[i] ){idx = i;break;}}return idx;}
		catch (e){alert('Array.getIndex:'+e.message);}
		finally{i = null;idx = null;}
	};
	this.clear = function(){this.length = 0;return this;};
	this.without = function()
	{
		var values = $A(arguments);
		return this.select(function(value) {return !values.include(value);});
	};
	this.select = function(iterator)
	{
		try{var results = [];this.each(function(value, index){if ( iterator(value, index) ) results.push(value);});return results;}
		catch (e){alert('Array.select'+e.message);}finally{results = null;iterator = null;}
	};
	this.include = function(object)
	{
		var found = false;
		this.each(function(value){if (value == object) found = true;});
		return found;
	};
	this.map = function(iterator)
	{
		var results = [];
		this.each(function(value, index) 
		{
			results.push((iterator || $K)(value, index));
		});
		return results;
	};
	this.fill = function()
	{
	};
});
$extend(String.prototype,new function()
{
	this.$ = function(){return $(this);};
	this.len = function(){return this.replace(/[^\x00-\xff]/g,"aa").length;};
	this.cut = function(len,_l)
	{
		_l = _l || 3;
		_l = isNaN(_l) ? 3 : _l;
		var tmplen =0,i=0;
		var returnStr= this;
		for(var i=0;i< this.length;i++)
		{
			tmplen += (this.charCodeAt(i) > 255) ? _l : 1;
			if(tmplen > len)
			{
				returnStr = this.substr(0, i);
				alert("已超過" + len +"個字元，系統將自動截取剩餘部分!!\r\n剩餘部分：「"+this.substr(i, this.length)+"」");
				break;
			}
		}
		tmplen = null;i=null;
		return returnStr;
	};
	this.trim = function()
	{
		try
		{
			var repChar = '';
			var str = this;
			if ( arguments.length )
			{
				for ( var i =0;i<arguments.length;i++ )
				{
					if ( String(arguments[i]||'').len() )
					{
						eval("repChar=/"+arguments[i]+"/ig;");
						str = str.replace(repChar,'');
					}
				}
			}
			str = str.replace(/(^\s*)|(\s*$)/g, "");
			return str;
		}catch (e){}finally{repChar = null;str = null;}
	};
	this.evalScripts = function(){return this.extractScripts().map(function(script) { return window.eval(script);});};
	this.extractScripts = function()
	{
		try
		{
			var matchAll = new RegExp('(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)', 'img');
			var matchOne = new RegExp('(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)', 'im');
			return (this.match(matchAll) || []).map(function(scriptTag) 
			{
				return (scriptTag.match(matchOne) || ['', ''])[1];
			});
		}
		catch (e){alert('String.extractScripts:'+e.message);}finally{matchAll = null;matchOne = null;}
	};
	this.isEmail=function(){var a=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/;return a.test(this)};
});
var modMethod = new function()
{
	this.$ = function(){};
	this.clone = function(object) {return $extend({}, object);};
	this.elementExists = function(){return $type(this) == 'element';};
	this.hide = function(){if ( this.style ){this.style.display = 'none';this.style.visibility  = 'hidden';}};
	this.disp = function(){if ( this.style ){this.style.display = 'block';this.style.visibility  = 'visible';}};
	this.isDisplay = function(){return this.style ? (this.style.display == 'block' || this.style.visibility == 'visible' || this.style.display == '') : false;};
	this.set=function(txt){this.innerHTML = txt;};
	this.get=function(){return this.innerHTML;};
	this.parentLoop = function(_match,_attrName,_endTag)
	{
		try
		{
			_endTag = _endTag || 'BODY';
			_attrName = _attrName || 'id';
			var doLoop = function(_obj)
			{
				switch(typeof _match)
				{
					case 'function':
						if ( _match(_obj) ) return _obj;
						break;
					case 'string':
						if ( _obj.nodeName == _match )return _obj;
						break;
					case 'object':
						if ( _match instanceof Array && (_match.exists(_obj.getAttribute(_attrName)) || _aMatch.exists(_obj) || _aMatch.exists(_obj.nodeName)) )
						{
							return _obj;
						}
						break;
				}
				_obj = _obj.parentElement ? _obj.parentElement : (_obj.parentNode ? _obj.parentNode : _obj.offsetParent);
				if ( _obj && _obj.nodeName != _endTag) return doLoop(_obj); else return null;
			};
			return doLoop(this);
		}
		catch (e){}finally{_obj = null;doLoop = null;_match = null;_endTag = null;}
	};
	this.lChild = function()
	{
		if ( this.childNodes )
		{
			try
			{
				var _max_idx =  this.childNodes.length - 1;
				while(_max_idx > 0 && this.childNodes[_max_idx].nodeName == '#text' ){_max_idx = ~-_max_idx;}
				return _max_idx >= 0 ? this.childNodes[_max_idx] : null;
			}catch (e){alert('modMethod.lastChild:'+e.message);}finally{_max_idx=null;}
		}else return null;
	};
};
var modSelect = new function()
{
	this.clear = function(_1)
	{
		_1 = $splat(_1);
		if ( _1.length == 1 ){_1 = _1[0] || 1;}
		try
		{
			var i =0;
			while(this.options[i])
			{
				if ( (_1 == 1 && this.options[i].selected) || (typeof _1 == 'boolean' && _1) || (typeof _1 == 'object' && (_1.exists(this.options[i].value) || _1.exists(this.options[i].text))) )
					this.options[i] = null;
				else i = - (~i);
			}
		}
		catch (e){alert('modSelect.clear'+e.message);}finally{i = null;_1 = null;}
	};
	this.set=function()
	{
		if ( !arguments.length )return;
		var idx = this.options.length;
		for ( var i = 0;i<arguments.length ;i++ )
		{
			if ( typeof arguments[i] == 'object' && arguments[i].length )
			{
				arguments[i][0] = typeof arguments[i]['text'] == 'undefined' ? (typeof arguments[i][0] == 'undefined' ? '' : arguments[i][0]) : arguments[i]['text'];
				if ( !this.exists(arguments[i]) )
				this.options[idx] = new Option(arguments[i][0] || arguments[i]['text'] || '',arguments[i][1] || arguments[i]['value'] || '');
				idx = - (~idx);
				if ( this.type == 'select-one' )break;
			}
		}
		idx = null;
	};
	this.exists = function(_val)
	{
		try
		{
			_val = $splat(_val);
			_val[1] = _val[1] || null;
			var tmp,i = 0;
			while( (tmp = this.options[i]) )
			{
				if ( tmp.value == _val[0] || tmp.text == _val[1] ) return true;
				i = - (~i);
			}
			return false;
		}
		catch (e){alert('modSelect.exists:'+e.message);}finally{i = null;tmp = nul;_val = null;}
		
	};
	this.get=function(_all)
	{
		if ( this.type == 'select-multiple' || _all )
		{
			var arr = [];
			var i = 0;
			while( this.options[i] )
			{
				if ( _all || this.options[i].selected ) arr.push(this.options[i].value);
				i = - (~i);
			}
			i = null;
			return arr;
		}
		else if ( this.type == 'select-one' )
		{
			return this.value;
		}
	};
};
var modForm = function()
{
	this.init = function()
	{
		this.nameAmount = 0;
		this.names = [];
		this.paras = {};
		this.isNormal = true;
		this._disableSubmit = null;
		this.extJoinFun = null;
		this.putDoneFun = null;
		var i = 0;
		while(this.elements[i])
		{
			if ( this.elements[i].name )
			{
				$(this.elements[i]);
				var result = this.elements[i].parentLoop(function(_obj)
				{	
					return _obj.style.display == 'none';
				},'FORM');
				if ( !result && typeof this.paras[this.elements[i].name] == 'undefined' )
				{
					if ( this.elements[i].type == 'select-multiple' && !this.elements[i].noSelectAll ) this.multipleNames.push(this.elements[i].name);
					if ( this.elements[i].type == 'button' )
					{
						if ( this.elements[i].name && this.elements[i].getAttribute('is_submit') )
						{
							this.setSubmitBtn(this.elements[i].name,this.elements[i].getAttribute('is_submit'));
						}
					}
					else
					{
						this.paras[this.elements[i].name] = '';
						this.names.push(this.elements[i].name);
						this.nameAmount = -(~this.nameAmount);
					}
				}
				result = null;
			}
			i = -(~i);
		}
		i = null;
	};
	this.submitReqParas = function()
	{
		var name,i = 0;
		while( (name = this.names[i]) )
		{
			if ( typeof this.paras[name] == 'object' && this.paras[name].length > 0 )
				Req.addPostParas(name.replace("[]",''),this.paras[name]);
			else Req.addPostParas(name,this.paras[name]);
			i = -(~i);
		}
		if ( typeof this.extJoinFun == 'function' )
		{
			try{ name = this.extJoinFun(); if ( !name ){Req.clearPostParas();return;}} catch (e){}
		}
		name = null; i =null;
		if ( typeof this.putDoneFun == 'function' ) this.putDoneFun.apply(this);
	};
	this.doDisableSubmit = function()
	{
		if ( this._disableSubmit )
		{
			this._disableSubmit[0].disabled = arguments.length && arguments[0] ? true : false;
			this._disableSubmit[0].value = arguments.length && arguments[0] ? this._disableSubmit[1] : this._disableSubmit[2];
		}
	};
	this.setSubmitBtn = function(_name,_title)
	{
		try
		{
			if ( this.elements[_name] ) this._disableSubmit = [this.elements[_name],_title,this.elements[_name].value];
		}catch (e){alert('modForm.setDisableSubmit:'+e.message);}finally{_name = null;_title = null;}
	};
	this.security = function(_name,_val)
	{
		var _find = this.elements[_name].getAttribute('security');
		var result = true;
		var errMsg = '';
		if ( _find )
		{
			_find = _find.match(/\{([^\{\}]+)\}/ig);
			if ( _find && _find.length )
			{
				var tmp;i = 0;
				for ( i;i<_find.length;i++ )
				{
					tmp = _find[i].match(/([^\{\}]+):([^\{\}]*)/i);
					tmp[1] = String(tmp[1]).toLowerCase();
					if ( tmp && tmp.length == 3 )
					{
						switch(tmp[1])
						{
							case 'type':
								tmp[2] = String(tmp[2]).toLowerCase();
								if ( result && String(_val).len() > 0 )
								{
									switch(tmp[2])
									{
										case 'email':
											result = (/^([a-zA-Z0-9_\.\-])+\@{1,1}(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/).test(_val);
											errMsg = "不正確的郵件地址-"+errMsg;
											break;
										case 'fix':
											break;
										case 'float':
											result = (/^([0-9])+\.{1,1}([0-9])+$/).test(_val);
											errMsg = "不正確的數字-"+errMsg;
											break;
										case 'int':
											result = (/^([0-9])+$/).test(_val);
											errMsg = "不正確的數字-"+errMsg;
											break;
										case 'letter':
											result = (/^([a-zA-Z])+$/).test(_val);
											errMsg = "含非法字母-"+errMsg;
											break;
										case 'phone':
											result = (/^([0-9-])+$/).test(_val);
											errMsg = "不正確的電話號碼-"+errMsg;
											break;
									}
								}
								break;
							case 'position':
								errMsg = errMsg + tmp[2];
								break;
							case 'limit':
								tmp[2] = tmp[2].split("-");
								tmp[2][0] = parseInt(tmp[2].length == 1 ? 0 : tmp[2][0]);
								if ( isNaN(tmp[2][0]) ) tmp[2][0] = 0;
								tmp[2][1] = parseInt(tmp[2].length == 1 ? tmp[2][0] : tmp[2][1]);
								if ( isNaN(tmp[2][1]) ) tmp[2][1] = 0;
								if ( tmp[2][0] > 0 && String(_val).len() < tmp[2][0] )
								{
									errMsg = "長度不滿足最小值「"+tmp[2][0]+"」-"+errMsg;
									result = false;
								}
								else if ( tmp[2][1] > 0 && String(_val).len() > tmp[2][1] )
								{
									errMsg = "長度超過最大值「"+tmp[2][1]+"」-"+errMsg;
									result = false;
								}
								break;
						}
					}
				}
			}
		}
		if ( !result ) this.alert(_name,errMsg);
		return result;
	};
	this.alert = function(_name,tmp)
	{
		tmp = tmp.split("-");
		tmp[1] = tmp[1] || 'left';
		this.elements[_name].setAttribute('info_'+tmp[1]+'_config','red');
		Msg.__buildElement(this.elements[_name],tmp[1],tmp[0] == '1' ? '不能為空' : tmp[0]);
		this.isNormal = false;
	};
};
$addMethod(modForm.prototype,'setParas',function(_name)
{
	try
	{
		var tmp,_val = null;
		switch($type(this.elements[_name]))
		{
			case 'collection':
				_val = this.elements[_name];
				this.paras[_name] = [];
				for ( var i = 0;i<_val.length;i++ )
				{
					if ( _val[i].checked && !_val[i].disabled )
					{
						if ( _val[i].type == 'checkbox' ) this.paras[_name].push(_val[i].value)
						else
						{
							this.paras[_name] = _val[i].value;
							break;
						}
					}
				}
				break;
			case 'element':
				_val = this.elements[_name].get();
				tmp = this.elements[_name].getAttribute('tip');
				if ( tmp ) _val = _val.replace(tmp,'');
				tmp = this.elements[_name].getAttribute('required');
				if ( typeof tmp == 'string' && !_val.length ) this.alert(_name,tmp);
				else
				{
					if ( _name.indexOf("[]") > 1 )
					{
						if ( typeof this.paras[_name] != 'object') this.paras[_name] = [];
						this.paras[_name].push(_val);
					}
					else if ( this.security(_name,_val) )  this.paras[_name] = _val;
				}
				break;
		}
	}
	catch (e){alert('modForm.setParas(1):'+e.message);}finally{_val = null;_name = null;tmp = null;}
});
$addMethod(modForm.prototype,'setParas',function()
{
	try
	{
		if ( this.nameAmount > 0 )
		{
			this.doDisableSubmit(true);
			var i = 0;
			while( (this.names[i]) )
			{
				this.setParas(this.names[i]);
				i = -(~i);
			}
			if ( !this.isNormal ) this.doDisableSubmit();
			i = null;
		}
	}
	catch (e){alert('modForm.setParas(0):'+e.message);}finally{_val = null;_name = null;}
});
$addMethod(modForm.prototype,'put',function()
{
	this.put(Url.get());
});
$addMethod(modForm.prototype,'put',function(_url)
{
	this.setParas();
	if ( this.isNormal )
	{
		if ( typeof _url == 'function' ) this.put(Url.get(),_url);
		else
		{
			this.submitReqParas();
			if ( typeof _url == 'string' && _url.indexOf("http://") == -1 ) _url = Url.getHead() + _url;
			_url = Url.format(_url) + Req.getPostParas(true);
			Req.makeRequest(_url,function(_ajax)
			{
				this.doDisableSubmit();
				if ( _ajax && _ajax.responseText.length ) alert(_ajax.responseText); _self = null;
			},this);
		}
	}
});
$addMethod(modForm.prototype,'put',function(_url,_callBack)
{
	this.setParas();
	if ( this.isNormal )
	{
		this.submitReqParas();
		if ( typeof _callBack == 'function' )
		{
			Req.makeRequest(_url || Url.get(),function(_1)
			{
				this.doDisableSubmit();
				_callBack.apply(this,arguments);
			},this);
		}
		else this.put(_url);
	}
});
modForm = new modForm;
var modIframe = new function()
{
};
var modField = new function()
{
	this.set= function(_val)
	{
		if ( this.nodeName == 'INPUT')
		{
			if ( typeof obj.length == 'undefined'  ) this.value = _val;
			else
			{
				try
				{
					var i = 0;
					while( this[i] )
					{
						if ( this[i].value == _val )
						{
							this[i].checked = true;
							if ( this[i].type == 'radio' ) break;
						}
						i = - (~i);
					}
				}
				catch (e){alert('modField.set:'+e.message);}finally{ i = null;}
			}
		}
		else this.value = _val;
	};
	this.get= function()
	{
		if ( this.nodeName == 'INPUT')
		{
			if ( typeof this.length == 'undefined' )
			{
				return this.getAttribute('tip') == this.value ? '' : this.value;
			}
			else
			{
				try
				{
					var i = 0;
					var paras =  [];
					while( this[i] )
					{
						if ( this[i].checked )
						{
							if ( this[i].type == 'checkbox' ) paras.push(this[i].value);
							else
							{
								paras = this[i].value;
								break;
							}
						}
					}
					return paras;
				}catch (e){alert('modField.get:'+e.message);}finally{i = null;paras = null;}
			}
		}
		else return this.getAttribute('tip') == this.value ? '' : this.value;
	};
};
function $()
{
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) 
	{
		var element = arguments[i];
		if (typeof element == 'string') element = document.getElementById(element);
		if ( element )
		{
			$extend(element,modMethod);
			switch(element.nodeName)
			{
				case 'INPUT':
				case 'TEXTAREA':
					$extend(element,modField);
					break;
				case 'SELECT':
					$extend(element,modSelect);
					break;
				case 'FORM':
					$extend(element,modForm);
					break;
				case 'IFRAME':
					$extend(element,modIframe);
					break;
			}
		}
		else 
		{
			element = new Object;
			$extend(element,modMethod);
		}
		if ( typeof element.init == 'function' )element.init();
		if (arguments.length == 1) return element;
		elements.push(element);
	}
	return elements;
}
function $N(_name,_win){if ( !_name || _name == '' ) return null;_win = _win || self;if ( _win.document ) return _win.document.getElementsByName(_name); else return null;}
function $T(_tag,_doc){if ( !_tag || _tag == '' ) return null;_doc = _doc || document;if ( _doc ) return _doc.getElementsByTagName(_tag); else return null;}
// 獵取目標對象的屬性
function $type(obj)
{
	if (obj == undefined) return false;
	if (obj.$family) return obj.$family;
	if (obj.htmlElement) return 'element';
	var type = typeof obj;
	if (obj.nodeName)
	{
		switch (obj.nodeType)
		{
			case 1: return 'element';
			case 3: return (/\S/).test(obj.nodeValue) ? 'textnode' : 'whitespace';
		}
	}
	else if (typeof obj.length == 'number')
	{
		if (obj.item) return 'collection';
		if (obj.callee) return 'arguments';
		if (type == 'object') return 'array';
	}
	if (type == 'number' && !isFinite(obj)) return false;
	return type;
}
function $P(_obj,_sNodeName)
{
	if ( !_obj ) return null;
	_sNodeName = _sNodeName || 'FORM';
	if ( _obj.nodeName == _sNodeName ) return _obj;
	_obj = $(_obj.parentElement ? _obj.parentElement : (_obj.parentNode ? _obj.parentNode : _obj.offsetParent));
	return _obj.elementExists() ? $P(_obj,_sNodeName) : null;
}
function $O(_obj,_aMatch,_attrName)
{
	if ( !_aMatch || !_obj ) return null;
	_attrName = _attrName || 'id';
	_aMatch = $splat(_aMatch);
	if ( _obj.getAttribute && (_aMatch.exists(_obj.getAttribute(_attrName)) || _aMatch.exists(_obj) || _aMatch.exists(_obj.nodeName)) ) return _obj;
	else
	{
		_obj = $(_obj.parentElement ? _obj.parentElement : (_obj.parentNode ? _obj.parentNode : _obj.offsetParent));
		return _obj.elementExists() ? $O(_obj,_aMatch,_attrName) : null;
	}
}
function lastChild(_obj)
{
	if ( !_obj ) return;
	if ( _obj.childNodes )
	{
		var _max_idx =  _obj.childNodes.length - 1;
		while(_max_idx > 0 && _obj.childNodes[_max_idx].nodeName == '#text' )
		{
			_max_idx = ~-_max_idx;
		}
		return _max_idx >= 0 ? _obj.childNodes[_max_idx] : null;
	}
	else return null;
}
function MM_findObj(n, d) 
{
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length){
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_dragLayer(objName,e) 
{
	var i,j,aLayer,retVal,curDrag=null,curoutPut=null,curLeft,curTop,IE=document.all,NS4=document.layers;
	var NS6=(!IE&&document.getElementById), NS=(NS4||NS6); if (!IE && !NS) return false;
	retVal = true;
	if(IE && event ) event.returnValue = true;
	if (MM_dragLayer.arguments.length > 1 )
	{
		e   =   window.event||e; 
		if(!document.curDrag) document.curDrag = MM_findObj(objName);
		with(document.curDrag)
		{
			MM_dragOk = true;
			MM_oldX = offsetLeft || 0;
			MM_oldY = offsetTop || 0;
			MM_oldClientX = e.clientX;
			MM_oldClientY = e.clientY;
		}

		document.onmousedown = MM_dragLayer; 
		document.onmouseup = MM_dragLayer;
		if (NS) document.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
	}
	else
	{
		var theEvent = ((NS)?objName.type:event.type);
		if (theEvent == 'mousedown') 
		{
			if (document.curDrag) 
			{
				if (NS) document.captureEvents(Event.MOUSEMOVE);
				document.onmousemove = MM_dragLayer;
				retVal = false; if(!NS4&&!NS6) event.returnValue = false;
			}
		}
		else if (theEvent == 'mousemove') 
		{
			if (document.curDrag) with (document.curDrag) 
			{
				var mouseX = (NS)?objName.pageX : event.clientX + document.body.scrollLeft;
				var mouseY = (NS)?objName.pageY : event.clientY + document.body.scrollTop;
				if (NS4) 
				{
					left = MM_oldX - (MM_oldClientX - mouseX);
					top = MM_oldY - (MM_oldClientY - mouseY) - window.pageYOffset;
				}
				else if (NS6)
				{
					style.left = (MM_oldX - (MM_oldClientX - mouseX)) + "px"; 
					style.top = (MM_oldY - (MM_oldClientY - mouseY)- window.pageYOffset) + "px";
				}
				else
				{
					style.pixelLeft = MM_oldX - (MM_oldClientX - mouseX); 
					style.pixelTop = MM_oldY - (MM_oldClientY - mouseY);
				}
				retVal = false; if(!NS) event.returnValue = false;
			}
		}
		else if (theEvent == 'mouseup') 
		{
			if (NS) document.releaseEvents(Event.MOUSEMOVE);
			if (NS) document.captureEvents(Event.MOUSEDOWN); 
			if (document.curDrag) with (document.curDrag) {retVal = false; if(!NS) event.returnValue = false;}
			document.curDrag = null;
		}
		//if (NS) document.routeEvent(objName);
	}
	return retVal;
}
function unmarkAllPrompt(form)
{
	var _tags = $T('div',form);
	var i = 0;
	while(_tags[i])
	{
		if ( _tags[i].prompt )
		{
			_tags[i].prompt = false;
			_tags[i].style.display = 'none';
		}
		i = -(~i);
	}
}
function unmarkAllFields(form) 
{
	for (i = 0; i < form.elements.length ; i++) 
	{
		form.elements[i].style.backgroundColor = "";
	}
}
function markTheField(obj,nofocus) 
{
	if(obj[0])
	{
		var i = 0;
		while(obj[i])
		{
			obj[i].style.backgroundColor = "#FFF8CE";
			i = -(~i);
		}
	}
	else
	{
		if ( !nofocus )obj.focus();
		obj.style.backgroundColor = "#FFF8CE";
	}
}
// 整理使用者於表單上的輸入

function refineUserEntry(theForm)
{
	for (var i = 0; i < theForm.elements.length; i++) 
	{
		if (theForm.elements[i].type == "text") {
			theForm.elements[i].value = toSafeStr(theForm.elements[i].value);
		}
	}
}
// 安全字串轉換

function toSafeStr(strMessage) 
{
	var strResult;
	var charTemp;
	var str;
	var safeStr = '';

	str = strMessage.trim();

	for (var i = 0; i < str.length; i++) 
	{
		charTemp = str.charAt(i);
		if ( charTemp == "\"") charTemp = "」";
		if ( charTemp == "'")charTemp = "』";
		safeStr = safeStr + charTemp;
	}
	return safeStr;
}
function regExpressionValid(controlToValidID,validationExpression,msgSpanID,errMsg,nofocus)
{
	var objRegExp = new RegExp(validationExpression,"g");
    var objControlToValid=typeof controlToValidID == 'string' ? $(controlToValidID) : controlToValidID;
	var isValid=objRegExp.test(objControlToValid.value);
	if(!isValid)
    {
		var objSpan=null;
		if ( (objSpan = $(msgSpanID)) )
		{
			markTheField(controlToValidID,nofocus);
			objSpan.innerHTML = errMsg;
			objSpan.style.display = 'block';
		}
		return false;
	}
	else return true;
}
function checkRequiredField(field, prompt,field_name, max_length, min_length,nofocus) 
{
	switch(field.type)
	{
		case 'text':
		case 'password':
			return checkTextRequiredField(field, prompt,field_name, max_length, min_length,nofocus);
		default:
			if ( field.nodeName == 'TEXTAREA') return checkTextRequiredField(field, prompt,field_name, max_length, min_length,nofocus);
			return checkEleRequiredField(field, prompt,field_name,nofocus);
	}
}
function checkEleRequiredField(field, prompt,field_name,nofocus)
{
	var checked = false;
	if ( field.length )
	{
		var i = 0;
		while(field[i])
		{
			if ( ( checked = field[i].checked) ) break;
			i = -(~i);
		}
	}
	else checked = field.checked;
	if ( !checked )
	{
		markTheField(field,nofocus);
		if ( typeof prompt == 'string' )
			$prompt(field_name + '未選擇',prompt);
		else
			$alert(field_name + '未選擇');
		return false;
	}
	return checked;
}
function checkTextRequiredField(field, prompt,field_name, max_length, min_length,nofocus) 
{
	var len = field.value.len();
	if ( len == 0) 
	{
		markTheField(field,nofocus);
		if ( typeof prompt == 'string' )
			$prompt(field_name + '未填',prompt);
		else
			$alert(field_name + '未填');
		return false;
	}
	else if ( max_length && len > max_length) 
	{
		markTheField(field,nofocus);
		if ( typeof prompt == 'string' )
			$prompt(field_name + '的長度超過 ' + max_length + ' 個字元',prompt);
		else
			$alert(field_name + '的長度超過 ' + max_length + ' 個字元');
		return false;
	} 
	else if ( min_length  && len < min_length) 
	{
		markTheField(field,nofocus);
		if ( typeof prompt == 'string' )
			$prompt(field_name + '的長度不足 ' + min_length + ' 個字元',prompt);
		else
			$alert(field_name + '的長度不足 ' + min_length + ' 個字元');
		return false;
	}
	len = null;
	return true;
}
function checkIsNeedLoad(obj,index)
{
	if ( obj && obj.length > 0 )
	{
		var i = 0;
		while(obj[i])
		{
			if( i == index ) return obj[i].innerHTML.length;
			i = -(~i);
		}
		i = null;
	}
	return 0;
}
function __doPostBack(eventTarget, eventArgument,actionUrl) 
{
	var theForm = document.forms['form1'];
	if (!theForm)theForm = document.form1;
	if ( theForm && !theForm.onsubmit ) 
	{
		var newElement = null;
		if (!theForm.__EVENTTARGET)
		{
			newElement = document.createElement("<INPUT TYPE='hidden' NAME='__EVENTTARGET' VALUE='"+eventTarget+"'>")
			theForm.insertBefore(newElement);
		}
		if ( !theForm.__EVENTARGUMENT ) 
		{
			newElement = document.createElement("<INPUT TYPE='hidden' NAME='__EVENTARGUMENT' VALUE='"+eventArgument+"'>")
			theForm.insertBefore(newElement);
		}
		theForm.__EVENTTARGET.value = eventTarget;
		theForm.__EVENTARGUMENT.value = eventArgument;
		if ( actionUrl ) theForm.action = actionUrl;
		else if ( !theForm.action ) theForm.action = window.location.href;
		theForm.submit();
	}
}
function getcolor(st, mycolor) { st.style.backgroundColor = mycolor; }
function abar(st) { st.style.backgroundColor = '#FFE6D9'; }
function aabar(st) { st.style.backgroundColor = '#FFFFFF'; }
function isValidEmailFormat(email) 
{
	var rege = /^([a-zA-Z0-9_\.\-])+\@{1,1}(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/;
	if (rege.exec(email) == null) return false; else return true;
}

// 整理使用者於表單上的輸入

function refineUserEntry(theForm) {
	for (var i = 0; i < theForm.elements.length; i++) {
		if (theForm.elements[i].type == "text") {
			theForm.elements[i].value = toSafeStr(theForm.elements[i].value);
		}
	}
}
function isChinese(str) {
	var strlen = str.length;
	if (strlen > 0) {
		var oldstrlen = str.length;
		for (var i = 0; i < strlen; i++) {
			c = '';
			c = escape(str.charAt(i));
			if (c.charAt(0) == '%') {
				cc = c.charAt(1);
				// IE : ~ u, NS : ~ A
				if (cc == 'A' || cc == 'u') {	// 是中文字
					return true;
				}
			}
		}
		return false;
	} else {
		return false;
	}
}
function removeNonChinese(obj) 
{
	var orilen = obj.value.length;
	for (; ;) {
		for (var i = 0; i < chars.length; i++) {
			obj.value = obj.value.replace(chars.charAt(i), "");
		}
		if (orilen == obj.value.length) return;
		orilen = obj.value.length;
	}
}
//打開小窗口
function popUpWindow(url, width, height,name) 
{
	var chasm = screen.availWidth;
	var mount = screen.availHeight;
	if(typeof name != 'undefined') window.name = name;
	var hWnd = window.open(url, '_blank', 'dependent, resizable=yes, scrollbars=yes, width = ' + width + ', height = ' + height + ', left = ' + ((chasm - width - 10) * .5) + ', top = ' + ((mount - height - 30) * .5));
	if ((document.window != null) && ( ! hWnd.opener)) hWnd.opener = document.window;
}
function atLeastOneChecked(opt) 
{
	for (var i = 0; i < opt.length; i++) 
	{
		if (opt[i].checked === true) 
		{
			return true;
			break;
		}
	}
	return false;
}