function findPositionWithScrolling( oElement ) {
	
	function getNextAncestor( oElement ) {
		var actualStyle;
		
		if ( window.getComputedStyle )
			actualStyle = getComputedStyle(oElement,null).position;
		else if ( oElement.currentStyle )
			actualStyle = oElement.currentStyle.position;
		else
			//fallback for browsers with low support - only reliable for inline styles
			actualStyle = oElement.style.position;
		
		if ( actualStyle == 'absolute' || actualStyle == 'fixed' ) {
			//the offsetParent of a fixed position element is null so it will stop
			return oElement.offsetParent;
		}
		
		return oElement.parentNode;
	}
	
	if ( typeof( oElement.offsetParent ) != undefined ) {
		var originalElement = oElement;

		for ( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ) {
			posX += oElement.offsetLeft;
			posY += oElement.offsetTop;
		}
		
		if ( !originalElement.parentNode || !originalElement.style || typeof( originalElement.scrollTop ) == undefined ) {
			//older browsers cannot check element scrolling
			return [ posX, posY ];
		}
		
		oElement = getNextAncestor(originalElement);
		while ( oElement && oElement != document.body && oElement != document.documentElement ) {
			posX -= oElement.scrollLeft;
			posY -= oElement.scrollTop;
			
			oElement = getNextAncestor(oElement);
		}
		return [ posX, posY ];
	} else {
		return [ oElement.x, oElement.y ];
	}
}

$(document).ready(function(){
	// initialize
	$("a[rel*=lightbox]").lightBox(); // Select all links that contains lightbox in the attribute rel
	
	$(".menu-main-lang a img:even").css({'opacity' : '1.0'});
	$(".menu-main-lang a img:odd").css({'opacity' : '0.0'});
	
	$(".menu-main-lang-sk a img:even").css({'opacity' : '1.0'});
	$(".menu-main-lang-sk a img:odd").css({'opacity' : '0.0'});
	
	$(".menu-main-lang-en a img:even").css({'opacity' : '1.0'});
	$(".menu-main-lang-en a img:odd").css({'opacity' : '0.0'});

	$(".menu-main-showcase a img:even").css({'opacity' : '1.0'});
	$(".menu-main-showcase a img:odd").css({'opacity' : '0.0'});

	$(".menu-main-contact a img:even").css({'opacity' : '1.0'});
	$(".menu-main-contact a img:odd").css({'opacity' : '0.0'});
	
	$(".menu-main div a img:even").css({'opacity' : '1.0'});
	$(".menu-main div a img:odd").css({'opacity' : '0.0'});
	
	$(".item-inactive").css({'opacity' : '0.5'});
	$(".item-inactive .item-type img:even").css({'opacity' : '1.0'});
	$(".item-inactive .item-type img:odd").css({'opacity' : '0.0'});
	$(".item-inactive .item-description img:even").css({'opacity' : '1.0'});
	$(".item-inactive .item-description img:odd").css({'opacity' : '0.0'});
//	$(".item-inactive .item-technologies img:even").css({'opacity' : '1.0'});
//	$(".item-inactive .item-technologies img:odd").css({'opacity' : '0.0'});
	
	$(".menu-footer-sendmsg button img:even").css({'opacity' : '1.0'});
	$(".menu-footer-sendmsg button img:odd").css({'opacity' : '0.0'});
	
	$("div.item-thumbnails").hide();

	// main menu
	$(".menu-main div").mouseenter(function () {
		$('a img:eq(0)', this).animate({
			opacity:	"0.0"
		}, { queue: false, duration: 250 });
		$('a img:eq(1)', this).animate({
			opacity:	"1.0"
		}, { queue: false, duration: 250 });
	});
	
	$(".menu-main div").mouseleave(function () {
		$('a img:eq(0)', this).animate({
			opacity:	"1.0"
		}, { queue: false, duration: 250 });
		$('a img:eq(1)', this).animate({
			opacity:	"0.0"
		}, { queue: false, duration: 250 });
	});


	// language - name
/*	$(".menu-main-lang").mouseenter(function () {
		$('a img:eq(0)', this).animate({
			opacity:	"0.0"
		}, { queue: false, duration: 250 });
		$('a img:eq(1)', this).animate({
			opacity:	"1.0"
		}, { queue: false, duration: 250 });
	});
	
	$(".menu-main-lang").mouseleave(function () {
		$('a img:eq(0)', this).animate({
			opacity:	"1.0"
		}, { queue: false, duration: 250 });
		$('a img:eq(1)', this).animate({
			opacity:	"0.0"
		}, { queue: false, duration: 250 });
	});*/
	
	// language - sk
	$(".menu-main-lang-sk").mouseenter(function () {
		$('a img:eq(0)', this).animate({
			opacity:	"0.0"
		}, { queue: false, duration: 250 });
		$('a img:eq(1)', this).animate({
			opacity:	"1.0"
		}, { queue: false, duration: 250 });
	});
	
	$(".menu-main-lang-sk").mouseleave(function () {
		$('a img:eq(0)', this).animate({
			opacity:	"1.0"
		}, { queue: false, duration: 250 });
		$('a img:eq(1)', this).animate({
			opacity:	"0.0"
		}, { queue: false, duration: 250 });
	});
	
	// language - en
	$(".menu-main-lang-en").mouseenter(function () {
		$('a img:eq(0)', this).animate({
			opacity:	"0.0"
		}, { queue: false, duration: 250 });
		$('a img:eq(1)', this).animate({
			opacity:	"1.0"
		}, { queue: false, duration: 250 });
	});
	
	$(".menu-main-lang-en").mouseleave(function () {
		$('a img:eq(0)', this).animate({
			opacity:	"1.0"
		}, { queue: false, duration: 250 });
		$('a img:eq(1)', this).animate({
			opacity:	"0.0"
		}, { queue: false, duration: 250 });
	});	
	
	// showcase
	$(".menu-main-showcase").mouseenter(function () {
		$('a img:eq(0)', this).animate({
			opacity:	"0.0"
		}, { queue: false, duration: 250 });
		$('a img:eq(1)', this).animate({
			opacity:	"1.0"
		}, { queue: false, duration: 250 });
	});
	
	$(".menu-main-showcase").mouseleave(function () {
		$('a img:eq(0)', this).animate({
			opacity:	"1.0"
		}, { queue: false, duration: 250 });
		$('a img:eq(1)', this).animate({
			opacity:	"0.0"
		}, { queue: false, duration: 250 });
	});
	
	// contact
	$(".menu-main-contact").mouseenter(function () {
		$('a img:eq(0)', this).animate({
			opacity:	"0.0"
		}, { queue: false, duration: 250 });
		$('a img:eq(1)', this).animate({
			opacity:	"1.0"
		}, { queue: false, duration: 250 });
	});
	
	$(".menu-main-contact").mouseleave(function () {
		$('a img:eq(0)', this).animate({
			opacity:	"1.0"
		}, { queue: false, duration: 250 });
		$('a img:eq(1)', this).animate({
			opacity:	"0.0"
		}, { queue: false, duration: 250 });
	});
	
	// items
	$(".item-inactive").mouseenter(function () {
		$(this).animate({
			opacity:	"1.0"
		}, { queue: false, duration: 500 });
		
		if (this.children.length > 3)
		{
			$(this).animate({
				height: "310px"
			}, { queue: false, duration: 500 });
			
			$("div.item-thumbnails", this).show();
			$('div.item-thumbnails', this).animate({
				opacity:	"1.0"
			}, { queue: false, duration: 500 });
		}
		
		$('.item-type img:eq(1)', this).animate({
			opacity:	"1.0"
		}, { queue: false, duration: 500 });
		$('.item-description img:eq(1)', this).animate({
			opacity:	"1.0"
		}, { queue: false, duration: 500 });
/*		$('.item-technologies img:eq(1)', this).animate({
			opacity:	"1.0"
		}, { queue: false, duration: 500 });*/
		
  		$(this).css({
			'background-color' : '#000',
			'border' : '1px solid #333',
			'padding-top' : '9px',
			'padding-bottom' : '10px',
			'padding-left' : '14px',
			'padding-right' : '14px',
			'margin-bottom' : '0'
		});
	});

	$(".item-inactive").mouseleave(function () {
		$(this).animate({
			opacity:	"0.5",
			height:	"200px"
		}, { queue: false, duration: 500 });
		
		$('.item-type img:eq(1)', this).animate({
			opacity:	"0.0"
		}, { queue: false, duration: 500 });
		$('.item-description img:eq(1)', this).animate({
			opacity:	"0.0"
		}, { queue: false, duration: 500 });
/*		$('.item-technologies img:eq(1)', this).animate({
			opacity:	"0.0"
		}, { queue: false, duration: 500 });*/
		
		$('div.item-thumbnails', this).animate({
			opacity:	"0.0"
		}, { queue: false, duration: 500 });
		
		$(this).css({
			'background-color' : 'transparent',
			'border' : 'none',
			'padding-top' : '10px',
			'padding-bottom' : '10px',
			'padding-left' : '15px',
			'padding-right' : '15px',
			'margin-bottom' : '1px'		
		});
	});
	
	// item scrolling
	//Get our elements for faster access and set overlay width
	var div = $('div.item-thumbnails');
		 // unordered list's left margin
//		 ulPadding = 15;
	
	//Remove scrollbars
	//div.css({overflow: 'hidden'});
	
	//When user move mouse over menu
/*	div.mouseenter(function(e) {
		var ul = $('ul.item-thumbnails', this);
		var ulObject = document.getElementById(ul.attr("id"));
		var ulPos = findPositionWithScrolling(ulObject)
		
		var spanObject = document.getElementById("span_" + ul.attr("id"));
		
		var mouseXPos = e.pageX - ulPos[0];	// x-coord of mouse relative to wrapslide
//		spanObject.innerHTML = mouseXPos + "";
//		alert(mouseXPos); 1690   2413
		
		//Get menu width
		var divWidth = $(this).width();
//		spanObject.innerHTML = divWidth + "";
//		alert(divWidth);
		
		//Find last image container
		var lastLi = $('li', ul); //ul.find('li');
//		spanObject.innerHTML = lastLi.attr("id") + "";
	
		//As images are loaded ul width increases,
		//so we recalculate it each time
		var ulWidth = ul.width();
//		spanObject.innerHTML = ul.width() + "";
//		var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth();
		
		var left = (e.pageX - $(this).offset().left) * (ulWidth-divWidth) / divWidth;
		spanObject.innerHTML = left + "";
		
/*		setInterval(function() {
//			div.scrollLeft(div.left-200);
			div.left -= 20;
			alert("aa");
		}, 2000);* /
		div.scrollLeft(div.left-200);
	});*/
	
	// send message
	$(".menu-footer-sendmsg").mouseenter(function () {
		$('button img:eq(0)', this).animate({
			opacity:	"0.0"
		}, { queue: false, duration: 250 });
		$('button img:eq(1)', this).animate({
			opacity:	"1.0"
		}, { queue: false, duration: 250 });
	});
	
	$(".menu-footer-sendmsg").mouseleave(function () {
		$('button img:eq(0)', this).animate({
			opacity:	"1.0"
		}, { queue: false, duration: 250 });
		$('button img:eq(1)', this).animate({
			opacity:	"0.0"
		}, { queue: false, duration: 250 });
	});
	
});

