/**
 * Styleswitch stylesheet switcher built on jQuery
 * Under an Attribution, Share Alike License
 * By Kelvin Luck ( http://www.kelvinluck.com/ )
 * @notes  piPatched: all Cookie functions jQuerysed (C)pinuts.de
 */

(function($)
{

	// cookie functions http://www.quirksmode.org/js/cookies.html
	$.fn.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=/";
		
		//alert('Click-createCookie: '+name);

	}
	
	$.fn.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) {
					//alert('Click-readCookie: '+c.substring(nameEQ.length,c.length));
					return c.substring(nameEQ.length,c.length);
			}
		}

		return null;
	}
	
	$.fn.eraseCookie = function(name) {
		$(this).createCookie(name,"",-1);
		//alert('Click-eraseCookie');
	}

	$.fn.switchStylestyle = function(styleName){

		$('link[rel*=style][title]').each(function(i) 
		{
			this.disabled = true;
			if (this.getAttribute('title') == styleName) this.disabled = false;
		});
		$(this).createCookie('style', styleName, 365);
		
	}
	
})(jQuery);

