var conf={};
conf.valid=[];
conf.msg=[];
conf.config=[];

/************define****************/
conf.config['valid_form_type']=1;
conf.msg['SelectRecords']='';
conf.valid['float']=conf.valid['double'];
conf.valid['numeric']=conf.valid['number'];
conf.valid['integer']=conf.valid['int'];
conf.valid['web']=conf.valid['url'];
conf.valid['tel']=conf.valid['phone'];
conf.valid['mail']=conf.valid['email'];
conf.valid['currency']=conf.valid['money'];

function selectAll(ctl,obj)
{
  if(!ctl)return;
  if(!ctl.length)
	{
		ctl.checked=obj.checked;
		return;
	}
  for(var i=0;i<ctl.length;i++)ctl[i].checked=obj.checked;
}

function cbxSel(obj)
{
  if(!obj.length)return obj.checked?1:0;
  var iSel=0;
  for(var i=0;i<obj.length;i++)
  {
    if(obj[i].checked)iSel++;
  }
  return iSel;
}

function cbxValue(obj)
{
  if(!obj.length)return obj.checked?obj.value:"";
  var sValue="";
  for(var i=0;i<obj.length;i++)
  {
    if(obj[i].checked)sValue+=obj[i].value+",";
  }
  return sValue.length==0?"":sValue.substring(0,sValue.length-1);
}

function _del(obj,page)
{
  if(obj==null||obj=='')obj=frm.id;
  if(page==null||page=='')page="";
  if(cbxSel(obj)==0)return alert(conf.msg['SelectRecords']);
  window.location=page+'?del='+cbxValue(obj);
}

function _edit(obj,page)
{
  if(obj==null||obj=='')obj=frm.id;
  if(page==null||page=='')page="edit.asp";
  if(cbxSel(obj)!=1)return alert('select one item please');
  window.location=page+'?id='+cbxValue(obj);
}

/*************************COOKIES*********************/
function setCookie(name,value,expires,path)
{
	document.cookie=name+"="+escape(value)+
		((expires)?"; expires="+expires.toGMTString():"; expires=Thu,01-Jan-10 00:00:01 GMT")+
		((path)?"; path="+path:"");
}

function getCookie(name)
{
	var dc=document.cookie;
	var prefix=name + "=";
	var begin=dc.indexOf("; " + prefix);
	if (begin==-1)
	{
		begin=dc.indexOf(prefix);
		if (begin != 0) return null;
	}
	else
	{
		begin += 2;
	}
	var end=document.cookie.indexOf(";",begin);
	if (end==-1)end=dc.length;
	return unescape(dc.substring(begin + prefix.length,end));
}

/*****************************AJAX*************************/
function _getAjax()
{
	var ajax=false; 
	try
	{ 
		ajax=new ActiveXObject("Msxml2.XMLHTTP"); 
	}
	catch (e)
	{ 
		try{ajax=new ActiveXObject("Microsoft.XMLHTTP");}catch(E){ajax=false;}
	}
	if (!ajax && typeof XMLHttpRequest!='undefined')ajax=new XMLHttpRequest();
	return ajax;
}

function ajaxGet(_url,_fun,_oop) 
{ 
	var ajax=_getAjax();
	ajax.open("GET",_url,true);
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4 && ajax.status==200)_fun(_str2obj(ajax.responseText,_oop));
	}
	ajax.send(null); 
}

/***STR TO OBJECT***/
function _str2obj(str,_oop)
{
	if(!_oop)return str;
	var obj={};
	var arrSplit=str.split("/`/");
	var i,strValue;
	for(i=0;i<arrSplit.length;i++)
	{
		if(arrSplit[i]!='')
		{
			var arr=arrSplit[i].split("=`=");
			if(arr.length==2)
			{
				strValue=arr[1];
				try{eval("obj."+arr[0]+"=strValue;");}catch(e){}
			}
		}
	}
	return obj;
}

/*******************VALID FORM*********************/
var FormChecker=
{
	'require':/.+/,
	'email':/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,
	'mail':/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,
	'phone':/^((\(\d{2,3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}(\-\d{1,4})?$/,
	'tel':/^((\(\d{2,3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}(\-\d{1,4})?$/,
	'mobile':/^((\(\d{2,3}\))|(\d{3}\-))?13\d{9}$/,
	'url':/^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/,
	'web':/^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/,
	'currency':/^\d+(\.\d+)?$/,
	'money':/^\d+(\.\d+)?$/,
	'number':/^\d+$/,
	'numeric':/^\d+$/,
	'zip':/^[1-9]\d{5}$/,
	'integer':/^[-\+]?\d+$/,
	'int':/^[-\+]?\d+$/,
	'double':/^[-\+]?\d+(\.\d+)?$/,
	'float':/^[-\+]?\d+(\.\d+)?$/,
	'english':/^[A-Za-z]+$/,
	'chinese': /^[\u0391-\uFFE5]+$/,
	'notnull':/.+/,
	'filter':"this._filter(value,getAttribute('accept'))",
	'len':"this._limit(value.length,getAttribute('min'), getAttribute('max'))",
	'lenb':"this._limit(this._lenB(value),getAttribute('min'),getAttribute('max'))",
	'date':"this._date(value)",
	'repeat':"value==$(getAttribute('to')).value",
	'range':"getAttribute('min')<(value|0)&&(value|0)<getAttribute('max')",
	'group':"this._check(getAttribute('name'),getAttribute('min'),getAttribute('max'))",
	'errItem':[],
	'strErr':[],
	
	init:function()
	{
		for(var i=0;i<document.forms.length;i++)
		{
			var objFrm=document.forms[i];
			objFrm.onsubmit=function()
			{

				return FormChecker.valid(this) && FormChecker.disableSubmit(this);
			};
		}
	},

	disableSubmit:function(obj)
	{
		try
		{
			for(var i=0;i<obj.elements.length;i++)
			{
				var o=obj.elements[i];
				if(o.type=='submit' || o.type=='reset')o.disabled=true;
			}
		}
		catch(e){return false}
	},

	valid:function(theForm)
	{
		var obj=theForm;
		var count=obj.elements.length;
		this.strErr.length=1;
		this.errItem.length=1;
		this.errItem[0]=obj;
		for(var i=0;i<count;i++)
		{
			with(obj.elements[i])
			{
				var _valid=getAttribute("valid");
				if(_valid==null||_valid=='')continue;
				_valid=_valid.toString().toLowerCase();
				this._cls(obj.elements[i]);
				if(getAttribute("require")=="false" && value=="")continue;
				switch(_valid)
				{
					case "date":
					case "repeat":
					case "range":
					case "group":
					case "len":
					case "lenb":
					case "filter":
						if(!eval(this[_valid]))this._err(i,_valid,getAttribute("msg"),obj.elements[i]);
						break;
					case "custom":
						try
						{
							if(!eval(getAttribute('callback')))return false;
						}catch(e){}
						break;
					default :
						if(this[_valid])
						{
							if(!this[_valid].test(value))
							{
								this._err(i,_valid,getAttribute("msg"),obj.elements[i]);
							}
						}
						break;
				}
			}
		}
		
		if(this.strErr.length>1)
		{
			var mode=obj.getAttribute("alertType");
			if(!mode)mode=conf.config['valid_form_type'];

			var errCount=this.errItem.length;
			if(mode==1)
			{
				alert(this.strErr[1]);
				this.errItem[1].style.backgroundColor="#ff6600";
				try{this.errItem[1].focus();}catch(e){}
			}
			else
			{
				for(var i=1;i<errCount;i++)
				{
					try
					{
						var span=$ce("SPAN");
						span.id="__err__";
						span.style.color="red";
						this.errItem[i].parentNode.appendChild(span);
						span.innerHTML="&nbsp;&nbsp;"+this.strErr[i].replace(/\d+:/,"*");
					}catch(e){}
				}
				try{this.errItem[1].focus();}catch(e){}
			}
			return false;
		}
		return true;
	},

	_limit:function(len,min,max){
		min=min || 0;
		max=max || Number.MAX_VALUE;
		return min<=len&&len<=max;
	},
	_lenB:function(str){
		return str.replace(/[^\x00-\xff]/g,"**").length;
	},
	_cls:function(elem){
		with(elem)
		{
			style.backgroundColor="";
			var lastNode=parentNode.childNodes[parentNode.childNodes.length-1];
			if(lastNode.id=="__err__")parentNode.removeChild(lastNode);
		}
	},
	_err:function(index,valid,str,obj){
		this.errItem[this.errItem.length]=this.errItem[0].elements[index];
		if(str==null||str=='')str=conf.valid[valid]?conf.valid[valid]:conf.valid['default'];

		if(valid=='len' || valid=='lenb' || valid=='range')
		{
			str=str.replace(/{a}/g,obj.getAttribute("min"));
			str=str.replace(/{b}/g,obj.getAttribute("max"));
		}

		this.strErr[this.strErr.length]=str;
	},
	_check:function(name,min,max){
		var groups=document.getElementsByName(name);
		var hasChecked=0;
		min=min || 1;
		max=max || groups.length;
		for(var i=groups.length-1;i>=0;i--)if(groups[i].checked) hasChecked++;
		return min <= hasChecked && hasChecked <= max;
	},
	_filter:function(input,filter){
		return new RegExp("^.+\.(?=EXT)(EXT)$".replace(/EXT/g,filter.split(/\s*,\s*/).join("|")),"gi").test(input);
	},
	_date:function(sDate){
		var iaMonthDays = [31,28,31,30,31,30,31,31,30,31,30,31];
		var iaDate = new Array(3);
		var year, month, day;
		iaDate = sDate.toString().split("-");
		if (iaDate.length != 3) return false;
		if (iaDate[1].length > 2 || iaDate[2].length > 2) return false;
		year = parseFloat(iaDate[0]);
		month = parseFloat(iaDate[1]);
		day=parseFloat(iaDate[2]);
		if (year < 1900 || year > 2100) return false;
		if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) iaMonthDays[1]=29;
		if (month < 1 || month > 12) return false;
		if (day < 1 || day > iaMonthDays[month - 1]) return false;
		return true;
	}
}

/****************RICHEDIT****************************/

var RichEdit=
{
	cmd:function(typ,id,v)
	{
		if(typ=='html')
		{
			try
			{
				eval(id+".focus();");
				eval(id + ".document.selection.createRange().pasteHTML(v);");
			}
			catch(e){}
			return;
		}

		if(v)
		{
			eval(id+".document.execCommand(typ,'',v);");
		}
		else
		{
			eval(id+".document.execCommand(typ);");
		}
	},

	exec:function(obj)
	{
		var _id="_" + Math.random().toString().replace(".","");

		_sm =" onmouseover=\"this.style.backgroundColor='#ffffff';\" ";
		_sm+=" onmouseout=\"this.style.backgroundColor='';\" ";
		_sm+=" style='font-size:12px;width:20;height:18;border:1px #000000 solid;cursor:hand' ";
		_disabled="";
		if(obj.getAttribute('readonly') || obj.getAttribute('disabled'))_disabled=" disabled ";
		_sm+=_disabled;

		_str_tool ="<input type=button style='font-weight:bold' value='B' onclick=RichEdit.cmd('Bold','{id}') "+_sm+"> ";
		_str_tool+="<input type=button style='font-style:italic' value='I' onclick=RichEdit.cmd('Italic','{id}') "+_sm+"> ";
		_str_tool+="<input type=button style='text-decoration: underline' value='U' onclick=RichEdit.cmd('Underline','{id}') "+_sm+"> ";
		_str_tool+="<input type=button style='text-align:left' value='左' onclick=RichEdit.cmd('JustifyLeft','{id}') "+_sm+"> ";
		_str_tool+="<input type=button style='text-align:center' value='中' onclick=RichEdit.cmd('JustifyCenter','{id}') "+_sm+"> ";
		_str_tool+="<input type=button style='text-align:right' value='右' onclick=RichEdit.cmd('JustifyRight','{id}') "+_sm+"> ";
		_str_tool+="<input type=button style='text-align:right' value='URL' onclick=RichEdit.cmd('CreateLink','{id}') "+_sm+"> ";
		_str_tool+="<select "+_disabled+" onchange=\"RichEdit.cmd('fontsize','{id}',this.value)\"><option value=''>字号<option value=3>三号<option value=4>四号<option value=5>五号<option value=6>六号<option value=7>七号</select> ";
		_str_tool+="<select "+_disabled+" onchange=\"RichEdit.cmd('ForeColor','{id}',this.value)\"><option value=''>颜色<option value='#ff0000' style='background-color:#ff0000'><option value='#00ff00' style='background-color:#00ff00'><option value='#0000ff' style='background-color:#0000ff'><option value='#ffff00' style='background-color:#ffff00'><option value='#00ffff' style='background-color:#00ffff'><option value='#ffffff' style='background-color:#ffffff'><option value='#000000' style='background-color:#000000'></select> ";
		if(obj.getAttribute('readonly') || obj.getAttribute('disabled'))_str_tool+=" <label disabled style='font-size:12'>*仅查看*</label>";
		if(obj.getAttribute('toolbar')=='no')_str_tool='';
		obj.style.display='none';
		obj.insertAdjacentHTML("afterEnd","<table border=0 cellspacing=0 cellpadding=0 width=100% ><tr><td style='padding:1;font-size:8' bgcolor='eeeeee'>"+_str_tool.replace(/{id}/g,_id)+"</td></tr><tr><td><iframe MARGINWIDTH=0 MARGINHEIGHT=0 frameborder=no src='about:blank' style=\"border:1px #000000 solid;"+obj.style.cssText+";display:\" id=\""+_id+"\"></iframe></td></tr></table>");
		var doc=$(_id).contentWindow.document;
		doc.open();
		doc.write("<body STYLE='font-size:12px'>"+obj.value+"</body>");
		doc.close();
		if(!(obj.getAttribute('readonly') || obj.getAttribute('disabled')))
		{
			doc.designMode="On";
			doc.contentEditable=true; 
		}
		obj.form.attachEvent("onsubmit",function(){obj.value=doc.body.innerHTML;});
		obj.form.attachEvent("onreset",function(){doc.body.innerHTML=obj.value;});

		return _id;
	},

	init:function()
	{
		var str ="<form style='display:none' target=_tmp_frm_ action='upfile.asp' name='_tmp_frm_'>";
		str+="<input type=file id='_tmp_upload_file_'>";
		str+="<input type=hidden name=id value='' id='_tmp_frm_id_'>";
		str+="</form>";
		str+="<iframe src='about:blank' name=_tmp_frm_ style='display:none'></iframe>";

		for(var i=0;i<document.forms.length;i++)
		{
			var obj=document.forms[i];
			for(j=0;j<obj.elements.length;j++)
			{
				o=obj.elements[j];
				if(o.type=='textarea' && o.getAttribute("richedit")=='true')RichEdit.exec(o);
			}
		}
	}
}

/*********************************COMBOBOX***************************/
/*
<input type=text combo="true|yes|no" items="aaa,bbb,ccc,ddd" readonly? disabled?>
*/
var ComboBox=
{
	exec:function(obj)
	{
		if(obj.getAttribute("readonly") || obj.getAttribute("disabled"))return;
		if(obj.getAttribute("items")=='')return;
		obj.setAttribute('autocomplete','off');
		obj.onclick=function(){ComboBox._doSelect(obj);};
		var _img=$ce("img");
	},
	
	_doSelect:function(objText)
	{
		var x=$("_tmp_combobox_div_");
		if(!x)x=$ce("div");
		var _css ="LEFT:"+(_leftOffset(objText))+";";
		_css+="WIDTH:"+(objText.clientWidth+4)+";";
		_css+="TOP:"+(_topOffset(objText)+objText.clientHeight+3)+";";
		_css+="POSITION: absolute;height:100;cursor:hand;overflow:auto;border:1px #333333 solid;overflow-x:hidden;background-color:#ffffff";
		x.innerHTML='';
		x.style.cssText=_css;
		x.id="_tmp_combobox_div_";
		x.style.display='block';
		
		var tbl=$ce("table");
		tbl.width="100%";
		tbl.border=0;
		tbl.cellpadding=0;
		tbl.cellspacing=0;
		var tBody=$ce("tbody");
		tbl.appendChild(tBody);
		
		var _items=objText.getAttribute("items")+"";
		_arr=_items.split(",");
		for(i in _arr)
		{
			if(_arr[i]=='null')continue;
			var tr=$ce("tr");
			tBody.appendChild(tr);
			var td=$ce("td");
			td.style.cssText="font-size:12px;padding:0;height:20;overflow:hidden";
			td.onmouseover=function(){this.bgColor='#0088ff';};
			td.onmouseout=function(){this.bgColor='';};
			td.title=_arr[i];
			td.onclick=function(){objText.value=this.innerText;};
			td.innerHTML="<nobr>"+_arr[i]+"</nobr>";
			tr.appendChild(td);
		}
		
		x.appendChild(tbl);
		document.body.insertAdjacentElement("beforeEnd",x);
		document.attachEvent('onmouseup',function(){x.style.display='none';});
	},

	init:function()
	{
		var objs=$tags("input");
		for(var i=0;i<objs.length;i++)
		{
			var obj=objs[i];
			if(obj.type=='text')
			{
				if	(obj.getAttribute("combo")=='true'
						||obj.getAttribute("combo")=='on'
						||obj.getAttribute("combo")=='yes')
				{
					ComboBox.exec(obj);
				}
			}
		}
	}
}

/******************DatePicker*****************/

function __ocx_Date()
{
	this.GetDateStr=function(y,m){
			this.DayArray=[];
			for(var i=0;i<42;i++)this.DayArray[i]=" ";
			for(var i=0;i<new Date(y,m,0).getDate();i++)this.DayArray[i+new Date(y,m-1,1).getDay()]=i+1;
			return this.DayArray;
			}
	this.GetTableStr=function(str,y,m)
	{
		this.objTextId=str;
		this.DateArray=["0","1","2","3","4","5","6"];
		var DStr="<table width='140'><tr><td colspan='7'>";
		DStr+="<table width='100%' border='0' cellpadding='0' cellspacing='0'><tr align='center'>\n"+
			"<td width='20' style='font-family:\"webdings\";font-size:9pt' onclick='__ocx_Date().JumpToRun(\"b\")'>3</td>\n"+
			"<td id='YearTD' width='70' onclick='__ocx_Date().WriteSelect(this,this.innerText.split(\" \")[0],\"y\",false)'>"+y+" Year</td>\n"+
			"<td id='MonthTD' width='47' onclick='__ocx_Date().WriteSelect(this,this.innerText.split(\" \")[0],\"m\",false)'>"+m+" Month</td>\n"+
			"<td width='20' style='font-family:\"webdings\";font-size:9pt' onclick='__ocx_Date().JumpToRun(\"n\")'>4</td></tr></table>\n"+
			"</td></tr>\n"+
			"<tr align='center'>";
		for(var i=0;i<7;i++)DStr+="<td>"+DateArray[i]+"</td>";
		DStr+="</tr>";
		for(var i=0;i<6;i++)
		{
			DStr+="<tr align='center'>";
			for(var j=0;j<7;j++)
			{
					DStr+="<td id=TD onclick='__ocx_Date().AlertDay()'>"+this.GetDateStr(y,m)[i*7+j]+"</td>\n";
			}
			DStr+="</tr>";
		}
		DStr+="</tabe>";
		return DStr;
	}

	this.WriteSelect=function(obj,values,action,getobj){
			if(values=="")return;
			if(getobj){
					obj.innerHTML=values+(action=="y"?" Year":" Month");
					this.RewriteTableStr(YearTD.innerText.split(" ")[0],MonthTD.innerText.split(" ")[0]);
					return false;
					}
			var StrArray=[];
			if(action=="y"){
					for(var i=0;i<15;i++){
							var year=values-7+i;
							StrArray[i]="<option value='"+year+"' "+(values==year?"selected":"")+"> "+year+"Year</option>\n";
							}
					obj.innerHTML="<select id='select1' style='width:67' onchange='__ocx_Date().WriteSelect(parentElement,this.value,\"y\",true)' onblur='YearTD.innerText=this.value+\" Year\"'>\n"+StrArray.join("")+"</select>";
					select1.focus();
					}
			if(action=="m"){
					for(var i=1;i<13;i++)
							StrArray[i]="<option value='"+i+"' "+(i==values?"selected":"")+"> "+i+"Month</option>\n";
					obj.innerHTML="<select id='select2' style='width:47' onchange='__ocx_Date().WriteSelect(parentElement,this.value,\"m\",true)' onblur='MonthTD.innerText=this.value+\" Month\"'>\n"+StrArray.join("")+"</select>";
					select2.focus();
					}
			}
	this.RewriteTableStr=function(y,m){
			var TArray=this.GetDateStr(y,m);
			for(var i=0;i<TArray.length;i++)TD[i].innerHTML=TArray[i];
			}
	this.JumpToRun=function(action){
			var YearNO=YearTD.innerText.split(' ')[0];
			var MonthNO=MonthTD.innerText.split(' ')[0];
			if(action=="b"){
					if(MonthNO=="1"){
							MonthNO=13;
							YearNO=YearNO-1;
							}
					MonthTD.innerText=MonthNO-1+" Month";
					YearTD.innerText=YearNO+" Year";
					this.RewriteTableStr(YearNO,MonthNO-1);
					}
			if(action=="n"){
					if(MonthNO=="12"){
							MonthNO=0;
							YearNO=YearNO-(-1);
							}
					YearTD.innerText=YearNO+" Year";
					MonthTD.innerText=MonthNO-(-1)+" Month";
					this.RewriteTableStr(YearNO,MonthNO-(-1));
					}
			}
	this.AlertDay=function()
	{
		if(event.srcElement.innerText!="")
		{
			var dt=(YearTD.innerText.split(' ')[0]+"-"+MonthTD.innerText.split(' ')[0]+"-"+event.srcElement.innerText);
			$(this.objTextId).value=dt;
			$("_tmp_datepicker_div_").style.display='none';
		}
	}
	return this;
}

var DatePicker=
{
	exec:function(obj)
	{
		if(obj.getAttribute("readonly") || obj.getAttribute("disabled"))return;
		obj.setAttribute('autocomplete','off');
		obj.readOnly=true;
		obj.style.cursor='hand';
		obj.onclick=function(){DatePicker._doSelect(obj);};
	},
	
	_doSelect:function(objText)
	{
		var x=$("_tmp_datepicker_div_");
		if(!x)x=$ce("div");
		var _css ="LEFT:"+(_leftOffset(objText))+";";
		_css+="TOP:"+(_topOffset(objText)+objText.clientHeight+3)+";";
		_css+="POSITION: absolute;cursor:hand;border:1px #333333 solid;background-color:#ffffff";
		x.innerHTML='';
		x.style.cssText=_css;
		x.id="_tmp_datepicker_div_";
		x.style.display='block';
		if(objText.id=='')objText.id="_" + Math.random().toString().replace(".","");
		x.innerHTML=__ocx_Date().GetTableStr(objText.id,new Date().getYear(),new Date().getMonth()+1);
		document.body.insertAdjacentElement("beforeEnd",x);
	},
	
	init:function()
	{
		var objs=$tags("input");
		for(var i=0;i<objs.length;i++)
		{
			var obj=objs[i];
			if(obj.type=='text')
			{
				if	(obj.getAttribute("datepicker")=='true'
						||obj.getAttribute("datepicker")=='on'
						||obj.getAttribute("datepicker")=='yes')
				{
					DatePicker.exec(obj);
				}
			}
		}
	}

	
};

/*******************TreeView**********************/
var TreeView=
{
	exec:function(obj)
	{
		var t=new jsTree(obj);
		if(obj.getAttribute('checkbox')=='false')t.showCheckBox=false;
		if(obj.getAttribute('readonly')=='true')t.readonly=true;
		TreeView.div2treeItem(obj,t);
		t.expandToTier(2);
	},

	div2treeItem:function(obj,tree,parent)
	{
		var _parent,o,i;
		if(obj.childNodes.length<1)return;

		for(i=0;i<obj.childNodes.length;i++)
		{
			o=obj.childNodes[i];
			_title=o.getAttribute("title");
			if(_title=='')continue;
			if(parent)
			{
				_parent=parent.add(_title,o.getAttribute("image"),o.getAttribute("type"),o.getAttribute("href"),o.getAttribute("value"));
			}
			else
			{
				_parent=tree.root.add(_title,o.getAttribute("image"),o.getAttribute("type"),o.getAttribute("href"),o.getAttribute("value"));
			}
			TreeView.div2treeItem(o,tree,_parent);
		}
	},

	init:function()
	{
		TreeView._Do();
	},

	_Do:function()
	{
		var i;
		var objs=$tags("div");
		for(var i=0;i<objs.length;i++)
		{
			var obj=objs[i];
			if(obj.getAttribute("treeview")=='true')TreeView.exec(obj);
		}
	}
}
/*************************END TREEVIEW***********************************/


/******************************ajaxFill*****************************************/
var ajaxFill=
{
	exec:function(obj)
	{
		ajaxGet(obj.getAttribute("ajaxSrc"),function(s){obj.innerHTML=s;},false);
	},

	init:function()
	{
		var objs=$tags("div");
		for(var i=0;i<objs.length;i++)
		{
			var obj=objs[i];
			if(obj.getAttribute("ajaxSrc"))ajaxFill.exec(obj);
		}
	}
};

/*************************util**********************************************/
function $ce(s){return document.createElement(s);}
function $(s){return document.getElementById(s);}
function $tags(s){return document.getElementsByTagName(s);}
var ie=function(){return (navigator.userAgent.toLowerCase().indexOf("msie")!=-1);}

function time()
{
	var d = new Date();
	var sec = d.getSeconds();
	var hr = d.getHours();
	var min = d.getMinutes();
	if (hr <= 9) hr = "0" + hr;
	if (min <= 9) min = "0" + min;
	if (sec <= 9) sec = "0" + sec;
	return hr + ":" + min + ":" + sec;
}

function date()
{
	var today = new Date();
	var d = today.getDate();
	var m = today.getMonth()+1;
	var y = today.getYear();
	return y + "-" + m + "-" + d;
}

function _leftOffset(elem)
{
	var left = 0;
	while (elem.tagName != "BODY")
	{
		left += elem.offsetLeft;
		elem = elem.offsetParent;
	}
	return left;
}

function _topOffset(elem) 
{
	var top = 0;
	while (elem.tagName != "BODY") 
	{
		top += elem.offsetTop;
		elem = elem.offsetParent;
		}
	return top;
}

function $import(path,type,title)
{
	var s,i;
	if(type=="js")
	{
		var ss=$tags("script");
		for(i=0;i<ss.length;i++)
		{
			if(ss[i].src && ss[i].src.indexOf(path)!=-1)return ss[i];
		}
		s=$ce("script");
		s.type="text/javascript";
		s.src=path;
	}
	else if(type=="css")
	{
		var ls=$tags("link");
		for(i=0;i<ls.length;i++)
		{
			if(ls[i].href && ls[i].href.indexOf(path)!=-1)return ls[i];
		}
		s=$ce("link");
		s.rel="alternate stylesheet";
		s.type="text/css";
		s.href=path;
		s.title=title;
		s.disabled=false;
	}
	else
	{
		return;
	}
	var head=$tags("head")[0];
	head.appendChild(s);
	return s;
}


/***attach event***/
if(ie)
{
	FormChecker.init();			//form valider
	RichEdit.init();			//richedit
	TreeView.init();			//treeview
	ComboBox.init();			//ComboBox
	DatePicker.init();			//datepicker
	ajaxFill.init();			//ajax callback
}
else
{

}


