 var STATE_ID 		= '__State';
 var REGION_ID 		= '__Region';
 var SUBREGION_ID	= '__SubRegion';
 var TOWN_ID 		= '__Town';
 var AREA_ID 		= '__Area';

 // selected objects 
 var selectedState		= new State();
 var selectedRegion 	= new Region();
 var selectedSubRegion	= new SubRegion();
 var selectedTown 		= new Array(); //Town();
 var selectedArea 		= new Area(); 

 var statesArray = new Array();
 var regionsArray = new Array(); 
 var subregionsArray = new Array(); 
 var townsArray = new Array();  
 var townsArray1 = new Array();  
 var areasArray = new Array();   
 var townAreasArray = new Array()
 var AllInfoArray = new Array()
 var geoItemsDuration = 0;
 var specialCase = false  



/**
 * -------------------------------------------------------------------------
 *  General objects
 * -------------------------------------------------------------------------
 */

 /**
 * State object 
 */
 function State(id, name){
 		this.id = id; 	
 		this.name = name;
 }
 
 /**
 * Region object 
 */
 function Region(id, name, stateId){
 		this.id = id; 	
 		this.name = name;
 		this.stateId = stateId;
 }
 
 /**
 * SubRegion object 
 */
 function SubRegion(id, name, regionId){
 		this.id = id; 	
 		this.name = name;
 		this.regionId = regionId;
 }
 
 /**
 * Town object 
 */
 function Town(id, name, stateId, regionId, subregionId){
 		this.id = id; 	
 		this.name = name;
 		this.stateId = stateId;
 		this.regionId = regionId;
 		this.subregionId = subregionId;
 }


 /**
 * Area object 
 */
 function Area(id, name){
 		this.id = id; 	
 		this.name = name;
 } 
 

 /**
 * TownArea object 
 */
 function TownArea(townId, areaId){
 		this.townId = townId; 	
 		this.areaId = areaId;
 } 

 /**
 * All-in-one object 
 */
 function AllInfo(stateID,regionID,subregionID,townID,areaID){
 	this.stateID=stateID;
 	this.regionID=regionID;
 	this.subregionID=subregionID;
 	this.townID=townID;
 	this.areaID=areaID;
 }

 function specialLetters(str){

	for(var i=0;i<str.length;i++){
		if(str.charCodeAt(i) > 192)
		{
			break;
		}
		return str;
	}

 	//À	&#192;
 	str = str.replace(String.fromCharCode(192),"AZ_")
 	//Á	&#193;
 	str = str.replace(String.fromCharCode(193),"AZ_") 	
 	//Â	&#194;
 	str = str.replace(String.fromCharCode(194),"AZ_")
 	//Ã	&#195;
 	str = str.replace(String.fromCharCode(195),"AZ_")
 	//Ä	&#196
 	str = str.replace(String.fromCharCode(196),"AZ_")
	//Å	&#197;
	str = str.replace(String.fromCharCode(197),"AZ_")
	//Æ	&#198;
	str = str.replace(String.fromCharCode(198),"AZ_")

 	//à	&#224;
 	str = str.replace(String.fromCharCode(224),"az_", "g")
 	//á	&#225;
 	str = str.replace(String.fromCharCode(225),"az_", "g")
 	//â	&#226;
 	str = str.replace(String.fromCharCode(226),"az_", "g")
	//ã	&#227; 	
	str = str.replace(String.fromCharCode(227),"az_", "g")	
 	//ä	&#228;
	str = str.replace(String.fromCharCode(228),"az_", "g")
	//å	&#229;
	str = str.replace(String.fromCharCode(229),"az_", "g")	
 	
	//Ò	&#210;
	str = str.replace(String.fromCharCode(210),"OZ_", "g")
	//Ó	&#211;
	str = str.replace(String.fromCharCode(211),"OZ_", "g")
	//Ô	&#212;
	str = str.replace(String.fromCharCode(212),"OZ_", "g")
	//Õ	&#213;
	str = str.replace(String.fromCharCode(213),"OZ_", "g")
	//Ö	&#214;
	str = str.replace(String.fromCharCode(214),"OZ_", "g")

	//ò	&#242;
	str = str.replace(String.fromCharCode(242),"oz_", "g")
	//ó	&#243;
	str = str.replace(String.fromCharCode(243),"oz_", "g")
	//ô	&#244;
	str = str.replace(String.fromCharCode(244),"oz_", "g")
	//õ	&#245;
	str = str.replace(String.fromCharCode(245),"oz_", "g")	
	//ö	&#246;
	str = str.replace(String.fromCharCode(246),"oz_", "g")
 	
 	//Ý	&#221;
	str = str.replace(String.fromCharCode(221),"YZ_", "g")
	//ý	&#253;
	str = str.replace(String.fromCharCode(253),"yz_", "g")
	 	
 	//ß	&#223;
 	str = str.replace(String.fromCharCode(223),"sz_", "g")
 	
	//Ù	&#217;
	str = str.replace(String.fromCharCode(217),"UZ_", "g")
	//Ú	&#218;
	str = str.replace(String.fromCharCode(218),"UZ_", "g")
	//Û	&#219;
	str = str.replace(String.fromCharCode(219),"UZ_", "g")
 	//Ü	&#220;
	str = str.replace(String.fromCharCode(220),"UZ_", "g")
	
	//ù	&#249;
	str = str.replace(String.fromCharCode(249),"uz_", "g")
	//ú	&#250;
	str = str.replace(String.fromCharCode(250),"uz_", "g")
	//û	&#251;
	str = str.replace(String.fromCharCode(251),"uz_", "g")
	//ü	&#252;
	str = str.replace(String.fromCharCode(252),"uz_", "g")
 	
 	
 	//Ç	&#199;
 	str = str.replace(String.fromCharCode(199),"CZ_", "g")
 	//ç	&#231;
 	str = str.replace(String.fromCharCode(231),"cz_", "g")
 	
	//È	&#200;
	str = str.replace(String.fromCharCode(200),"EZ_", "g")
	//É	&#201;
	str = str.replace(String.fromCharCode(201),"EZ_", "g")
	//Ê	&#202;
	str = str.replace(String.fromCharCode(202),"EZ_", "g")
	//Ë	&#203;
	str = str.replace(String.fromCharCode(203),"EZ_", "g")
	
	//è	&#232;
	str = str.replace(String.fromCharCode(232),"ez_", "g")
	//é	&#233;
	str = str.replace(String.fromCharCode(233),"ez_", "g")
	//ê	&#234;
	str = str.replace(String.fromCharCode(234),"ez_", "g")
	//ë	&#235;
	str = str.replace(String.fromCharCode(235),"ez_", "g")
	
	//Ì	&#204;
	str = str.replace(String.fromCharCode(204),"IZ_", "g")
	//Í	&#205;
	str = str.replace(String.fromCharCode(205),"IZ_", "g")
	//Î	&#206;
	str = str.replace(String.fromCharCode(206),"IZ_", "g")
	//Ï	&#207;
	str = str.replace(String.fromCharCode(207),"IZ_", "g")
	
	//ì	&#236;
	str = str.replace(String.fromCharCode(236),"iz_", "g")	
	//í	&#237;
	str = str.replace(String.fromCharCode(237),"iz_", "g")	
	//î	&#238;
	str = str.replace(String.fromCharCode(238),"iz_", "g")	
	//ï	&#239;
	str = str.replace(String.fromCharCode(239),"iz_", "g")	
 	
 	str = str.toLowerCase()
 	return str;
 }



var selectedStateID='';
var selectedRegionID='';
var selectedSubregionID='';
var selectedTownID='';
var selectedAreaID='';
var liteMode = false
 var specialCase;
 
 function prepareAllInfo_stop()
 {
  specialCase = false;
 	for (var town = 0; town < townsArray.length; town++)
 	{
		var townID = townsArray[town].id;
		var stateID = townsArray[town].stateId;
		var regionId = townsArray[town].regionId;
		var subregionId = townsArray[town].subregionId;
		if (subregionId==0) subregionId='';
		var hasArea = false;
 		for(ta=0; ta<townAreasArray.length; ta++)
 		{	
 			if (townAreasArray[ta].townId == townID)
 			{
 				hasArea=true;
 				AllInfoArray[AllInfoArray.length]=new AllInfo(stateID,regionId,subregionId,townID,townAreasArray[ta].areaId);
 			}
 		}
 		if (!hasArea) {
	 		AllInfoArray[AllInfoArray.length]=new AllInfo(stateID,regionId,subregionId,townID,'');
 		}
 	}
 }
 
 
 function prepareAllLiteInfo()
 {
  		liteMode = true
	 	shownStates = new Array();
	
		shownRegions = new Array();
	
		shownSubregions = new Array();
	
		shownTowns = new Array();
	
		shownAreas = new Array();

  		for(var i=0; i<statesArray.length; i++){
			shownStates[i] = statesArray[i].id
	 	}
  		for(var i=0; i<regionsArray.length; i++){
			shownRegions[i] = regionsArray[i].id
	 	}
  		for(var i=0; i<subregionsArray.length; i++){
			shownSubregions[i] = subregionsArray[i].id
	 	}
  		for(var i=0; i<townsArray.length; i++){
			shownTowns[i] = townsArray[i].id
	 	}
  		for(var i=0; i<areasArray.length; i++){
			shownAreas[i] = areasArray[i].id
	 	}

		sortStates()
		sortRegions()
		sortSubregions()							
		sortAreas()
		sortTowns()

	
	
	 	renderItems(STATE_ID,shownStates,statesArray, selectedStateID);
		renderItems(REGION_ID,shownRegions,regionsArray,selectedRegionID);
		renderItems(SUBREGION_ID,shownSubregions,subregionsArray,selectedSubregionID);
		renderItems(TOWN_ID,shownTowns,townsArray,selectedTownID);
		renderItems(AREA_ID,shownAreas,areasArray,selectedAreaID);	 		 		 		 		 	
 }
/**
* helper  select functions
*/

function fillRenderArrays(state,region,subregion,town)
{
 	for (var i = 0; i < AllInfoArray.length; i++) 
 	{
 		// states 		
 		shownStates[AllInfoArray[i].stateID] = AllInfoArray[i].stateID;
		
		if ((state=="") || (state==AllInfoArray[i].stateID)){
			//regions
			shownRegions[AllInfoArray[i].regionID] = AllInfoArray[i].regionID;
			
 		 	if ((region=="") || (region==AllInfoArray[i].regionID)){
 		 		//subregions
 		 		shownSubregions[AllInfoArray[i].subregionID] = AllInfoArray[i].subregionID;
 		
		 		//towns	
		 		if (AllInfoArray[i].townID=='-ALL-'){
					shownTowns["-ALL-"]="-ALL-";	
				} 		
	 		 	if ((subregion=="") || (subregion==AllInfoArray[i].subregionID)){	 
	 		 		//towns		 		 	
					shownTowns[AllInfoArray[i].townID] = AllInfoArray[i].townID;
					
					// areas
					if (AllInfoArray[i].areaID=='-ALL-'){
				 		shownAreas["-ALL-"]="-ALL-";	 	
			 		}	
		 		 	if ((town=="") || (town==AllInfoArray[i].townID)){
			 		 	shownAreas[AllInfoArray[i].areaID] = AllInfoArray[i].areaID;
		 		 	}
		 		}
		 	}
		}
	}				
}
function renderItems(elementID,itemsArray,namesArray,selectedItemID)
{
	if(BrowserDetect.browser == "Netscape" || ( BrowserDetect.browser == "Firefox" && BrowserDetect.version < 2 ) )
	{
		renderItems_option(elementID,itemsArray,namesArray,selectedItemID)
	}
	else
	{
		renderItems_innerHTML(elementID,itemsArray,namesArray,selectedItemID)
	}	
}

function renderItems_option(elementID,itemsArray,namesArray,selectedItemID)
{
  	var obj = document.getElementById(elementID);
  	if(obj != null){
	  	obj.length = 0
		i=0
		for (theItem in itemsArray)
		{
		    if(selectedItemID == itemsArray[theItem]){
				optionObj = new Option(namesArray[itemsArray[theItem] + "_"].name, itemsArray[theItem], true, true);
			}else{				
				optionObj = new Option(namesArray[itemsArray[theItem] + "_"].name, itemsArray[theItem], false, false);
			}
			obj.options[i]=optionObj;
			i++;
		}
	}
}
function renderItems_innerHTML(elementID,itemsArray,namesArray,selectedItemID)
{
  	var obj = document.getElementById(elementID);
  	if(obj != null){
  		var html = new StringBuffer()  		
		for (theItem in itemsArray)
		{
		    html.append("<option ")
		    if(selectedItemID == itemsArray[theItem]){
    		    html.append(" selected=\"selected\" ")
			}
		    html.append(" value='")
		    html.append(itemsArray[theItem])
		    html.append("'>")
		    html.append(namesArray[itemsArray[theItem] + "_"].name)
		    html.append("</option> ")
		}		
		if(document.all) { // Or any IE testing
		  	selectHtml = obj.outerHTML
	  	    stopIndex = selectHtml.indexOf(">")
		  	selectHtml = selectHtml.substr(0,stopIndex+1)
   			obj.outerHTML = selectHtml + html.toString() + "</select>";
		}else
		{
			obj.innerHTML = html.toString() 
		}
		//alert(obj.innerHTML )

	}
}
function get_selectedStateID(region)
{
 	for (var i = 0; i < AllInfoArray.length; i++) {
 		if (AllInfoArray[i].regionID==region) {
	 		return AllInfoArray[i].stateID;
 		}
 	}
 	return '';
}

function get_selectedRegionID(subregion)
{
 	for (var i = 0; i < AllInfoArray.length; i++) {
 		if (AllInfoArray[i].subregionID==subregion) {
	 		return AllInfoArray[i].regionID;
 		}
 	}
 	return '';
}

//this func sets all upper towns inside
function set_selectedByTown(town)
{
 	for (var i = 0; i < AllInfoArray.length; i++) {
 		if (AllInfoArray[i].townID==town) {
		 	selectedSubregionID = AllInfoArray[i].subregionID;
		 	selectedRegionID = AllInfoArray[i].regionID;
		 	selectedStateID = AllInfoArray[i].stateID;
	 		return;
 		}
 	}
}

function get_selectedTownID(area)
{
 	for (var i = 0; i < AllInfoArray.length; i++) {
 		if (AllInfoArray[i].areaID==area) {
	 		return AllInfoArray[i].townID;
 		}
 	}
 	return '';
}


function isSpecialArea(area)
{
 	specialAreaInfo = new Array();
 	var cnt = 0
 	for (var i = 0; i < AllInfoArray.length; i++) {
 		if (AllInfoArray[i].areaID==area) {
	 		cnt++;
	 		specialAreaInfo[AllInfoArray[i].townID] = AllInfoArray[i];
	 		shownStates[AllInfoArray[i].stateID] = AllInfoArray[i].stateID;
	 		shownRegions[AllInfoArray[i].regionID] = AllInfoArray[i].regionID;
	 		shownSubregions[AllInfoArray[i].subregionID] = AllInfoArray[i].subregionID;
	 		shownTowns[AllInfoArray[i].townID] = AllInfoArray[i].townID;
	 		shownAreas[AllInfoArray[i].areaID] = AllInfoArray[i].areaID;
 		}
 	}
 	if (cnt>1) {
 		return true; 	
 	}else {
	 	shownStates = new Array();
		shownStates[""]=""; //include all
		shownRegions = new Array();
		shownRegions[""]=""; //include *all*
		shownSubregions = new Array();
		shownSubregions[""]=""; //include *all*
		shownTowns = new Array();
		shownTowns[""]=""; //include *all*
		shownAreas = new Array();
		shownAreas[""]=""; //include *all*
	 	return false;
 	}
}

 function renderListsNEW(Obj)
 {
	var date1 = new Date(); 
	var milliseconds1 = date1.getTime();
	var skipListBuilder = false;
 	if(Obj == null){
	 	Obj = new Object();
	 	Obj.id = '';		
 	}
 	
 	//check if its more than one item
	var itemCount = 0;
 	if (document.getElementById(STATE_ID)) itemCount++;
 	if (document.getElementById(REGION_ID)) itemCount++;
 	if (document.getElementById(SUBREGION_ID)) itemCount++;
 	if (document.getElementById(TOWN_ID) || document.getElementById('SrchOrte') ) itemCount++;
 	if (document.getElementById(AREA_ID)) itemCount++;
 	
	// 	if (itemCount <= 1 && Obj.id != '' || itemCount == 0 ) return;
	// Ticket #10694 
 	if (itemCount <= 0 && Obj.id != '' || itemCount == 0 ) return;
 	
 	if(liteMode) return;
 	
 	shownStates = new Array();
	shownStates[""]=""; //include all
	shownRegions = new Array();
	shownRegions[""]=""; //include *all*
	shownSubregions = new Array();
	shownSubregions[""]=""; //include *all*
	shownTowns = new Array();
	shownTowns[""]=""; //include *all*
	shownAreas = new Array();
	shownAreas[""]=""; //include *all*

 	switch(Obj.id){
	 	case STATE_ID:
			 	selectedStateID = Obj.value;		 	
				 	selectedRegionID='';
				 	selectedSubregionID='';
				 	selectedTownID='';
			 	if (!specialCase)	selectedAreaID='';
	 		break;
	 	case REGION_ID:
			 	if (Obj.value!='' && Obj.value!='-ALL-'){
				 	selectedStateID = get_selectedStateID(Obj.value);
				}
			 	selectedRegionID= Obj.value;
			 	selectedSubregionID='';
			 	selectedTownID='';
				if (!specialCase)	selectedAreaID='';
				
	 		break;
	 	case SUBREGION_ID:
			 	if (Obj.value!='' && Obj.value!='-ALL-'){
				 	selectedRegionID = get_selectedRegionID(Obj.value);
				 	selectedStateID = get_selectedStateID(selectedRegionID);
				}
			 	selectedSubregionID = Obj.value;
			 	selectedTownID='';
				if (!specialCase) 	selectedAreaID='';
				
	 		break;
	 	case TOWN_ID:
			 	if (Obj.value!='' && Obj.value!='-ALL-'){
				 	set_selectedByTown(Obj.value);
				}
			 	selectedTownID = Obj.value;
				if (!specialCase) 	selectedAreaID='';
			 	
	 		break;
	 	case AREA_ID:
			 	if (Obj.value!='' && Obj.value!='-ALL-'){
			 		//check for special area case (one area -> many towns)
			 		if(isSpecialArea(Obj.value)) {
			 		 	skipListBuilder=true;
					 	selectedAreaID = Obj.value;
			 		 	break;
			 		}
					selectedTownID = get_selectedTownID(Obj.value);
				 	set_selectedByTown(selectedTownID);
				}
			 	selectedAreaID = Obj.value;
	 		break;
 	}

 	// in this mode there is no connection between geographics items

	//check for element status
 	if (!document.getElementById(STATE_ID)) selectedStateID='';
 	if (!document.getElementById(REGION_ID)) selectedRegionID='';
 	if (!document.getElementById(SUBREGION_ID)) selectedSubregionID='';
 	if (!document.getElementById(TOWN_ID)) {
	 	//pool checkboxes case
	 	if(!document.getElementById('SrchOrte')) selectedTownID='';
 	}
 	if (!document.getElementById(AREA_ID)) selectedAreaID='';

	if(!skipListBuilder && selectedAreaID!='' && selectedAreaID!='-ALL-' && isSpecialArea(selectedAreaID)) 
	{
		skipListBuilder=true;
 	}

	if(!skipListBuilder) 
	{
		specialCase = false;
		fillRenderArrays(selectedStateID,selectedRegionID,selectedSubregionID,selectedTownID);
	} 
	else //special case
	{
	 	specialCase = true;
	}	

	selectedTown = new Array();
	selectedTown[selectedTown.length] = townsArray[selectedTownID+"_"];
	
	
	if (document.getElementById(STATE_ID))	sortStates()
	if (document.getElementById(REGION_ID))	sortRegions()
	if (document.getElementById(SUBREGION_ID)) sortSubregions()							
	if (document.getElementById(AREA_ID)) sortAreas()

	renderItems(STATE_ID,shownStates,statesArray, selectedStateID);
	renderItems(REGION_ID,shownRegions,regionsArray,selectedRegionID);
	renderItems(SUBREGION_ID,shownSubregions,subregionsArray,selectedSubregionID);
	renderItems(TOWN_ID,shownTowns,townsArray,selectedTownID);
	renderItems(AREA_ID,shownAreas,areasArray,selectedAreaID);

	var date2 = new Date(); 
	var milliseconds2 = date2.getTime(); 
	geoItemsDuration = milliseconds2 - milliseconds1; 
 }
 
 
 function sortAreaObject(id1, id2){ 
 	var obj1 = areasArray[id1+"_"]
 	var obj2 = areasArray[id2+"_"] 	
 	
 	if(obj1.id == "" && obj2.id == "-ALL-") return -1
 	if(obj1.id == "-ALL-" && obj2.id == "") return 1
 	
 	if(obj1.id == "" || obj1.id == "-ALL-") return -1
 	if(obj2.id == "" || obj2.id == "-ALL-") return 1

 	if(specialLetters(obj1.name) > specialLetters(obj2.name))
 		return 1
 	else
 		return -1
 }
 function sortRegionObject(id1, id2){ 
 	var obj1 = regionsArray[id1+"_"]
 	var obj2 = regionsArray[id2+"_"] 	

 	if(obj1.id == "" && obj2.id == "-ALL-") return -1
 	if(obj1.id == "-ALL-" && obj2.id == "") return 1
 	
 	if(obj1.id == "" || obj1.id == "-ALL-") return -1
 	if(obj2.id == "" || obj2.id == "-ALL-") return 1

 	if(specialLetters(obj1.name) > specialLetters(obj2.name))
 		return 1
 	else
 		return -1
 }
 function sortSubregionsObject(id1, id2){ 
 	var obj1 = subregionsArray[id1+"_"]
 	var obj2 = subregionsArray[id2+"_"] 	

 	if(obj1.id == "" && obj2.id == "-ALL-") return -1
 	if(obj1.id == "-ALL-" && obj2.id == "") return 1
 	
 	if(obj1.id == "" || obj1.id == "-ALL-") return -1
 	if(obj2.id == "" || obj2.id == "-ALL-") return 1

 	if(specialLetters(obj1.name) > specialLetters(obj2.name))
 		return 1
 	else
 		return -1
 }

 function sortStatesObject(id1, id2){ 
 	var obj1 = statesArray[id1+"_"]
 	var obj2 = statesArray[id2+"_"] 	

 	if(obj1.id == "" && obj2.id == "-ALL-") return -1
 	if(obj1.id == "-ALL-" && obj2.id == "") return 1
 	
 	if(obj1.id == "" || obj1.id == "-ALL-") return -1
 	if(obj2.id == "" || obj2.id == "-ALL-") return 1

 	if(specialLetters(obj1.name) > specialLetters(obj2.name))
 		return 1
 	else
 		return -1
 }
 
  function sortTownsObject(id1, id2){ 
 	var obj1 = townsArray[id1+"_"]
 	var obj2 = townsArray[id2+"_"] 	

 	if(obj1.id == "" && obj2.id == "-ALL-") return -1
 	if(obj1.id == "-ALL-" && obj2.id == "") return 1
 	
 	if(obj1.id == "" || obj1.id == "-ALL-") return -1
 	if(obj2.id == "" || obj2.id == "-ALL-") return 1

	return 0
 }
 
 function sortAreas(){
  	var tmpArray = new Array()
 	var i=0;
 	for (theItem in shownAreas)
	{
		tmpArray[i] = shownAreas[theItem]
		i++;
	}		
	shownAreas = tmpArray
 	shownAreas.sort(sortAreaObject)
 }

 function sortRegions(){
 	var tmpArray = new Array()
 	var i=0;
 	for (theItem in shownRegions)
	{
		tmpArray[i] = shownRegions[theItem]
		i++;
	}	
	shownRegions = tmpArray
 	shownRegions.sort(sortRegionObject)
 } 	

 function sortSubregions(){
   	var tmpArray = new Array()
   	var i=0;
 	for (theItem in shownSubregions)
	{
		tmpArray[i] = shownSubregions[theItem]
		i++;
	}		
	shownSubregions = tmpArray
 	shownSubregions.sort(sortSubregionsObject)
 } 

 function sortStates(){
   	var tmpArray = new Array()
   	var i=0;
 	for (theItem in shownStates)
	{
		tmpArray[i] = shownStates[theItem]
		i++;
	}		
	shownStates = tmpArray
 	shownStates.sort(sortStatesObject)
 }
 
  function sortTowns(){
   	var tmpArray = new Array()
   	var i=0;
 	for (theItem in shownTowns)
	{
		tmpArray[i] = shownTowns[theItem]
		i++;
	}		
	shownTowns = tmpArray
 	shownTowns.sort(sortTownsObject)
 }
 
 
 function fillTownArea(townId, areaId){
 	townAreasArray[townAreasArray.length] = new TownArea(townId, areaId);	
/*
 	var found = false;
	for(i=0;i<townAreasArray.length;i++){
		if(townAreasArray[i].townId == townId && townAreasArray[i].areaId == areaId){
			found = true;
			break;
		}
	}
	if(!found){
		townAreasArray[townAreasArray.length] = new TownArea(townId, areaId);	
	}
*/
 }
 


 function StringBuffer() { 
   this.buffer = []; 
 } 

 StringBuffer.prototype.append = function append(string) { 
   this.buffer.push(string); 
   return this; 
 }; 

 StringBuffer.prototype.toString = function toString() { 
   return this.buffer.join(""); 
 }; 
