var Idontsmoke={};
Idontsmoke.StyleSwitcher={
  setActiveStyleSheet:function(title) {
    var a;
	for (var i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
		if (a.getAttribute("rel") && a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
			a.disabled = true;
			if (a.getAttribute("title") == title) a.disabled = false;
		}
	}
	if (Idontsmoke.StyleSwitcher.getActiveStyleSheet() == null) {
		title = Idontsmoke.StyleSwitcher.getPreferredStyleSheet();
		if (title != null) Idontsmoke.StyleSwitcher.setActiveStyleSheet(title, true);
	}
	Idontsmoke.StyleSwitcher.createCookie("style",title, 365);
  },
  getActiveStyleSheet:function() {
	var a;
	for (var i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
		if (a.getAttribute("rel") && a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
	}
	return null;
  },
  getPreferredStyleSheet:function() {
	var a;
	for (var i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
		if (a.getAttribute("rel") && a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("rel").indexOf("alt") == -1 && a.getAttribute("title")) return a.getAttribute("title");
	}
	return null;
  },
  createCookie:function(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	} else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
  },
  readCookie:function(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
  },
  start:function(e) {
	var cookie = Idontsmoke.StyleSwitcher.readCookie("style");
	var title = cookie ? cookie : Idontsmoke.StyleSwitcher.getPreferredStyleSheet();
	Idontsmoke.StyleSwitcher.setActiveStyleSheet(title);
  },
  end:function(e) {
	var title = Idontsmoke.StyleSwitcher.getActiveStyleSheet();
	Idontsmoke.StyleSwitcher.createCookie("style", title, 365);
  }
}

//Habrá que adaptarlo cuando se utilice
//que no voy a dejar estos 2 fragmentos de codigo así
if (window.addEventListener) {
	window.addEventListener("load", Idontsmoke.StyleSwitcher.start, true);
	window.addEventListener("unload", Idontsmoke.StyleSwitcher.end, true);
} else if (window.attachEvent) {
	window.attachEvent("onload", Idontsmoke.StyleSwitcher.start);
	window.attachEvent("onunload", Idontsmoke.StyleSwitcher.end);
}

if (document.getElementsByTagName) {
	var cookie = Idontsmoke.StyleSwitcher.readCookie("style");
	var title = cookie ? cookie : Idontsmoke.StyleSwitcher.getPreferredStyleSheet();
	Idontsmoke.StyleSwitcher.setActiveStyleSheet(title);
}

if(document.getElementById)
{
    sty_str = '<style type="text/css"> div#selector ul{-moz-opacity: 0.6; filter:alpha(opacity=60%); opacity=0.6;} </style>';
    document.write(sty_str);
}
