var h = 1;
var minStep = 4;
var maxStep = 1;
var step = maxStep;
var speed = 15;
var movingBackward=true;

function moveContainer(cnt)
{
	var ic = document.getElementById(cnt);

	if(movingBackward == true)
	{
		
		if(h >= 0)
		{
			h = ic.offsetHeight/2*-1;
		}
	}
	else
	{
		if(h*-1 >= ic.offsetHeight/2)
		{
			h = 0;
		}
	}
	ic.style.bottom = h+'px';
	h+=step;
}
/*
var site_array = new Array();
site_array['O_nas'] = 'o_nas.html';
site_array['Oferta'] = 'oferta.html';
site_array['Realizacje'] = 'realizacje.html';
site_array['Kontakt'] = 'kontakt.html';
var globalAnchor = 'Oferta';
var thisUrl = document.location.toString();

if (thisUrl.match('#')) 
{
	var globalAnchor = thisUrl.split('#')[1];
	globalAnchor = globalAnchor.substr(1, globalAnchor.length);
	var myUrl = thisUrl.split('#')[0];
}

function gotoPage(elem)
{
	
	if(elem.substr(0,1) == '#')
	{
		elem = elem.substr(2, elem.length);
	}
	$('#content').load(site_array[elem], function(){
		if(elem == 'Oferta')
		{
			$('#list').accordion({ 
				header: 'div.title',  
				alwaysOpen: false, 
				animated: 'easeslide', 
				autoheight: false 
			});
		}
	});
			
}

function addEventListener()
{
	if (thisUrl.match('#')) 
	{
		var localAnchor = thisUrl.split('#')[1];
		localAnchor.substr(1, localAnchor.length);
		if(globalAnchor != localAnchor)
		{
			globalAnchor = localAnchor;
			
			gotoPage(globalAnchor);
			//$('#content').load(site_array[globalAnchor]);
		}
	}
}

$(document).ready(function() {
	
	
	$('.navi ul li').click(function(){
		//var elem = $(this).find('a').attr('href').substr(1, 20);
		//elem = elem.substr(1, elem.length);
		gotoPage($(this).find('a').attr('href'));
		void(0);
		
		$('.navi ul li').each(function(i){
			$(this).removeClass('selected');
		});
		
		$(this).addClass('selected');
		
	});
	
	$('.navi ul li').each(function(i){
			//alert($(this).find('a').attr('href'));
			if($(this).find('a').attr('href') == '#/'+globalAnchor)
				$(this).addClass('selected');
			else
				$(this).removeClass('selected');
	});
	
	gotoPage(globalAnchor);
	

});
*/

(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)


$(document).ready(function() {
	
	$('a.logoset').cluetip({
		tracking: true,
		dropShadow: false,
		topOffset: 5,
		leftOffset: 5
	});
	
	$('#center #down').mouseover(function() { movingBackward=false; step = minStep*-1; });
	$('#center #down').mouseout(function() { movingBackward=true; step = maxStep; });
	
	$('#center #up').mouseover(function() { step = minStep; });
	$('#center #up').mouseout(function() { step = maxStep; });
	
	$('#center #inner-container').mouseover(function() { step = 0; });
	$('#center #inner-container').mouseout(function() { step = maxStep; });
	
	$("#main").center();
	
	//jQuery.preLoadImages('img/left-navi-realizacje-over.jpg','img/left-navi-onas-over.jpg','img/left-navi-oferta-over.jpg','img/left-navi-kontakt-over.jpg');
	
});

$(document).ready(function(){
	$('#list').accordion({ 
		header: 'div.title',  
		alwaysOpen: false, 
		animated: 'easeslide', 
		autoheight: false 
	});
	$('a[rel=external]').click(function(){
		window.open(this.href);
	
		return false;
	});
	
	var oWidth = 160;//$('img.resize').width();
	var oHeight = 120;//$('img.resize').height();
	var mpx = 2.5;
	
	$('img.resize').hover(function(){
		czi = $(this).css('z-index');
		if($(this).hasClass('left'))
		{
			l = -120;
			t = -110;
		}
		else if($(this).hasClass('bottom'))
		{
			l = -120;
			t = -180;
		}
		else
		{
			l = -240;
			t = -100;
		}
   $(this)
     .stop()
		 .css({'z-index':'1000'})
     .animate({
          width: (oWidth * mpx) +'px',
          height: (oHeight * mpx) +'px',
					left: l+'px', 
					top: t+'px'
     },500);
	},
	function(){
   $(this)
      .stop()
			.css({'z-index':czi, 'width': oWidth +'px', 'height': oHeight +'px', 'left': '0px', 'top': '0px'})
      /*.animate({
            width: oWidth +'px',
            height: oHeight +'px',
						left: '0px', 
						top: '0px'
      },500);*/
	});

	
});

