
/* 
/*	The following code is being included only to make special features work in the online demo. 
/*	This includes things like the skin changer and other not theme related items. You do not 
/*	need to have this file in your production website.
*/


/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};


//
// Load after the page is completed
// --------------------------------

$(document).ready(function() {
	// initialize skin changer
	$('#theme-changer').cycle({ 
		fx: 'scrollHorz',
		easing: 'easeOutCubic',
		speed:  'slow', 
		timeout: 0, 
		cleartypeNoBg: true,
		next:   '#theme-next', 
		prev:   '#theme-prev',
		before:   skinPreviewUpdate 
		
	});
	function skinPreviewUpdate() { 
		$('#theme-title').attr('title',this.alt); 
	}
	var skin = $.cookie("skin");
	if (skin == "" || skin === null) skin="mirage";
	switchSkin(skin);
	
	// stops demo links using # (as placeholders) from jumping to top
	$("a[href='#']").click( function(){
		return false;
	});
	
	//slide show button
	$('.rounded').css({
		'-moz-border-radius': '3px',
		'-webkit-border-radius': '3px',
		'border-radius': '3px'
	});
	$('.slide-sample-button').css({
		'opacity': '.75',
		'filter': 'alpha(opacity=75)'
	});
});


//
// Skin changing functions
// -----------------------

// skin names for adding and removing
skinList = ["blue", "green", "orange", "purple", "red", "teal", "chocolate", "mirage"]
// real-time skin changing
function switchSkin(skin) {
	$(skinList).each(function (i,style) {
		$('body').removeClass(style);
	});
	$('body').addClass(skin);
	$.cookie("skin", skin);
}


