function findPos(oElement ) {
  if( typeof( oElement.offsetParent ) != 'undefined' ) {
    for( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ) {
      posX += oElement.offsetLeft;
      posY += oElement.offsetTop;
    }
    return [ posX, posY ];
  } else {
    return [ oElement.x, oElement.y ];
  }
}

$(function(){
	$('.header a:nth-child(2)').css('float', 'right');
	$('.header a:nth-child(1)').css('background-image', 'url(img/arrow3.gif)');
	$('.box:nth-child(3)').css('border', 'none');
	$('.sht').css('display', 'none');
	$('.tabela tr td:nth-child(2)').css('text-align', 'left');
	$('.tabela tr:odd').css('background', '#113249');
	$('#kp').click(function(){
		$('#copc').show('slow');						
	});
	$('#copc').mouseleave(function(){
			$('#copc').hide('slow');	
	});			
	$("#foto").jCarouselLite({
        btnNext: "#next1",
        btnPrev: "#prev1"
    });
	$("#video").jCarouselLite({
        btnNext: "#next2",
        btnPrev: "#prev2"
    });
	$('.galeria img').hover(function(){
			var id = $(this).attr('alt');
			$('#'+id+'').show('slow');
			if(screen.width <= 972){
			var howw=0;
			}else{
			var howw = screen.width - 972;
			var howw = howw/2;
			}
			var howw = findPos(this)[0] - howw;
			var howh = findPos(this)[1];
			
			$(id).css('left', howw+50);
			$(id).css('top', howh+100);
	});	
	$('.galeria img').mouseleave(function(){
			var id = $(this).attr('name');
			$(id).hide('slow');	
	});	
	
	$('.header a').click(function(){
				var co = $(this).parent('.header');
				var co2 = $(this).parents('.box');
				$('a', co).css('background-image', 'none');
				$(this).css('background-image', 'url(img/arrow3.gif)');
				//$('.op', co2).css('display', 'none');
				//$('.sht', co2).css('display', 'none');
				$('.op', co2).hide('slow');
				$('.sht', co2).hide('slow');
				var href =  $(this).attr('href');
				if(href == '#1'){$('.op', co2).show('slow');}
				else{$('.sht', co2).show('slow');}
	});	
});


sfHover = function() {
       var sfEls = document.getElementById("menu").getElementsByTagName("LI");
       for (var i=0; i<sfEls.length; i++) {
              sfEls[i].onmouseover=function() {
                     this.className+=" sfhover";
              }
              sfEls[i].onmouseout=function() {
                     this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
              }
       }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

