
function getElementPosition(elem) {
    var w = elem.offsetWidth;
    var h = elem.offsetHeight;

    var l = 0;
    var t = 0;

    while (elem) {
        l += elem.offsetLeft;
        t += elem.offsetTop;
        elem = elem.offsetParent;
    }

    return { "left": l, "top": t, "width": w, "height": h };
}



window.onload = function()
{
	$('#gallery .next').trigger('click');
};


$(document).ready(function() {	$('#menu a').each(function(){		$(this).addClass('colorlinks-' + $(this).attr('href').split('/')[1]);	});

			$('.liquid').liquidcarousel({height:200, duration:100, hidearrows:false});


			$('#menu ul li:not(".active")').hover(
				function(){
					$(this).css({'background': 'url(/images/menu-hat.gif) no-repeat 50% 0px'});
				},
				function(){
					$(this).css({'background': 'none'});
				}
			);



			$('.tooltip').hover(
				function(){
					e = $('img', $(this));
					d = $('#tooltip');


					d.html($(this).attr('tooltip').split('[').join('<').split(']').join('>'));


					d.css({'top': e.position().top + e.height() + 'px', 'left' : e.position().left - parseInt(d.width()/2) + parseInt(e.width()/2) + 55 + 'px'});


					d.show();

				},

				function(){
					d = $('#tooltip');
					d.hide();
				}

			);

            var galleryImagesCnt = document.getElementById('gallery').getElementsByTagName('img').length - 2;
            var currentImage  = 0;
            var to = null;

			$('#gallery .next').bind('click', function(){

				window.clearTimeout(to);

				currentImage++;

				if (currentImage > galleryImagesCnt)
					currentImage = 1;

				$('#gallery .pic').hide();
				$('#gallery .p' + currentImage).fadeIn();

				to = window.setTimeout("$('#gallery .next').trigger('click');", 20000);

			});

			$('#gallery .prev').bind('click', function(){
				currentImage--;

				if (currentImage < 1)
					currentImage = galleryImagesCnt;

				$('#gallery .pic').hide();
				$('#gallery .p' + currentImage).fadeIn();
			});






});


