/****************************************
*
Bosch Powertools Landingpage
Kittelberger media solutions GmbH | 2011-08 
*
*****************************************/

/* START Accordion */
$(document).ready(function(){
	/*
	$("#accordion li.root").hover(function(){
		$('.ctryLayer').removeClass('visible');
		$('#accordion li.root').animate({width: "114px"}, {duration:300, queue:false});
		$(this).animate({width: '486px'}, {duration:300, queue:false});
		$(this).find ('.ctryLayer').addClass('visible');
	});
	*/
	
	$("#accordion li.root").bind('mouseenter', function(){
		$('#accordion li.root h6').css({'height': '19px'});
		$(this).css('cursor', 'pointer');
		$(this).find('h6').animate({height: '50px'}, {duration:200, queue:false});
	});
	$("#accordion li.root").bind('mouseleave', function(){
		$('#accordion li.root h6').animate({height: '19px'}, {duration:100, queue:false});
		$('#accordion li.root').css('cursor', 'default');
	});
	$("#accordion li.root").bind('click', function(){
		$('.ctryLayer').removeClass('visible');
		$('#accordion li.root').animate({width: "114px"}, {duration:300, queue:false});
		$(this).animate({width: '486px'}, {duration:300, queue:false});
		$(this).find ('.ctryLayer').addClass('visible');
	});
	$("#accordion").bind('mouseleave', function(){
		$('.ctryLayer').removeClass('visible');
		$('#accordion li.root').animate({width: "188px"}, {duration:300, queue:false});
	});
 
});
/* END Accordion */
		
/* START: Country hover */
$(window).load (function () {

	$('.ctryLayer.countrySel ul > li').bind ('click', function () {
		$('.ctryLayer.countrySel ul > li').removeClass('hover');
		$(this).addClass('hover');					
		var ctryLayerHeight = $(this).closest('.ctryLayer.countrySel').height();
		// has submenu
		if ($(this).find('ul').length > 0) {
			var curUl = $(this).find('ul');
			var curTop = $(this).position().top;
			
			if ((curTop+curUl.height()) >= ctryLayerHeight) {
				curUl.css ('margin-top', (ctryLayerHeight -(curTop+curUl.height() )) + 'px' );
			};
		};					
	});

	$('.ctryLayer.countrySel ul > li').bind ('mouseleave', function () {
		$(this).removeClass('hover');
	});
});
/* END: Country hover */
		
