/* =================================================================================
Title: styleswitch.js
Description: Adds switcher and functionality
Call: $('.styleswitchContainer').picShow({options});
Options:
	styles				- array of names of stylesheets, Ex: ['Style1', 'Style2']
	colorswatches	- locations of color swatch images, Ex: ['images/colorswatch1', ...]
Adapted from:
	By Kelvin Luck ( http://www.kelvinluck.com/ )
	Under an Attribution, Share Alike License
==================================================================================== */

(function($){$.fn.addStyleswitch=function(options){var defaultSettings={styles:[],colorswatches:[]},settings=$.extend({},defaultSettings,options),$container=this,ssHtml="",styleCookie=readCookie('style');if(styleCookie){switchStyle(styleCookie);}ssHtml='Style:\n';for(i=0;i<settings.styles.length;i++){ssHtml+='<a href="?style='+settings.styles[i]+'" rel="'+settings.styles[i]+'" class="styleswitch">';ssHtml+='<img src="'+settings.colorswatches[i]+'" alt="'+settings.styles[i]+'" align="top" /></a>\n';}ssHtml+=' |';$($container).prepend(ssHtml);$target=$('.styleswitch');$($target).click(function(){switchStyle(this.getAttribute("rel"));return false;});function switchStyle(styleName){$('link[@rel*=style][title]').each(function(i){if(this.getAttribute('title')==styleName){this.disabled=false;}else{this.disabled=true;}});createCookie('style',styleName,365);}}})(jQuery);function createCookie(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=/";}function readCookie(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;}function eraseCookie(name){createCookie(name,"",-1);}
