

$(document).ready(function()
	{
	
	//slideshow
	setInterval( "slideSwitch()", 5000 );
	 
	/**
	 * Złap linki ajaxowe
	 */
	$('.ajaxLink').click(function(){
	
		var href = $(this).attr('href');
		//$(this).append('<img src="/images/small-load.gif" />');
		obj = $(this)
		$(this).addClass('small-load');
		$.getScript(href, function(){
				 // alert("Script loaded and executed.");
				  obj.removeClass('small-load');
		});
		return false;
	});
	
		//this is the floating content
	var $floatingbox = $('#floating-box');
 
	if($('#body').length > 0){
 
	  var bodyY = parseInt($('#body').offset().top) - 20;
	  var originalX = $floatingbox.css('margin-left');
 
	  $(window).scroll(function () { 
 
	   var scrollY = $(window).scrollTop();
	   var isfixed = $floatingbox.css('position') == 'fixed';
 
	   if($floatingbox.length > 0){
 
//	      $floatingbox.html("srollY : " + scrollY + ", bodyY : " 
//                                    + bodyY + ", isfixed : " + isfixed);
 
	      if ( scrollY > bodyY && !isfixed ) {
			$floatingbox.stop().css({
			  position: 'fixed',
			  left: '50%',
			  top: 20,
			  marginLeft: -500
			});
		} else if ( scrollY < bodyY && isfixed ) {
		 	  $floatingbox.css({
			  position: 'relative',
			  left: 0,
			  top: 0,
			  marginLeft: originalX
		});
	     }		
	   }
       });
     }
     
     /* centrowanie messaga */
     var cont = $("#container");
     var offset = cont.offset();

     $floatingbox.css({left: offset.left});
   
     $floatingbox.animate({height: 11}).show();
	 var h = $(".message-content").height();
     $floatingbox.animate({height: h+50});
});


function closeMessage() {
  	var $floatingbox = $('#floating-box');
  // $floatingbox.animate({height: 0}).hide();
   $floatingbox.slideUp();
}
function slideSwitch() {
	 var $active = $('#slideshow IMG.active');

	    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

	    var $next =  $active.next().length ? $active.next()
	        : $('#slideshow IMG:first');

	    $active.addClass('last-active');

	    $next.css({opacity: 0.0})
	        .addClass('active')
	        .animate({opacity: 1.0}, 1000, function() {
	            $active.removeClass('active last-active');
	        });

}




function spr(that) {
	if (that.checked != true) {
		document.getElementById("address2").style.display="none";
	}
	else {
		document.getElementById("address2").style.display="block";
	}
}

function showToggle(that,id) {
	
	commentsDiv = document.getElementById(id);
	
	var vi = commentsDiv.style.display;
	if (vi=="" || vi=='block') {
		commentsDiv.style.display='none';
		$(that).text("Pokaż");
		$.cookie('showCom', '0');
	} else {
		commentsDiv.style.display='block';
		$(that).text("Ukryj");
		$.cookie('showCom', '1');
		
	}

	return false;
}

