jQuery(document).ready(function(){
	/* Hover Effekt für das Menu erstellen*/
	jQuery('#menu-accordion li').not(jQuery('.third-layer, .active-second-layer, .active-third-layer')).hover(function(){
		var liHeight = jQuery(this).height();
		var liWidth = jQuery(this).width();
		var bgPosX = 0;
		var bgPosY = 0;
		
		if (liWidth == 144) bgPosX = -169;
		if (liHeight == 22) bgPosY = -27;
		if (liHeight == 33) bgPosY = -65;
		
		jQuery(this).css({
			'background-image' : 'url(/skin/frontend/default/fotoquip/images/hover-active-background.gif)',
			'background-repeat' : 'no-repeat',
			'background-position' : bgPosX+'px '+bgPosY+'px'
		});
	},function(){
		jQuery(this).css({
			'background-image' : 'none'
		});
	});
	/* Hintergrund für Aktive Kategorien der ebene 2 und 3 erstellen*/
	var secondActive = jQuery('#menu-accordion li.active-second-layer');
	var thirdActive = jQuery('#menu-accordion li.active-third-layer');
	var seActLiHeight = secondActive.height();
	var seActLiWidth = secondActive.width();
	var thActLiHeight = thirdActive.height();
	var thActLiWidth = thirdActive.width();
	
	var seBgPosX = 0;
	var seBgPosY = 0;
	var thBgPosX = 0;
	var thBgPosY = 0;
	
	if (seActLiWidth == 144) seBgPosX = -169;
	if (seActLiHeight == 33) seBgPosY = -65;
	if (seActLiHeight == 22) seBgPosY = -27;
	
	if (thActLiWidth == 144) thBgPosX = -169;
	if (thActLiHeight == 22) thBgPosY = -27;
	if (thActLiHeight == 33) thBgPosY = -65;
	
	jQuery(secondActive).css({
		'background-image' : 'url(/skin/frontend/default/fotoquip/images/hover-active-background.gif)',
		'background-repeat' : 'no-repeat',
		'background-position' : seBgPosX+'px '+seBgPosY+'px'
	});
	
	jQuery(thirdActive).css({
		'background-image' : 'url(/skin/frontend/default/fotoquip/images/hover-active-background.gif)',
		'background-repeat' : 'no-repeat',
		'background-position' : thBgPosX+'px '+thBgPosY+'px'
	});
	/* Accordion Effekt für Menu Einstellen*/
	/* Den Offenen Start Eintrag Festlegen */
	if(jQuery('#menu-accordion div.active').length == 0) {
		jQuery('#menu-accordion div.head:eq(0)')
			.addClass('active')
			.siblings('ol:eq(0)')
			.addClass('active');
	}
	
	jQuery('#menu-accordion div.head')
		.siblings('ol')
		.not(jQuery('.active'))
		.slideUp('fast');
	
	var isSliding = false;
	
	jQuery('#menu-accordion div.head').mousemove(function(){
		if(!isSliding){
			if(jQuery(this).hasClass('active')){
			}
			else{
				if(jQuery(this).next('ol').length != 0){
					isSliding = true;
					var actualDiv = this;
					jQuery('#menu-accordion ol.active').slideUp(1000)
						.removeClass('active').siblings('div.active').removeClass('active');
						//console.log(actualDiv);
					jQuery(actualDiv).toggleClass('active').next('ol').slideToggle(1000,function(){
						isSliding = false;	
					}).addClass('active');
				}
			}
		}
	});
});
