jQuery.fn.styleSwitcher = function(){
	jQuery(this).click(function(){
		loadStyleSheet(this);
		return false;
	});
	function loadStyleSheet(obj) {
		jQuery('body').append('<div id="overlay" />');
		jQuery('body').css({height:'3000px'});
		jQuery('body').css({width:'100%'});
		jQuery('#principal')
			.css({
				display: 'none',
				position: 'absolute',
				top:0,
				left: 0,
				width: '100%',
				height: '100%',
				zIndex: 1000,
				background: 'black url(../img/loading.gif) no-repeat center'
			})
			.fadeIn(500,function(){
				jQuery.get( obj.href+'&js',function(data){
					jQuery('#stylesheet').attr('href','css/' + data + '.css');
					cssDummy.check(function(){
						jQuery('#overlay').fadeOut(500,function(){
							jQuery(this).remove();
						});	
					});
				});
			});
	}
	var cssDummy = {
		init: function(){
			jQuery('<div id="dummy-element" style="display:none" />').appendTo('body');
		},
		check: function(callback) {
			if (jQuery('#dummy-element').width()==2) callback();
			else setTimeout(function(){cssDummy.check(callback)}, 200);
		}
	}
	cssDummy.init();
}