function addOptions(obj, opt_array){
	if(opt_array==null || obj==null)return;
	var l=obj.options.length;
	if(arguments[2]==1){
		for(var i=0; i<opt_array.length; i+=2)obj.options[l+parseInt(i/2)]=new Option(opt_array[i+1], decodeURI(opt_array[i]));
	}
	else{
		for(var i=0; i<opt_array.length; i+=2)obj.options[l+parseInt(i/2)]=new Option(opt_array[i+1], opt_array[i]);
	}
}
function translate(){
	var np;
	var n=location.pathname.substring(0, 4);
	if(n=='/eng') np='/big5/index.php';
	else np='/eng/index.php';
	var a=location.href.split('?', 2);
	if(a[1])location=np+'?'+a[1];
	else location=np;

}
function addyearoption(obj, baseyr){
	var today=new Date();
	var toyr=today.getFullYear();
	if(arguments[3])toyr=argunebts[3];
	if(toyr<baseyr)toyr=baseyr;
	for(var i=toyr; i>=baseyr; i--) obj.options[obj.options.length]=new Option(i, i);
	if(arguments[2]!=null)setSelect(obj, arguments[2]);
}
function validateemail(email){
	email=email.replace(/(^)(\s*)/g, '$1');
	email=email.replace(/(\s*)($)/g, '$2');
	var i;
	for(i=0; i<email.length; i++){
		if(email.charCodeAt(i)>127) return '';
	}
	if( email.match(/^(.+)@(.+)\.([^.\s]{2,})$/) ) return email;
	return '';
}
//function confirmdel(){
//	var id=arguments[0];
//	var msg=arguments[1];
//
//
//}

function confirmgo(url){
	var msg;
	msg=arguments[2] ? arguments[2] : "Are you sure to delete this item?";
	if(arguments[1])url+="&redirect="+encodeURIComponent(location.href);
	if(confirm(msg))location.href=url;
}

function reloadpage(){
	window.location.reload();
}
function parseprice(p){
	var k=String(p);
	k=k.replace(/[kK]/, '000');
	k=k.replace(/\..*/g, '');
	k=k.replace(/\D/g, '');
	return parseInt(k);
}
function urlmodified(url, name, v){
	if(url==null || url=='')return '';
	var obj=new Object();
	var a=url.split('&');
	if(a==null || a.length==null)return '';
	for(var i=0; i<=a.length; i++){
		if(a[i]==null) continue;
		var a2=a[i].split('=', 2);
		if(a2[1]!=null && a2[1]!='') obj[a2[0]]=a2[1];
	}
	obj[name]=encodeURIComponent(v);
	var r='';
	for(var i in obj)r+="&"+i+'='+obj[i];
	return r.substring(1);
}
function locationmodify(name, v){
	var s=window.location.search.substr(1);
	if(arguments[2] && url2value(s, name)==v)v=arguments[2];
	window.location.search='?'+urlmodified(s, name, v);
}
function url2obj(url){
	var obj=new Object();
	if(url==null || url=='')return obj;
	var a=url.split('&');
	if(a==null || a.length==null)return '';
	for(var i=0; i<=a.length; i++){
		if(a[i]==null) continue;
		var a2=a[i].split('=', 2);
		if(a2[1]!=null && a2[1]!='') obj[a2[0]]=decodeURIComponent(a2[1]);
	}
	return obj;

}
function urlanticache(url){
	var h=url ? url : '';
	var d=new Date();
	return h+(h.indexOf('?')>=0 ? '&' : '?')+"anticache="+d.getTime();
}
function obj2url(obj){
	if(!obj)return '';
	var r='';
	for(var i in obj)r+="&"+i+'='+encodeURIComponent(obj[i]);
	return r.substring(1);
}
function location2obj(){
	return url2obj(window.location.search.substr(1));
}
function locationprechange(vname){
	var obj=url2obj(window.location.search.substr(1));
	delete obj[vname];
	var r=obj2url(obj);
	return '?'+r+'&'+vname+'=';
}
function url2value(url, vname){
	var obj=url2obj(url);
	return obj[vname];
}
function location2value(vname){
	return url2value(window.location.search.substr(1), vname);
}
function toggletr(id, color1, color2){
	var i=0;
	var s=document.getElementById(id);
	if(!(id && s))return;
	for(s=s.firstChild; s!=null; s=s.nextSibling){
		if(tr.style.display=='none' || tr.style.display=='hidden') continue;
		if((++i)%2==1)s.style.backgroundColor=color1;
		else s.style.backgroundColor=color2;
	}
}
function toggletrneibr(id, color1, color2){
	var tr=document.getElementById(id);
	var color=color2;
	var n;
	if(arguments[3]!=null)n=1;
	else n=arguments[3];
	if(tr==null)return;
	for(tr=tr.nextSibling; tr!=null; tr=tr.nextSibling){
		if(tr.style.display=='none' || tr.style.display=='hidden') continue;
		color=color==color1 ? color2 : color1;
		tr.style.backgroundColor=color;
	}
}
function setSelect(s, v){
	if(!s || v===null) return;
	for(var i=0; i<s.options.length; i++){
		if(s.options[i].value==v){
			s.selectedIndex=i;
			return;
		}
	}
	return;
	if(arguments[2]!==null && arguments[2]!=''){
		s.options[s.options.length]=new Option(arguments[2], v);
		s.selectedIndex=s.options.length-1;
	}
}
function setradio(r, v){
	if(r==null || !(r.length>0)) return;
	for(var i=0; i<r.length; i++){
		if(r[i].value==v){
			r[i].checked=1;
			return;
		}
	}
}
function getradiovalue(r){
	if(r && r.length){
		for(var i=0; i<r.length; i++){
			if(r[i].checked) return r[i].value;
		}
	}
	return null;
}
function getselected(s){
	var r=new Object();
	if(!s)return r;
	if(s && s.selectedIndex!=null && (arguments[1] || s.selectedIndex>0)){
		r.value=s.options[s.selectedIndex].value;
		r.text=s.options[s.selectedIndex].text;
	}
	else return false;
	return r;
}
function refreshSelect(s, v, t){
	if(v==null)return;
	if(s.value!=v) {
		s.options[s.options.length]=new Option(t, v);
		s.selectedIndex=s.options.length-1;
	}
	else if(s.options[s.selectedIndex].text!=t) s.options[s.selectedIndex].text=t;
}
function fitPic(p){
	window.open('picture.html?'+p,'fitWindow','height=100,width=100,top=0,left=0,z-lock=1,resizable=1');
}
function chksubmit(f){
	var fds, alt;
	if(arguments[1]!=null && arguments[1]!=''){
		if(arguments[2]==null || arguments[2]=='') arguments[2]=arguments[1];
		fds=arguments[1].split(',');
		alt=arguments[2].split(',');
		for(var i=0; i<fds.length; i++){
			p1=eval('f.'+fds[i]);
			if(p1.value==''){
				alert('�п�J'+alt[i]);
				return false;
			}
		}
	}
	f.submit();
	return true;
}
function fitDialog(){
	var b=document.body;
	window.dialogWidth=parseInt(window.dialogWidth.substring(0, window.dialogWidth.length-2))+b.scrollWidth-b.clientWidth+'px';
	window.dialogHeight=parseInt(window.dialogHeight.substring(0, window.dialogHeight.length-2))+b.scrollHeight-b.clientHeight+'px';
	var x, y;
	x=(window.screen.width-parseInt(window.dialogWidth.substring(0, window.dialogWidth.length-2)))/2;
	y=(window.screen.height-parseInt(window.dialogHeight.substring(0, window.dialogHeight.length-2)))/2;
	if(x>=0)window.dialogLeft=x;
	else window.dialogLeft=0;
	if(y>=0)window.dialogTop=y;
	else window.dialogTop=0;
}

function fitwin(){
	if(window.innerWidth){
		window.resizeBy(document.width-window.innerWidth, document.height-window.innerHeight);
	}
	else if(document.body.clientWidth){
		window.resizeBy(document.body.scrollWidth-document.body.clientWidth, document.body.scrollHeight-document.body.clientHeight);
	}
}

function dialogclose(){
	opener.location.reload();
	window.close();
}

function centerwin(){
	var x, y;
	if(window.outerWidth){
		x=(screen.availWidth-window.outerWidth)/2;
		y=(screen.availHeight-window.outerHeight)/2;
	}
	else if(document.body.offsetWidth){
		x=(screen.availWidth-document.body.offsetWidth)/2;
		y=(screen.availHeight-document.body.offsetHeight)/2;
	}
	if(x>0 && y>0)window.moveTo(x,y);
}

function getoffset(obj){
	var x=0, y=0;
	var o;
	for(o=obj;o;o=o.offsetParent){
		x+=o.offsetLeft;
		y+=o.offsetTop;
	}
	return [x, y];
}

function mousepos(e){

	var e=arguments[0] ? arguments[0] : window.event;
	var x=0, y=0;

	if(e.clientX || e.clientY){
		x=parseInt(e.clientX)+parseInt(document.body.scrollLeft);
		y=parseInt(e.clientY)+parseInt(document.body.scrollTop);
	}
	else if(e.pageX || e.pageY){
		x=e.pageX;
		y=e.pageY;
	}
	return [x, y];
}

function modalOpen(url){
	return showModalDialog(url, window, "status:0;resizable:1;");
}
//function popupOpen(url, w, h){
//	if(!w)w=600;
//	if(!h)h=400;
//	var win = window.open (url,"winemailfriend", "toolbar=no,location=no,directories=no,status=0,menubar=no,scrollbars=yes,resizable=1,width=" + w + ",height=" + h);
//	win.focus();
//}

function popupOpen(url, w, h){
	var name=arguments[3] ? arguments[3] : 'winemailfriend';

	if(!w)w=600;
	if(!h)h=400;
	var win = window.open (url,name, "toolbar=no,location=no,directories=no,status=0,menubar=no,scrollbars=yes,resizable=1,width=" + w + ",height=" + h);
	win.focus();
}
function placecenter(obj, ow, oh){
	var ww=0, wh=0, top=0, left=0;
	if(window.innerWidth){
		ww=window.innerWidth;
		wh=window.innerHeight;
		top=parseInt((wh-oh)/2)+window.pageYOffset;
		left=parseInt((ww-ow)/2)+window.pageXOffset;
	}
	else if(document.body.clientWidth){
		ww=document.body.clientWidth;
		wh=document.body.clientHeight;
		top=parseInt((wh-oh)/2)+document.body.scrollTop;
		left=parseInt((ww-ow)/2)+document.body.scrollLeft;
	}
	obj.style.top=top>0 ? top :100;
	obj.style.left=left>0 ? left : 100;
}

function setCookie(name, value){
	var r=name+"="+escape(value)+';';
	var k;
	if(arguments[2]==null || arguments[2]=='')k=7;
	else k=parseInt(arguments[2]);
	if(k>0 || k<0){
		var n=new Date();
		nd=n.getDate();
		n.setDate(nd+k);
		r+=" expires="+n.toGMTString();
	}
	var path, domain;
	if(arguments[3]==null) path='/';
	if(arguments[4]==null) domain='.gocarsite.com';
	if(path!='')r+="; path="+path;
	if(domain!='')r+="; domain="+domain;
	document.cookie=r;
}
function getCookie(name){
	var reg=new RegExp('(?:^|\\W)'+name+"=([^;]*)");
	var r=reg.exec(document.cookie);
	if(r==null)return '';
	r=RegExp.$1;
	if(!r)return '';
	return unescape(r);
}
function keySearch(ar, v){
	for(var i=0; i<ar.length; i+=2) {
		if(ar[i]==v) return i;
	}
	return -1;
}
function showHide2(e, sh){
	var i, j;
	var d=[{display : 'none', visibility : 'hidden'}, {display : '', visibility : 'visible'}];
	for(i=0; i<e.length; i++){
		for(j=0; j<e[i].length; j++){
			e[i][j].style.display=d[sh[i]].display;
			e[i][j].style.visibility=d[sh[i]].visibility;
		}
	}
}
function showHide(e, sh){
	var i, j;
	var d=[{display : 'none', visibility : 'hidden'}, {display : '', visibility : 'visible'}];
	for(i=0; i<e.length; i++){
		for(j=0; j<e[i].length; j++){
			e[i][j].style.display=d[sh[i]].display;
			e[i][j].style.visibility=d[sh[i]].visibility;
		}
	}
}
function elementshowhide(obj){
	if(!obj)return;
	if(arguments[1]){
		obj.style.display='';
		obj.style.visibility='';
	}
	else{
		obj.style.display='none';
		obj.style.visibility='hidden';
	}
}

function SelectLicenceDue(sy, sm, ldon){
	this.ldchanged=function(){
		if(this.sy.value==''){
			this.ldon.style.display='none';
			this.ldon.style.visiblility='hidden';
		}
		else {
			this.ldon.style.display='inline';
			this.ldon.style.visibility='visible';
		}
	}
	this.setld=function(ld){
		if(ld=='') setSelect(this.sy, '');
		else{
			var y=ld.substring(0, 4), m=ld.substring(5,7);
			setSelect(this.sy, y);
			setSelect(this.sm, m);
		}
		this.ldchanged();
	}
	this.getld=function(){
		return this.sy.value=='' ? '' : this.sy.value+'-'+this.sm.value;
	}
	this.ldon=ldon;
	this.sm=sm;
	this.sy=sy;
	var today=new Date();
	var toyr=today.getFullYear();
	for(var i=toyr+1; i>=toyr; i--){
		this.sy.options[this.sy.options.length]=new Option(i, i);
	}
	for(var i=1; i<13; i++){
		var j=i<10 ? '0'+i : i;
		this.sm.options[this.sm.length]=new Option(j, j);
	}
}
function SelectLicenceDue_create(vname, sy, sm, ldon){
	eval(vname+"=new SelectLicenceDue(sy, sm, ldon);");
	eval("sy.onchange=function(){"+vname+".ldchanged();};");
}

function ModifyNew(f, m, n, cnt){
	this.modname=m;
	this.newname=n;
	this.cntname=cnt;
	this.colormodify='#ccffcc';
	this.colornew='#dddddd';
	this.f=f;

	this.setmode=function (){
		if(arguments[0]=='new') this.f.id.value='';
		var e=[], sh;
		e[0]=document.getElementsByName(this.modname);
		e[1]=document.getElementsByName(this.newname);
		sh= this.f.id.value=='' ? [0, 1] : [1, 0];
		showHide(e, sh);

		var c=document.getElementById(this.cntname);
		c.style.backgroundColor=this.f.id.value==''  ? this.colornew : this.colormodify;
	}
}


function ActSelect(select, act, opt){

	this.loadOptions1=function(ops){
		var o=this.select.options;
		for(var i=o.length; i>0; i--)o[i]=null;
		if(ops!=null)addOptions(this.select, ops);
		else {
			if(this.predecessor==null) addOptions(this.select, this.opt);
			else {
				var v=this.predecessor.select.value;
				if(v!='') addOptions(this.select, this.opt[v]);
			}
		}
		this.selectChanged();
	}
	this.loadOptions=function(ops){this.loadOptions1(ops);}

	this.setSelect1=function(v){
		setSelect(this.select, v);
		this.selectChanged();
	}
	this.setSelect=function(v){this.setSelect1(v);}

	this.refreshSelect1=function(id, name){
		var a=this.select.value;
		refreshSelect(this.select, id, name);
		if(this.select.value!=a) this.selectChanged();
	}
	this.refreshSelect=function(id, name){this.refreshSelect1(id, name);}

	this.editSelect1=function(){
		if(this.act==null) return;
		var v=this.select.value, a=this.act.value;
		var rv;

		switch(a){
			case 'new':
				var extra=this.predecessor==null ? '' : "&"+this.predecessor.select.name+"="+this.predecessor.select.value;
				rv=showModalDialog('?w=modal&act=form&o='+this.select.name+extra, window,'status:0;resizable:1;');
				break;
			case 'edit':
				rv=showModalDialog('?w=modal&act=form&o='+this.select.name+'&id='+v,window,'status:0;resizable:1;');
				break;
			case 'delete':
				if(confirm("Are you sure to delete \""+this.select.options[this.select.selectedIndex].text+"\" ?")) rv=showModalDialog('?w=modal&act=delete&id='+v+'&o='+this.select.name,window,'status:0;resizable:1;dialogWidth:250px;dialogHeight:150px;');
				break;
			default:
				return;
		}
		if(rv!=null) {
			this.modalvalue=rv;
			this.selectEdited(rv);
		}
		this.act.selectedIndex=0;
		this.act.blur();
	}
	this.editSelect=function(){this.editSelect1();}

	this.selectEdited1=function(obj){
		if(this.act==null)return;
		var i=this.select.value, iname=this.select.options[this.select.selectedIndex].text, j=this.act.value;
		if(this.loadframe!='')document.frames(this.loadframe).history.go(0);
		var opt;
		if(this.predecessor==null) opt=this.opt;
		else{
			if(this.opt[this.predecessor.select.value]==null) this.opt[this.predecessor.select.value]=new Array();
			opt=this.opt[this.predecessor.select.value];
		}

		if(j=='delete'){
			var k=keySearch(opt, i);
			if(k>=0)opt.splice(k, 2);
			this.select.options[this.select.selectedIndex]=null;
		}
		else{
			if(obj.id==null)return;

			if(j=='new')opt.push(obj.id, obj.name);
			else if(obj.name!=iname){
				var k=keySearch(opt, i);
				if(k>=0)opt[k+1]=obj.name;
			}
			this.refreshSelect(obj.id, obj.name);
		}
		if(i!=this.select.value)this.selectChanged();
	}
	this.selectEdited=function(obj){this.selectEdited1(obj);}

	this.refreshAct1=function(){
		if(this.act==null)return;
		var o=this.act.options, i=this.select.selectedIndex;
		if(this.select.value==''){
			o[3]=null;
			o[2]=null;
		}
		else{
			if(o[2]==null)o[2]=new Option('Edit', 'edit');
			if(o[3]==null)o[3]=new Option('Delete', 'delete');
		}
		if(this.predecessor!=null){
			if(this.predecessor.select.value=='')this.act.options[1]=null;
			else if(this.act.options[1]==null)this.act.options[1]=new Option('New', 'new');
		}
	}
	this.refreshAct=function(){this.refreshAct1();}

	this.selectChanged1=function(){
		this.preChange();
		this.refreshAct();
		if(this.successor!=null) this.successor.loadOptions();
		this.postChange();
	}
	this.selectChanged=function(){this.selectChanged1();}

	this.preChange=function(){};
	this.postChange=function(){};

	this.select=select;
	this.act=act;
	this.opt=opt;
	this.predecessor=null;
	this.successor=null;
	this.vname='';
	this.handler='general.php';
	this.loadframe='';
	if(this.act!=null){
		this.act.options[0]=new Option('(Action)', '');
		this.act.options[1]=new Option('New', 'new');
	}
	if(this.select.options.length<1)this.select.options[0]=new Option('', '');
	this.modalvalue=null;
}
function ActSelect_create(vn, select, act, opt){
	eval(vn+'=new ActSelect(select, act, opt);'+vn+'.vname=vn;');
	eval("select.onchange=function(){"+vn+'.selectChanged();}');
	if(act!=null)eval("act.onchange=function(){"+vn+'.editSelect();}');
	if(arguments[4]!=null) eval(vn+".handler=arguments[4];");
}
function ActSelect_link(pre, suc){
	pre.successor=suc;
	suc.predecessor=pre;
}


function TextEditor(ta){
	this.ta=ta;

	this.addurl=function(){
		var u=prompt("Pls enter the url:", 'http://');
		if(u=='' || u==null) return 0;
		var t=prompt("pls enter the link text:", 'Link');
		if(t!='' && t!=null) this.insertstr("[url="+u+"]"+t+"[/url]");
	}
	this.addimg=function(){
		var u=prompt("Pls enter the url:", 'http://');
		if(u=='' || u==null) return 0;
		this.insertstr("[img]"+u+"[/img]");
	}
	this.addtag=function(t){
		var p='';
		if(arguments[1]!=null)p=arguments[1]+'=';
		if(t.value!='') this.insertstr('['+p+t.value+']');
		t.selectedIndex=0;
	}

	this.matchnum=function(exp, st){
		var reg=new RegExp(exp, 'gi');
		var r=st.match(reg);
		return (r && r.length) ? r.length : 0;
	}

	this.closealltag=function(){
		var c=this.ta.value;
		var a=['u', 'i', 'b', 'font=(?:\\w*?)', 'size=(?:\\w*?)', 'color=(?:\\w*?)'];
		var endt, d, d1;

		for(var i in a){
			endt=a[i].split('=', 2);
			d=matchnum('\\['+a[i]+'\\]', c)-matchnum('\\[/'+endt[0]+'\\]', c);
			if(d>0){
				for(d1=d; d1>0; d1--)c+='[/'+endt[0]+']';
			}
		}
		this.ta.value=c;
		this.insertstr('');
	}

	this.insertstr=function(str){
		this.ta.focus();
		var str1='';
		if(arguments[1])str1=arguments[1];
		if(document.selection){
			var range=document.selection.createRange();
			range.text=str+str1;
			if(str1){
				range.moveStart('character', -str1.length);
				range.moveEnd('character', -str1.length);
			}
			range.select();
		}
		else if(this.ta.selectionStart!=null){
			var sstart=this.ta.selectionStart;
			this.ta.value=this.ta.value.substr(0, this.ta.selectionStart)+str+str1+this.ta.value.substr(this.ta.selectionEnd);
			this.ta.selectionStart=this.ta.selectionEnd=sstart+str.length;

		}
		else{
			this.ta.value+=str+str1;
		}
	}
}


function SearchEdit(modefield, dtmode, dtprice){
	if(arguments[3]!=null)this.prefix=arguments[3];
	else this.prefix='';

	this.editallform=document[this.prefix+'editallform'];
	this.searcheditform=document[this.prefix+'searcheditform'];
	this.sfield_mode=modefield;
	this.sdt_mode=dtmode;
	this.sdt_price=dtprice;
	this.outdata_mode=new Array();
	this.outdata_price=new Array();
	var m;
	for(var i in this.sdt_mode){
		m=this.searcheditform['mode'+i];
		addOptions(m, this.sfield_mode);
		setSelect(m, this.sdt_mode[i]);
	}

	this.setvalue=function (name, value){
		var f=this.searcheditform;
		if(f[name])f[name].value=value;
	}
	this.getvalue=function (name){
		var f=this.searcheditform;
		if(f[name])return f[name].value;
		return null;
	}
	this.quickedit=function(id){
		var f=this.searcheditform;
		var qf=this.editallform;
		qf.ids.value=id;
		qf.modes.value=parseInt(this.getvalue('mode'+id));
		qf.prices.value=parseprice(this.getvalue('price'+id));
		qf.submit();
	}
	this.editall=function(){
		var ai=new Array();
		var am=new Array();
		var ap=new Array();
		for (var k in this.outdata_mode){
			ai.push(k);
			am.push(this.outdata_mode[k]);
			ap.push(this.outdata_price[k]);
		}
		var f=this.editallform;
		f.ids.value=ai.join(',');
		f.modes.value=am.join(',');
		f.prices.value=ap.join(',');
		f.submit();
	}
	this.infoedited=function(id){
		var tr=document.getElementById(this.prefix+'schtr'+id);
		var f=this.searcheditform;
		var c='#aaffbb';
		var price=this.getvalue('price'+id);
		var mode=this.getvalue('mode'+id);

		if(price!=this.sdt_price[id] || mode!=this.sdt_mode[id]){
			if(tr.style.backgroundColor!=c){
				tr.lastcolor=tr.style.backgroundColor;
				tr.style.backgroundColor=c;
			}
			this.outdata_mode[id]=parseInt(mode);
			this.outdata_price[id]=parseprice(price);
		}
		else{
			delete this.outdata_mode[id];
			delete this.outdata_price[id];
			tr.style.backgroundColor=tr.lastcolor;
		}
	}

}

function ProgressBar(){
	this.color1='#222';
	this.color2='red';
	this.bgcolor='#f2f2f2';
	this.bordercolor='#888';
	this.width=250;
	this.height=103;
	this.length=13;
	this.barlength=1;
	this.tbid='progresstb';
	this.trid='progresstr';
	this.current=null;
	this.speed=1300;
	this.vname='progressbar';

	if(arguments[0]){
		for(var i in arguments[0])this[i]=arguments[0][i];
	}

	this.init=function (){
		var r='', len=this.length+this.barlength, xstyle='';
		for(var i=0; i<len; i++){
			xstyle=i>this.length ? "display:none;visibility:hidden;" : "";
			r+="<td style='font-weight:bold;vertical-align:middle; line-height:10px;font-size:20px;background-color:"+this.color1+";"+xstyle+"'>&nbsp;";
		}
		document.write("<table id='"+this.tbid+"' width='"+this.width+"' height='"+this.height+"' style='background-color:"+this.bgcolor+";z-index:3;position:absolute;border:1px solid "+this.bordercolor+";display:none;visibility='hidden;'><tr><td align='center' valign='middle'>��ƤW��, �еy��...<div style='line-height:6px;'>&nbsp;</div><table class='box center' align='center' cellspacing='4'><tr id='"+this.trid+"' >"+r+"</table></table>");
		var par=document.getElementById(this.trid);
		this.current=par.lastChild;
	}
	this.animate=function(){
		var i, o1, o2;
		var par=document.getElementById(this.trid);
		o1=this.current;
		o2=o1.nextSibling ? o1.nextSibling : par.firstChild;
		this.current=o2;

		var n=this.barlength;
		for(i=0;i<n;i++){
			if(o1){
				o1.style.backgroundColor=this.color1;
				o1=o1.previousSibling ? o1.previousSibling : par.lastChild;
			}
			if(o2){
				o2.style.backgroundColor=this.color2;
				o2=o2.previousSibling ? o2.previousSibling : par.lastChild;
			}
		}
		var tb=document.getElementById(this.tbid);
		placecenter(tb, this.width, this.height);
		setTimeout(this.vname+".animate()", '1300');
	}
	this.start=function(){
		var tb=document.getElementById(this.tbid);
//		placecenter(tb, this.width, this.height);
		tb.style.display='';
		tb.style.visibility='';
		this.animate();
	}

}
function ProgressBar_create(vn){
	eval(vn+"=new ProgressBar();"+vn+".vname='"+vn+"';");
}
function loadimage(img){	//used in <img>, called by onload, img usually is 'this'
	var w=0.7;
	if(arguments[1]) w=arguments[1];
	this.alt='�I;�ݭ��';
	this.img=img;

	this.img_load=function(){
		if(this.img.width>screen.width*w){
			var src=this.img.src;
			this.img.resized=true;
			this.img.width=screen.width*w;
			this.img.alt=this.alt;
			this.img.onmourseover=this.mourse_over();
			this.img.onclick=function(){window.open(src);};
		}
	}
	this.mourse_over=function(){
		this.img.style.cursor='hand';
		this.img.alt=this.alt;
	}
	this.img_load();
}

function setDate(year, month, date){
	this.begin_year=-2;
	this.end_year=8;
	this.year=year;
	this.month=month;
	this.date=date;
	this.year_v='';
	this.month_v='';
	this.date_v='';
	if(arguments[3]){
		this.year_v=arguments[3].substr(0,4);
		this.month_v=arguments[3].substr(5,2);
		this.date_v=arguments[3].substr(8,2);
	}
	if(this.year_v==0 || this.month_v==0 || this.date_v==0){
		this.year_v='';
		this.month_v='';
		this.date_v='';
	}
	this.loadYear=function(){
		var d=new Date();
		var current_year = d.getFullYear();
		for(var i=current_year + this.begin_year; i<current_year + this.end_year; i++){
			this.year.options[this.year.options.length]=new Option(i,i);
		}
	}
	this.loadMonth=function(){
		var v;
		for(var i=1;i<=12;i++){
			v= i<10 ? '0'+i : i;
			this.month.options[this.month.options.length]=new Option(v,v);
		}
	}
	this.loadDate=function(){
		var d, v;
		var y=this.year.options[this.year.selectedIndex].value;
		var m=this.month.options[this.month.selectedIndex].value;
		if(y=='' || m=='') return;
		if(m==2){
			if(y%4==0) d=29;
			else d=28;
		}
		else if(m==1 || m==3 || m==5 || m==7 || m==8 || m==10 || m==12){
			d=31;
		}
		else{
			d=30;
		}
		for(var i=1;i<=d;i++){
			v= i<10 ? '0'+i : i;
			this.date.options[this.date.options.length]=new Option(v,v);
		}
	}
	this.clearSelect=function(obj){
		while(obj.options.length){
			obj.options[obj.options.length-1]=null;
		}
	}
	this.setSelect=function(s, v){
		if(!s || v===null) return;
		for(var i=0; i<s.options.length; i++){
			if(s.options[i].value==v){
				s.selectedIndex=i;
				return;
			}
		}
	}
	this.initMonth=function(){
		var date=new Date();
		var m=this.month_v ? this.month_v : date.getMonth()+1;
		this.loadMonth();
		this.setSelect(this.month, m);
	}
	this.initDate=function(){
		var date=new Date();
		var d=this.date_v ? this.date_v : date.getDate();
		this.clearSelect(this.date);
		this.loadDate();
		this.setSelect(this.date, d);
	}
	this.initYear=function(sd){
		var date=new Date();
		var y=this.year_v ? this.year_v : date.getFullYear();
		this.loadYear();
		this.setSelect(this.year, y);
	}
}
function initDate(sd){
	sd.month.onchange=function(){sd.initDate()};
	sd.year.onchange=function(){sd.initDate()};
	sd.initYear();
	sd.initMonth();
	sd.initDate();
}
function addnewoption(obj, msg){
	var name;
	name=window.prompt(msg+":", '');
	if(name==null || name=='') return null;
	var opt=obj.options;
	if(opt[opt.length-1].value=='new')opt[opt.length-1].text=name;
	else opt[opt.length]=new Option(name, 'new');
	obj.selectedIndex=opt.length-1;
	return name;
}
