﻿/*
 *  Matthieu - octobre 2010
 */

var StyleSwitcher = {
	_tab_classes: ['red', 'orange', 'yellow', 'green', 'blue', 'pink'],

	_initButton: function(buttonID, className) {
		$(buttonID).click( function() {
			document.body.className = className;
			$.cookie('crush_theme_color', className);
			return false;
		});
	},

	init: function() {
		this._initButton('#red', 'red');
		this._initButton('#orange', 'orange');
		this._initButton('#yellow', 'yellow');
		this._initButton('#green', 'green');
		this._initButton('#blue', 'blue');
		this._initButton('#pink', 'pink');
		
		this.set($.cookie('crush_theme_color'));
	},
	
	set: function(className) {
		if (typeof(className) == 'undefined')
			return false;
		
		if ($.inArray(className, this._tab_classes)) {
			document.body.className = className;				  
			return true;
		}
		return false;
	}
}


var Crush = {
	init: function() {
		/* Add Rounded Corners For .box-es */
		$('.post').prepend("<span class='btl'><!-- --></span><span class='btr'><!-- --></span><span class='bbl'><!-- --></span><span class='bbr'><!-- --></span>");
	},

	initArchives: function() {
		$('.entry').addClass('stc-disp-none');
		$('.stc-show').addClass('stc-disp-block');
		return false;
	},

	hidePostsExcept: function(num) {
		$('.stc-show:not(#stc-show-'+num+')').hide('normal');
		$('.entry:not(#stc-entry-'+num+')').hide('normal');
		return false;
	},

	hidePost: function(num) {
		$('#stc-entry-'+num).hide();
		$('#stc-show-'+num).show('normal');
		return false;	
	},

	showPost: function(num) {
		$('#stc-show-'+num).hide();
		$('#stc-entry-'+num).show('normal');
		return false;		
	}
}



$(document).ready(function() {
	/* $('#menu a').prepend("<span><!-- --></span>"); */

	StyleSwitcher.init();
	Crush.init();

	/* preload images */
	img01 = new Image(); img01.src = img_dir + 'navbtnhover.jpg';
	img02 = new Image(); img02.src = img_dir + 'navbtnhover_orange.jpg';
	img03 = new Image(); img03.src = img_dir + 'navbtnhover_red.jpg';
	img04 = new Image(); img04.src = img_dir + 'navbtnhover_blue.jpg';
	img05 = new Image(); img05.src = img_dir + 'navbtnhover_green.jpg';

});



