$(document).ready(function(){



	$('p.icon img').each(function (i) {
		$(this).parent().parent().addClass('with_photo');
	});

	$('#presentation p.visual1').parent().addClass('with_photo');

	//$('div.all_products ul.productsList ').jScrollPane();

	homeCarousel();

	$('#presentation ul.gallery li a').lightBox();

	$("ul.lvl_2 li:has(ul)").addClass("lvl_3");


	/* -- taburi pagina produs -- */
	var n = $('#sections_tabs ul li').length;
	$('#sections_tabs ul li').click(function(){
		$('#sections_tabs ul li').removeClass('selected');
		$('#sections_tabs ul li').removeClass('first');
		$('#page_sections div.section').removeClass('active');
		$(this).addClass('selected');

		for (var i = 0; i < n+1; i++) {
			if ($(this).hasClass('pos_'+i))
			{
					$('#page_sections div.pos_'+i).addClass('active');
					return false;
			}
		}
	});
	/* -- // taburi pagina produs -- */


	/* -- dictionar --*/
	$('#dictionar ul.pages li').click(function(){
		$('#dictionar ul li').removeClass('current_item');
		$(this).addClass('current_item');
		return false;
	});
	/* -- // dictionar --*/


	/* -- slideshow home -- */
	$('div.promo_rotate div.promo:first').css('display','block');
	/* -- // slideshow home -- */


	/* -- menuiu -- */
	$('#main_nav').hover(
		function () {
			$(this).addClass('inside_nav');
		}, 
		function () {
			$(this).removeClass('inside_nav');
			$('ul.menu li').removeClass('current');
		}
	);

	$('ul.menu li').hover(
		function () {
			$(this).addClass('current');
		}, 
		function () {
			$(this).removeClass('current');
		}
	);

	$('ul.lvl_2 li').hover(
		function () {
			if ($(this).hasClass('lvl_3'))
			{
				$(this).addClass('current_submenu');
			} else {
				$(this).addClass('current_no_child');
			}
		}, 
		function () {
			$(this).removeClass('current_no_child');
			$(this).removeClass('current_submenu');
		}
	);


	/* -- // menuiu -- */


	$('ul.video li').hover(
		function () {
			$(this).addClass('current');
		}, 
		function () {
			$(this).removeClass('current');
		}
	);


});


function addMenuClass(x) {
		y = x+1;
		$('ul.menu li').removeClass('current');
		$('ul.menu li.pos_'+y).addClass('current');
}



// Homepage rotating banners stuff (start)
function carouselClick(carousel) {
		$('.jcarousel-control a').bind('click', function() {
		carousel.scroll($.jcarousel.intval(jQuery(this).attr('title')));
		//$(this).addClass('active');
		return false;
	});
};

function itemVisibleIn(carousel, li, index, state)
{
	$('#crslIndex_'+index).addClass('active');
}

function itemVisibleOut(carousel, li, index, state)
{
	$('#crslIndex_'+index).removeClass('active');
}

function homeCarousel()
{
	$('#mycarousel').jcarousel({
		scroll: 1,
		auto: 20,
		animation: 350,
		wrap: 'both',
		buttonNextHTML: null,
		buttonPrevHTML: null,
		initCallback: carouselClick,
		itemVisibleInCallback: itemVisibleIn,
		itemVisibleOutCallback: itemVisibleOut
    });
}
// Homepage rotating banners stuff (end!)

