/**
 * @author simon money
 * @projectDescription SMTreeView
 * @version 0.1
 * 		
 */
Function.prototype.Bind = function(object) 
{
	var __method = this; 
	var __arg = arguments;
	return function() 
	{ 
		__method.apply(object, __arg); 
	} 
}
String.prototype.Trim = function() 
{ 
	return this.replace(/(^\s*)|(\s*$)/g, ""); 
} 

String.prototype.LTrim = function() 
{ 
	return this.replace(/(^\s*)/g, ""); 
} 

String.prototype.RTrim = function() 
{ 
	return this.replace(/(\s*$)/g, ""); 
} 
String.prototype.GetCount = function(str,mode){return eval("this.match(/("+str+")/g"+(mode?"i":"")+").length");}
function $(AID)
{
	return document.getElementById(AID);
}
function $F(AID)
{
	return document.getElementById(AID).value;
}
function URLEncode(str)
{
 	/*-- Modify from qiushuiwuhen --*/
	var i,temp,p,q,result="";
	for(i=0;i<str.length;i++){
		temp = str.charCodeAt(i);
		if(temp>=0x4e00){
			execScript("ascCode=hex(asc(\""+str.charAt(i)+"\"))", "vbscript");
			result+=ascCode.replace(/(.{2})/g, "%$1");
		}else{
			result+=escape(str.charAt(i));
		}
	}
	return result;
}
function URLDecode(str)
{
	var i,temp,result="";
	for(i=0;i<str.length;i++)
	{
		if(str.charAt(i)=="%")
		{
			if(str.charAt(++i)=="u")
			{
				temp=str.charAt(i++) + str.charAt(i++) + str.charAt(i++) + str.charAt(i++) + str.charAt(i);
		    	result += unescape("%" + temp);
			}else{
		    	temp = str.charAt(i++) + str.charAt(i);
		    	if(eval("0x"+temp)<=160){
				result += unescape("%" + temp);
			}else{
		    	temp += str.charAt(++i) + str.charAt(++i) + str.charAt(++i);
		    	result += this.Decode_unit("%" + temp);
		    }
		   }
		}else if(str.charAt(i)=="+")result+=" ";
		else{result += str.charAt(i);}
	}
	return result;
}
function Decode_unit(str)
{
	 var p,q = "";
	 if(str.GetCount("%")!=2)return str;
	 p=eval("0x" + str.split("%")[1]);
	 q=eval("0x" + str.split("%")[2]);
	 if(p<160 || q<160)return unescape(str);
	 str=str.replace(/%/g,"");
	 execScript("temp=&H"+str, "vbscript");
	 execScript("result=chr("+temp+")", "vbscript");
	 return result;
}
function SMRes()
{
	this.PathCur = null;
	this.PathCss = 'css/default/';
	this.icons = 
	{
		L0        	: 'L0.gif',  //
		L1        	: 'L1.gif',  //
		L2        	: 'L2.gif',  //
		L3        	: 'L3.gif',  //
		L4        	: 'L4.gif',  //
		PM0       	: 'P0.gif',  //
		PM1       	: 'P1.gif',  //
		PM2       	: 'P2.gif',  //
		PM3       	: 'P3.gif',  //
		empty     	: 'L5.gif',     //
		root      	: 'root.gif',   //
		root_lock	: 'root_lock.gif',
		folder    	: 'folder.gif', //
		folder_lock	: 'folder_lock.gif',
		file      	: 'file.gif',   //
		file_lock	: 'file_lock.gif',
    	exit      	: 'exit.gif'
	};
	this.iconsExpand = 
	{  
		PM0       	: 'M0.gif',     //
		PM1       	: 'M1.gif',     //
		PM2       	: 'M2.gif',     //
		PM3       	: 'M3.gif',     //
		folder    	: 'folderopen.gif',
		folder_lock	: 'folderopen_lock.gif',
		file	  	: "fileopen.gif",
		file_lock	: 'fileopen_lock.gif',
		exit      	: 'exit.gif'
	};
	this.iconsMouseOver=
	{
		PM1         : 'G1.gif',  //
		PM2         : 'G2.gif',  //
		PM1_        : 'F1.gif',  //
		PM2_	    : 'F2.gif'  //		
	}
	
	this.styles=
	{
		TreeTitle	: 'TreeTitle',
		Nodee		: 'Nodee',
		LoadHint	: 'LoadHint',
		HeadImgLeaf	: 'HeadImgLeaf',
		HeadImgDoc	: 'HeadImgDoc',
		HeadLink	: 'HeadLink',
		NodeBody	: 'NodeBody'
	}
	this.stylesShow=
	{
		NodeBody	: 'NodeBodyShow'
	}
	this.stylesMouseOver=
	{
		Nodee		: 'Nodee',
		HeadImgLeaf	: 'HeadImgLeaf',
		HeadImgDoc	: 'HeadImgDoc',
		HeadLink	: 'HeadLinkMouseOver',
		NodeBody	: 'NodeBody'
	}
	this.stylesFocus=
	{
		Nodee		: 'Nodee',
		HeadImgLeaf	: 'HeadImgLeaf',
		HeadImgDoc	: 'HeadImgDoc',
		HeadLink	: 'HeadLinkFocus',
		NodeBody	: 'NodeBody'
	}
	
	this.Init();
	this.CompleteIconPath();	
}
SMRes.prototype.BrowIsIE=function()
{
	var ua = window.navigator.userAgent.toLowerCase();
	return (/msie/i.test(ua));
}
SMRes.prototype.Init=function()
{
	//jspath
	var i;var scriptlist=document.getElementsByTagName("script");
	for (i=0;i<scriptlist.length;i++)
	{
		var s;
		s=scriptlist[i].src;
		if (s.substr(s.length-15,15)=="smlib/common.js")
		{
			this.PathCur=s.substr(0,s.length-9);
			break;
		}
	}
	this.PathCss=this.PathCur+this.PathCss;

	//load css
	if (this.BrowIsIE())
		document.createStyleSheet(this.PathCss+"smjscomp.css");
	else 
	{
		var head = document.getElementsByTagName('HEAD').item(0);
		var style = document.createElement('link');
		style.href = this.PathCss+"smjscomp.css";
		style.rel = 'stylesheet';
		style.type = 'text/css';
		head.appendChild(style);			
	}
}
SMRes.prototype.CompleteIconPath=function()
{
	this.icons.L0=this.PathCss+this.icons.L0;
	this.icons.L1=this.PathCss+this.icons.L1;
	this.icons.L2=this.PathCss+this.icons.L2;
	this.icons.L3=this.PathCss+this.icons.L3;
	this.icons.L4=this.PathCss+this.icons.L4;
	this.icons.PM0=this.PathCss+this.icons.PM0;
	this.icons.PM1=this.PathCss+this.icons.PM1;
	this.icons.PM2=this.PathCss+this.icons.PM2;
	this.icons.PM3=this.PathCss+this.icons.PM3;
	this.icons.empty=this.PathCss+this.icons.empty;
	this.icons.root = this.PathCss + this.icons.root;
	this.icons.root_lock = this.PathCss + this.icons.root_lock;
	this.icons.folder = this.PathCss + this.icons.folder;
	this.icons.folder_lock = this.PathCss + this.icons.folder_lock;
	this.icons.file = this.PathCss + this.icons.file;
	this.icons.file_lock = this.PathCss + this.icons.file_lock;
	this.icons.exit=this.PathCss+this.icons.exit;
	
	this.iconsExpand.PM0=this.PathCss+this.iconsExpand.PM0;
	this.iconsExpand.PM1=this.PathCss+this.iconsExpand.PM1;
	this.iconsExpand.PM2=this.PathCss+this.iconsExpand.PM2;
	this.iconsExpand.PM3=this.PathCss+this.iconsExpand.PM3;
	this.iconsExpand.folder=this.PathCss+this.iconsExpand.folder;
	this.iconsExpand.folder_lock=this.PathCss+this.iconsExpand.folder_lock;
	this.iconsExpand.file=this.PathCss+this.iconsExpand.file;
	this.iconsExpand.file_lock=this.PathCss+this.iconsExpand.file_lock;
	this.iconsExpand.exit=this.PathCss+this.iconsExpand.exit;
	
	this.iconsMouseOver.PM1=this.PathCss+this.iconsMouseOver.PM1;
	this.iconsMouseOver.PM2=this.PathCss+this.iconsMouseOver.PM2;
	this.iconsMouseOver.PM1_=this.PathCss+this.iconsMouseOver.PM1_;
	this.iconsMouseOver.PM2_=this.PathCss+this.iconsMouseOver.PM2_;
}
var SMResObj = new SMRes();

function SMCookie()
{
	
}
//AKey可以为null
SMCookie.prototype.Read=function(AName,AKey)
{
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++)
	{
		var p,cname,cstr;
		p = aCookie[i].indexOf("=");
		if(p==-1)continue;
		cname=aCookie[i].substring(0,p);
		if(cname==AName)
		{
			cstr=aCookie[i].substring(p+1,aCookie[i].length);
			if(AKey==null){return URLDecode(cstr);}
			var values=cstr.split("&");
			for(var j=0;j<values.length;j++)
			{
				var p,ckey,cvalue;
				p=values[j].indexOf("=");
				if(p==-1)return "";
				ckey=values[j].substring(0,p);
				if(ckey==AKey)return URLDecode(values[j].substring(p+1,values[j].length));
			}
		}
	}
	
	return "";
}
SMCookie.prototype.Write=function(AName,AValue,AForever)
{
	if(AForever){
		document.cookie = AName + "=" + escape(AValue) + "; path=/; expires=Fri, 31 Dec 3000 23:59:59 GMT;"
	}else{
		document.cookie = AName + "=" + escape(AValue) + "; path=/;"
	}
}
SMCookie.prototype.Del=function(AName)
{
	document.cookie = AName + "=; expires=Fri, 31 Dec 1899 23:59:59 GMT;";
}
SMCookie.prototype.SetP=function(AName,APeriod)
{
	
}
var Cookie = new SMCookie();
function SMXmlhttp()
{
	this.Url="";
	this.Creator=null;
	this.OnBeginPost=null;
	this.OnPosted=null;
	this.XmlHttp=null;
	this.DataBody='';
	this.HintDiv=null;
	this.HintText="Doing"
	this.ShowHint=true;
	this.KeepHint=true;
	this.OldDocOnclick=null;
	
	this.Init();
}
SMXmlhttp.prototype.Init=function()
{
	this.XmlHttp=new ActiveXObject("MSXML2.XmlHttp");
	this.XmlHttp.onreadystatechange=this.DoReadStateChange.Bind(this);
	this.HintDiv=document.createElement("div");
	this.HintDiv.className="SMXmlhttpHint";
	this.HintDiv.style.display="none";
}
SMXmlhttp.prototype.AddParam=function(PName,PValue)
{
	if(this.DataBody=="")this.DataBody+=PName+'='+URLEncode(PValue);
	else this.DataBody+="&"+PName+'='+URLEncode(PValue);
}
SMXmlhttp.prototype.Post=function(AMethod)
{
	if(this.OnBeginPost)this.OnBeginPost();
	this.OpenHint();
	if(AMethod==""||AMethod==null) AMethod="post";
	AMethod=AMethod.toLowerCase();
	if(AMethod=='get')
	{
		this.XmlHttp.open( "GET", this.Url, true );		
	}
	else
	{	
		this.XmlHttp.open( "POST", this.Url, true );
		this.XmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		this.XmlHttp.setRequestHeader("Content-Length",this.DataBody.length);
		this.XmlHttp.setRequestHeader("Connection", "close");
		this.XmlHttp.send(this.DataBody);
	}
}
SMXmlhttp.prototype.DoReadStateChange=function()
{
	if(this.XmlHttp.readyState!= 4) return;
	var msgid,msg;
	if(this.XmlHttp.responseXML.documentElement)
	{
		var DomRoot=this.XmlHttp.responseXML.documentElement;
		if(DomRoot.nodeName=="smjxml")
		{
			msgid=DomRoot.getAttribute("msgid");
			msg=DomRoot.getAttribute("msg");
			if(msgid=="-1"){alert(msg);window.location="/";return;}
		}
	}
	this.CloseHint(msg);
	if(this.OnPosted)this.OnPosted(msgid,this.XmlHttp.responseXML.documentElement);
}
SMXmlhttp.prototype.OpenHint=function()
{
	if(this.ShowHint)
	{
		document.body.appendChild(this.HintDiv);
		var str=this.HintText;
		if(window.event)
		{
			//this.HintDiv.style.left=window.event.clientX;
			//this.HintDiv.style.top=window.event.clientY;
			if(window.event.srcElement) 
			{
				if(window.event.srcElement.value)str=window.event.srcElement.value
				else if(window.event.srcElement.innerText)str=window.event.srcElement.innerText;
			}
		}
		this.HintDiv.innerHTML=str+"...";
		this.HintDiv.style.display="";	
	}
}
SMXmlhttp.prototype.CloseHint=function(AHint)
{
	if(this.ShowHint)
	{
		if(this.KeepHint)
		{
			if(AHint==null||AHint=="")this.HintDiv.innerHTML=this.HintDiv.innerHTML+" Done!";
			else this.HintDiv.innerHTML=AHint;
			this.OldDocOnclick=document.onclick;
			document.onclick=this.DoDocClick.Bind(this);
		}else this.HintDiv.style.display="none";	
	}
}
SMXmlhttp.prototype.HideHint=function()
{
	this.HintDiv.style.display="none";
}
SMXmlhttp.prototype.DoDocClick=function()
{
	this.HintDiv.style.display="none";
	document.onclick=this.OldDocOnclick;
}
SMXmlhttp.prototype.ClearParams=function()
{
	this.DataBody="";
}
function SMPage()
{
	this.ck=new SMCookie();
	this.xh=new SMXmlhttp();
}
SMPage.prototype.Param=function(APname)
{
	var s=window.location.search;
	if(s.indexOf(APname+"=")==-1)return"";
	s=s.substring(1,s.length);
	var r=s.split("&");
	for(var i=0;i<r.length;i++)
	{
		if(r[i].indexOf(APname+"=")==0)
		{
			return(URLDecode(r[i].substring((APname+"=").length,r[i].length)))
		}
	}
	return "";
}
SMPage.prototype.addEvent=function(obj,eventstr,func)
{
	if(this.BrowIsIE())obj.attachEvent(eventstr,func);
	else obj.addEventListener(eventstr,func);
}
SMPage.prototype.BrowIsIE=function()
{
	return (/msie/i.test(window.navigator.userAgent.toLowerCase()));
}
SMPage.prototype.CancelSelect=function()
{
	this.addEvent(document.body,"onselectstart",this.DoSelectStart);
}
SMPage.prototype.DoSelectStart=function()
{
	window.event.cancelBubble = true;
	window.event.returnValue = false;
	return false;
}
var Page=new SMPage();
function SMTable(ATabeID)
{
	this.tbobj=$(ATabeID);
	this.ClassLine=null;
	this.ClassOver=null;
	this.ClassFocus=null;
	this.TitleCount=1;
	this.SelectLine=null;
}
SMTable.prototype.Fix=function()
{
	this.tbobj.style.tableLayout="fixed";
}
SMTable.prototype.Line=function()
{
	for(var i=this.TitleCount;i<this.tbobj.rows.length;i++)
	{
		var row=this.tbobj.rows[i];
		if(row.onmouseover==null)
		{
			row.className="SMTableLine";
			row.onmouseover=this.DoLineMouseOver.Bind(this,i);
			row.onmouseout=this.DoLineMouseOut.Bind(this,i);
			row.onclick=this.DoLineClick.Bind(this,i);			
		}
	}
}
SMTable.prototype.DeleteRows=function(start,end)
{
	if(start<0)start=0;
	if(end==null)end=this.tbobj.rows.length-1;
	for(var i=end;i>=start;i--)this.tbobj.deleteRow(i)
}
SMTable.prototype.ElpTD=function(atd)
{
	atd.style.overflow="hidden";	
	atd.style.textOverflow="ellipsis";	
	atd.noWrap=true;
}
SMTable.prototype.DoLineMouseOver=function(tb,i)
{
	if(this.SelectLine!=this.tbobj.rows[i])
	{
		if(this.ClassOver)this.tbobj.rows[i].className=this.ClassOver
		else this.tbobj.rows[i].className="SMTableLine_MouseOver";
	}
}
SMTable.prototype.DoLineMouseOut=function(tb,i)
{
	if(this.SelectLine!=this.tbobj.rows[i])
	{
		if(this.ClassLine) this.tbobj.rows[i].className=this.ClassLine
		else this.tbobj.rows[i].className="SMTableLine";
	}
}
SMTable.prototype.DoLineClick=function(tb,i)
{
	if(this.SelectLine!=null)this.SelectLine.className="SMTableLine";
	this.SelectLine=this.tbobj.rows[i];
	if(this.ClassFocus)this.SelectLine.className=this.ClassFocus;
	else this.SelectLine.className="SMTableLine_Select";
}
function SMFloatBtn(AID)
{
	this.BtnObj=$(AID);
	if(this.BtnObj==null)return;
	this.BtnObj.className="SMFloatBtn";
	this.BtnObj.onmouseover=this.DoMouseOver.Bind(this);
	this.BtnObj.onmouseout=this.DoMouseOut.Bind(this);
	this.BtnObj.onmousedown=this.DoMouseDown.Bind(this);
	this.BtnObj.onmouseup=this.DoMouseUp.Bind(this);
}
SMFloatBtn.prototype.DoMouseOver=function()
{
	this.BtnObj.style.borderColor = "ThreeDHighlight ThreeDDarkShadow ThreeDDarkShadow ThreeDHighlight";
}
SMFloatBtn.prototype.DoMouseDown=function()
{
	this.BtnObj.style.borderColor = "ThreeDDarkShadow ThreeDHighlight ThreeDHighlight ThreeDDarkShadow";
}
SMFloatBtn.prototype.DoMouseUp=function()
{
	this.BtnObj.style.borderColor = "ThreeDHighlight ThreeDDarkShadow ThreeDDarkShadow ThreeDHighlight";
}
SMFloatBtn.prototype.DoMouseOut=function()
{
	this.BtnObj.style.borderColor = "#D6D3CE";
}
SMSwapImg=function(AID,ASrcMouseOver)
{
	this.Img=$(AID);
	this.Src=this.Img.src;
	this.SrcMouseOver=ASrcMouseOver;
	this.Img.onmouseover=this.DoMouseOver.Bind(this);
	this.Img.onmouseout=this.DoMouseOut.Bind(this);
}
SMSwapImg.prototype.DoMouseOver=function()
{
	this.Img.src=this.SrcMouseOver;
}
SMSwapImg.prototype.DoMouseOut=function()
{
	this.Img.src=this.Src;
}
function SMTreeNode(ATreeView,AParentNode,AXMLNode)
{
	this.TreeView = ATreeView;
	this.ParentNode = AParentNode;
	this.NodeId = AXMLNode.getAttribute("nodeid");
	this.NodeText = AXMLNode.getAttribute("title");
	this.NodeHref = AXMLNode.getAttribute("href");
	this.NodeXmlSrc = AXMLNode.getAttribute("nodexmlsrc");
	this.ImgLock = (AXMLNode.getAttribute("imglock")=="true");
	this.Img = AXMLNode.getAttribute("img");
	this.ImgSel = AXMLNode.getAttribute("imgsel");
	this.CheckBox = AXMLNode.getAttribute("checkbox");
	this.CheckBoxValue = AXMLNode.getAttribute("checkboxvalue");
	this.CheckBoxObj = null;
	this.Radio_ = AXMLNode.getAttribute("radio");
	this.RadioValue = AXMLNode.getAttribute("radiovalue");
	this.RadioObj = null;
	this.NodeIsFolder = (AXMLNode.childNodes.length>0||AXMLNode.getAttribute("nodexmlsrc"));
	this.NodeIsLastOne = (AXMLNode==AXMLNode.parentNode.lastChild);
	this.ChildHasCreated = false;
	this.ChildIsShow = false;
	this.Class=null;
	this.AutoExpanded=false;
	this.Target = AXMLNode.getAttribute("target");
	this.NodeIndex=ATreeView.Items.length;
	this.Items=new Array();
	if(AParentNode)
	{
		AParentNode.ChildHasCreated=true;
		this.Class=AParentNode.Class+1;
	}
	else
	{
		this.Class=1;
	}
	
	this.Dom_Node=null;//div
	this.Dom_HeadText_ImgLeaf=null;//img
	this.Dom_HeadText_ImgDoc=null;//img
	this.Dom_HeadText_Link=null;//href
	this.Dom_Body=null;//div
	
	ATreeView.Items[ATreeView.Items.length]=this;
	this.CreateNode();
	this.CheckedIfInPreCheckIds();
}
SMTreeNode.prototype.CheckedIfInPreCheckIds=function(){
	if(this.RadioObj!=null){
		if(this.TreeView.PreCheckedIds == this.NodeId)
			this.RadioObj.checked = true;
	}
	if(this.CheckBoxObj != null){
		if(this.TreeView.PreCheckedIds.indexOf("|"+this.NodeId+"|")>-1)
			this.CheckBoxObj.checked = true;		
	}
}
SMTreeNode.prototype.NodeClsTitle=function(ASep)
{
	var s=this.NodeText;
	var pnode=this.ParentNode;
	while(pnode!=null)
	{
		s=pnode.NodeText+ASep+s;
		pnode=pnode.ParentNode;
	}
	return s;
}
SMTreeNode.prototype.NodeClsStr=function()
{
	var vsep=".";
	var s=vsep+this.NodeId+vsep;
	var pnode=this.ParentNode;
	while(pnode!=null)
	{
		s=vsep+pnode.NodeId+s;
		pnode=pnode.ParentNode;
	}
	return s;
}
SMTreeNode.prototype.CreateNode=function()
{
	//NodeDiv
	var Nodee=document.createElement("div");;
	{	    
		this.Dom_Node=Nodee;
		Nodee.className=SMResObj.styles.Nodee;
		if (this.ParentNode) this.ParentNode.Dom_Body.appendChild(Nodee);
		else this.TreeView.DivTree.appendChild(Nodee);
	}
	//HeadTextDiv_ImgLeaf
	var ImgLeaf=document.createElement("img");
	{
		this.Dom_HeadText_ImgLeaf=ImgLeaf;
		ImgLeaf.className=SMResObj.styles.HeadImgLeaf;
		if(this.NodeIsFolder)
		{
			ImgLeaf.style.cursor="pointer";
			ImgLeaf.onmouseover=this.DoLeafMouseOver.Bind(this);
			ImgLeaf.onmouseout=this.DoLeafMouseOut.Bind(this);
			ImgLeaf.onclick=this.DoLeafClick.Bind(this);
		}
		Nodee.appendChild(ImgLeaf);
		{
			if (this.NodeIsFolder)
			{
				if (this.NodeIsLastOne)ImgLeaf.src=SMResObj.icons.PM2;
				else ImgLeaf.src=SMResObj.icons.PM1;
			}
			else
			{
				if (this.NodeIsLastOne)ImgLeaf.src=SMResObj.icons.L2;
				else ImgLeaf.src=SMResObj.icons.L1;
			}
		}
	}
	//ClassImg
	this.CreateClassImages();
	//HeadTextDiv_ImgDoc
	if(this.CheckBox==null&&this.Radio_==null){
		var ImgDoc=document.createElement("img");
		{
			this.Dom_HeadText_ImgDoc=ImgDoc;
			ImgDoc.className=SMResObj.styles.HeadImgDoc;
			Nodee.appendChild(ImgDoc);
			
			if (this.NodeIsFolder)
			{
				if(this.Img!=null) ImgDoc.src=this.Img;
				else {
					if(this.ImgLock) ImgDoc.src=SMResObj.icons.folder_lock;
					else ImgDoc.src=SMResObj.icons.folder;
				}
				ImgDoc.onclick=this.DoLeafClick.Bind(this);
				ImgDoc.style.cursor="pointer";
			}else{
				if(this.Img!=null) ImgDoc.src=this.Img;
				else {
					if(this.ImgLock) ImgDoc.src=SMResObj.icons.file_lock;
					else ImgDoc.src=SMResObj.icons.file;
				}
			}
		}
	}
	if(this.CheckBox!=null){
		var ck = document.createElement("<input type=checkbox name="
			+this.CheckBox+" value="+this.CheckBoxValue+" style='width:15px;height:15px;' />");		
		if(this.TreeView.OnNodeSelObjClick != null) ck.onclick = this.TreeView.OnNodeSelObjClick.Bind(this);
		else ck.onclick = this.DoCheckBoxClick.Bind(this); 
		this.CheckBoxObj = ck;
		Nodee.appendChild(ck);		
	}
	if(this.Radio_!=null){
		var rd = document.createElement("<input type=radio name="
			+this.Radio_+" value="+this.RadioValue+"  style='width:15px;height:15px;' />");
		if(this.TreeView.OnNodeSelObjClick != null) rd.onclick = this.TreeView.OnNodeSelObjClick.Bind(this);
		this.RadioObj = rd;
		Nodee.appendChild(rd);
	}
	//HeadTextDiv_Link
	var TextLink=document.createElement("span");
	{
		this.Dom_HeadText_Link=TextLink;
		TextLink.className=SMResObj.styles.HeadLink;
		TextLink.href=this.NodeHref;
		TextLink.innerHTML=this.NodeText;
		TextLink.title=this.NodeText;
		TextLink.onmouseover=this.DoLinkMouseOver.Bind(this);
		TextLink.onmouseout=this.DoLinkMouseOut.Bind(this);
		TextLink.onclick=this.DoLinkClick.Bind(this);
		Nodee.appendChild(TextLink);
	}
	//BodyDiv
	var BodyDiv=document.createElement("div");
	{
		this.Dom_Body=BodyDiv;
		BodyDiv.className=SMResObj.styles.NodeBody;
		Nodee.appendChild(BodyDiv);
	}
}
SMTreeNode.prototype.CreateClassImages=function()
{
	var pnode=this.ParentNode,refChild=this.Dom_HeadText_ImgLeaf;
	while(pnode)
	{
		var img=document.createElement("img");
		this.Dom_Node.insertBefore(img,refChild);
		if(pnode.NodeIsLastOne)img.src=SMResObj.icons.empty;
		else img.src=SMResObj.icons.L4;
		img.className=SMResObj.styles.HeadImgLeaf;
		refChild=img;
		//this.Dom_HeadText.appendChild(img)
		pnode=pnode.ParentNode;
	}
}
SMTreeNode.prototype.AddChildItem=function(ANodeChild)
{
	this.Items[this.Items.length]=ANodeChild;
}
SMTreeNode.prototype.OpenLink=function()
{
	if(this.NodeHref!=""&&this.NodeHref!=null)
	try{
		if(this.Target) window.open(this.NodeHref,this.Target);
		else window.open(this.NodeHref,this.TreeView.Target);		
	}catch(e){}
}
SMTreeNode.prototype.LostFocus=function()
{
	this.Dom_HeadText_Link.className=SMResObj.styles.HeadLink;
	//if (!this.NodeIsFolder){
	if ( (!this.NodeIsFolder) && (this.Dom_HeadText_ImgDoc!=null) ){
		if(this.Img!=null) this.Dom_HeadText_ImgDoc.src = this.Img;
		else {
			if(this.ImgLock)this.Dom_HeadText_ImgDoc.src = SMResObj.icons.file_lock;
			else this.Dom_HeadText_ImgDoc.src = SMResObj.icons.file;
		}
	}
}
//
SMTreeNode.prototype.Focus=function()
{
	if (this.TreeView.SelectedNode)this.TreeView.SelectedNode.LostFocus();
	
	if ( (!this.NodeIsFolder) && (this.Dom_HeadText_ImgDoc!=null) ){
		if(this.ImgSel!=null) this.Dom_HeadText_ImgDoc.src = this.ImgSel;
		else {
			if(this.ImgLock)this.Dom_HeadText_ImgDoc.src = SMResObj.iconsExpand.file_lock;
			else this.Dom_HeadText_ImgDoc.src = SMResObj.iconsExpand.file;
		}
	}

	this.TreeView.SelectedNode=this;
	this.Dom_HeadText_Link.className=SMResObj.stylesFocus.HeadLink;
}
SMTreeNode.prototype.ShowChildTree=function()
{
	if (this.NodeIsFolder)
	{
		if(this.NodeIsLastOne)this.Dom_HeadText_ImgLeaf.src=SMResObj.iconsExpand.PM2;
		else this.Dom_HeadText_ImgLeaf.src=SMResObj.iconsExpand.PM1;
		
		if(this.Dom_HeadText_ImgDoc!=null){
			if(this.ImgSel!=null)this.Dom_HeadText_ImgDoc.src=this.ImgSel;
			else {
				if(this.ImgLock)this.Dom_HeadText_ImgDoc.src=SMResObj.iconsExpand.folder_lock;
				else this.Dom_HeadText_ImgDoc.src=SMResObj.iconsExpand.folder;
			}
		}
		
		this.Dom_Body.className=SMResObj.stylesShow.NodeBody;
		this.ChildIsShow=true;
	}
}
SMTreeNode.prototype.HideChildTree=function()
{
	if (this.NodeIsFolder)
	{
		if(this.NodeIsLastOne)this.Dom_HeadText_ImgLeaf.src=SMResObj.icons.PM2;
		else this.Dom_HeadText_ImgLeaf.src=SMResObj.icons.PM1;
		
		if(this.Dom_HeadText_ImgDoc!=null){
			if (this.Img!=null)this.Dom_HeadText_ImgDoc.src=this.Img;
			else{
				if(this.ImgLock) this.Dom_HeadText_ImgDoc.src=SMResObj.icons.folder_lock;
				else this.Dom_HeadText_ImgDoc.src=SMResObj.icons.folder;
			}
		}
		
		this.Dom_Body.className=SMResObj.styles.NodeBody;
		this.ChildIsShow=false;	
	}
}
SMTreeNode.prototype.Collapse=function()
{
	this.HideChildTree();
}
SMTreeNode.prototype.Expand=function()
{
	if(this.NodeIsFolder)
	{
		if(!this.ChildHasCreated)this.TreeView.CreateChildTree(this);	
		if(!this.ChildIsShow)this.ShowChildTree();
	}		
}
SMTreeNode.prototype.AutoExpand=function()
{
	this.Dom_HeadText_Link.scrollIntoView(false);
	if(this.Class==this.TreeView.ScrollIds.length)
	{
		this.Focus();
		if(this.NodeIsFolder)this.Expand();	
	  	/*var iY = this.Dom_HeadText_Link.offsetTop - window.document.body.clientHeight/2;
	  	var iX = this.Dom_HeadText_Link.offsetLeft - 15;
	    window.scrollTo( iX , iY );*/	
		if(this.TreeView.AutoExpandCheck){
			if (this.RadioObj!=null) this.RadioObj.checked = true;
			if (this.CheckBoxObj!=null){
				this.TreeView.CheckBoxSelCount++;
				this.CheckBoxObj.checked = true;
			} 	
		}
		setTimeout(this.TreeView.VarName+".ScrollByIds()",100);
		return true;//auto expand end	
	}
	else
	{
		if(!this.NodeIsFolder)return;
		if(this.ChildHasCreated)
		{
			this.Expand();
			this.TreeView.AutoExpandNode(this);
		}
		else
		{
			this.AutoExpanded=true;
			this.Expand();		
		}
		return false;
	}
}
SMTreeNode.prototype.DoLinkMouseOver=function()
{
	this.Dom_HeadText_Link.className=SMResObj.stylesMouseOver.HeadLink;
}
SMTreeNode.prototype.DoLinkMouseOut=function(ANode)
{
	if(ANode==ANode.TreeView.SelectedNode) ANode.Dom_HeadText_Link.className=SMResObj.stylesFocus.HeadLink;
	else ANode.Dom_HeadText_Link.className=SMResObj.styles.HeadLink;
}
SMTreeNode.prototype.DoCheckBoxClick=function(vnode){
	if(this.CheckBoxObj.checked)this.TreeView.CheckBoxSelCount++; else this.TreeView.CheckBoxSelCount--;

	if(this.TreeView.CheckBoxSelCount>this.TreeView.CheckBoxSelMax&&this.TreeView.CheckBoxSelMax!=0&&this.CheckBoxObj.checked){
		this.CheckBoxObj.checked = ! this.CheckBoxObj.checked;
		if(this.CheckBoxObj.checked)this.TreeView.CheckBoxSelCount++; else this.TreeView.CheckBoxSelCount--;
		alert(this.TreeView.CheckBoxSelOverHint);
	} 
}
SMTreeNode.prototype.DoLinkClick=function()
{
	if(this.CheckBoxObj!=null){
		this.CheckBoxObj.checked = ! this.CheckBoxObj.checked;
		if(this.CheckBoxObj.onclick != null)this.CheckBoxObj.onclick();
	} 
	if(this.RadioObj!=null){
		this.RadioObj.checked = ! this.RadioObj.checked;
		if(this.RadioObj.onclick != null) {this.RadioObj.onclick();}
	}
	
	if(this.TreeView.SelectChange(this))
	{
		this.Focus();
		this.OpenLink();
		if(this.NodeIsFolder){
			if(this.TreeView.CollapseWhenReClickLink){
				if(this.ChildIsShow)this.Collapse();
				else this.Expand();
			}else this.Expand();
		}		
	}
	else
	{
		if(this.TreeView.LinkReOpen) this.OpenLink();
		if(this.TreeView.CollapseWhenReClickLink){
			if(this.ChildIsShow)this.Collapse();
			else this.Expand();
		}
	}
}
SMTreeNode.prototype.DoLeafMouseOver=function(ANode)
{
	if(ANode.NodeIsFolder)
	{
		if(ANode.NodeIsLastOne)
		{
			if (ANode.ChildIsShow)
				ANode.Dom_HeadText_ImgLeaf.src=SMResObj.iconsMouseOver.PM2;
			else
				ANode.Dom_HeadText_ImgLeaf.src=SMResObj.iconsMouseOver.PM2_;		
		}
		else
		{
			if (ANode.ChildIsShow)
				ANode.Dom_HeadText_ImgLeaf.src=SMResObj.iconsMouseOver.PM1;
			else
				ANode.Dom_HeadText_ImgLeaf.src=SMResObj.iconsMouseOver.PM1_;		
		}
	}
}
SMTreeNode.prototype.DoLeafMouseOut=function(ANode)
{
	if(ANode.NodeIsFolder)
	{
		if(ANode.NodeIsLastOne)
		{
			if (ANode.ChildIsShow)
				ANode.Dom_HeadText_ImgLeaf.src=SMResObj.iconsExpand.PM2;
			else
				ANode.Dom_HeadText_ImgLeaf.src=SMResObj.icons.PM2;		
		}
		else
		{
			if (ANode.ChildIsShow)
				ANode.Dom_HeadText_ImgLeaf.src=SMResObj.iconsExpand.PM1;
			else
				ANode.Dom_HeadText_ImgLeaf.src=SMResObj.icons.PM1;		
		}
	}
}
SMTreeNode.prototype.DoLeafClick=function(ANode)
{
	if(ANode.NodeIsFolder)
	{
		if(ANode.ChildIsShow)ANode.Collapse();
		else ANode.Expand();
	}
}
function SMTreeView(treezone, VarName)
{
	if(typeof(treezone) != "string" || treezone == "")
	throw(new Error("need argment"));	
	if(typeof(VarName) != "string" || VarName == "")
	throw(new Error("need var name"));	

	this.DivTree = document.getElementById(treezone);
	this.VarName = VarName;								//Expand的时需要通过settimeout进行
	this.RootTitle = "SMTreeView";
	this.RootLink = null;
	this.RootLinkObj = null;							//创建的RootLink对象，是个href
	this.RootLinkAutoOpen = false;
	this.RootLinkImgLock = false;						//是否显示带锁图标
	this.LoadingHint = "Loading...";
	this.TreeXml = "tree.xml";
	this.ScrollXml = null;								//自动展开的 xml文件地址，Scroll级别比ScrollIdStrs高
	this.ScrollIdStrs = null;							//自动展开的 idstrs
	this.IdStrs = new Array();
	this.IdStrsPos = 0;
	this.ScrollIds = new Array();
	this.Target = "_blank";
	this.SelectedNode = null;
	this.Items = new Array();
	this.RootItems = new Array();
	this.XmlHttp = null;
	this.XmlHttpScroll = null;
	this.RootLoadHintObj = null;
	this.LinkReOpen = false;							//重复点击Tree的Node时是否再次执行Open Link的操作
	this.CheckBoxSelMax = 0;
	this.CheckBoxSelCount = 0;
	this.CheckBoxSelOverHint = "Select too much!";
	this.CollapseWhenReClickLink = false;
	this.AutoExpandCheck = true;
	this.PreCheckedIds = "";
	this.OnNodeSelObjClick = null;
	this.AutoExpendParentNode = true;					//是否自动展开treexml中有子节点（xmlnode）的父节点，不是通过nodexmlsrc展开的父节点
	
	this.TreeXml = SMResObj.PathCur + this.TreeXml;
}
SMTreeView.prototype.Init=function()
{
	var d = new Date().getTime();

	this.DecomposeIdsStr();
	this.DivTree.className="divtreeview";	
	this.CreateRootTitle();
	this.CreateChildTree(null);	
	
	//window.status=("All Cost Time = "+ (new Date().getTime()-d) +" ms; "+ this.Items.length +" nodes.");
}
//check browser
SMTreeView.prototype.BrowIsIE=function()
{
	var ua = window.navigator.userAgent.toLowerCase();
	return (/msie/i.test(ua));
}
SMTreeView.prototype.ScrollByXML=function()
{
	if(this.ScrollXml!=null){
		this.XmlHttpScroll=null;
		if (window.ActiveXObject)
		{
			this.XmlHttpScroll=null;
			this.XmlHttpScroll=new ActiveXObject("MSXML2.XmlHttp");	
			this.XmlHttpScroll.onreadystatechange =this.DoXMLHttpScrollXmlComplete.Bind(this);
			this.XmlHttpScroll.open( "GET", this.ScrollXml, true );
			this.XmlHttpScroll.send();			
		} 
		else 
		{
			//xmldoc = document.implementation.createDocument("","",null);	
			this.XmlHttpScroll=null;
			this.XmlHttpScroll= new XMLHttpRequest();	
		}
	}
}
SMTreeView.prototype.DecomposeIdsStr=function(){
	this.IdStrs.length = 0;
	if(this.ScrollIdStrs == null || this.ScrollIdStrs == "")return;
	
	this.IdStrs = this.ScrollIdStrs.split("|");
	this.IdStrsPos = 0;
}
SMTreeView.prototype.ScrollByIds=function(){
	if(this.IdStrsPos>=this.IdStrs.length)return;
	var j= this.IdStrsPos;

	for(var i=j;i<this.IdStrs.length;i++){
		this.IdStrsPos ++;
		if(this.IdStrs[i].Trim()=="")continue;
			
		this.ScrollIds.length = 0;
		var Ids = this.IdStrs[i].split(".");
		for(var j=0;j<Ids.length;j++){
			if(Ids[j].Trim()!=""){
				this.ScrollIds[this.ScrollIds.length] = Ids[j].Trim();
			}					
		}
		this.AutoExpandNode(null);
		break;
	}
}
SMTreeView.prototype.DoRootLinkClick=function(){
	if(this.SelectedNode!=null){
		this.SelectedNode.LostFocus();
		this.SelectedNode = null;
	}
}
SMTreeView.prototype.CreateRootTitle=function()
{
	var div = document.createElement("div");
	this.DivTree.appendChild(div);
	
	var img = document.createElement("img");
	if(this.RootLinkImgLock) img.src = SMResObj.icons.root_lock;
	else img.src = SMResObj.icons.root;
	img.className = SMResObj.styles.HeadImgDoc;
	img.setAttribute("align","absMiddle");
	div.appendChild(img);
	
	var vspan = document.createElement("span");
	vspan.innerHTML = this.RootTitle;
	vspan.className = SMResObj.styles.TreeTitle;
	div.appendChild(vspan);

	this.RootLoadHintObj=document.createElement("marquee");
	this.RootLoadHintObj.className=SMResObj.styles.LoadHint;
	this.RootLoadHintObj.setAttribute("behavior","alternate");
	this.RootLoadHintObj.innerHTML=this.LoadingHint;
	this.DivTree.appendChild(this.RootLoadHintObj);
	
	if(this.RootLink&&this.RootLink!=''){
		var RootLinkObj = document.createElement("A");
		RootLinkObj.target = this.Target;
		RootLinkObj.href = this.RootLink;
		RootLinkObj.innerText = this.RootTitle;
		RootLinkObj.onclick = this.DoRootLinkClick.Bind(this);
		vspan.innerHTML = "";
		vspan.appendChild(RootLinkObj);
		this.RootLinkObj = RootLinkObj;
		//如果没有scroll设置，并且设定了自动打开RootLink，那么就打开Rootlink
		if(this.ScrollXml==null && this.ScrollIdStrs==null && this.RootLinkAutoOpen)
			window.open(this.RootLink,this.Target);
	} 
}
SMTreeView.prototype.AutoExpandNode=function(ANode)
{
	//return (weather expend to end node)
	var i,inode,items,nodeclass;
	if(ANode){items=ANode.Items;nodeclass=ANode.Class;}
	else{items=this.RootItems;nodeclass=0;}
	
	//to check not overflow
	if(this.ScrollIds.length>nodeclass)
	{
		for(i=0;i<items.length;i++)
		if(items[i].NodeId==this.ScrollIds[nodeclass])
		{
			return items[i].AutoExpand();
		}
		return true;
	}else return true;
}
SMTreeView.prototype.DoXMLHttpNodeXmlComplete=function(object,ANodeIndex)
{
	if(this.XmlHttp.readyState!= 4) return;
	//alert(arguments.length)
	if(ANodeIndex!=null)
	{
		//close loading hint
		this.Items[ANodeIndex].Dom_Body.style.marginLeft=0;
		this.Items[ANodeIndex].Dom_Body.innerHTML="";
	}
	else
	{
		//close loading hint
		this.RootLoadHintObj.style.display="none";
	}
	if(this.XmlHttp.responseXML.xml!="")
	{
		this.CreateChildTree_(this.Items[ANodeIndex],this.XmlHttp.responseXML.documentElement);
		//support auto expand
		this.XmlHttp=null;
		if(ANodeIndex!=null){
			if(this.Items[ANodeIndex].AutoExpanded){
				this.AutoExpandNode(this.Items[ANodeIndex])
			}
		}
	}
	else
	{
		this.XmlHttp=null;
		//close loading hint
		if(ANodeIndex!=null)this.Items[ANodeIndex].Dom_Body.className=SMResObj.styles.NodeBody;
		alert("Load XML Error!");
	}
	
	//begin scroll by tree node
	if(ANodeIndex==null){
		if(this.ScrollXml) this.ScrollByXML();
		else this.ScrollByIds();
	}
}
SMTreeView.prototype.DoXMLHttpScrollXmlComplete=function(ATreeVar)
{	
	if(  this.XmlHttpScroll.readyState != 4 ) return;
	if(ATreeVar.XmlHttpScroll.responseXML.xml!="")
	{
		if(ATreeVar.XmlHttpScroll.responseXML.documentElement.childNodes.length>0)
		{
			this.ScrollIdStrs = ".";
			for(var i=0 ;i<ATreeVar.XmlHttpScroll.responseXML.documentElement.childNodes.length;i++){
				this.ScrollIdStrs = this.ScrollIdStrs + ATreeVar.XmlHttpScroll.responseXML.documentElement.childNodes[i].getAttribute("id") + ".";
			}
			this.DecomposeIdsStr();
			this.ScrollByIds();
		}
	}
	else alert("Load ScrollXML Error!");
}
//create item chilren with xmlnode
SMTreeView.prototype.CreateChildTree_=function(AParentTreeNode,axmlnode)
{
	var inode,vnode,i;
	for (i=0;i<axmlnode.childNodes.length;i++)
	{
		inode=axmlnode.childNodes[i];
		vnode=new SMTreeNode(this,AParentTreeNode,inode);
		if(AParentTreeNode)AParentTreeNode.AddChildItem(vnode);
		else this.RootItems[this.RootItems.length]=vnode;
		if (inode.childNodes.length>0){
			this.CreateChildTree_(vnode,inode);
			if(this.AutoExpendParentNode) vnode.Expand();
		}
	}
}
//create item children
SMTreeView.prototype.CreateChildTree=function(AParentTreeNode)
{
	//if(this.XmlHttp){alert("wait...");return;}
	var d = new Date().getTime();
	var xmldoc;		
	if (window.ActiveXObject)
	{
		/*xmldoc=new ActiveXObject("Microsoft.XMLDOM");	
		xmldoc.async = true;
		if(AParentTreeNode)
		{
			//loading hint
			AParentTreeNode.ShowChildTree();
			AParentTreeNode.Dom_Body.style.marginLeft=AParentTreeNode.Dom_HeadText_Link.offsetLeft;
			AParentTreeNode.Dom_Body.innerHTML="<marquee class="+SMResObj.styles.LoadHint+" behavior='alternate'>"+this.LoadingHint+"</marquee>";
			xmldoc.load(AParentTreeNode.NodeXmlSrc);
		} 
		else
		{
			xmldoc.load(this.TreeXml);
		} 	
		if (xmldoc.xml!="")
		{
			var rootnode;
			rootnode=xmldoc.documentElement;
			this.CreateChildTree_(AParentTreeNode,rootnode);
		} 
		else
		{*/
			this.XmlHttp=null;
			this.XmlHttp=new ActiveXObject("MSXML2.XmlHttp");	
			if(AParentTreeNode)
			{
				AParentTreeNode.Dom_Body.style.marginLeft=AParentTreeNode.Dom_HeadText_Link.offsetLeft;
				AParentTreeNode.Dom_Body.innerHTML="<marquee class="+SMResObj.styles.LoadHint+" behavior='alternate'>"+this.LoadingHint+"</marquee>";
				this.XmlHttp.onreadystatechange=this.DoXMLHttpNodeXmlComplete.Bind(this,AParentTreeNode.NodeIndex);
				this.XmlHttp.open( "GET", AParentTreeNode.NodeXmlSrc, true );
				this.XmlHttp.send();			
			} 
			else
			{
				//一级node
				this.XmlHttp.onreadystatechange=this.DoXMLHttpNodeXmlComplete.Bind(this,null);
				this.XmlHttp.open( "GET", this.TreeXml, true );
				this.XmlHttp.send();			
			} 
		//} 
	}
	else 
	{
		//xmldoc = document.implementation.createDocument("","",null);	
		this.XmlHttp=null;
		this.XmlHttp= new XMLHttpRequest();	
		if(AParentTreeNode)
		{
			this.XmlHttp.onreadystatechange =this.DoXMLHttpNodeXmlComplete.Bind(this,AParentTreeNode.NodeIndex);
			this.XmlHttp.open( "GET", AParentTreeNode.NodeXmlSrc, true );
			this.XmlHttp.send(null);			
		} 
		else
		{
			this.XmlHttp.onreadystatechange =this.DoXMLHttpNodeXmlComplete.Bind(this,null);
			this.XmlHttp.open( "GET", this.TreeXml, true );
			this.XmlHttp.send(null);			
		} 
	}

	//window.status=("All Cost Time = "+ (new Date().getTime()-d) +" ms " + this.Items.length);
}
SMTreeView.prototype.SelectChange=function(AFocusNode)
{
	return (this.SelectedNode!=AFocusNode);
}
function SMTabCtrl(ADIVName)
{
	this.TabObj=$(ADIVName);
	this.Position=1;/*1,up;2,bottom;*/
	this.Head=null;
	this.Body=null;
	this.SelectIndex=-1;
	this.Tabs=new Array();
	this.Zones=new Array();
	this.OnTabChanged=null;
	this.ColorF;
	this.ColorB;
	this.Init();
	this.SelectTab(this.SelectIndexRead());
}
SMTabCtrl.prototype.Init=function()
{
	this.TabObj.className="SMTabCtrl";
	
	var i;
	for(i=0;i<this.TabObj.children.length;i++)
	if(this.TabObj.children[i].tagName=="DIV")
	{
		this.Zones[i]=this.TabObj.children[i];
		this.Zones[i].style.display="none";
	}

	var tablewhole = document.createElement("table");
	tablewhole.className = "SMTabCtrl_table";
	this.TabObj.appendChild(tablewhole);
	
	var tr,td;
	
    tr = tablewhole.insertRow();	
    td = tr.insertCell();	
	this.Head = td;
	this.Head.className="SMTabCtrl_Head";
	
    tr = tablewhole.insertRow();	
    td = tr.insertCell();	
	this.Body = td;
	this.Body.className="SMTabCtrl_Body";
	
	for(i=0;i<this.Zones.length;i++)
	{
		this.Tabs[i]=document.createElement("SPAN");
		this.Tabs[i].className="SMTabCtrl_Tab";
		this.Tabs[i].style.display="none";
		this.Tabs[i].onclick=this.DoTabClick.Bind(this,i);
		this.Head.appendChild(this.Tabs[i]);
		
		this.Body.appendChild(this.Zones[i]);
	}
	
	switch(this.Position)
	{
		case 1:			
			break;
	}
	
	if(this.TabObj.style.height=="100%"){
		tablewhole.style.height = "100%";
	}
}
SMTabCtrl.prototype.SetColor=function(AColorF, AColorB){
	this.ColorF = AColorF;
	this.ColorB = AColorB;
	if (this.ColorF!=null&&this.ColorB!=null){
		for(var i=0;i<this.Tabs.length;i++){
			if(i==this.SelectIndex){
				this.Tabs[i].style.backgroundColor = this.ColorF;
				this.Tabs[i].style.borderColor = this.ColorF;
			}else{
				this.Tabs[i].style.backgroundColor = this.ColorB;
				this.Tabs[i].style.borderColor = this.ColorF;
			}
		}
		this.Body.style.borderColor = this.ColorF;
	}
}
SMTabCtrl.prototype.TabName=function(AIndex,AName)
{
	if(AIndex<this.Tabs.length)
	{
		this.Tabs[AIndex].innerText=AName;
		this.Tabs[AIndex].style.display="";
	}
}
SMTabCtrl.prototype.SelectTab=function(AIndex)
{
	if(this.Zones.length==0)return;
	if(AIndex<0) AIndex = 0;
	if(this.SelectIndex!=-1)
	{
		this.Tabs[this.SelectIndex].className="SMTabCtrl_Tab";
		this.Tabs[this.SelectIndex].style.backgroundColor = this.ColorB;
		this.Zones[this.SelectIndex].style.display="none";
	}
	this.SelectIndex=AIndex;
	this.Zones[AIndex].style.display="";
	this.Tabs[AIndex].className="SMTabCtrl_Tab_Select";
	if(this.ColorF!=null)this.Tabs[AIndex].style.backgroundColor = this.ColorF;	
	if(this.OnTabChanged)this.OnTabChanged(AIndex);
}
SMTabCtrl.prototype.DoTabClick=function(ATabCtrl,ATabIndex)
{
	this.SelectTab(ATabIndex);
	this.SelectIndexWrite(ATabIndex);
}
SMTabCtrl.prototype.SelectIndexRead = function(){
	var aCookie = document.cookie.split("; ");
	var vIndex = -1;
  for (var i=0; i < aCookie.length; i++){
    var aCrumb = aCookie[i].split("=");
    if (aCrumb[0] == "SMTabCtrlIndex"){
	    if (aCrumb.length==2) vIndex = parseInt(unescape(aCrumb[1]));
			break;
		}
  }
	if(this.Tabs.length>vIndex)return vIndex;
	else return -1;
}
SMTabCtrl.prototype.SelectIndexWrite = function(AIndex){
	document.cookie = "SMTabCtrlIndex=" + AIndex + ";";
}