	gSelectBox = {
		Counter: 0,
		getNextHighestDepth: function() {return gSelectBox.Counter++},
		OpenedSelectBox:"",
		// moti - update - 081117
		oSelectBoxesLinkage:{}
	}

	if (Browser.Moz)
	{
		var View = {
			OffsetLeft:function (oEl) {
				for (var iX=0;oEl;iX+=oEl.offsetLeft,oEl=oEl.offsetParent);
				return iX;
			}
		}
	}

	var Depth = {
		Counter: 100,
		getNext: function() {return Depth.Counter++}
	}

	function getTop(theObj) {
		var iCount=0;
		while(theObj) {
			iCount+=(theObj.offsetTop?theObj.offsetTop-theObj.scrollTop:0);
			theObj=theObj.offsetParent;
		}
		return iCount;
	}


	function getExacPos(obj){ 
		var curleft = 0; 
		if (obj.offsetParent) { 
			while (1) { 
				curleft+=obj.offsetLeft; 
				if (!obj.offsetParent) { 
					break; 
				} 
				obj=obj.offsetParent; 
			} 
		} else if (obj.x) { 
			curleft+=obj.x; 
		} 
		return curleft;
	}


	function OpenDropUp() {
		
	}
	
	function getLeft(theObj,isIE) {
		if (Browser.Moz)
		{
			return View.OffsetLeft(theObj) + 2; // moti - update - 081124
		} else {
			return (theObj.getClientRects()[0].left-2) + 2;
		}		
	}

	var SelectBox = function(oParams) {

		var This = this;
		
		this.Skins = {
			0: {pTop:0,ddFontSize:10,ddHeight:14,dFontSize:12,height:17,bg:"#e9e9e9",dLeft:"url("+ROOT_URL+"images/controllers/select/ddleft.gif)",btnOpen:"url("+ROOT_URL+"images/controllers/select/ddbtn.gif)",btnOpenWidth:19},
			1: {pTop:0,ddFontSize:10,ddHeight:14,dFontSize:12,height:17,bg:"#ffffff",dLeft:"url("+ROOT_URL+"images/controllers/select/ddleft2.gif)",btnOpen:"url("+ROOT_URL+"images/controllers/select/ddbtn2.gif)",btnOpenWidth:19},
			2: {pTop:1,ddFontSize:12,ddHeight:16,dFontSize:15,height:21,bg:"#ffffff",dLeft:"url(/images/sprites/sprite-index.gif) 0px -1480px no-repeat",btnOpen:"url(/images/sprites/sprite-index.gif) 0px -1562px no-repeat",btnOpenWidth:23},
			
			3: {pTop:0,ddFontSize:10,ddHeight:14,dFontSize:12,height:17,bg:"#ffffff",dLeft:"url("+ROOT_URL+"images/controllers/select/ddleft3.gif)",btnOpen:"url("+ROOT_URL+"images/controllers/select/ddbtn3.gif)",btnOpenWidth:19},
			4: {pTop:1,ddFontSize:12,ddHeight:16,dFontSize:15,height:21,bg:"#ffffff",dLeft:"url("+ROOT_URL+"images/controllers/select/ddleft4.gif)",btnOpen:"url("+ROOT_URL+"images/controllers/select/ddbtn4.gif)",btnOpenWidth:23},
			5: {pTop:0,ddFontSize:10,ddHeight:14,dFontSize:12,height:17,bg:"#ffffff",dLeft:"url("+ROOT_URL+"images/controllers/select/ddleft5.gif)",btnOpen:"url("+ROOT_URL+"images/controllers/select/ddbtn5.gif)",btnOpenWidth:19}
		}

		if (oParams && oParams.SpriteMini)
		{
			this.Skins[3]["btnOpen"] = "url("+ROOT_URL+"images/sprites/sprite-index-mini.gif) -385px 0px no-repeat";
			this.Skins[4]["btnOpen"] = "url("+ROOT_URL+"images/sprites/sprite-index-mini.gif) -414px 0px no-repeat";
			this.Skins[5]["btnOpen"] = "url("+ROOT_URL+"images/sprites/sprite-index-mini.gif) -447px 0px no-repeat";

			this.Skins[3]["dLeft"] = "url("+ROOT_URL+"images/sprites/sprite-index-mini.gif) -476px 0px no-repeat";
			this.Skins[4]["dLeft"] = "url("+ROOT_URL+"images/sprites/sprite-index-mini.gif) -493px 0px no-repeat";
			this.Skins[5]["dLeft"] = "url("+ROOT_URL+"images/sprites/sprite-index-mini.gif) -510px 0px no-repeat";
		}

		this.Linkage = null;
		this.Depth = 0;
		this.bDisposed = false;
		this.selectedIndex = -1;
		this.lastSelectedIndex = -1;
		this.values = [];
		this.Width = 100;
		this.onclick = null;
		this.MaxViewedItems = 5;
		this.defaultValue = "";
		this.oElContainer = null;
		this.AlertDepth = 0; // for elements that have position:abosolute... (Alerts)
		this.oElPopped = null;
		this.TextColor = "#969696";
		this.Skin = "0";
		this.Float = "none";
		this.LeftOffset = 0;
		this.TopOffset = 0;
		this.isIE = navigator.appName.indexOf("Microsoft") > -1;
		// this.scrollProb = false;  --> moti - update - 081022 -- Removed!!

		this.onchange = null;

		this.Options = {

			Add:function(sString,sValue) {
				This.values.push([sString.toString(),sValue.toString()]);
				if (This.bDisposed)
					This.Dispose();
			},

			Remove:function(iIndex) {
				if (iIndex == This.selectedIndex)
					This.selectedIndex = 0;
				This.values.splice(iIndex,1);
				if (This.bDisposed)
					This.Dispose();
			},

			RemoveByValue:function(sValue) {
				
				for (var i=0;i<This.values.length;i++)
				{
					if (This.values[i][1] == sValue)
					{
						This.values.splice(i,1);
					}
				}

				if (This.bDisposed)
					This.Dispose();
			},

			RemoveAll:function() {
				This.values = [];
				This.selectedIndex = -1;
				if (This.bDisposed)
					This.Dispose();
			}
		}

		
		this.bodyF = function() {

			try
			{
				e = event?event:arguments[0];
				var oEl = (e.srcElement || e.target);

				
				if (oEl != This.oElContainer.lastChild && oEl.className != "txt") {
					
					if (This.values.length > This.MaxViewedItems)
					{	
						var isScroll = false;
						while (oEl.tagName != "BODY")
						{
							if (oEl.className.indexOf("CustomScroller") > -1)
							{
								
								isScroll = true;
								break;
							}
							oEl = oEl.parentNode;
						}

						if (!isScroll)
							This.Hide();
					} else {
						This.Hide();	
					}
				} else if (oEl.className == "txt")
				{
					setTimeout(function() {
						if (gSelectBox.OpenedSelectBox != This.Depth)
							This.Hide();
					},30);
				}
			}
			catch (e)
			{
				document.body.detachEvent("onmouseup",This.bodyF);
			}

				
			
		}

		this.setValue = function(iIndex,sValue) {
			This.values[iIndex][0] = sValue;
			if (This.bDisposed)
				This.Dispose();
		}

		this.Dispose = function(sIdToAppend) {

			// moti - update - 081117
			gSelectBox.oSelectBoxesLinkage[This.Linkage] = This;

			var sHtmlStr = "";
			document.body.attachEvent("onmouseup",This.bodyF);

			if (!This.bDisposed)
			{

				iSelectBoxDepth = gSelectBox.getNextHighestDepth();

				sHtmlStr += "<div class=\"DropDown\" id=\"DropDown_"+iSelectBoxDepth+"\" style=\"position:relative;z-index:50000;float:"+This.Float+";width:"+(This.Width)+"px;height:"+This.Skins[This.Skin]["height"]+"\">";
					sHtmlStr += "<div class=\"L\" style=\"height:"+(This.Skins[This.Skin]["height"])+"px;background:"+This.Skins[This.Skin]["dLeft"]+";\"></div>";
					sHtmlStr += "<div class=\"txt\" style=\"font-size:"+This.Skins[This.Skin]["dFontSize"]+"px;padding-top:"+This.Skins[This.Skin]["pTop"]+"px;height:"+(This.Skins[This.Skin]["height"]-This.Skins[This.Skin]["pTop"])+"px;width:"+(This.Width - (This.Skins[This.Skin]["btnOpenWidth"]+7))+"px;color:"+This.TextColor+";background:"+This.Skins[This.Skin]["bg"]+";\"></div>";
					sHtmlStr += "<div class=\"R\" style=\"width:"+This.Skins[This.Skin]["btnOpenWidth"]+"px;height:"+(This.Skins[This.Skin]["height"])+"px;background:"+This.Skins[This.Skin]["btnOpen"]+";\"></div>";
				sHtmlStr += "</div>";

				

				sHtmlStr += "<div class=\"DropDownPopped\" id=\"DropDown_PoppedDiv_"+iSelectBoxDepth+"\" style=\"width:"+(This.Width-4)+"px\">";
					
					sHtmlStr += "<div style=\"background:url("+ROOT_URL+"images/controllers/select/bgl.png) left repeat-y;\">";						
						sHtmlStr += "<div style=\"width:"+(This.Width-4)+";background:url("+ROOT_URL+"images/controllers/select/bgr.png) right repeat-y;\">";
							sHtmlStr += "<div style=\"background:white;margin-left:6px;margin-right:6px;\">";
							
								sHtmlStr += "<div id=\"DropDown_DataContent_Scroller_"+iSelectBoxDepth+"\" class=\"Scroller CustomScroller\" style=\"font-size:1px;position:absolute;margin:0px;padding:0px;margin-top:2px;width:11px;margin-left:"+(This.isIE?(This.Width-28):(This.Width-28))+"px\">&nbsp;</div>";
								sHtmlStr += "<div id=\"DropDown_DataContent_"+iSelectBoxDepth+"\" class=\"DataContent\" style=\"width:"+(This.Width - 17)+"px\"></div>";

							sHtmlStr += "</div>";
						sHtmlStr += "</div>";	
					sHtmlStr += "</div>";
					
					
					if (jQuery.browser.version == "6.0")
					{
						sHtmlStr += "<div style=\"float:left;font-size:0px;background:url("+ROOT_URL+"images/controllers/select/bgbl.gif) left bottom no-repeat;width:13px;height:6px;\"></div>";
						sHtmlStr += "<div style=\"float:left;font-size:0px;background:url("+ROOT_URL+"images/sprites/sprite-transparent-boxes.png) 0px -248px repeat-x;width:"+(This.Width - 30)+"px;height:6px;\"></div>";
						sHtmlStr += "<div style=\"float:left;font-size:0px;background:url("+ROOT_URL+"images/controllers/select/bgbr.gif) left bottom no-repeat;width:13px;height:6px;\"></div>";
					} else {
						sHtmlStr += "<div style=\"float:left;font-size:0px;background:url("+ROOT_URL+"images/sprites/sprite-transparent-boxes.png) 0px -196px no-repeat;width:13px;height:6px;\"></div>";
						sHtmlStr += "<div style=\"float:left;font-size:0px;background:url("+ROOT_URL+"images/sprites/sprite-transparent-boxes.png) 0px -248px repeat-x;width:"+(This.Width - 30)+"px;height:6px;\"></div>";
						sHtmlStr += "<div style=\"float:left;font-size:0px;background:url("+ROOT_URL+"images/sprites/sprite-transparent-boxes.png) 0px -222px no-repeat;width:13px;height:6px;\"></div>";
					}

				sHtmlStr += "</div>";

				if (sIdToAppend!=null && sIdToAppend!="")
				{
					document.getElementById(sIdToAppend).innerHTML = sHtmlStr;
				} else {
					document.write(sHtmlStr);
				}

				This.oElContainer = document.getElementById("DropDown_"+iSelectBoxDepth);
				This.oElPopped = document.getElementById("DropDown_DataContent_"+iSelectBoxDepth);
				$(This.oElContainer).children().bind("click", function() {
					if (This.onclick) {
						if (This.onclick())
							This.Show(true)
					} else {
						This.Show(true);
					}
				});

				This.Depth = iSelectBoxDepth;
				This.Hide();
			}

			This.oElPopped.innerHTML = "";
			This.SetValue();
			
			for (var i=0;i<This.values.length;i++)
			{
				oDiv = document.createElement("DIV");
				oDiv.style.cssText = "background:#f0f0f0;color:#969696;overflow:hidden;height:"+This.Skins[This.Skin]["ddHeight"]+"px;font-size:"+This.Skins[This.Skin]["ddFontSize"]+"px;";

				oDiv.innerHTML = This.values[i][0];
				oDiv.setAttribute("iIndex",i);
				oDiv.onmousedown = function() {

					var bChange = This.selectedIndex != this.getAttribute("iIndex");
					This.lastSelectedIndex = This.selectedIndex;
					This.selectedIndex = this.getAttribute("iIndex");
					This.SetValue();
					This.Hide();

					if (bChange && This.onchange)
						This.onchange(This.values[This.selectedIndex][0],This.values[This.selectedIndex][1]);
				}

				oDiv.onmouseover = function() {
					this.style.color = "#cc0101";
					this.style.backgroundColor = "#e9e9e9";
				}

				oDiv.onmouseout = function() {
					this.style.color = "#969696";
					this.style.backgroundColor = "#f0f0f0";					
				}
				
				This.oElPopped.appendChild(oDiv);
			}

			

			if (This.values.length > This.MaxViewedItems)
			{	

				document.getElementById("DropDown_DataContent_Scroller_"+This.Depth).style.display = 'inline';
				document.getElementById("DropDown_DataContent_"+This.Depth).style.width = (This.Width - 28) + "px";

				if (This.isIE) {
					
					document.getElementById("DropDown_DataContent_"+This.Depth).style.width = (This.Width - 28) + "px";
					document.getElementById("DropDown_DataContent_Scroller_"+This.Depth).style.marginLeft = (This.Width - 28) + "px";
				}

				document.getElementById("DropDown_DataContent_"+This.Depth).style.paddingRight = "11px";
				document.getElementById("DropDown_DataContent_"+This.Depth).style.height = ((This.MaxViewedItems * 15)+1) + "px";
				
				//  moti - update - 081022 -- Removed!!
				/*
				This.Show();
				

				try
				{
					oS = new Scroller();
					oS.Apply("DropDown_DataContent_"+This.Depth,"DropDown_DataContent_Scroller_"+This.Depth);
					oS.Update();

					alert(document.getElementById("DropDown_DataContent_Scroller_"+This.Depth).offsetHeight);

				}
				catch (e)
				{
					
					This.scrollProb = true;
				}
				

				This.Hide();
				*/
		
			} else {

				if (document.getElementById("DropDown_DataContent_Scroller_"+This.Depth))
					document.getElementById("DropDown_DataContent_Scroller_"+This.Depth).style.display = 'none';
				
				This.oElPopped.style.width = (This.Width - 14) + "px";



				document.getElementById("DropDown_DataContent_"+This.Depth).style.width = (This.Width - 16) + "px";
				if (This.isIE)
					document.getElementById("DropDown_DataContent_"+This.Depth).style.width = (This.Width - 16) + "px";


				document.getElementById("DropDown_DataContent_"+This.Depth).style.marginRight = "0px";
				document.getElementById("DropDown_DataContent_"+This.Depth).style.paddingRight = "0px";
			}

			document.getElementById("DropDown_PoppedDiv_"+This.Depth).style.display = 'none';
			This.bDisposed = true;
			
			
		}

		this.SetValue = function() {
			document.getElementById("DropDown_"+This.Depth).childNodes[1].innerHTML = This.defaultValue;
			document.getElementById(This.Linkage).value = This.defaultValue;
			if (This.values.length && This.selectedIndex > -1) {
				document.getElementById("DropDown_"+This.Depth).childNodes[1].innerHTML = This.values[This.selectedIndex][0];
				document.getElementById(This.Linkage).value = This.values[This.selectedIndex][1];
			}
		}

		this.Reset = function() {
			This.selectedIndex = -1;
			This.SetValue();
		}

		this.changeSelectedIndex = function(iIndex) {
			try
			{
				if (This.values.length < iIndex)
					throw "SelectBox Error: selectedIndex out of range";
				This.selectedIndex = iIndex;
				This.SetValue();
			}
			catch (e) {alert(e)}
		}

       this.changeValue = function(value) {
            value=""+value;
            for (var i=0;i<This.values.length;i++) {
                if ((""+This.values[i][1])==value) {
                    This.changeSelectedIndex(i);
                    return;
                }
            }
        }

		this.Show = function(bClicked) {

			if (document.getElementById("DropDown_PoppedDiv_"+This.Depth).style.display != "none")
			{
				This.Hide();
			} else {

				if (This.AlertDepth == 0)
				{
					var iLeft = getLeft(document.getElementById("DropDown_"+This.Depth).firstChild,This.isIE);
					var iTop = getTop(document.getElementById("DropDown_"+This.Depth));

					iLeft -= This.LeftOffset;
					iTop -= This.TopOffset;
					if (This.LeftOffset > 0)
					{
						if (window.addEventListener) {
							
							//var iOffLeft = 0;
							var moz_obj = document.getElementById("DropDown_"+This.Depth);
							
							//alert(getExacPos(moz_obj));
							
							iLeft = moz_obj.offsetLeft + 2;
							

						} else if ($.browser.msie && $.browser.version == 6) {
							iLeft += 5;
						}
					}

				} else {
					var iLeft = document.getElementById("macao_"+This.AlertDepth).offsetLeft + document.getElementById("DropDown_"+This.Depth).parentNode.offsetLeft + 2;
					var iTop = getTop(document.getElementById("DropDown_"+This.Depth)) - document.getElementById("macao_"+This.AlertDepth).offsetTop - 10;
				}
				
				document.getElementById("DropDown_PoppedDiv_"+This.Depth).style.left = (iLeft).toString() + "px";
				document.getElementById("DropDown_PoppedDiv_"+This.Depth).style.top = (iTop + This.Skins[This.Skin]["height"]).toString() + "px";
				document.getElementById("DropDown_PoppedDiv_"+This.Depth).style.display = 'block';

				//if (This.scrollProb)
				//{
					oS = new Scroller();
					oS.Apply("DropDown_DataContent_"+This.Depth,"DropDown_DataContent_Scroller_"+This.Depth);
					oS.Update();
					//This.scrollProb = false;
				// }


				gSelectBox.OpenedSelectBox = This.Depth;
			
			}
			
		}

		this.Hide = function() {
			document.getElementById("DropDown_PoppedDiv_"+This.Depth).style.display = "none";
		}

	}