/////////////////////////////////////////////
//Copyright © 2006-2007 by FarStone Technology, Inc.
//////////////////////////////////////////////


Array.prototype.push=function(value)
{
	this[this.length]=value;
}
//单选按钮控件
////////////////////////Class radioButton///////////////////////////////////
//nav bar
//preproty:	text		//the text display in the radio button
//			
//Method:	setValue(String value) 		
//			applyStyle(UIStyle style)	//apply the uistyle object to the radio button;
//			attachMeToContainer(string containerName)	//attach radio to a group container
//			displayButton()		//display the button in html page
//			Enable()			//
//			Disable()				//
//			check()				// 
//			unCheck()
//event : 	onclick()  //Fire when click on the object
//			oncheck()  //Fire when check the radioButton
//
//
/////////////////////////
var uiBox=function()
{
	this.width=0;
	this.height=0;
	this.backGround="";
	this.startPositionX=0;
	this.startPositionY=0;
	this.text="&nbsp;";
	this.setProperty=function(bgPic,width,height,x,y)
	{
		this.backGround=bgPic;
		this.width=width;
		this.height=height;
		this.startPositionX=x;
		this.startPositionY=y;
	}
}

var radioButton=function()
{
	this.Super=uiBox;
	this.Super();
	this.containerName="";
	this.otX=0;
	this.otY=0;
	this.target="";
	this.url="";
	this.jsString="";
	var htmlStr="";
	this.value=""
	this.Default=false;
	this.flag="";	
	this.data="";
	this.id="";
	var id="rbt"+(Math.floor(Math.random()*100000))+"_"+(Math.floor(Math.random()*100000));
	this.id = id; 
	this.disableX="";
	this.disableY="";
	this.isEnable=true;
	this.onclick=function(){};
	this.oncheck=function(){};
	this.text="";
	this.checkText="";
	
	this.setFlag=function(flag)
	{
		this.flag=flag;	
	}
	
	this.setData=function(data)
	{
		this.data=data;	
	}
	
	this.attachMeToContainer=function(cname)
	{
		this.containerName=cname;
		var objContainer=eval(cname);
		objContainer.addRadioButtonId(this)
	}
	
	this.setDisablePoint=function(x,y)
	{
		this.disableX=x;
		this.disableY=y;
	}
	
	this.applyStyle=function(styleObj)
	{
		this.backGround=styleObj.picture
		this.width=styleObj.width
		this.height=styleObj.height
		this.startPositionX=styleObj.startX
		this.startPositionY=styleObj.startY
		this.otX=styleObj.otX
		this.otY=styleObj.otY
		this.disableX=styleObj.disableX
		this.disableY=styleObj.disableY
		this.disableSelectedX=styleObj.disableSelectedX;
		this.disableSelectedY=styleObj.disableSelectedY;
	}
	
	this.displayButton=function()
	{
		var htmlStr;
		if (this.backGround=="" || this.width==0)
		{
			return "";
		}
		
		var positonPropertiseString="dx=\""+this.disableX+"\" dy=\""+this.disableY+"\" ex=\""+this.startPositionX+"\" ey=\""+this.startPositionY+"\" otx=\""+this.otX+"\" oty=\""+this.otY+"\" dsx=\""+this.disableSelectedX+"\" dsy=\""+this.disableSelectedY+"\""
		
		if (this.Default)
		{
			htmlStr="<div "+positonPropertiseString+" isdisable=\"false\" id=\""+this.id+"\" evalue='"+this.value+"' stpst=\""+this.startPositionX+"|"+this.startPositionY+"\"  style=\"background-image:url("+this.backGround+");width:"+this.width+"px;height:"+this.height+"px;padding: 0;margin: 0;cursor:hand;background-position-x:-"+this.otX+"px;background-position-y:-"+this.otY+"px;\" ";
		}
		else
		{
			htmlStr="<div "+positonPropertiseString+" isdisable=\"false\" id=\""+this.id+"\" evalue='"+this.value+"' stpst=\""+this.startPositionX+"|"+this.startPositionY+"\"  style=\"background-image:url("+this.backGround+");width:"+this.width+"px;height:"+this.height+"px;padding: 0;margin: 0;cursor:hand;background-position-x:-"+this.startPositionX+"px;background-position-y:-"+this.startPositionY+"px;\" ";
		}
		

		htmlStr+=">"
		if (this.text=="")
		{
			htmlStr+="<img name=\"\" src=\"\" width=\"1\" height=\"1\" alt=\"\" /></div>"
		}
		else
		{
			htmlStr+=(this.text+"</div>")	
		}
		document.write(htmlStr);
		if (this.Default)
		{			
			eval(this.containerName+".proObj=document.getElementById('"+id+"');")			
		}
		//document.getElementById(this.id).attachEvent("onclick",this.onClickEvent(this));
		document.getElementById(this.id).onclick=this.onClickEvent(this);
	}
	
	this.GetHeml=function()
	{
		if (this.backGround=="" || this.width==0)
		{
			return "";
		}
		
		var positonPropertiseString="dx=\""+this.disableX+"\" dy=\""+this.disableY+"\" ex=\""+this.startPositionX+"\" ey=\""+this.startPositionY+"\" otx=\""+this.otX+"\" oty=\""+this.otY+"\" dsx=\""+this.disableSelectedX+"\" dsy=\""+this.disableSelectedY+"\""
		
		if (this.Default)
		{
			htmlStr="<div  "+positonPropertiseString+"  isdisable=\"false\" id=\""+this.id+"\" evalue='"+this.value+"' stpst=\""+this.startPositionX+"|"+this.startPositionY+"\"  style=\"background-image:url("+this.backGround+");width:"+this.width+"px;height:"+this.height+"px;padding: 0;margin: 0;cursor:hand;background-position-x:-"+this.otX+"px;background-position-y:-"+this.otY+"px;\" ";
		}
		else
		{
			htmlStr="<div  "+positonPropertiseString+"   isdisable=\"false\" id=\""+this.id+"\" evalue='"+this.value+"' stpst=\""+this.startPositionX+"|"+this.startPositionY+"\"  style=\"background-image:url("+this.backGround+");width:"+this.width+"px;height:"+this.height+"px;padding: 0;margin: 0;cursor:hand;background-position-x:-"+this.startPositionX+"px;background-position-y:-"+this.startPositionY+"px;\" ";
		}
		
		if (this.url!="")
		{
			htmlStr+=" onclick=\""+this.containerName+".doSwitch(this,"+this.otX+","+this.otY+");window.open('"+this.url+"','"+this.target+"');\""	
		}
		else if(this.jsString!="")
		{
			htmlStr+=" onclick=\""+this.containerName+".doSwitch(this,"+this.otX+","+this.otY+");"+this.jsString+";\""	
		}
		else
		{
			htmlStr+=" onclick=\""+this.containerName+".doSwitch(this,"+this.otX+","+this.otY+");\"";
		}
		htmlStr+=">"
		if (this.text=="")
		{
			htmlStr+="<img name=\"\" src=\"\" width=\"1\" height=\"1\" alt=\"\" /></div>"
		}
		else
		{
			htmlStr+=(this.text+"</div>")	
		}
		//document.write(htmlStr);
		if (this.Default)
		{
			//eval(this.containerName+".proObj=document.getElementById('"+id+"');")
			//alert("document.getElementById('"+id+"').click();");
			//eval("document.getElementById('"+id+"').click();");
		}
		return htmlStr;
	}
	
	this.onClickEvent=function(obj)
	{
		return function()
		{
			obj.onclick();
			if (obj.isEnable==false)
			{
				return;	
			}
			var ctnObj=eval(obj.containerName);
			if (obj.url!="")
			{
				ctnObj.doSwitch(this,obj.otX,obj.otY,obj);
				window.open(obj.url,obj.target);
			}
			else if(obj.jsString!="")
			{
				ctnObj.doSwitch(this,obj.otX,obj.otY,obj);
				eval(this.jsString);
			}
			else
			{
				ctnObj.doSwitch(this,obj.otX,obj.otY,obj);
			}
			if (obj.checkText!="")
			{
				this.innerHTML=obj.checkText;
			}
			obj.oncheck();
		}
	}
	
	
	
	this.setOtPosition=function(x1,y1)
	{
		this.otX=x1;
		this.otY=y1;
	}
	this.setOpenUrl=function(target,url)
	{
		this.target=target;
		this.url=url;
	}
	this.setJavascriptOperation=function(jsString)
	{
		this.jsString=jsString;
	}
	this.setValue=function(value)
	{
		this.value=value;
	}
	this.setDefault=function()
	{
		var ctn=eval(this.containerName);
		ctn.proObjID=this.id;
		this.Default=true;
	}
	this.Check=function()
	{
		document.getElementById(this.id).click();
	}
	
	this.Enable=function()
	{
		var ctn=eval(this.containerName);
		var domObj=document.getElementById(this.id);
		ctn.setBgPosition(domObj,domObj.otx,domObj.oty)
		this.isEnable=true;
	}
	
	this.Disable=function()
	{
		var ctn=eval(this.containerName);
		var domObj=document.getElementById(this.id);
		ctn.setBgPosition(domObj,domObj.dsx,domObj.dsy)
		this.isEnable=false;
	}
	this.check=function()
	{
		var domObj=document.getElementById(this.id);
		domObj.click();
	}
	this.unCheck=function()
	{
		alert("eeee");	
	}
}
/////////////////// container Class //////////////////
//method: 	Disable()
//			Enable()
//			unCheckAll();
//property 	isEnable
/////////////////////////////
var container=function(value)
{
	this.proObj=null;
	this.value=value;
	this.proObjID="";
	this.rdbtArray=new Array();
	this.rdbtObjArray=new Array();
	this.isEnable=true;
	this.proCusObj=null;
	this.doSwitch=function(obj,x,y,cusObj)
	{
		if (!this.isEnable)
		{
			return;	
		}
		this.proObj=document.getElementById(this.proObjID);
		
		if(this.proObj!=null)
		{
			var tmpStr=this.proObj.stpst;
			var tmpArr=tmpStr.split("|");
			this.proObj.style.backgroundPositionX=(-(tmpArr[0]))+"px";
			this.proObj.style.backgroundPositionY=(-(tmpArr[1]))+"px";
		}
		if (this.proCusObj!=null && this.proCusObj.text!="")
		{
			document.getElementById(this.proCusObj.id).innerHTML=this.proCusObj.text;
		}
		this.value=obj.evalue;
		//this.proObj=obj;
		this.proObjID=obj.id;
		this.proCusObj=cusObj;
		this.setBgPosition(obj,x,y);
	}
	this.setBgPosition=function(obj,x,y)
	{
		obj.style.backgroundPositionX=(-x)+"px";
		obj.style.backgroundPositionY=(-y)+"px";
	}
	this.Disable=function()
	{
		this.isEnable=false;
		var tmpDomObj=null;
		for (var i=0;i<this.rdbtArray.length;i++)
		{
			tmpDomObj=document.getElementById(this.rdbtArray[i]);
			if (this.value==tmpDomObj.evalue)
			{
				this.setBgPosition(tmpDomObj,tmpDomObj.dsx,tmpDomObj.dsy)
			}
			else
			{
				this.setBgPosition(tmpDomObj,tmpDomObj.dx,tmpDomObj.dy)
			}
			this.rdbtObjArray[i].isEnable=false;
		}
	}
	this.Enable=function()
	{
		this.isEnable=true;
		var tmpDomObj=null;
		for (var i=0;i<this.rdbtArray.length;i++)
		{
			//alert(document.getElementById(this.rdbtArray[i]))
			tmpDomObj=document.getElementById(this.rdbtArray[i]);
			if (this.value==tmpDomObj.evalue)
			{
				this.setBgPosition(tmpDomObj,tmpDomObj.otx,tmpDomObj.oty)
			}
			else
			{
				this.setBgPosition(tmpDomObj,tmpDomObj.ex,tmpDomObj.ey)
			}
			this.rdbtObjArray[i].isEnable=true;
		}	
	}
	
	this.addRadioButtonId=function(obj)
	{
		this.rdbtObjArray.push(obj);
		this.rdbtArray.push(obj.id)
	}
	this.unCheckAll=function()
	{
		this.proObj_unck=document.getElementById(this.proObjID);
		if(this.proObj_unck!=null)
		{
			var tmpStr=this.proObj_unck.stpst;
			var tmpArr=tmpStr.split("|");
			this.proObj_unck.style.backgroundPositionX=(-(tmpArr[0]))+"px";
			this.proObj_unck.style.backgroundPositionY=(-(tmpArr[1]))+"px";
		}
		if (this.proCusObj!=null && this.proCusObj.text!="")
		{
			document.getElementById(this.proCusObj.id).innerHTML=this.proCusObj.text;
		}
	}
}
///////////////////////////end radioButton Class/////////////////////
//sample:
//var container1=new container("2");
//radioButton1=new radioButton();创建一个单选按钮对?
//radioButton1.setProperty("images/radiobutton.jpg",12,12,12,0);
//radioButton1.setOtPosition(0,0);
//radioButton1.attachMeToContainer("container1");将VALUE保存在container1?
//radioButton1.setValue("2");
//radioButton1.setDefault();设置默认选中
//radioButton1.setJavascriptOperation("isselect();");单击事件要执行的函数
//<script language="javascript">radioButton1.displayButton();<\\script>//
var UIStyle=function()
{
	this.className="UIStyle";
	this.picture="";
	this.width="";
	this.height="";
	this.startX="";
	this.startY="";
	this.otX="";
	this.otY="";
	this.disableX="";
	this.disableY="";
	this.disableSelectedX="";
	this.disableSelectedY="";
	this.setStyle=function(picture,width,height,startX,startY)
	{
		this.picture=picture;
		this.width=width;
		this.height=height;
		this.startX=startX;
		this.startY=startY;
	}
	this.setReversalPosition=function(otX,otY)
	{
		this.otX=otX;
		this.otY=otY;
	}
	this.setDisablePosition=function(disableX,disableY)
	{
		this.disableX=disableX;
		this.disableY=disableY;
	}
	this.setDisableSelectedPosition=function(disableSelectedX,disableSelectedY)
	{
		this.disableSelectedX=disableSelectedX;
		this.disableSelectedY=disableSelectedY;
	}
}






////////////////Class downListCreator/////////////
// 	It's drop down list generator.
// 	 	method:  	getCtrl(Array listValue,String dropDownListName,String parentNodeName,String defaultValue,int size)
//						listValue:   List value 
//						dropDownListName: The name of the dropdownlist, it's exclusive.
//						parentNodeName: Where you want the dropdownlist to be append, it's the parent node's id.
//						defaultValue:default Value.
//						size: size of dropdownlist;
//					return: dropDownList Object
//				------------------------------------------------------------------
//	dropDownList object:
//		method:		Enable()
//					Disable()
//					setValue(text)
//					add(text,value)   (String to be displayed, the value of the text)
//		property:	isEnable
//					value				selected value
//		event:		onChange
//
/////////////////////////////////////////////
var downListCreator=function()
{
	this.ranId="ID"+parseInt(Math.random()*100000)+"_"+parseInt(Math.random()*100000);
	var scriptDiv=document.createElement("div");
	scriptDiv.id=this.ranId;
	scriptDiv.style.display="none";
	document.body.appendChild(scriptDiv);
	
	
	this.getCtrl=function(arrList,ctrlName,ctrlParentNode,dftVal,size)
	{

		var haveMatchVar=false;
		this.listValue=arrList;
		this.ctrlName=ctrlName;
		var tmpArr=new Array();
		var scriptElement=document.createElement("script");
		scriptElement.language="javascript";
		var innerText1='var downlist_'+this.ctrlName+'=new editselect("'+this.ctrlName+'","'+size+'","'+dftVal+'",false,100,1,"'+ctrlParentNode+'");';
		
		// dftVal=dftVal.replace(/+/g,"\+");
		 dftVal=dftVal.replace(/([^a-zA-Z0-9\s])/g,"\\$1");
		 eval("var expStr=/^"+dftVal+"\\|/;")
		 //alert(expStr)
		//alert("dododo|2".match(expStr)==null)
		for (i=0;i<arrList.length;i++)
		{
			tmpArr=arrList[i].split("|");
			innerText1+='downlist_'+this.ctrlName+'.add("'+tmpArr[0]+'","'+tmpArr[1]+'");'
			//alert(expStr);
			if (arrList[i].match(expStr)!=null)
			{
				//alert("kaokao");
				scriptElement.value=tmpArr[1];
				haveMatchVar=true;
			}
		}
		if (!haveMatchVar)
		{
			scriptElement.value="";
		}
		scriptElement.text=innerText1
		document.getElementById(this.ranId).appendChild(scriptElement);
		scriptElement.Enable=this.dlEnableFunction(this.ctrlName,scriptElement)
		scriptElement.Disable=this.dlDisableFunction(this.ctrlName,scriptElement);
		scriptElement.setValue=this.getSetValueFunction(this.ctrlName,scriptElement,arrList);
		scriptElement.setText=this.getSetTextFunction(this.ctrlName,scriptElement,arrList);
		scriptElement.add=this.getAddFunction(this.ctrlName,scriptElement,arrList);
		scriptElement.isEnable=true;
		scriptElement.onChange=function(){}
		scriptElement.id="downlist_script_"+this.ctrlName
		return scriptElement;
	}
	
	this.dlEnableFunction=function(name,scObj)
	{
		return function()
		{
			scObj.isEnable=true;
			var dlObj=eval("downlist_"+name)
			dlObj.Enable();
		}
	}
	
	this.dlDisableFunction=function(name,scObj)
	{
		return function()
		{
			scObj.isEnable=false;
			var dlObj=eval("downlist_"+name)
			dlObj.Disable();
		}
	}
	
	this.getSetValueFunction=function(name,scObj,arrList)
	{
		return function(newValue)
		{
			var tmpArr;
			eval("var expStr=/^"+newValue+"\\|/;")
			for (i=0;i<arrList.length;i++)
			{
				if (arrList[i].match(expStr)!=null)
				{
					tmpArr=arrList[i].split("|");
					scObj.value=tmpArr[1];
					document.getElementById(name+"_button_input").value=newValue;
					return;
				}
			}
		}
	}
	this.getSetTextFunction=function(name,scObj,arrList)
	{
		return function(newValue)
		{
			var tmpArr;
			eval("var expStr=/\\|"+newValue+"$/;")
			for (i=0;i<arrList.length;i++)
			{
				if (arrList[i].match(expStr)!=null)
				{
					tmpArr=arrList[i].split("|");
					scObj.value=tmpArr[1];
					document.getElementById(name+"_button_input").value=tmpArr[0];
					return;
				}
			}
		}
	}
	
	this.getAddFunction=function(name,scObj,arrList)
	{
		return function(text,value)
		{
			var dlObj=eval("downlist_"+name);
			dlObj.add(text,value);
			arrList.push(text+"|"+value)
		}
	}
}



scHTML='<div id="selectcontent" class="selectdiv" style="visibility:hidden;"><div id="selecthtml" class="selectcontent">select</div></div>'
document.write(scHTML)
vDiv=selectcontent
vDivHtml=selecthtml
function editselect(name,size,defaulttext,width,height,readonly,parentNodeName)
{
	this.Enable=function()
	{
		this.enable=true;	
		document.getElementById(this.buttonname+"_input").className="selecttext"
		document.getElementById(this.buttonname).className="selectbutton"
	}
	this.Disable=function()
	{
		this.enable=false;
		document.getElementById(this.buttonname+"_input").className="selecttextdis"
		document.getElementById(this.buttonname).className="selectbuttondis"
	}
  	var combo=this;
  	this.options=new Array();
  	this.name=name;
  	this.divname=name+'_div';
  	this.buttonname=name+'_button';
  	this.tablename=name+'_table';
  	this.htmltable=name+'_html';
  	this.hasFirstDropDown=false;
  	this.enable=true;
  	this.selectedIndex=0;
  	this.hightLightValue="";
  	this.excusiveId="BT_"+Math.floor(Math.random(100)*10000)+"_"+Math.floor(Math.random(100)*10000);
	this.previousSelectId=0;
  
  	if (!height) this.height=0; else this.height=height
  	if (width) this.width=width
  	if (!size) size=8
  	if (!defaulttext) defaulttext=""
  	if (!readonly || readonly==0) {readonly="" }else {if (readonly==1) readonly="readonly style=cursor:default";this.readonly=1}
  
  	esHTML='<div id='+this.divname+'>'
  		+'<table id='+this.tablename+'><tr><td valign="bottom">'
         +'<input type=text id="'+this.buttonname+'_input"  class="selecttext" size="'+size+'" name='+name+' value="'+defaulttext+'" '+readonly+'><span onfocus="" tabindex="-1" class=selectbutton id='+this.buttonname+' /></td></tr></table>'
         +'</div>'
	var parentNodeObject=document.getElementById(parentNodeName);
	if (parentNodeObject==null)
	{
  		document.write(esHTML)
	}
	else
	{
		parentNodeObject.innerHTML=esHTML;

	}
	
	document.getElementById(this.buttonname).onblur=document.getElementById(this.buttonname+'_input').onblur=function()// When lose focus, hide the drop down list
	{
		//document.getElementById("selectcontent").style.visibility="hidden";
	}
	

    
  	this.sbutton=eval("document.all."+this.buttonname)
  	this.subInputBox=null;
  	this.subInputBox=document.getElementById(this.buttonname+'_input');
  
  	if (this.readonly==1) this.subInputBox.onclick=function()
	{
		if (document.getElementById("selectcontent").style.visibility!="hidden")
		{
			return;
		}
		combo.show(1)
	}
  
  	this.getKeydownFunction=function(obj)
  	{
  		return function()
		{
			
			if (event.keyCode==27 || event.keyCode==9)// user press "esc" key or "tab" key;
			{
				document.getElementById("selectcontent").style.visibility="hidden";
			}
			if (event.keyCode==40)// user press "down" key
			{
				obj.selectedIndex++;
				if(document.getElementById("selectcontent").style.visibility=="hidden")
				{
					obj.selectedIndex=1;
				}
				if(obj.options.length<obj.selectedIndex)
				{
					obj.selectedIndex=obj.options.length;
					return;
				}
				obj.show(obj.selectedIndex)
				obj.hightLightValue=obj.options[obj.selectedIndex-1]
				
				var downObj=document.getElementById("selecthtml")////////set scroll bar position
					//alert(downObj.scrollTop);
					//downObj.scrollTop=20;
				var topDsts=downObj.scrollTop;/////distance from top to the "top" of list can be see 
				var viewBottomDsts=topDsts+obj.height;/////distance from  top to the "bottom" the list can be see 
				if ((obj.selectedIndex)*19<viewBottomDsts)
				{
					return;
				}
				var scrollTopVal=((obj.selectedIndex)*19-obj.height)
				if (scrollTopVal>0)
				{
						downObj.scrollTop=scrollTopVal;
				}
				return false;
				//alert(obj.hightLightValue)
			}
			else if (event.keyCode==38)// user press "up" key
			{
				
				obj.selectedIndex--;
				if(document.getElementById("selectcontent").style.visibility=="hidden")
				{
					obj.selectedIndex=1;
				}
				if(0==obj.selectedIndex)
				{
					obj.selectedIndex=1;
					return;
				}
				obj.show(obj.selectedIndex)
				obj.hightLightValue=obj.options[obj.selectedIndex-1]
				//alert(obj.hightLightValue)
				var downObj=document.getElementById("selecthtml")////////set scroll bar position
					//alert(downObj.scrollTop);
					//downObj.scrollTop=20;
				var scrollTopVal=((obj.selectedIndex-1)*19);
				var topDsts=downObj.scrollTop;/////distance from top to the "top" of the list can be see 
				var viewBottomDsts=topDsts+obj.height;/////distance from  top to the "bottom" of the list can be see 
				if ((obj.selectedIndex-1)*19>topDsts)
				{
					return;
				}
				if (scrollTopVal<0)
				{
					scrollTopVal=0;
				}
				if (scrollTopVal>=0)
				{
						downObj.scrollTop=scrollTopVal;
				}

			}
			else if(event.keyCode==13)// user press "enter" key
			{
				if(typeof(obj.hightLightValue)=="undefined")
				{
					return false;
				}
				if (obj.hightLightValue=="")
				{
					return false;
				}
				if(document.getElementById("selectcontent").style.visibility=="hidden")
				{
					return false;
				}
				obj.subInputBox.value=obj.hightLightValue.split("|&")[0];
				setSelectValue(obj.hightLightValue.split("|&")[1],obj.name);
				vDiv.style.visibility="hidden";
				obj.subInputBox.select();
				return false
			}
			else if(event.keyCode==35)/////////////////user press "End" button
			{
				obj.show(obj.options.length);
				obj.hightLightValue=obj.options[obj.options.length-1];
				var downObj=document.getElementById("selecthtml")////////set scroll bar position
				var scrollTopVal=((obj.options.length+1)*19-obj.height)
				if (scrollTopVal>0)
				{
						downObj.scrollTop=scrollTopVal;
				}
			}
			else if (event.keyCode==36)/////////////////user press "Home" button
			{
				obj.show(1);
				obj.hightLightValue=obj.options[0];
				var downObj=document.getElementById("selecthtml")////////set scroll bar position
				downObj.scrollTop=0;
			}
			else if (event.keyCode==34)//user press "page down" key
			{
				var pageSize=parseInt(obj.height/19,10);
				var nextID=pageSize+obj.selectedIndex;
				if (nextID>obj.options.length)
				{
					nextID=obj.options.length
				}
				obj.show(nextID);
				obj.hightLightValue=obj.options[nextID-1];
				var downObj=document.getElementById("selecthtml")////////set scroll bar position
				var scrollTopVal=((nextID)*19-obj.height)
				if (scrollTopVal>0)
				{
						downObj.scrollTop=scrollTopVal;
				}
			}
			else if (event.keyCode==33)//user press "page up" key
			{
				var pageSize=parseInt(obj.height/19,10);
				var nextID=obj.selectedIndex-pageSize;
				if (nextID<1)
				{
					nextID=1;
				}
				obj.show(nextID);
				obj.hightLightValue=obj.options[nextID-1];
				var downObj=document.getElementById("selecthtml")////////set scroll bar position
				var scrollTopVal=((nextID-1)*19)
				if (scrollTopVal<0)
				{
					scrollTopVal=0;
				}
				if (scrollTopVal>=0)
				{
						downObj.scrollTop=scrollTopVal;
				}
			}
			
		}
  	}  
  	this.subInputBox.onkeydown=this.getKeydownFunction(this)
	this.sbutton.onkeydown=this.getKeydownFunction(this)
  
  	this.sbutton.onclick=function(){combo.show(1)}
	
	this.sendEventHandleToDropDown=function(obj,div)
	{
		return function()
		{
			if(event.propertyName=="style.visibility")
			{
				if (div.style.visibility=="hidden")
				{
					obj.selectedIndex=0;
				}
				//alert(obj.hightLightValue)
			}
			
		}
	}
	//document.getElementById("selectcontent").attachEvent("onpropertychange",this.sendEventHandleToDropDown(this,document.getElementById("selectcontent")))
  
	this.getDownFocusFun=function(obj)
	{
		return function()
		{
			obj.subInputBox.focus();
		}
	}
	
  	this.show=function(showid)
  	{
		
		this.selectedIndex=showid;
		this.hightLightValue=this.options[showid-1];
		document.getElementById("selecthtml").onfocus=this.getDownFocusFun(this);
		if (this.enable==false)
		{
			return;
		}
		pDiv=eval(combo.divname)
		pTable=eval(combo.tablename)
		var isHiddenList=false;

		if (vDiv.style.visibility=="hidden")
		{
			var vHTML='<table id=htmltable cellspacing="0" cellpadding="2" bgcolor="#EFF1F3" class="selecttable" width="100%">'
			for (i=0;i<combo.options.length;i++)
			{
				if (showid-1==i)
				{
		   			vHTML+='<tr id="'+this.excusiveId+'_'+i+'" style="background-color:#000099;color:#ffffff;" fvalue="'+combo.options[i].split("|&")[1]+'"  onclick="onClickItem(this,document.all.'+combo.name+',selectcontent,\''+this.name+'\');" ><td>'+combo.options[i].split("|&")[0]
				}
				else
				{
		   			vHTML+='<tr id="'+this.excusiveId+'_'+i+'" fvalue="'+combo.options[i].split("|&")[1]+'"   onclick="onClickItem(this,document.all.'+combo.name+',selectcontent,\''+this.name+'\');" ><td>'+combo.options[i].split("|&")[0]
				}
			}
			vHTML+="</table>"
    		vDivHtml.innerHTML=vHTML;
			isHiddenList=true;
		}

		if(document.getElementById(this.excusiveId+'_'+this.previousSelectId)!=null)
		{
			document.getElementById(this.excusiveId+'_'+this.previousSelectId).style.backgroundColor="";
			document.getElementById(this.excusiveId+'_'+this.previousSelectId).style.color="#000000";
			if (showid>0)
			{
				document.getElementById(this.excusiveId+'_'+(showid-1)).style.backgroundColor="#000099";
				document.getElementById(this.excusiveId+'_'+(showid-1)).style.color="#ffffff";
				this.previousSelectId=showid-1;
			}
			//alert(document.getElementById(this.excusiveId+'_'+this.selectedIndex));
			if (isHiddenList==false)
			{
				return;
			}
		}

		this.getDownListMouseoverFun=function(obj,ii)
		{
			return function()
			{
				obj.hightLightValue=obj.options[ii];
				var arr1=this.id.split("_");
				var showid=(arr1[arr1.length-1]*1);
				if (!isNaN(showid))
				{
					var downObj=document.getElementById("selecthtml")
					var trArr=(downObj.childNodes[0].childNodes[0].childNodes)
					for (var i=0;i<trArr.length;i++)
					{
						trArr[i].style.backgroundColor="";
						trArr[i].style.color="#000000"
					}
					this.style.backgroundColor="#000099"
					this.style.color="#ffffff"
					//alert(downObj.scrollTop);
					//downObj.scrollTop=20;
					var scrollTopVal=((showid+1)*20-obj.height)
					if (scrollTopVal>0)
					{
						//downObj.scrollTop=scrollTopVal;
					}
					obj.selectedIndex=showid+1;
					obj.previousSelectId=showid;
				}
			}
		}
		
		
		for (i=0;i<combo.options.length;i++)
		{
			var mouseObj=document.getElementById(this.excusiveId+"_"+i);
			mouseObj.onmouseover=this.getDownListMouseoverFun(this,i);
		}
		
    	
    	vtop=pDiv.offsetTop+pDiv.offsetHeight-4;
    	vleft=pDiv.offsetLeft+1
    
    
    	vParent = pDiv.offsetParent;
		
    	while (vParent.tagName.toUpperCase() != "BODY")
		{
			var scroTop=vParent.scrollTop;
			vleft += vParent.offsetLeft;
			vtop += (vParent.offsetTop-scroTop);
			vParent = vParent.offsetParent;
		}

   		var redge=document.body.clientWidth-vleft
   		var bedge=document.body.clientHeight-vtop
 
  	

		if (!combo.width) {vDiv.style.width=pTable.offsetWidth} else {vDiv.style.width=combo.width}
    

    	if (combo.height==0)
      	{
        	vDiv.style.pixelHeight=parseInt(htmltable.offsetHeight)+2
        	vDivHtml.style.pixelHeight=parseInt(htmltable.offsetHeight)+2
      	}
      	else
      	{
         	if (htmltable.offsetHeight>combo.height)
          	{
            	vDiv.style.pixelHeight=combo.height
            	vDivHtml.style.pixelHeight=combo.height
            } 
           	else 
           	{
          
              	vDiv.style.pixelHeight=parseInt(htmltable.offsetHeight)+2
              	vDivHtml.style.pixelHeight=parseInt(htmltable.offsetHeight)+2
           	}
       	}
    
    	vDivHtml.scrollTop=0
    
    	if (redge<vDiv.offsetWidth)
      		vDiv.style.left=vleft-1-(vDiv.offsetWidth-redge)+3
        else
      		vDiv.style.left=vleft-1+4
      

   		if (bedge<vDiv.offsetHeight)
    		//vDiv.style.top=vtop-vDiv.offsetHeight-pDiv.offsetHeight
    		vDiv.style.top=vtop-vDiv.offsetHeight-20
    		
         else
      		vDiv.style.top=vtop
      
    
    	vDivHtml.style.width=parseInt(vDiv.style.width)-6
      	vDiv.style.visibility="visible";
		document.getElementById("selecthtml").scrollTop="0px";
		if (this.hasFirstDropDown==false)
		{
			this.hasFirstDropDown=true;
			this.show(showid);
		}
  	}
  
  	this.add=function(text,value)
  	{
     	combo.options[combo.options.length]=text+"|&"+value
  	}
  
  	this.about=function()
	{
  		alert("Drop down list for AOL");
 	}
	
	//////////////////////////////////////////
	this.onSelectChangeFunction=function()
	{
		
	}
	this.firstChangeValue=false;
	this.getInputBoxChangeFunction=function(obj)//// on input box value change
	{
		return function()
		{
			if (event.propertyName!="value")
			{
				return;
			}
			////////////////////////////// dropdown list change event call the fllow function
			obj.onValueChange();
		}
	}
	document.getElementById(this.buttonname+'_input').onpropertychange=this.getInputBoxChangeFunction(this);
	this.onValueChange=function()
	{
		
	}
}


	function mo(obj)
	{
		obj.style.backgroundColor="#000099"
		obj.style.color="#ffffff"
	}

	function mu(obj)
	{
		obj.style.backgroundColor=""
		obj.style.color="#000000"
	}

	function onClickItem(itemObj,mainText,hiddenObj,name)
	{
		mainText.value=itemObj.innerText;
		hiddenObj.style.visibility="hidden";
		setSelectValue(itemObj.fvalue,name);
	}


	function setSelectValue(value,name)
	{
		var scriptObj=document.getElementById("downlist_script_"+name);
		scriptObj.value=value;
		scriptObj.onChange();
	}


	function mouseDownFun2()
	{
		return function()
		{
			
			if (vDiv.style.visibility=="visible")
			{
				mx=event.x + document.body.scrollLeft
				my=event.y + document.body.scrollTop;
				
				x1=vDiv.offsetLeft
				y1=vDiv.offsetTop
				
				x2=vDiv.offsetLeft+vDiv.offsetWidth
				y2=vDiv.offsetTop+vDiv.offsetHeight
				
				if (mx<x1 || my<y1 || x2<mx || y2<my) 
				{ 
					vDiv.style.visibility='hidden'
				}
			}
		}
	}
	document.attachEvent("onmousedown",mouseDownFun2());


///////////////////////////Class checkBox()////////////////////////////
//  			checkBox(string parentNodeId,bool isChecked)
//					parentNodeId:		Where you want the checkBox to be append, it's the parent node's id.
//					isChecked:			default value
//				---------------------------------------------------
//  method		apply()					To display the checkBox
//				Enable()
//				Disable()
//				setChecked(bool ischeck)	Check or Uncheck the CheckBox
//				setPartCheck()			Partly check
//				----------------------------------------------------
//	porperty	checked					
//				isEnable
//				partCheck
//				----------------------------------------------------
//  event		onClick
//				onCheck
//				onUncheck
//
/////////////////////////////////////////////////////////////////

var checkBox=function(parentNodeId,isChecked)
{

	this.pid=parentNodeId;
	this.element=document.createElement("div");
	this.element.cssFloat="left";
	this.element.style.width="12";
	this.element.style.height="12";
	this.element.innerHTML="<img width=1 height=1 src='' />"
	this.isEnable=true;
	this.flag="";
	this.data="";
	this.partCheck=false;
	
	this.checked=isChecked==true?true:false;
	this.onClick=function(){}
	this.onCheck=function(){}
	this.onUncheck=function(){}
	
	///Flannian Begin--处理Flag,Value
	this.setFlag=function(flag)
	{
		this.flag=flag;
	}
	
	this.setData=function(data)
	{
		this.data=data;
	}
	///Flannian End--	
	
	this.setChecked=function(isChecked)
	{
		if (this.isEnable==false)
		{
			return;	
		}
		this.checked=isChecked==true?true:false;
		this.partCheck=false;
		if (this.checked)
		{	
			this.element.style.backgroundImage="url(checkboximages/checkbox_checked.jpg)";
			this.onCheck();
		}
		else
		{	
			this.element.style.backgroundImage="url(checkboximages/checkbox_notchecked.jpg)";
			this.onUncheck();
		}
	}
	
	this.setPartCheck=function()
	{
		if (this.isEnable==false)
		{
			return;	
		}
		this.partCheck=true;
		this.checked=true;
		this.element.style.backgroundImage="url(checkboximages/checkbox_part.jpg)";
	}
	
	if (this.checked)
	{
		
		this.element.style.backgroundImage="url(checkboximages/checkbox_checked.jpg)";
	}
	else
	{
		this.element.style.backgroundImage="url(checkboximages/checkbox_notchecked.jpg)";
	}
	
	
	this.apply=function()
	{
		document.getElementById(this.pid).appendChild(this.element);
		return this.element;
	}
	this.cbClick=function(obj)
	{
		return function()
		{
			obj.onClick();
			if (obj.isEnable==false)
			{

			}
			else
			{
				obj.partCheck=false;
				if(obj.checked)
				{
					obj.checked=false;
					obj.element.style.backgroundImage="url(checkboximages/checkbox_notchecked.jpg)";	
					obj.onUncheck();
				}
				else
				{
					obj.checked=true;
					obj.element.style.backgroundImage="url(checkboximages/checkbox_checked.jpg)";
					obj.onCheck();
				}
			}
			
		}
	}
	this.Disable=function()
	{
		this.isEnable=false;
		if (this.checked)
		{
			if (this.partCheck)
			{
				this.element.style.backgroundImage="url(checkboximages/checkbox_part_dis.jpg)";
			}
			else
			{
				this.element.style.backgroundImage="url(checkboximages/checkbox_checked_dis.jpg)";
			}
		}
		else
		{
			this.element.style.backgroundImage="url(checkboximages/checkbox_notchecked_dis.jpg)";
		}
	}
	
	this.Enable=function()
	{
		this.isEnable=true;
		if (this.checked)
		{
			if (this.partCheck)
			{
				this.element.style.backgroundImage="url(checkboximages/checkbox_part.jpg)";
			}
			else
			{
				this.element.style.backgroundImage="url(checkboximages/checkbox_checked.jpg)";
			}
		}
		else
		{
			this.element.style.backgroundImage="url(checkboximages/checkbox_notchecked.jpg)";	
		}

	}
	
	
	this.element.onclick=this.cbClick(this);
	
	
}

///////////////////////////applyButton()   function///////////////////////////
//
//Apply Button to page
//		It will change the IE default button style to the custom style.
//		it support onClick event, support enable and disable porperty.
//
//
//
//
//////////////////////////////////////////////////


//-------------------------------------------------------------------------

	  
function applyButton()
{
	var a=document.getElementsByTagName("button")
	var tmpBtObj;
	var RIT_btArr=new Array();
	for (i=0;i<a.length;i++)
	{
		if (a[i].cstyle!="rit") continue;
		a[i].style.display="none";
		RIT_btArr[i]=new RITButton(a[i].id,a[i].innerHTML);
		RIT_btArr[i].attachObj(a[i]);
		a[i].insertAdjacentHTML("beforeBegin",RIT_btArr[i].getHTML());
		document.getElementById(RIT_btArr[i].btID+"_RIT").onclick=Rit_button_getClickFun(RIT_btArr[i]);
		document.getElementById(RIT_btArr[i].btID+"_RIT").onmousedown=Rit_button_getMouseDownFun(RIT_btArr[i]);
		document.getElementById(RIT_btArr[i].btID+"_RIT").onmouseup=Rit_button_getMouseUpFun(RIT_btArr[i]);
		document.getElementById(RIT_btArr[i].btID+"_RIT").onmouseout=Rit_button_getMouseOutFun(RIT_btArr[i]);
	}
}

function Rit_button_getClickFun(ritBtObj)
{
	return function()
	{
		if(ritBtObj.btObj.dsiabled)
		{
			return;	
		}
		document.getElementById(ritBtObj.btID).click();	
	}
}

function Rit_button_getMouseDownFun(ritBtObj)
{
	
	return function()
	{
		
		if(ritBtObj.btObj.dsiabled)
		{
			return;	
		}
		button_switchStatus(1,"",document.getElementById(ritBtObj.btID+"_RIT"))	;	
	}
}

function Rit_button_getMouseUpFun(ritBtObj)
{
	return function()
	{
		if(ritBtObj.btObj.dsiabled)
		{
			return;	
		}
		button_switchStatus(0,"",document.getElementById(ritBtObj.btID+"_RIT"))	;	
	}
}

function Rit_button_getMouseOutFun(ritBtObj)
{
	return function()
	{
		if(ritBtObj.btObj.dsiabled)
		{
			return;	
		}
		button_switchStatus(0,"",document.getElementById(ritBtObj.btID+"_RIT"))	;
	}
}

var RITButton=function(id,text)
{
	this.btText=text
	this.onclick=function(){}
	this.btObj=null;
	this.btID=id;
	this.pChange=function(pObj)
	{
		return function()
		{
			if (event.propertyName=="dsiabled")
			{
				//alert(pObj.btObj.dsiabled)
				if(pObj.btObj.dsiabled)
				{
					
					button_switchStatus(2,pObj.btID+"_RIT",document.getElementById(pObj.btID+"_RIT"))
				}
				else
				{
					button_switchStatus(0,pObj.btID+"_RIT",document.getElementById(pObj.btID+"_RIT"))	
				}
			}
		}
	}
	
	this.attachObj=function(buttonObj)
	{
		this.btObj=buttonObj;
		this.btObj.onpropertychange=this.pChange(this);
		this.btObj.setValue=this.setButotnValue(this);
		this.btObj.GetValue=this.GetButotnValue();
	}
	
	this.setId=function(id)
	{
		this.btID=id;
	}
	this.GetButotnValue=function()
	{
		//return function(val)
//		{
//			if (val.length>20)
//			{
//				
//			}
//			else
//			{
//				var intI=20-val.length+2;
//				intI=parseInt(intI/2);
//				var tmpStr9="";
//				for( var i=0;i<intI;i++)
//				{
//					tmpStr9+="&nbsp;";	
//				}
//				val=tmpStr9+val+tmpStr9;
//			}
//			val=val.replace(/\</g,"&lt;");
//			val=val.replace(/\>/g,"&gt;");
//			document.getElementById(this.id+"_RIT_spanb").innerHTML=val;
//		}
		//return document.getElementById(this.id+"_RIT_spanb").innerHTML;
	}
	this.setButotnValue=function(cusObj)
	{
		return function(val)
		{
			if (val.length>20)
			{
				
			}
			else
			{
				var intI=20-val.length+2;
				intI=parseInt(intI/2);
				var tmpStr9="";
				for( var i=0;i<intI;i++)
				{
					tmpStr9+="&nbsp;";	
				}
				val=tmpStr9+val+tmpStr9;
			}
			val=val.replace(/\</g,"&lt;");
			val=val.replace(/\>/g,"&gt;");
			document.getElementById(this.id+"_RIT_spanb").innerHTML=val;
		}
	}
	this.setText=function(text)
	{
		this.btText=text;
	}
	this.getHTML=function()
	{
		if (this.btID=="" || this.btText=="")
		{
			return "";
		}
		var htmlStr="";
		htmlStr+='<table   id=\"'+this.btID+'_RIT\" border="0" cellspacing="0" cellpadding="0" style="display:inline; cursor:default;" onselectstart="return false">';
		htmlStr+='<tr>';
		htmlStr+='<td>';
		htmlStr+='<span id=\"'+this.btID+'_RIT_spana\" style="margin:0px;height:20px; width:6px; background-image:url(buttonimages/button_left.jpg); float:left;"><img src="buttonimages/spacer.gif" style="width:1px; height:1px;" /></span>';
		if (this.btText.length>14)
		{
			htmlStr+='<span id=\"'+this.btID+'_RIT_spanb\" style="margin:0px;height:20px;background-image:url(buttonimages/button_center.jpg); line-height:20px; display:inline-table; font-family:Tahoma,Arial, Helvetica, sans-serif; font-size:11px; padding-left:3px; padding-right:3px;float:left;" onselectstart="return false">'+this.btText+'</span>';
		}
		else
		{
			var intI=14-this.btText.length+2;
			intI=parseInt(intI/2);
			var tmpStr9="";
			for( var i=0;i<intI;i++)
			{
				tmpStr9+="&nbsp;";	
			}
			htmlStr+='<span id=\"'+this.btID+'_RIT_spanb\" style="margin:0px;height:20px;background-image:url(buttonimages/button_center.jpg); line-height:20px; display:inline-table; font-family:Tahoma,Arial, Helvetica, sans-serif; font-size:11px; padding-left:3px; padding-right:3px;float:left;" onselectstart="return false">'+tmpStr9+this.btText+tmpStr9+'</span>';
		}
		htmlStr+='<span id=\"'+this.btID+'_RIT_spanc\" style="margin:0px;height:20px; width:6px; background-image:url(buttonimages/button_right.jpg); float:left; background-position:right;"><img src="buttonimages/spacer.gif" style="width:1px; height:1px;" /></span>';
		htmlStr+='</td>';
		htmlStr+='</tr>';
		htmlStr+='</table>';
		return htmlStr;
	}
}

function button_switchStatus(flag,id,obj)
{
		if (flag==1)
		{
			//document.getElementById(id+"_spana").style.backgroundImage="url(images/button_left_b.jpg)";
			//document.getElementById(id+"_spanb").style.backgroundImage="url(images/button_center_b.jpg)";
			//document.getElementById(id+"_spanc").style.backgroundImage="url(images/button_right_b.jpg)";
			obj.firstChild.firstChild.firstChild.childNodes[0].style.backgroundImage="url(buttonimages/button_left_b.jpg)";
			obj.firstChild.firstChild.firstChild.childNodes[1].style.backgroundImage="url(buttonimages/button_center_b.jpg)";
			obj.firstChild.firstChild.firstChild.childNodes[1].style.color="#000000";
			obj.firstChild.firstChild.firstChild.childNodes[2].style.backgroundImage="url(buttonimages/button_right_b.jpg)";
		}
		else if (flag==0)
		{
			//document.getElementById(id+"_spana").style.backgroundImage="url(images/button_left.jpg)";
			//document.getElementById(id+"_spanb").style.backgroundImage="url(images/button_center.jpg)";
			//document.getElementById(id+"_spanc").style.backgroundImage="url(images/button_right.jpg)";
			obj.firstChild.firstChild.firstChild.childNodes[0].style.backgroundImage="url(buttonimages/button_left.jpg)";
			obj.firstChild.firstChild.firstChild.childNodes[1].style.backgroundImage="url(buttonimages/button_center.jpg)";
			obj.firstChild.firstChild.firstChild.childNodes[1].style.color="#000000";
			obj.firstChild.firstChild.firstChild.childNodes[2].style.backgroundImage="url(buttonimages/button_right.jpg)";
		}
		else if (flag==2)
		{
			//document.getElementById(id+"_spana").style.backgroundImage="url(images/button_left.jpg)";
			//document.getElementById(id+"_spanb").style.backgroundImage="url(images/button_center.jpg)";
			//document.getElementById(id+"_spanc").style.backgroundImage="url(images/button_right.jpg)";
			obj.firstChild.firstChild.firstChild.childNodes[0].style.backgroundImage="url(buttonimages/button_left_c.jpg)";
			obj.firstChild.firstChild.firstChild.childNodes[1].style.backgroundImage="url(buttonimages/button_center_c.jpg)";
			obj.firstChild.firstChild.firstChild.childNodes[1].style.color="#999999";
			obj.firstChild.firstChild.firstChild.childNodes[2].style.backgroundImage="url(buttonimages/button_right_c.jpg)";
		}
}


/////////////////////Class progressControl 用于显示进度//////////////////////////////
//						progressControl(int width,DomObj parentNodeObj)
//							width:宽度
//							parentNodeObj:需要展开到的节点对象或者是id
//----------------------------------------------
//	Method				setProgress(int progress);	//设置进度
//						getProgress();				//得到进度	返回当前进度
//
//
//	Event				onEnd;		//结束时触发
//
/////////////////progress control////////////////
var progressControl=function(width,parentNodeObj)
{
	this.pNode=null;
	this.cWidth=width;
	this.currentProgress=0;
	
	this.getElementPosition=function(element)
	{
		if (element==null)
		{
			return "";
		}
		var vParent=null;
		var vleft=0;
		var vtop=0;
		vParent=element;
    	while (vParent.tagName.toUpperCase() != "BODY")
		{
			var scroTop=vParent.scrollTop;
			vleft += vParent.offsetLeft;
			vtop += (vParent.offsetTop-scroTop);
			vParent = vParent.offsetParent;
		}
		return vleft+"|"+vtop;
	}
	
	
	if (typeof(parentNodeObj)=="object")
	{
		this.pNode=parentNodeObj;
	}
	else if (typeof(parentNodeObj)=="string")
	{
		this.pNode=document.getElementById(parentNodeObj);
		if (this.pNode==null)//////////////parent node not fund
		{
			return false;
		}
	}
	else//////////////parent node not fund
	{
		return false;
	}
	if(typeof(width)!="number") {return false}///////
	
	this.pNode.style.position="relative";
	
	this.progressDiv=document.createElement("div");
	this.progressDiv.style.width=width+"px";
	this.progressDiv.style.height="21px";
	this.progressDiv.style.backgroundImage='url(progressimages/progress_base_mid.jpg)';
	
	this.progressDiv_base_left=document.createElement("div");
	this.progressDiv_base_left.style.width=width+"px";
	this.progressDiv_base_left.style.height="21px";
	this.progressDiv_base_left.style.backgroundImage='url(progressimages/progress_base_left.jpg)';
	this.progressDiv_base_left.style.backgroundRepeat='no-repeat';
	
	this.progressDiv_base_right=document.createElement("div");
	this.progressDiv_base_right.style.width=width+"px";
	this.progressDiv_base_right.style.height="21px";
	this.progressDiv_base_right.style.backgroundImage='url(progressimages/progress_base_right.jpg)';
	this.progressDiv_base_right.style.backgroundRepeat='no-repeat';
	this.progressDiv_base_right.style.backgroundPosition="right";
	
	this.progressDiv_top=document.createElement("div");
	this.progressDiv_top.style.width="1px";
	this.progressDiv_top.style.height="21px";
	this.progressDiv_top.style.backgroundImage='url(progressimages/progress_top_mid.jpg)';

	this.progressDiv_top_left=document.createElement("div");
	this.progressDiv_top_left.style.width="1px";
	this.progressDiv_top_left.style.height="21px";
	this.progressDiv_top_left.style.backgroundImage='url(progressimages/progress_top_left.jpg)';
	this.progressDiv_top_left.style.backgroundRepeat='no-repeat';
	
	this.progressDiv_top_right=document.createElement("div");
	this.progressDiv_top_right.style.width="1px";
	this.progressDiv_top_right.style.height="21px";
	this.progressDiv_top_right.style.backgroundImage='url(progressimages/progress_top_right.jpg)';
	this.progressDiv_top_right.style.backgroundRepeat='no-repeat';
	this.progressDiv_top_right.style.backgroundPosition="right";
	
	
	this.progressDiv_top_left.appendChild(this.progressDiv_top_right);
	this.progressDiv_top.appendChild(this.progressDiv_top_left);
	this.progressDiv_base_right.appendChild(this.progressDiv_top);
	this.progressDiv_base_left.appendChild(this.progressDiv_base_right);
	this.progressDiv.appendChild(this.progressDiv_base_left);
	

	this.progressText=document.createElement("div");
	this.progressText.style.position="absolute";
	this.progressText.style.top="0px";
	this.progressText.style.textAlign="center";
	this.progressText.style.fontSize="12px";
	this.progressText.style.paddingTop="4px";
	this.progressText.style.width=width+"px";
	this.progressText.style.height="21px";
	this.progressText.style.color="#000000";
	this.progressText.innerHTML="0%";
	
	
	

	this.pNode.appendChild(this.progressDiv);
	this.pNode.appendChild(this.progressText);
	
	
	this.setProgress=function(num)
	{
		if (num>100)
		{
			num=100;
		}
		this.currentProgress=num;
		var newWidth=Math.floor(this.cWidth*num/100);
		
		this.progressDiv_top.style.width=newWidth+"px";
		this.progressDiv_top_left.style.width=newWidth+"px";
		this.progressDiv_top_right.style.width=newWidth+"px";
		this.progressText.innerHTML=num+"%";
		if (num==100)
		{
			if(typeof(this.onEnd)=="function")
			{
				this.onEnd();
			}
		}
	}
	

	
	
	this.getProgress=function()
	{
		return this.currentProgress;
	}
	
	this.onEnd=function()
	{
		
	}
	
	
}
/////////////////progress control end////////////////





//////////////////////////////////////////////
//需要空间 ， 剩余空间 图形显示。
//
/////////////////////////////////////////////
var onePartitionInfoBar=function(width,id,text,size,type)
{
	this.pNode=null;
	this.cWidth=width;
	this.currentProgress=0;
	this.id=id;
	this.text=text;
	this.size=size;
	this.isEndOne=false;
	if (type=="end")
	{
		this.isEndOne=true;
		this.rightPadding=5;
	}
	else
	{
		this.rightPadding=4;
	}
	
	while (id>=1)
	{
		id-=4;	
	}
	this.id=id+4;
	
	this.getBar=function()
	{
		if(typeof(this.cWidth)!="number") {return null}///////
		this.spaceInfoDiv=document.createElement("div");
		this.spaceInfoDiv.style.width=this.cWidth+"px";
		this.spaceInfoDiv.style.height="44px";
		this.spaceInfoDiv.style.backgroundImage='url(controlimages/space_info_color'+this.id+'_mid.jpg)';
		this.spaceInfoDiv.style.styleFloat="left";
	
		this.spaceInfoDiv_base_left=document.createElement("div");
		this.spaceInfoDiv_base_left.style.width=this.cWidth+"px";
		this.spaceInfoDiv_base_left.style.height="44px";
		this.spaceInfoDiv_base_left.style.backgroundImage='url(controlimages/space_info_color'+this.id+'_left.jpg)';
		this.spaceInfoDiv_base_left.style.backgroundRepeat='no-repeat';
	
		this.spaceInfoDiv_base_right=document.createElement("div");
		this.spaceInfoDiv_base_right.style.width=this.cWidth+"px";
		this.spaceInfoDiv_base_right.style.height="44px";
		this.spaceInfoDiv_base_right.style.backgroundImage='url(controlimages/space_info_color'+this.id+'_right.jpg)';
		this.spaceInfoDiv_base_right.style.backgroundRepeat='no-repeat';
		//this.spaceInfoDiv_base_right.style.backgroundPosition="right";
		this.spaceInfoDiv_base_right.style.backgroundPositionX=(this.cWidth-this.rightPadding)+"px";
		this.spaceInfoDiv_base_right.innerText=this.text;
		this.spaceInfoDiv_base_right.title="Partition "+this.text+"\nSize "+this.size;
		this.spaceInfoDiv_base_right.style.color="#1C4478";
		this.spaceInfoDiv_base_right.style.paddingLeft="6px";
		this.spaceInfoDiv_base_right.style.paddingTop="4px";
		this.spaceInfoDiv_base_right.style.fontSize="12px";
		this.spaceInfoDiv_base_right.style.fontFamily="Tahoma, Arial";
		this.spaceInfoDiv_base_right.style.overflow="hidden";
	
		this.spaceInfoDiv_base_left.appendChild(this.spaceInfoDiv_base_right);
		this.spaceInfoDiv.appendChild(this.spaceInfoDiv_base_left);
		return this.spaceInfoDiv;
	}

}


var partitionInfoBar=function()
{
	this.pNode=null;
	this.totalSize=0;
	
	this.showInfo=function(array1,width,parentNodeId)
	{
		var tmpArray=new Array();
		var tmpNumber=0;
		var tmpOneBarLength=0;
		var tmpCreateNodeObj;
		var returnElementArray=new Array();
		if (typeof(parentNodeId)=="object")
		{
			this.pNode=parentNodeId;
		}
		else if (typeof(parentNodeId)=="string")
		{
			this.pNode=document.getElementById(parentNodeId);
			if (this.pNode==null)//////////////parent node not fund
			{
				return false;
			}
		}
		if (typeof(array1)!="object")
		{
			return false;	
		}
		if(array1.length){}else{return false;}
		if(typeof(width)!="number") {return false}
		
		for (i=0;i<array1.length;i++)
		{
			tmpArray=array1[i].split("|");
			tmpNumber=parseInt(tmpArray[1]);
			this.totalSize+=tmpNumber;
		}
		if (this.totalSize==0)
		{
			return false;	
		}
		
		
		for (i=0;i<array1.length;i++)
		{
			tmpArray=array1[i].split("|");
			tmpNumber=parseInt(tmpArray[1]);
			tmpOneBarLength=Math.floor((width/this.totalSize)*tmpNumber);
			if (i==array1.length-1)//if it's last one;
			{
				tmpCreateNodeObj=new onePartitionInfoBar(tmpOneBarLength,i,tmpArray[0],tmpArray[1],"end");
			}
			else
			{
				tmpCreateNodeObj=new onePartitionInfoBar(tmpOneBarLength,i,tmpArray[0],tmpArray[1]);
			}
			returnElementArray[i]=tmpCreateNodeObj.getBar();
			this.pNode.appendChild(returnElementArray[i]);
		}
		
		////////////set a padding//////////
		var padOnePixDiv=document.createElement("div");
		padOnePixDiv.style.clear="both";
		padOnePixDiv.style.height="1px";
		padOnePixDiv.style.width="1px";
		padOnePixDiv.style.overflow="hidden";
		this.pNode.appendChild(padOnePixDiv);
	}
}
//////////////////////space need ////////////////////////
var NeedSpaceBar=function()
{
	this.totalDiscNum=0;
	this.totalSpaceNeeded=0;
	this.getSpaceNeedInfo=function(storeType,total,spaceNeeded,width,hdss)
	{
		this.totalSpaceNeeded=spaceNeeded;
		var onePieceSpace;
		var pieceNeeded;
		var onePieceWidth;
		var lastPiecePercent;
		var errWidth;
		var addCount;
		var tmpStr="";
		var hddBgPersent=0;
		if (storeType=="cd") onePieceSpace=650-hdss;
		if (storeType=="dvd") onePieceSpace=4000-(5*hdss);
		if (storeType=="hdd" && total==0)
		{
			return "";
		}
		else if(storeType=="hdd" && total<spaceNeeded)
		{
			tmpStr+='<ul style="width:'+width+'px; margin:0px; height:16px; background-image:url(images/progresswaiting.jpg); background-repeat:repeat-x;">'
			tmpStr+='<li style="list-style:none; height:15px; font-size:12px; background-image:url(images/progressfinishedred.jpg); width:'+width+'px; border-left:1px solid #ffffff; text-align:center; float:left; line-height:15px; background-repeat:no-repeat;">&nbsp;</li>'
			tmpStr+="</ul>"
			return tmpStr;
		}
		if (storeType!="hdd")
		{
			if (Math.floor(spaceNeeded/onePieceSpace)==spaceNeeded/onePieceSpace)
			{
				pieceNeeded=Math.floor(spaceNeeded/onePieceSpace)
			}
			else
			{
				pieceNeeded=Math.floor(spaceNeeded/onePieceSpace)+1
			}
			this.totalDiscNum=pieceNeeded;
			onePieceWidth=Math.floor(width/pieceNeeded)
			errWidth=width-(onePieceWidth*pieceNeeded)
			lastPiecePercent=(spaceNeeded-((pieceNeeded-1)*onePieceSpace))/onePieceSpace
			lastPiecePercent=Math.floor(lastPiecePercent*100)
		}
		else
		{
			hddBgPersent=(spaceNeeded/total)*100
			tmpStr+='<ul style="width:'+width+'px; margin:0px; height:16px; background-image:url(images/progresswaiting.jpg); background-repeat:repeat-x;">'
			tmpStr+=this.getOnePieceShow(width,hddBgPersent,"")
			tmpStr+="</ul>"
			return tmpStr;
		}
		
		tmpStr+='<ul style="width:'+width+'px; margin:0px; height:16px; background-image:url(images/progresswaiting.jpg); background-repeat:repeat-x;">'
		for (i=0;i<pieceNeeded;i++)
		{
			if (errWidth>0)
			{
				errWidth=errWidth-1;
				addCount=1;
			}
			else
			{
				addCount=0;
			}
			
			if (i==pieceNeeded-1)
			{
				if (onePieceWidth<13)
				{
					tmpStr+=this.getOnePieceShow(onePieceWidth+addCount,lastPiecePercent,"")
				}
				else if (onePieceWidth<37)
				{
					tmpStr+=this.getOnePieceShow(onePieceWidth+addCount,lastPiecePercent,(i+1))
				}
				else
				{
					tmpStr+=this.getOnePieceShow(onePieceWidth+addCount,lastPiecePercent,"Disk"+(i+1))
				}
			}
			else
			{
				if (onePieceWidth<13)
				{
					tmpStr+=this.getOnePieceShow(onePieceWidth+addCount,100,"")
				}
				else if (onePieceWidth<37)
				{
					tmpStr+=this.getOnePieceShow(onePieceWidth+addCount,100,(i+1))
				}
				else
				{
					tmpStr+=this.getOnePieceShow(onePieceWidth+addCount,100,"Disk"+(i+1))
				}
			}
		}
		tmpStr+="</ul>"
		return tmpStr;
	}
	this.getOnePieceShow=function(width,percent,innerText)
	{
		var outStr;
		var lastShowWidth;
		lastShowWidth=(width*percent/100)-500;
		outStr='<li style="list-style:none; height:15px; font-size:12px; background-image:url(images/progressfinished.jpg); width:'+width+'px; border-left:1px solid #ffffff; text-align:center; float:left; line-height:15px;background-position-x:'+lastShowWidth+'px; background-repeat:no-repeat; overflow:hidden;">'+innerText+'</li>'
		return(outStr)
	}
}


/////////////////////numBox///////////////////////
//			构造  	(name,width,defaultNum,step,editable) 名字，宽度，默认数字，步长，是否可输入
//			方法		display(parentNode)			parentNode:父节点的名字或父对象
//			属性		minimumNum:最小值
//					maximalNum:最大值
/////////////////////////////////////////////
var numBox=function(name,width,defaultNum,step,editable)
{
	if(isNaN(parseInt(width)) || isNaN(parseInt(defaultNum))  || isNaN(parseInt(step)))
	{
		alert("Create numBox failed.");
		return;
	}
	this.randID=Math.floor(Math.random()*10000);
	this.CtrName=name;
	this.width=width;
	this.defaultNumber=defaultNum;
	this.step=step;
	this.editable=editable;
	this.boderColor="#666666";
	this.minimumNum=0;
	this.maximalNum="";
	
	this.display=function(parentNode)
	{
		var parentObject=null
		if(typeof(parentNode)=="string")
		{
			parentObject=document.getElementById(parentNode);
		}
		else if (typeof(parentNode)=="object")
		{
			parentObject=parentNode
		}
		else
		{
			alert("Object display failed!\nPlease specify the Parent Node.")
			return;
		}
		parentObject.cusObj=this;
		parentObject.innerHTML='<div style="float:left; width:20px;">'
								+'<input value='+this.defaultNumber+' id="'+this.randID+this.CtrName+'_input" type="text" name="textfield" style="height:20px; width:'+this.width+'px; border-bottom:1px solid #666666; border-left:1px solid #666666; border-right:0px; border-top:1px solid #666666; margin:0px; line-height:16px;"/>'
								+'</div>'
								+'<div style="float:left;border-bottom:1px solid #666666; border-right:1px solid #666666; border-left:0px; border-top:1px solid #666666; line-height:18px; height:18px; font-size:11px; margin-top:1px;">'
								+'	<div id="'+this.randID+this.CtrName+'_up_button" style="width:16; height:9px; background-image:url(numimages/num_up_arr.jpg); background-repeat:no-repeat; background-position-y:1px;"><img src="images/spacer.gif" width="1" height="1"/></div>'
								+'	<div id="'+this.randID+this.CtrName+'_down_button" style="width:16; height:9px; background-image:url(numimages/num_down_arr.jpg); background-repeat:no-repeat;background-position-y:1px;"><img src="images/spacer.gif" width="1" height="1"/></div>'
								+'</div>'
								
		document.getElementById(this.randID+this.CtrName+'_down_button').onclick=this.getDonwFunction(this)
		document.getElementById(this.randID+this.CtrName+'_up_button').onclick=this.getUpFunction(this)
	}
	
	this.getDonwFunction=function(obj)
	{
		return function()
		{
			var inputObj=document.getElementById(obj.randID+obj.CtrName+'_input');
			if (  isNaN(parseInt(inputObj.value))  )
			{
				return;
			}
			var currentNum=parseInt(inputObj.value);
			dstNum=currentNum-obj.step;
			if (dstNum<obj.minimumNum)
			{
				inputObj.value=obj.minimumNum
			}
			else
			{
				inputObj.value=dstNum;
			}
		}
	}
	
	this.getUpFunction=function(obj)
	{
		return function()
		{
			var inputObj=document.getElementById(obj.randID+obj.CtrName+'_input');
			if (inputObj.value=="")
			{
				inputObj.value=0;
			}
			if (  isNaN(parseInt(inputObj.value))  )
			{
				return;
			}
			var currentNum=parseInt(inputObj.value);
			dstNum=currentNum+obj.step;
			if (obj.maximalNum=="")
			{
				inputObj.value=dstNum;
			}
			else
			{
				if (dstNum>obj.maximalNum)
				{
					inputObj.value=obj.minimumNum
				}
				else
				{
					inputObj.value=dstNum;
				}
			}
		}
	}
}

///////////////numBox Class///////////////
//构造：(name,width,defaultNum,step,editable)
//				name:控件名字
//				width:宽度
//				defaultNum:默认值
//				step:步长
//				editable:是否可编辑
//
//方法	：display(parentNode)
//						parentNode:父节点的ID
//		：setValue(value)
//						value:改变的值
//		:getValue()	:得到当前的值
//属性：	minimumNum:最小值
//		maximalNum:最大值
//		value	:当前值
//事件：onChang()  :当值改变的时候触发
/////////////////////////////////////////

var numBox=function(name,width,defaultNum,step,editable)
{
	if(isNaN(parseInt(width)) || isNaN(parseInt(defaultNum))  || isNaN(parseInt(step)))
	{
		alert("Create numBox failed.");
		return;
	}
	this.randID=Math.floor(Math.random()*10000);
	this.CtrName=name;
	this.width=width;
	this.defaultNumber=defaultNum;
	this.step=step;
	this.editable=editable;
	this.boderColor="#666666";
	this.minimumNum=0;
	this.maximalNum="";
	this.value=defaultNum
	this.timeOutObj=null;
	this.onChange=function(){};
	
	this.display=function(parentNode)
	{
		var parentObject=null
		if(typeof(parentNode)=="string")
		{
			parentObject=document.getElementById(parentNode);
		}
		else if (typeof(parentNode)=="object")
		{
			parentObject=parentNode
		}
		else
		{
			alert("Object display failed!\nPlease specify the Parent Node.")
			return;
		}
		parentObject.cusObj=this;
		parentObject.innerHTML='<div style="float:left; width:20px;">'
								+'<input maxlength="12" value='+this.defaultNumber+' id="'+this.randID+this.CtrName+'_input" type="text" name="textfield" style="height:20px; width:'+this.width+'px; border-bottom:1px solid #666666; border-left:1px solid #666666; border-right:0px; border-top:1px solid #666666; margin:0px; line-height:16px;"/>'
								+'</div>'
								+'<div style="float:left;border-bottom:1px solid #666666; border-right:1px solid #666666; border-left:0px; border-top:1px solid #666666; line-height:18px; height:18px; font-size:11px; margin-top:1px;">'
								+'	<div id="'+this.randID+this.CtrName+'_up_button" style="width:16; height:9px; background-image:url(numimages/num_up_arr.jpg); background-repeat:no-repeat; background-position-y:1px;"><img src="images/spacer.gif" width="1" height="1"/></div>'
								+'	<div id="'+this.randID+this.CtrName+'_down_button" style="width:16; height:9px; background-image:url(numimages/num_down_arr.jpg); background-repeat:no-repeat;background-position-y:1px;"><img src="images/spacer.gif" width="1" height="1"/></div>'
								+'</div>'
								
		document.getElementById(this.randID+this.CtrName+'_down_button').onclick=this.getDonwFunction(this);
		document.getElementById(this.randID+this.CtrName+'_up_button').onclick=this.getUpFunction(this);
		document.getElementById(this.randID+this.CtrName+'_input').onkeydown=this.getKeydownFunction(this);
		document.getElementById(this.randID+this.CtrName+'_input').onpropertychange=this.getPropertyChangeFunction(this);
		document.getElementById(this.randID+this.CtrName+'_input').onpaste=function(){return false;}
		if (this.defaultNumber<=this.minimumNum)
		{
			document.getElementById(this.randID+this.CtrName+'_down_button').style.filter="Gray()";
		}
	}
	
	this.setValue=function(value)
	{
		if (value<this.minimumNum)
		{
			document.getElementById(this.randID+this.CtrName+'_input').value=this.minimumNum;
		}
		else if (this.maximalNum!="")
		{
			if (value>this.maximalNum)
			{
				document.getElementById(this.randID+this.CtrName+'_input').value=this.maximalNum;
			}
			else
			{
				document.getElementById(this.randID+this.CtrName+'_input').value=value;	
			}
		}
		else
		{
			document.getElementById(this.randID+this.CtrName+'_input').value=value;	
		}
	}
	
	this.getValue=function()
	{
		if (parseInt(this.value)<this.minimumNum)	
		{
			return 	(this.minimumNum*1);
		}
		
		if (parseInt(this.value)>this.maximalNum && this.maximalNum!="")
		{
			return (this.maximalNum*1);
		}
		return (this.value*1);
	}
	
	this.getPropertyChangeFunction=function(obj)
	{
		return function()
		{
			if(event.propertyName=="value")
			{
				var inputObj=document.getElementById(obj.randID+obj.CtrName+'_input');
				if (inputObj.value=="")
				{
					inputObj.value=0;
				}
				if ((inputObj.value+"")!=(parseInt(inputObj.value)+""))
				{
					inputObj.value=parseInt(inputObj.value);
				}
				clearTimeout(obj.timeOutObj);
				obj.timeOutObj=setTimeout(obj.checkInput(obj),1000);
			}
			obj.value=this.value;
			obj.onChange();
		}
	}
	
	this.checkInput=function(obj)
	{
		return function()
		{
			
			var inputObj=document.getElementById(obj.randID+obj.CtrName+'_input');
			if (parseInt(inputObj.value)<obj.minimumNum)
			{
				inputObj.value=obj.minimumNum;
			}
			else if (parseInt(inputObj.value)>obj.maximalNum && obj.maximalNum!="")
			{
				inputObj.value=obj.maximalNum;
			}
			
			document.getElementById(obj.randID+obj.CtrName+'_down_button').style.filter="";
			document.getElementById(obj.randID+obj.CtrName+'_up_button').style.filter="";
			if (parseInt(inputObj.value)==obj.minimumNum)
			{
				document.getElementById(obj.randID+obj.CtrName+'_down_button').style.filter="Gray()";
			}
			else if(parseInt(inputObj.value)==obj.maximalNum)
			{
				document.getElementById(obj.randID+obj.CtrName+'_up_button').style.filter="Gray()";
			}
		}
	}
	
	this.getKeydownFunction = function (obj)
	{
		return function()
		{
				return true;
				var code=event.keyCode;
				if ((code >=48 && code<=57) || (code >=96 && code<=105) || code ==8 || code ==13 || code ==37 || code ==39 || code ==9 || code ==46  || code ==35 || code ==36)
				{
					return true;
				}
				else
				{
					
					return false;
				}
		}
	}
	
	this.getDonwFunction=function(obj)
	{
		return function()
		{
			var inputObj=document.getElementById(obj.randID+obj.CtrName+'_input');
			if (  isNaN(parseInt(inputObj.value))  )
			{
				return;
			}
			var currentNum=parseInt(inputObj.value);
			dstNum=currentNum-obj.step;
			if (dstNum<=obj.minimumNum)
			{
				inputObj.value=obj.minimumNum;
				document.getElementById(obj.randID+obj.CtrName+'_down_button').style.filter="Gray()";
			}
			else
			{
				inputObj.value=dstNum;
				document.getElementById(obj.randID+obj.CtrName+'_up_button').style.filter="";
			}
		}
	}
	
	this.getUpFunction=function(obj)
	{
		return function()
		{
			var inputObj=document.getElementById(obj.randID+obj.CtrName+'_input');
			if (inputObj.value=="")
			{
				inputObj.value=0;
			}
			if (  isNaN(parseInt(inputObj.value))  )
			{
				return;
			}
			var currentNum=parseInt(inputObj.value);
			dstNum=currentNum+obj.step;
			if (obj.maximalNum=="")
			{
				inputObj.value=dstNum;
			}
			else
			{
				if (dstNum>=obj.maximalNum)
				{
					inputObj.value=obj.maximalNum
					document.getElementById(obj.randID+obj.CtrName+'_up_button').style.filter="Gray()";
				}
				else
				{
					inputObj.value=dstNum;
					document.getElementById(obj.randID+obj.CtrName+'_down_button').style.filter="";
				}
			}
		}
	}
}