<!--

// switchClassByID - Control CSS class with JS

this.concertinaSet_array = new Array();
this.concertinaSetActiveConcertina_array = new Array();

this.switchClassByID = function (id_str, class_str) {
	var a = document.getElementById(id_str);
	a.className = class_str;
}

this.getClassNameByID = function (id_str) {
	var a = document.getElementById(id_str);
	return a.className;
}


// concertina

this.activateConcertina = function (id_str) {
	//alert(id_str);
	if (id_str == null) {
		return false;
	}

	set_str = this.getConcertinaSetFromId(id_str);

	if (set_str != false) {

		//close the active concertina within this set
		var currentActiveConcertina_str = this.concertinaSetActiveConcertina_array[set_str];
		if (currentActiveConcertina_str != "") {
			if (currentActiveConcertina_str != id_str) {
				var class_str = this.getClassNameByID(currentActiveConcertina_str);
				if (class_str == "concertina_open") {
					this.activateConcertina(currentActiveConcertina_str);
				}
			}
		}

		var class_str = this.getClassNameByID(id_str);
		switch (class_str) {
			case "concertina_open":
				class_str = "concertina_closed";
				break;
			case "concertina_closed":
				class_str = "concertina_open";
				break;
		}

		this.switchClassByID(id_str, class_str);

		this.concertinaSetActiveConcertina_array[set_str] = id_str;

	//} else {
		//pick a random concertina to expose
	//	var randomConcertina_num = Math.floor(Math.random()*(this.concertinaSet_array[set_str].length-1));
	//	var randomConcertinaId_str = this.concertinaSet_array[set_str][randomConcertina_num]
	//	this.activateConcertina(randomConcertinaId_str);
	}
}

this.getConcertinaSetFromId = function(id_str) {
	for (var set in this.concertinaSet_array) {
		for (var id in this.concertinaSet_array[set]) {
			if (this.concertinaSet_array[set][id] == id_str) {
				return set;
			}
		}
	}
	return false;
}

this.initConcertina = function(id_str, set_str) {
	set_str = set_str==undefined ? "miscset" : set_str;
	if (this.concertinaSet_array[set_str] == null) {
		this.concertinaSet_array[set_str] = new Array();
		this.concertinaSetActiveConcertina_array[set_str] = new String();
	}

	//collect the concertina ids in an array (for error trapping in activateConcertina
	this.concertinaSet_array[set_str][id_str] = id_str;

	//set to closed
	activateConcertina(id_str);
}

//-->

