<!--

/*-----------------------
 CSS切り替え for JQuery
------------------------*/

function switch_css( object, target, switches, default_key ) {
	
	this.object = object;
	this.target = target;
	this.switches = switches;
	this.default_key = default_key;
	
	this.init =
	function() {
		
		var cookie = $.cookie( this.object );
		
		if ( $.cookie( this.object ) ) {
			$( this.target ).attr( 'href', this.switches[ $.cookie( this.object ) ].file );
		}
		else {
			$( this.target ).attr( 'href', this.switches[ default_key ].file );
		}
		
		for ( var key in this.switches ) {
			
			$( this.switches[ key ].btn ).bind( 'click',
			{
				'object': this.object,
				'target': this.target,
				'file': this.switches[ key ].file,
				'key': key
			},
			function ( e ) {
				$( e.data.target ).attr( 'href', e.data.file );
				$.cookie( e.data.object, e.data.key, { expires:30, path:'/' } );
				
				$(window).trigger('resize');
				
				return false;
			});
		}
		
		$(window).trigger('resize');
	};
	
	return this;
}


// CSS切り替え開始
$(function () {
	
	var switches =
	{
		'small':   { 'btn': '#sw_font_small',   'file': '/css/small.css'   },
		'default': { 'btn': '#sw_font_default', 'file': '/css/normal.css' },
		'large':   { 'btn': '#sw_font_large',   'file': '/css/large.css'   }
	};
	
	var sw_css = new switch_css( 'sw_css', '#switch_css', switches, 'default' );
	sw_css.init();
});

// -->
