function Select(){
	this.options = new Array();
	this.selectedIndex = 0;
}
function Option(text,value,color){
	this.text = text;
	this.value = value;
	this.style = new Object();
	this.style.color = color;
}
Select.prototype.addOption = function(text,value,color){
	this.options[this.options.length] = new Option(text,value,color);
}
Select.copy = function(select1,select2){
	select2.options.length = select1.options.length;
	select2.selectedIndex = select1.selectedIndex;
	for (var i=0;i<select1.options.length;i++){
		select2.options[i].text = select1.options[i].text;
		select2.options[i].value = select1.options[i].value;
		if (select2.options[i].style){
			select2.options[i].style.color = select1.options[i].style.color;
		}
	}
}

function switchRegionResortSelect(select1,select2){
	/*
	When select1 is changed select2 is changed to the select object having the
	same index in regionArray.
	*/
	if (window.global_previouslySelectedRegion){
		global_previouslySelectedRegion.selectedIndex = select2.selectedIndex;
	}
	Select.copy(regionArray[select1.selectedIndex],select2);
	global_previouslySelectedRegion = regionArray[select1.selectedIndex];
}

regionArray = new Array();

function a(code,text){
	/*
	Creates a new select object for the lower drop down.  The "text" argument
	is optional	and allows initial values in the drop down such as "Please select
	a holiday area first" or "Please select a resort".  If "text" is unspecified
	no text is shown
	*/
	acode = code;	bcode = acode; ccode = bcode;	dcode = ccode;
	regionArray[regionArray.length] = new Select();
	currentRegion = regionArray[regionArray.length-1];
	if (text) currentRegion.addOption(text,"0","#000000");
}

function b(code,name){
	bcode = acode + "_" + code;	ccode = bcode; dcode = ccode;
	currentRegion.addOption(name,bcode,"#660000");
}

function c(code,name){
	ccode = bcode + "_" + code;	dcode = ccode;
	currentRegion.addOption("  "+name,ccode,"#006600");
}

function d(code,name){
	dcode = ccode + "_" + code;
	currentRegion.addOption("    "+name,dcode,"#000066");
}

function initialiseRegionSelect(select1,select2,initialValue){
	var currentSelect = regionArray[select1.selectedIndex];
	if(select2.selectedIndex){
		currentSelect.selectedIndex = select2.selectedIndex;
	}
	else if (initialValue){
		setSelectValue(currentSelect,initialValue);
	}
	Select.copy(currentSelect,select2);
}
