var Utils = function () {}

Utils.prototype.getElement = function ( e, f ) {
	if ( document.layers ) {
		f = (f) ? f : self;
		
		if ( f.document.layers[e] ) {
			return f.document.layers[e];
		}

		for ( W = 0; i < f.document.layers.length; W++ ) {
			return(getElement(e,fdocument.layers[W]));
		}
	}
	
	if ( document.all ) {
		return document.all[e];
	}
	
	return document.getElementById(e);
}

Utils.prototype.openWin = function ( pagina, scroll, nomefinestra, width, height ) {
	var larghezza   = screen.width;
	var altezza     = screen.height;
	var spazio_oriz = (larghezza-width) / 2;
	var spazio_vert = (altezza-height) / 2;
	var parametri   = "resizable=yes,scrollbars="+scroll+",width="+width+",height="+height+",left="+spazio_oriz+",top="+spazio_vert;
	window.open(pagina, nomefinestra, parametri);
}

var Tabber = function ( langs ) {
	this.langs = langs;
	this.Utils = new Utils();
}

Tabber.prototype.setActiveClassName = function ( activeClassName ) {
	this.activeClassName = activeClassName;
}

Tabber.prototype.setInactiveClassName = function ( inactiveClassName ) {
	this.inactiveClassName = inactiveClassName;
}

Tabber.prototype.setTab = function ( tabListObjName, linkedObjPrefix, currentIndex ) {
	for ( var key in this.langs ) {
		if ( key == currentIndex ) {
			this.Utils.getElement(tabListObjName + key).className = this.activeClassName;
			this.Utils.getElement(linkedObjPrefix + key).style.display = 'block';
		}
		else {
			this.Utils.getElement(tabListObjName + key).className = this.inactiveClassName;
			this.Utils.getElement(linkedObjPrefix + key).style.display = 'none';
		}
	}
}

var ObjsTabber = function ( tabObjs ) {
	this.tabObjs = tabObjs;
	this.Utils = new Utils();
}

ObjsTabber.prototype.setActiveClassName = function ( activeClassName ) {
	this.activeClassName = activeClassName;
}

ObjsTabber.prototype.setToActiveObj = function ( activeObj ) {
	this.toActiveObj = activeObj;
}

ObjsTabber.prototype.setTab = function ( tabListObj ) {
	for ( var key in this.tabObjs ) {
		var tab = this.tabObjs[key];
		/*
		if ( tabListObj == tab['name'] ) {
			this.Utils.getElement(tab['name']).className = this.activeClassName;
			this.Utils.getElement(tab['linkedObj']).style.display = 'block';
			this.toActiveObj.value = tab['name'];
		} else {
			this.Utils.getElement(tab['name']).className = this.inactiveClassName;
			this.Utils.getElement(tab['linkedObj']).style.display = 'none';
		}
		*/
		if ( tabListObj == tab.name ) {
			this.Utils.getElement(tab.name).className = this.activeClassName;
			this.Utils.getElement(tab.linkedObj).style.display = 'block';

            if ( this.toActiveObj ) {
                this.toActiveObj.value = tab.name;
            }
		} else {
			this.Utils.getElement(tab.name).className = this.inactiveClassName;
			this.Utils.getElement(tab.linkedObj).style.display = 'none';
		}
	}
}



