$(document).ready(function(){

	/*	
	// ramka w okól obrazka z podsisem z alta
	$('#content img').each(function() {
	    $(this).wrap('<div class="caption" style="' + $(this).attr('style') + '"></div>').after('<div class="imgcaptiontext">' + $(this).attr('alt') + '</div>');
	   
	});
	*/
	
	
	//$(".gallery .imagetiem:nth-child(4n)").css('margin-right', '0px');
	
	
	$(".gallery .imagetiem img").hover(function(){
	    $(this).stop().animate({"opacity": 0.8}, 170);
	},function(){
	    $(this).stop().animate({"opacity": 1}, 170);
	});

	
	
	
	
	// link na gore strony
	$('a[href=#top]').click(function(){
		$('html, body').animate({scrollTop:0}, 'slow');
		return false;
	});
	
	
	//tło nagłowków tabeli przyciemnone
	$('table').each(function() {
		$('tr:first', this).css('background-color', '#e0e4e8');
	});
	
	// chmura tagów
	$('div.chmuratagow p').each(function() {
		var randomnumber=Math.floor(Math.random()*13+10)
		$(this).css('font-size', randomnumber);
	});
	
	 	
  		
 

	// madanie id naglowka h4 w content-text
	var index = 1;
	$('#content-text h4').each(function() {
	    $(this).attr("id", index);
	    index++;	   
	});



	$("#contactForm").validate({
   		submitHandler: function(form) {
      
	      	var dataString = $("form#contactForm").serialize();
			//alert (dataString);return false;
			if ($.browser.msie && $.browser.version.substr(0,1)<8) {
	 		 // search for selectors you want to add hover behavior to
			
			} else {
				$(".contaktFormToggle").html("<div id=\"messagesend\"><img src=\"layouts/images/ajax-loader.gif\" alt=\"Postęp\" /><br /><p>Trwa wysyłanie.</p></div>");
			}
					
			$("#messagesend")
				.fadeIn(1500, function() {
					$("#messagesend");
				});
			
			$.ajax({
	      		type: "POST",
	      		url: "_wyslij.php",
	      		data: dataString,
	      		success: function() {
					$(".contaktFormToggle").html("<div id=\"message\"></div>");
					$("#message").html("<h2>Wiadomość została wysłana.</h2>")
					.append("<p>Wkrótce otrzymasz odpowiedz.</p>")
					.hide()
					.fadeIn(1500, function() {
					$("#message");
					});
				}
     		});
      
   			form.submit();
   		}	
	})
	



	$('a[rel=lightbox[gallery]]').lightBox();
	$('a[rel=lightbox[gallery2]]').lightBox();

	Cufon.replace('#blurb h1, #contentMain h2, aside#sidebar h4');





});




