$(document).ready(function() {
	$("#main").wysrodkuj();
	
	$("div.realizacje").hide();
	$("h2.realizacja").click(function() {
		if($(this).children("span").html() == "+") {
			$("div.realizacje").slideUp();
			$("h2.realizacja span").html("+");
			$(this).children("span").html("-");
			$(this).next().slideDown("slow");
		} else {
			$(this).children("span").html("+");
			$(this).next().slideUp("slow");
		}
	});
	
	$("div.real-budowa").hide();
	$("div.realizacje h3").click(function() {
		$("div.realizacje h3").css({"color":"#000", "backgroundPosition":"0 0"});
		if($(this).next().css("display") == "none") {
			$("div.real-budowa").slideUp();
			$(this).css({"color":"#48A5D0", "backgroundPosition":"0 -15px"});
			$(this).next().slideDown("slow");
		} else {
			$(this).css({"color":"#000", "backgroundPosition":"0 0px"});
			$(this).next().slideUp("slow");
		}
	});
	
	$("div.real-budowa p.zdjecia a").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
		return '<span id="fancybox-title-over">Zdjęcie ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	
	$("div.real-budowa p.zdjecia a img").css("opacity", "0.7");
	$("div.real-budowa p.zdjecia a img").mouseover(function() {
		$(this).animate({"opacity":1});
	}).mouseout (function() {
		$(this).animate({"opacity": 0.7});
	});
	
	
	/*
	$("div.referencje a.ref_img").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
		return '<span id="fancybox-title-over">Referencja ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	*/
	
	
	$("div.referencje ul li p a").click(function() {
		window.open($(this).attr("href"), $(this).attr("href"));
		return false;
	});
	
	$("div.referencje a.ref_img").click(function() {
		window.open($(this).attr("href"), $(this).attr("href"));
		return false;
	});
	
});
