// div swithcer
var DivSwitcher = Class.create();

DivSwitcher.prototype = {

	initialize: function(current, suffix, css, selectedCSS) {
		this.current = current || "";
		this.suffix = suffix || "_tab";
		this.css = css || "tab";
		this.selectedCSS = selectedCSS || "tab_active";
	},
	
	
	setCurrent: function(id) {
		this.pageSwitch(id);
		this.current = id;
	},

	pageSwitch: function(id){
		if (id) {
			var elem = $(id);
			var elemTab = $(id + this.suffix);
			var cElem = $(this.current);
			var cElemTab = $(this.current + this.suffix);
	
			// hide currently selected tab and show new tab
			if (cElem) {
				cElem.hide();
				if (cElemTab) {
					cElemTab.className = this.css;
				}
			}
	
			// show the new item
			if (elem) {
				elem.show();
				if (elemTab) {
					elemTab.className = this.selectedCSS;
				}		
			}
		} else {
			alert("Error")
		}
	}
	
	/*,
	showOneOfGroup: function(group, id) {
		if (group instanceof Array) {
			for (var i=0; i < group.length; i++) {
				var e = $(group[i]);
				if (e && Element.visible(e)) {
					e.hide();
				}
			}
		} else {
			alert('not array');
		}
		var show = $(id);
		show.show();
	}
	*/
}
	
function joSwapClass(id, a, b) {
	if (id) {
		var elem = $(id);
		if (elem) {
			if (elem.className != a) {
				elem.className = a;
			} else {
				elem.className = b;
			}
		}
	} else {
		//alert ("Error")
	}
}


