// JavaScript Document

$(document).ready(function() {



	//Default Action
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
	
	//On Click Event
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content
        $(".gorzanie").hide(); //Hide all content of gorzanie
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(1500); //Fade in the active content
		return false;
	});




	$(function() {
	//	$('#opisy a').lightBox();
		$('#gorzan1_opis a').lightBox();
    	$('#gorzan2_opis a').lightBox();
		$('#gorzan3_opis a').lightBox();
		$('#gorzan4_opis a').lightBox();
		$('#gorzan5_opis a').lightBox();
		$('#gorzan6_opis a').lightBox();
		$('#galeria a').lightBox();
	});
   
	 function ukryj_cdOpisy() {
	  	$('#dyskografia_opis').hide(); 
		$('.miniatury').hide(); 
		$('#cd1_opis').hide();
		$('#cd2_opis').hide();
		$('#cd3_opis').hide();
		$('#cd4_opis').hide();
		$('#cd5_opis').hide();
		$('#cd6_opis').hide();
		$('#cd7_opis').hide();
		
	 }
	 
	function ukryj_onasOpisy() {
		$('#onas_opis').hide();
		$('.onas_miniatury').hide();
		$('#gorzan1_opis').hide();
		$('#gorzan2_opis').hide();   	
		$('#gorzan3_opis').hide();
		$('#gorzan4_opis').hide();
		$('#gorzan5_opis').hide();
		$('#gorzan6_opis').hide();
	} 



	$('.onas_click').click(function(){
		ukryj_onasOpisy();
		$('#onas_powrot').show();
		var min_id = $(this).attr('id');
		var div_id = "#" + min_id + "_opis";
		$(div_id).fadeIn('slow', 'linear');
		//$('#onas_opis').html('dupa');
	
	 });
	 
	 $('#onas_powrot, #lnk_onas').click(function() {
        ukryj_onasOpisy();
	    $('#onas_opis').fadeIn();	 
		$('.onas_miniatury').fadeIn();		 
		$('#onas_powrot').hide();
	 });
	 
	
	 
	 $('.cd_click').click(function() {
		 ukryj_cdOpisy();
		$('#cd_powrot').show();		
		var min_id = $(this).attr('id');
		var div_id = "#" + min_id + "_opis";
		$(div_id).fadeIn('slow', 'linear');
		
	 });
	 

	 
	 $('.cd_click img').mouseover( function () {
			  var tytul = $(this).attr('title');
			  $('#dyskografia_tytul').text('"'+tytul+'"');
	 });
		   
	 $('.cd_click img').mouseout( function () {
  			  $('#dyskografia_tytul').text('');
		   
	 });
	 
	 
	 	$('#cd_powrot, #lnk_dyskografia').click(function() {
         ukryj_cdOpisy();
	    $('#dyskografia_opis').fadeIn();	 
		$('.miniatury').fadeIn();		 
		$('#cd_powrot').hide();
	 });


	//Execute the slideShow on first stage gorzanie
	    //slideShow();
	

// send Mail


$('#new_message').click(function() {
	 $('#sended').hide();
	 $('#contact_form').fadeIn();
	 $('#new_message').hide();
	 $("input#name").val('');
	 $("input#email").val('');
	 $("textarea#message").val('');
	 
});

$(function () {  
  $('.error').hide();  
  $(".button").click(function() {  
    // validate and process form here 
	
				$('.error').hide();  
				  var name = $("input#name").val();  
					if (name == "") {  
				  $("label#name_error").show();  
				  $("input#name").focus();  
				  return false;  
				}  
					var email = $("input#email").val();  
				    //var tb=$("input#email");
					if ( !(email.match(/^[0-9a-z_.-]+@([0-9a-z-]+.)+[a-z]{2,6}$/)) ||  (email == "") ){  
						$("label#email_error").show();  
						$("input#email").focus();  
						return false;  
				   }  
				
    
				   
				   var message = $("textarea#message").val();  
				   if (message == "") {  
				   $("label#message_error").show();  
				   $("textarea#message").focus();  
				  return false;  
				}
				
				var dataString = 'name='+ name + '&email=' + email + '&message=' + message;
				
  
	
					//alert (dataString);return false;  
				$.ajax({  
					type: "POST",  
					url: "send.php",  
					data: dataString,  
					success: function() {  
					 $('#contact_form').hide();
					 $('#sended').show();
					 $('#new_message').show();
					 $('#sended').html("<div id='message_status'></div>");  
					 //  $('#contact_LB').append(<div id='message_status'></div>);
					//$('#message_status').show();
					$('#message_status').html("<h2>Wiadomość została wysłana!</h2>")  
					.append("<p>Dziękujemy. </p>")  
					.hide()  
					.fadeIn(1000, function() {  
					  $('#message_status').append("<img id='checkmark' src='images/check.png'/>");  
				});  
				$('#message_new').show();
			  }  
			});  
			return false;    

	
	
  });  // button.click
  
});   // function 


}); // get Ready




/////////////////////// FUNCTIONS /////////////////////////////


/*

function slideSwitch() {
    var $active = $('#slideshow IMG.active');
    var $next = $active.next();    

    $next.addClass('active');

    $active.removeClass('active');


$(function() {
    setInterval( "slideSwitch()", 5000 );
});
}*/
/*
function slideSwitch() {
    var $active = $('#slideshow IMG.active');
    var $next = $active.next();

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});

*/

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() {
       setInterval( "slideSwitch()", 5000 );
    });



			
				







// gallery 
/*
function slideShow() {

	//Set the opacity of all images to 0
	$('#gallery a').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('#gallery a:first').css({opacity: 1.0});
	
	//Set the caption background to semi-transparent
	$('#gallery .caption').css({opacity: 0.7});

	//Resize the width of the caption according to the image width
	$('#gallery .caption').css({width: $('#gallery a').find('img').css('width')});
	
	//Get the caption of the first image from REL attribute and display it
	$('#gallery .content').html($('#gallery a:first').find('img').attr('rel'))
	.animate({opacity: 0.7}, 400);
	
	//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('gallery()',6000);
	
}


function gallery() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#gallery a.show')?  $('#gallery a.show') : $('#gallery a:first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery a:first') :current.next()) : $('#gallery a:first'));	
	
	//Get next image caption
	var caption = next.find('img').attr('rel');	
	
	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
	//Set the opacity to 0 and height to 1px
	$('#gallery .caption').animate({opacity: 0.0}, { queue:true, duration:300 });	
	
	//Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
$('#gallery .caption').animate({height: '100px'},500 ).animate({opacity: 0.7},100 );
/*	$('#gallery .caption').animate({
									 height : '100px',
									 opacity: 0.7
		                            },500 );*/

/*	
	//Display the content
	$('#gallery .content').html(caption); 
}

*/

   
    $(function(){
 
    $("#wysuwane").css("left","-210px");
 
$("#wysuwane").hover(
  function () {
    $("#wysuwane").animate({left: "0px"}, 100 );
        $(this).addClass("zamknij");
  },
  function () {
    $("#wysuwane").animate({left: "-210px"}, 100 );
        $(this).removeClass("zamknij");
  }
);
});
