//// starting the script on page load
$(document).ready(function(){
	tooltip();
});		


// -------------------------------------------------------------------------------
		$(document).ready(function(){
//// -----------------------------------------------------------------------------


var currentPosition = 0;
var slideWidth = 584;
var slides = $('.pr_photo');
var numberOfSlides = slides.length;
// Remove scrollbar in JS
$('#project_slidesContainer').css('overflow', 'hidden');
// Wrap all .slides with #slideInner div
slides
.wrapAll('<div id="project_slideInner"></div>')
// Float left to display horizontally, readjust .slides width
.css({
  'float' : 'left',
 'width' : slideWidth
 });
 // Set #slideInner width equal to total width of all slides
 $('#project_slideInner').css('width', slideWidth * numberOfSlides);
 // Insert controls in the DOM
 $('#left-right_scroll')
 .prepend('<span class="pr_control" id="pr_leftControl" > < </span>')
  .append('<span class="pr_control" id="pr_rightControl"> > </span>');

 // Hide left arrow control on first load
 manageControls(currentPosition);

 // Create event listeners for .controls clicks
  $('.pr_control')
    .bind('click', function(){
   // Determine new position
currentPosition = ($(this).attr('id')=='pr_rightControl') ? currentPosition+1 : currentPosition-1;

$('#left-right_scroll-number') 
.html((currentPosition+1)+' / '+numberOfSlides);

	// Hide / show controls
   manageControls(currentPosition);
    // Move slideInner using margin-left
    $('#project_slideInner').animate({
     'marginLeft' : slideWidth*(-currentPosition)
    });
  });

  // manageControls: Hides and Shows controls depending on currentPosition
 function manageControls(position){
   // Hide left arrow if position is first slide
	if(position==0){ $('#pr_leftControl').fadeOut('fast') } else{ $('#pr_leftControl').fadeIn('slow') }
// Hide right arrow if position is last slide
   if(position==numberOfSlides-1){ $('#pr_rightControl').fadeOut('fast') } else{ $('#pr_rightControl').fadeIn('slow') }
  }	















// show hide

//close all the content divs on page load
$('.mover').hide();

// fade in and out

$('#fadeInOut').toggle(function() {

$('.pusher').css('background', 'url(/images/btn_cross.gif) top right no-repeat')
$('.pusher span').css('color', '#fff')
$(this).siblings('.mover').fadeIn('fast');



}, function() {
$('.pusher').css('background', 'none')
$('.pusher span').css('color', '#010101')
$(this).siblings('.mover').fadeOut('fast');
});




//mapa dojazdu

$('#mapa').hide();

$('#mapaIn').click(function() {
	$(this).siblings('#mapa').fadeIn('slow');
});

$('#mapaOut').click(function() {
	$('#mapa').fadeOut('slow');
});

//form send

$('#formOut').click(function() {
	$('#formSend').fadeOut('slow');
});

							 






		

// linki w nowym oknie	
		
			$('a[rel="external"]').click( function() {
        		window.open( $(this).attr('href') );
        		return false;});
				
				$('a[rel="external"]').filter(function() {
         return this.hostname && this.hostname !== location.hostname;
        }).addClass('externalLink');


// link blur
		
			$("a").focus(function() {
  			$(this).blur();
			});
	


		
 // this initialises the demo scrollpanes on the page.
				$('#pane1, #pane2, #pane3').jScrollPane({scrollbarWidth:2, scrollbarMargin:15, dragMinHeight:35, dragMaxHeight:35, animateInterval:25});






//// -----------------------------------------------------------------------------
		});
// -------------------------------------------------------------------------------		


	
	
		
/*
 * Tooltip script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 


this.tooltip = function(){	
		
	$("a.tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";	
		this.r = this.rel;
		this.rel = "";
		
		$("#project-title").prepend("<h4 id='tooltip'>"+ this.t +"</h4>");
		$("#tooltip").css('filter','alpha(opacity=80)')
			.fadeIn("slow");		
			


		$("#project-title").append("<h5 id='tooltip2'>"+ this.r +"</h5>");
		$("#tooltip2").css('filter','alpha(opacity=80)')
			.fadeIn("slow");		
    },
	
	function(){
		this.title = this.t;	
		this.rel = this.r;	
		$("#tooltip").remove();
		$("#tooltip2").remove();		
    });	
	$("a.tooltip").mousemove(function(e){
		
	});			
};



	
