SELECCIONCSS = {
	/* Se encarga de manejar la hoja de estilos que el usuario selecciona como predefinida */
	/* ----------------------------------------------------------------------------------- */

	fijaEstilo : function (iNumEstilo) {
		document.cookie = "estilo=" + iNumEstilo; /*  + ";path=/codigo" */
	//alert (sEstilo);
		SELECCIONCSS.cambiaEstilo (iNumEstilo);
		return false;
	},

	leeYFijaEstilo : function () {
		var iNumEstilo
		iNumEstilo = SELECCIONCSS.getCookie("estilo");
		if (iNumEstilo == "0" || iNumEstilo == "1") {
			SELECCIONCSS.cambiaEstilo (iNumEstilo);
		}

		// Si estan los botones de cambio de estilo les asignamos el evento
		var oBotonVerde = document.getElementById("estiloVerdeMaga");
		if (oBotonVerde != null)
			oBotonVerde.onclick = function (iNumEstilo){return SELECCIONCSS.fijaEstilo (0)};

		var oBotonRojo = document.getElementById("estiloRojoVino");
		if (oBotonRojo != null)
			oBotonRojo.onclick = function (iNumEstilo){return SELECCIONCSS.fijaEstilo (1)};


	//alert ("Estilo: " + iNumEstilo);

	},

	cambiaEstilo : function (iNumEstilo) {
		var i, a;
		var sTitle = ["Verde maga", "Rojo vino"];
		for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
	//alert ( a.getAttribute("title") + " vs " + title[iTam] + " resultado: " + (a.getAttribute("title") == title[iTam]) + " css: " +a.getAttribute("href"));
			a.disabled = true;
			if(a.getAttribute("title") == sTitle[iNumEstilo])
				a.disabled = false;
			}
		}

	},

	getCookie : function (name) {
	  var dc = document.cookie;
	  var prefix = name + "=";
	  var begin = dc.indexOf("; " + prefix);
	  if (begin == -1) {
	    begin = dc.indexOf(prefix);
	    if (begin != 0) return null;
	  } else
	    begin += 2;
	  var end = document.cookie.indexOf(";", begin);
	  if (end == -1)
	    end = dc.length;
	  return unescape(dc.substring(begin + prefix.length, end));
	}
}
if(document.getElementsByTagName) COMUN.addEvent(window, 'load', SELECCIONCSS.leeYFijaEstilo, false);
