// Fading Divs

jQuery.noConflict();
jQuery(document).ready(function () {
  // find the div.fade elements and hook the hover event
  jQuery('div.fade').hover(function() {
    // on hovering over, find the element we want to fade *up*
    var fade = jQuery('> div', this);
    
    // if the element is currently being animated (to a fadeOut)...
    if (fade.is(':animated')) {
      // ...take it's current opacity back up to 1
      fade.stop().fadeTo(400, 1);
    } else {
      // fade in quickly
      fade.fadeIn(400);
    }
  }, function () {
    // on hovering out, fade the element out
    var fade = jQuery('> div', this);
    if (fade.is(':animated')) {
      fade.stop().fadeTo(400, 0);
    } else {
      // fade away slowly
      fade.fadeOut(400);
    }
  });
});


// jQuery Collapsible Sidebar

/**
* Original Script by Joshee (http://josh-r.net/), Modifed by Jessie S. (http://dynaxel.com)
**/

jQuery(function(jQuery) {
    jQuery(".toggle_clicked").hide();
    jQuery(".toggle").click(function() {
        jQuery("#sidebar").stop(true, true).animate({height: "hide", opacity: 0}, 400,
            function() {
                jQuery("#content").stop(true, true).animate({width: "100%"}, 200);
            });
        jQuery(this).hide();
        jQuery(".toggle_clicked").show();
        jQuery.cookie("sidebar","collapsed", {expires: 365});
        return false;
    });
    jQuery(".toggle_clicked").click(function() {
        jQuery("#content").stop(true, true).animate({paddingright: "200px"}, 200,
            function() {
                jQuery("#sidebar").stop(true, true).animate({height: "show", opacity: 1}, 600);
            });
        jQuery(this).hide();
        jQuery(".toggle").show();
        jQuery.cookie("sidebar","expanded", {expires: 365});
        return false;
    });
    if(jQuery.cookie("sidebar") == "collapsed") {
        jQuery(".toggle").hide();
        jQuery(".toggle_clicked").show();
        jQuery("#content").css("width","100%");
        jQuery("#sidebar").hide();
    };
});




// jQuery Style Switcher

/**
* By Kelvin Luck ( http://kelvinluck.com)
**/

(function(jQuery)
{
	jQuery(document).ready(function() {
		jQuery('.styleswitch').click(function()
		{
			switchStylestyle(this.getAttribute("rel"));
			return false;
		});
		var c = readCookie('style');
		if (c) switchStylestyle(c);
	});

	function switchStylestyle(styleName)
	{
		jQuery('link[rel*=style][title]').each(function(i) 
		{
			this.disabled = true;
			if (this.getAttribute('title') == styleName) this.disabled = false;
		});
		createCookie('style', styleName, 365);
	}
})(jQuery);

function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name)
{
	createCookie(name,"",-1);
}





jQuery(function(jQuery) {
    jQuery(".increase").hide();
    jQuery(".decrease").click(function() {
        jQuery(".navigation").stop(true, true).animate({fontSize: "12px"}, 200,
            function() {});
        jQuery(this).hide();
        jQuery(".increase").show();
        jQuery.cookie("navigation","smalltext", {expires: 365});
        return false;
    });
    jQuery(".increase").click(function() {
        jQuery(".navigation").stop(true, true).animate({fontSize: "16px"}, 200,
            function() {});
        jQuery(this).hide();
        jQuery(".decrease").show();
        jQuery.cookie("navigation","largetext", {expires: 365});
        return false;
    });
    if(jQuery.cookie("navigation") == "smalltext") {
        jQuery(".decrease").hide();
        jQuery(".increase").show();
        jQuery(".navigation").css("fontSize","12px");
    };
});



