	/** Load new stylesheet onclick - Created by Jasper Smet/dotProjects <jasper.smet at dotprojects dot be>
	 *  
	 *  The REL element (can be defined) needs at least a sheet parameter, if 'replace' is not given it will
	 *  assume position 0 in the object/array.
	 *
	 * 	usage: <a href="#" class="loadStyle" rel="sheet: [path/to/style.css], replace: [0]">Switch style</a>
	 *	
	 *  - sheet: path of the stylesheet
	 *  - replace: [0] - number of the stylesheet to replace (must be an integer and the first one is always 0)
	 */
	 
	Event.observe(window, 'load', switchStyle, false);
	function switchStyle() {
		var valueElement = "rel";
		$$('a.loadStyle').each(function(a) {
			Event.observe(a, 'click', function(event) {
				if(a.hasAttribute(valueElement)) {
					var valueObj = new String('{'+ a.getAttribute(valueElement) +'}').replace(/(\[|])/g, '"').evalJSON();
					var replaceSheet = (valueObj.replace ? valueObj.replace : 0);
					if(typeof valueObj.sheet == 'undefined') return alert('switchStyle: no stylesheet defined'); false;
					var styleObj = $$('head link[type=text/css][rel=stylesheet]')[replaceSheet];
					if(typeof styleObj !== "undefined") {
						var oldSheet = styleObj.getAttribute('href');
						styleObj.setAttribute('href', valueObj.sheet);
						a.setAttribute(valueElement, 'sheet: ['+ oldSheet +'], replace: ['+ replaceSheet +']');
					}
					else return alert('switchStyle: stylesheet definition not found on this page'); false;
				}
				Event.stop(event);
			}, false);
		});
	}
