(function($){
  $.fn.StyleSwichter = function(options){

  	var opts = $.extend({}, $.fn.StyleSwichter.defaults, options);
	var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
	    
  	
  	if ( $.browser.msie && $.browser.version < 7 ){
  		if(escape($.cookie('fontstyle')) != o.cssPath && o.cssPath !='' ){
  			  $.cookie(o.cookieName,o.cssPath,{
	            path: o.cookiePath,
	            expires: o.cookieDays,
	            domain: o.cookieDomain,
	            secure: o.cookieSecure
	          });
	          //window.location.replace(window.location.href);
  		}
 	}else{
	    $('link').each(function(i){
	      if(this.rel == 'stylesheet' && this.title == o.linkTitle){
	        if(o.cssPath != ''){
	          this.href = o.cssPath;
	          $.cookie(o.cookieName,this.href,{
	            path: o.cookiePath,
	            expires: o.cookieDays,
	            domain: o.cookieDomain,
	            secure: o.cookieSecure
	          });
	        }else if($.cookie(o.cookieName)){
	          this.href = $.cookie(o.cookieName);
	        }
	        return true;
	      }
	    });
  	}
    return false;
  };
  $.fn.StyleSwichter.defaults={
    cssPath: '',
    cookieDays: 30,
    cookiePath: '/',
    cookieDomain: '',
    cookieSecure: false,
    linkTitle: 'styleswichter',
    cookieName: 'fontstyle'
  }; 
})(jQuery);
