$(document).ready(function() {  
    
	//first encounter
	$('#scroll').hide;
	$('#scroll').fadeIn(1500);
	var img_f = $('#scroll:first-child');
	var link_f = img_f.find('a').attr('href');
	var title_f = img_f.find('img').attr('title');
	var alt_f = img_f.find('img').attr('alt');
	var alt_f2 = img_f.find('img').attr('alt2');
	
	//alert(link_f);
	
	
	$('#img_holder').append("<img id='theImg' src='"+ link_f +"'/>");
	$('#alt_holder').append("<h3>" + title_f + "</h3>");
	$('#alt_holder').append("<p>" + alt_f + "</p>");
	$('#alt_holder2').append("<p>" + alt_f2 + "</p>");
	
	////////////////////////////////////////////////////////////////////
	
	$('#content_galeria_nojs').hide();
	$('#content_galeria').show();
	
	$('.gal a ').live('click', function(ev){
		
	
    // Stop regular handling of "click" in most non-IE browsers
    ev.preventDefault();
    ev.stopPropagation();

	$('#img_holder').empty();
	$('#alt_holder').empty();
	$('#alt_holder2').empty();
    // Load the new content into the div (same code you had)
	var link = $(this).attr('href');
	var title = $(this).find('img').attr('title');
	var alt = $(this).find('img').attr('alt');
	var alt2 = $(this).find('img').attr('alt2');


    $('#img_holder').append("<img id='theImg' src='"+ link +"'/>");
	$('#alt_holder').append("<h3>" + title + "</h3>");
	$('#alt_holder').append("<p>" + alt + "</p>");
	$('#alt_holder2').append("<p>" + alt2 + "</p>");
	

    // Stop regular handling of "click" in IE (and some others)
    return false;
		
	
	});
	/*	Nawigacja dolnego panelu ze zdjęciami
	 * 	przesuniecie o (max/14)-1 ekranów
	 * 
	 */
	var i = 0;
	var max = $('#scroll').children().size()
	var maxnext = max/14;
	$('.next').click(function(){
		if (i < (maxnext-1)) {
			$('#scroll').animate({"left": "-=953"}, 'slow');
			i = i + 1;
			
			return false;
		}
		else {
			return false;
		}
		
		
		
	});
	$('.prev').click(function(){
		if (i == 0) {
			
		 return false;
		}
		else {
			$('#scroll').animate({"left": "+=953"}, 'slow');
			i = i-1;
			return false;
		}
	});
	
	/*	Nawigacja górnego panelu ze zdjęciami
	 * 	przesuniecie o (max_album/8)-1 ekranów lub gdy modulo 8 z max_album ( < 8 i > 0 ) to bez -1 ekranów
	 * 
	 */
	var m = 0;
	var max_album = $('#scroll_album').find('.alb').size()
	var maxnext_album = max_album/8;
	var maxmodulo = max_album%8;
	var minusnum;
	if ( 8 > maxmodulo > 0 ){ minusnum = 0}
	else { minusnum = 1}
	
	//alert (maxnext_album);
	$('.next_album').click(function(){
		if (m < ( maxnext_album - minusnum )) {
			var w = $('#scroll_album').css('width');
			$('#scroll_album').animate({"left": "-=1005"}, 'slow');
			m = m + 1;
			
			return false;
		}
		else {
			return false;
		}
		
		
		
	});
	$('.prev_album').click(function(){
		if (m == 0) {
			
		 return false;
		}
		else {
			$('#scroll_album').animate({"left": "+=1005"}, 'slow');
			m = m-1;
			return false;
		}
	});
	
	
	//////////////////////////////////////////////////////////
	/*
	/* jQuery Clock plugin
	/* http://www.techiegyan.com/?p=296
	/* 
	 * 
	 * timeNotation (String): Type of time display: ‘24h’ or ‘12h’ (‘12hh’ inserts leading 0). Default: ‘24h’
 	 * am_pm (Boolean): true/false. If true, displays A.M./P.M. Default: false (12h timeNotaion only)
 	 * utc (Boolean): true/false. If true, shows time using UTC. Defaul: false
	 * utc_offset (Number): If specified, sets offset from UTC, negative or positive. Default: 0
	 * fontFamily (String): If specified, sets CSS fontFamily. Default: null
	 * fontSize (Number): If specified, sets CSS fontSize. Default: null
	 * foreground (String): If specified, sets CSS foreground color. Default: null
	 * background (String): If specified, sets CSS background color. Default: null
	 * 
	 */
	/////////////////////////////////////////////////////////*/
	 
	 
	$(function($) {
		var options_m={
			timeNotation: '24h',
			am_pm: false, 
	        utc: true,
	        utc_offset: -4
	    };
		
		var options_l={
			timeNotation: '24h',
			am_pm: false, 
	        utc: true,
	        utc_offset: 0
      	};
	  
	  	var options_k={
			timeNotation: '24h',
			am_pm: false, 
	        utc: true,
	        utc_offset: 1
	     };
		 
	    $('#montreal').jclock(options_m);
		$('#london').jclock(options_l);
		$('#krakow').jclock(options_k);
	});



});  
