/*

http://www.selfcontained.us/2008/03/08/simple-jquery-image-rollover-script/

*/

$(function() {
    $('.rollover').hover(function() {
        var currentImg = $(this).attr('src');
        $(this).attr('src', $(this).attr('hover'));
        $(this).attr('hover', currentImg);
    }, function() {
        var currentImg = $(this).attr('src');
        $(this).attr('src', $(this).attr('hover'));
        $(this).attr('hover', currentImg);
    });
});


/* Menu functionality based on code from Marco van Hylckama Vlieg with note allowing for commercial use as listed on: http://www.i-marco.nl/weblog/archive/2008/05/08/simple_jquery_accordion_menu__

--------

This code snippet is free for NON-COMMERCIAL use. 
Feel free to adapt / improve it as well.

Copyright 2007 by Marco van Hylckama Vlieg

http://www.i-marco.nl/weblog/
marco@i-marco.nl
*/

function initMenus() {
	$('ul.menu ul').hide();

	$.each($('ul.menu'), function(){
		var cookie = $.cookie(this.id);
//		if(cookie === null || String(cookie).length < 1) {
//			$('#' + this.id + '.expandfirst ul:first').show();
//		}
//		else {
			$('#' + this.id + ' .' + cookie).next().show();
//	}
});


$('ul.menu li a').click(
	function() {
		var checkElement = $(this).next();
		var parent = this.parentNode.parentNode.id;
  
		if((String(parent).length > 0) && (String(this.className).length > 0)) {
			if($(this).next().is(':visible')) {
				$.cookie(parent, null);
			}
			else {
				$.cookie(parent, this.className);
			}
			$(this).next().slideToggle('normal');
		}

		if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
			if($('#' + parent).hasClass('collapsible')) {
				$('#' + parent + ' ul:visible').slideUp('normal');
			}
			return false;
		}

		if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
			$('#' + parent + ' ul:visible').slideUp('normal');
			if((String(parent).length > 0) && (String(this.className).length > 0)) {
				$.cookie(parent, this.className);
			}

			checkElement.slideDown('normal');
			return false;
		}
	});
}

$(document).ready(function() {initMenus();});
