//
// Menu.js - 'Scriptlets' 
//
// $Id: menu.js 1.7 2004/03/01 11:20:14 jordinas Exp $
//
// Joan Ordinas - <jordinas@EscolaDelTreball.ORG>
//

// Menu - Gestión de menus desplegables
function Menu(sSelector, aOptions) {
    document.write('<select class="menu2D" onchange="Menu_replace(this);" id="menu2D" name="menu2D">');
	document.write('<option value="?" selected="selected">'+sSelector+'</option>\n');
	for (var i = 0; i < aOptions.length; i += 2) {
		document.write('<option value="'+aOptions[i+1]+'">'+aOptions[i]+'</option>');
	}
    document.write('</select>');
}

function Menu_replace(oSelect) {
	if (oSelect.selectedIndex > 0)  {
    	var sURL = oSelect.options[oSelect.selectedIndex].value;
    	oSelect.selectedIndex = 0;
    	oSelect.blur();
    	top.location.href = sURL;
  	}
}

// HotImage - Gestión de imágenes clicables
function HotImage(sName, sOffURL, sOnURL, sAlt) {
	this.sName = sName;
	this.oOn = new Image();
	this.oOff = new Image();
	this.oOn.src = sOnURL;
	this.oOff.src = sOffURL;
	this.sText = sAlt;
	HotImage[sName] = this;
}

HotImage.prototype.focus = function () {
	document.images[this.sName].src = this.oOn.src;
	window.status = this.sText;
	return true;
}

HotImage.prototype.blur = function () {
	document.images[this.sName].src = this.oOff.src;
	window.status = g_msg_status;
	return true;
}

// Muestra la fecha
function dateStamp() {
	var oNow = new Date();
	var nMonth = oNow.getMonth();
	++nMonth;
	var nDay = oNow.getDate();
	var nYear = oNow.getFullYear();
	document.write(nDay, "/", nMonth, "/", nYear);
}

// Muestra la fecha del documento
function lastModified() {
	var oDate = new Date(Date.parse(document.lastModified));
	var nMonth = oDate.getMonth();
	++nMonth;
	var nDay = oDate.getDate();
	var nYear = oDate.getFullYear();
	document.write(nDay, "/", nMonth, "/", nYear);
}

// Netscape & Mozilla sidebar
function mozsidebar() {
	if ((typeof window.sidebar == "object")
		&& (typeof window.sidebar.addPanel == "function"))
	{
		window.sidebar.addPanel(
			"Escola del Treball",
			"http://www.escoladeltreball.org/"+State.Profile.language+"/sidebar.htm",
			"");
	}
} 


