	function AreaList(){
		this.Areas = SDOStatus.Games[0].Areas;
		this.AreaControl = "";
		this.ServerControl = "";
		this.AreaNameControl = "";
		this.ServerNameControl = "";
		this.ShortServerName = false;
		this.ShortAreaName = false;
		this.areaControl = function(){
			return document.getElementById(this.AreaControl);
		};
		this.serverControl = function(){
			return document.getElementById(this.ServerControl);
		};
		this.areaNameControl = function(){
			if(this.AreaNameControl != ""){
				return document.getElementById(this.AreaNameControl);
			}
			else{
				return "";
			}
		};
		this.serverNameControl = function(){
			if(this.ServerNameControl != ""){
				return document.getElementById(this.ServerNameControl);
			}
			else{
				return "";
			}
		};
		this.getShort = function(fullAreaName){
			var name = fullAreaName;
		
			name = name.replace(/\s/g, "");
			var i = name.indexOf("(");
			if(i == -1){
				i = name.indexOf("ги");
			}
			
			if(i > 0){
				name = name.substr(0, i);
			}
			
			return name;
		};
		this.Selected = function(areaId, serverId){
			var myserverId;
			if(arguments.length == 1){
				myserverId = -1;
			}
			else{
				myserverId = arguments[1];
			}
			for(var i=0;i<this.areaControl().length;i++){
				if(this.areaControl().options[i].value.toString() == areaId.toString()){
					this.areaControl().options[i].selected = true;
					while(this.serverControl().options.length > 0){
						this.serverControl().options.remove(0);
					}
					for(var k=0;k<this.Areas[i].Groups.length;k++){
						this.serverControl().options.add(new Option(this.Areas[i].Groups[k].Name, this.Areas[i].Groups[k].Id));
					}
					if(this.AreaNameControl != ""){
						this.areaNameControl().value = this.areaControl().options[this.areaControl().options.selectedIndex].text;
					}	
					if(myserverId == -1){
						this.serverControl().options[0].selected = true;
					}
					else{
						for(var j=0;j<this.serverControl().options.length;j++){
							if(this.serverControl().options[j].value == myserverId){
								this.serverControl().options[j].selected = true;
								break;
							}
						}
					}
					if(this.ServerNameControl != ""){
						this.serverNameControl().value = this.serverControl().options[this.serverControl().options.selectedIndex].text;
					}
					
					break;
				}
			}
		};
		this.AreaRemove = function(AresString){
			var arr = AresString.split(",");
			//var AreasArr2 = this.Areas;
			for(var i=0;i<this.Areas.length;i++){
				for(var j=0;j<arr.length;j++){
					if(this.Areas[i].Id == arr[j]){
						this.Areas[i] = null;
						break;
					}
				}
			}
			
			var j = 0;
			for(var i=0;i<this.Areas.length;i++){
				if(this.Areas[i] != null){
					this.Areas[j] = this.Areas[i];
					j++;
				}
			}
			this.Areas.length = j;
		};
		
		this.ServerRemove = function(AreaId, Servers){
			var area = null;
			var areaFlag = 0;
			
			for(var i=0;i<this.Areas.length;i++){
				if(this.Areas[i].Id == AreaId){
					area = this.Areas[i];
					areaFlag = i;
					break;
				}
			}
			var serverArr = Servers.split(",");
			var area2 = area;
			//alert(serverArr.length);
			for(var i=0;i<serverArr.length;i++){
				for(var j=0;j<area2.Groups.length;j++){
					if(area2.Groups[j].Id == serverArr[i]){
						//alert(area2.Groups[j].Id);
						area2.Groups[j] = null;
					}
				}
			}
			
			var j = 0;
			
			for(var i=0;i<this.Areas[areaFlag].Groups.length;i++){
				if(area2.Groups[i] != null){
					this.Areas[areaFlag].Groups[j] = area2.Groups[i];
					j++;
				}
			}
			
			this.Areas[areaFlag].Groups.length = j;
		};
		
		this.Bind = function(){
			if(this.ShortAreaName){
				for(var i=0;i<this.Areas.length;i++){
					this.Areas[i].Name = this.getShort(this.Areas[i].Name);
				}
			}
			if(this.ShortServerName){
				for(var i=0;i<this.Areas.length;i++){
					for(var j=0;j<this.Areas[i].Groups.length;j++){
						this.Areas[i].Groups[j].Name = this.getShort(this.Areas[i].Groups[j].Name);
					}
				}
			}
			for(var i=0;i<this.Areas.length;i++){
				this.areaControl().options.add(new Option(this.Areas[i].Name, this.Areas[i].Id));
			}
			for(var i=0;i<this.Areas[0].Groups.length;i++){
				this.serverControl().options.add(new Option(this.Areas[0].Groups[i].Name, this.Areas[0].Groups[i].Id));
			}

			if(this.AreaNameControl != ""){
				var oarea = this.areaControl();
				var oserver = this.serverControl();
				var oAreas = this.Areas;
				var oareaname = this.areaNameControl();
				var oservername = this.serverNameControl();
				if (this.areaNameControl()) this.areaNameControl().value = this.Areas[0].Name;
				this.areaControl().onchange = function(){
					while(oserver.options.length > 0){
						oserver.options.remove(0);
					}
					var j = oarea.options[0].value == "" ? oarea.options.selectedIndex - 1: oarea.options.selectedIndex;
					var fOAreas = oAreas[j].Groups;
					for(var i=0;i<fOAreas.length;i++){
						oserver.options.add(new Option(fOAreas[i].Name, fOAreas[i].Id));
					}
					
				if (oservername)
				{	oareaname.value = oarea.options[oarea.selectedIndex].text;
					oservername.value = oserver.options[0].text;}
				};
			}
			else{
				var oarea = this.areaControl();
				var oserver = this.serverControl();
				var oAreas = this.Areas;
				var oareaname = this.areaNameControl();
				this.areaControl().onchange = function(){
					while(oserver.options.length > 0){
						oserver.options.remove(0);
					}
					var j = oarea.options.selectedIndex;
					var fOAreas = oAreas[j].Groups;
					for(var i=0;i<fOAreas.length;i++){
						oserver.options.add(new Option(fOAreas[i].Name, fOAreas[i].Id));
					}
				};
			}
			if(this.ServerNameConttrol != ""){
				var oservername = this.serverNameControl();
				var oareas = this.Areas
				var oserver = this.serverControl();
				if (oservername) oservername.value = oareas[0].Groups[0].Name;
				oserver.onchange = function(){
					oservername.value = oserver.options[oserver.selectedIndex].text;
				};
			}
		};
	}