﻿// base.js



if(typeof jQuery != 'undefined') {
	
	$(document).ready(function() {
		//$('#mainmenu').prepend('<li class="name"></li>');
		
		var image;
		
		// put active link image to placeholder
		$('#mainmenu li a.active, #mainmenu li a.crumb').each(function() {
			$(this).parent().parent().find('> li.name').prepend(
				$(this).find('img').clone()
			);
		});
		
		$('#mainmenu li a').hover(function() {
			// save actual image
			image = $(this).parent().parent().find('> li.name img').clone();
			
			// clear image placeholder
			$(this).parent().parent().find('> li.name').html('');
			
			// attach new image to placeholder
			$(this).parent().parent().find('> li.name').prepend(
				$(this).find('img').clone()
			);
			
		}, function() {
			//alert('out');
			if(image) {
				$(this).parent().parent().find('> li.name').html('').prepend(image);
			} else {
				$(this).parent().parent().find('> li.name').html('');
			}
			
		});
		
		soundManager.onload = function() {
			soundManager.createSound('click', 'fileadmin/web/sounds/cordless-xrikazen-7428_hifi.mp3');
		}
		
		$("#mainmenu li a").bind('mouseover', function() {
			soundManager.play('click');
		});
	});
}
