﻿/*
jQuery Style Switcher plugin.
	
Author: Rashed Alee (rashed@computan.com)
Website: http://www.computan.com/
	
Version: 1.0
Revision History:
* 2011-02-15: Version 1.0. Initial Release
*/

var defaultStyle = "/css/style.css";
var contrastStyle = "/css/style-contrast.css";
var grayStyle = "/css/style-gray.css";

if ($.cookie("css")) {
    $('link[rel="stylesheet"]').each(function() {
    if ($(this).attr('href') == defaultStyle || $(this).attr('href') == contrastStyle || $(this).attr('href') == grayStyle) {
            $(this).attr("href", $.cookie("css"));
        }
    });
}
$(document).ready(function() {
    $("#nav li a").click(function() {
        var stylepath = $(this).attr('rel');
        $('link[rel="stylesheet"]').each(function() {
        if ($(this).attr('href') == defaultStyle || $(this).attr('href') == contrastStyle || $(this).attr('href') == grayStyle) {
                $(this).attr("href", stylepath);
                $.cookie("css", stylepath, { expires: 365, path: '/' });
                return false;
            }
        });
    });
});
