Cufon.replace('h2, #footer div ul li a, #content #right_col #main_menu ul li a, #content #right_col #info #top .text p, #content #right_col #info #top .text a, h3, #content #right_col .sub_info a, h4, #content #right_col #info #top .text .left, #content #right_col #info #top .text .right ', { fontFamily: 'Frutiger LT Com 57 Condensed' });
Cufon.replace('#content #left_col .contact .left', { fontFamily: 'Frutiger LT Com 45 Light' });
Cufon.replace('#content #left_col .contact .right, #content #right_col #info #bellka, #content #right_col .photos .belka1, #content #right_col .photos .belka2', { fontFamily: 'Frutiger LT Com 47 Light Cn' });


$(document).ready(function(){
		$(".preload").preloadify({ imagedelay:300, }); //load image after page
		if ($("#fancybox-mapka").length > 0) {$("#fancybox-mapka").fancybox({'hideOnContentClick': true,
	   		'width':'600px',
			'height':'510px'}); }
		$('#content #right_col .opacity').css({opacity:"0.5"});
		$('#content #right_col .opacity').hover(function(){ //hover efect on main page
		$(this).stop().animate({opacity:"1"})
		}, function(){$(this).stop().animate({opacity:"0.5"})});
		
	var wysokosc = $("#content").height();
	$("#content #left_col").css({minHeight:wysokosc+"px"});	
	
	//clear contact inputs
	var clearMePrevious = '';
	// clear input on focus
	 $('#content #right_col #kontakt .left input, #content #right_col #kontakt .left textarea').focus(function(){
		 if($(this).val()==$(this).attr('title'))
		 {
			 clearMePrevious = $(this).val();
			 $(this).val("");
		 }
	 });
	
	// if field is empty afterward, add text again
	 $('#content #right_col #kontakt .left input, #content #right_col #kontakt .left textarea').blur(function()
		 {
		 	if($(this).val()=="")
		 {
		 	$(this).val(clearMePrevious);
		 }
	 });
	 
	
	// var string = "";
	 //for (i=1;i<19;i++) {
	//	 string += '<div class="box"><a rel="galeria2/zaklad'+i+'.jpg" href="javascript:void(0)"><img alt="Zdjęcie" src="galeria2/min/zaklad'+i+'.jpg" height="232" width="260"></a></div>';
		 
	 //}
	// $('#gallery').html(string);
	 
	$('#gallery .box:nth-child(3n)').after('<div class="clear"></div><div class="line"></div><div class="clear"></div>');
	$('#contactform').submit(function(){ //contact form ajax send

		var action = $(this).attr('action');

		$('#submit').attr('disabled','disabled');

		$("#message").slideUp(750,function() {
		$('#message').hide();

		$.post(action, {
			name: $('#name').val(),
			email: $('#email').val(),
			phone: $('#phone').val(),
			comments: $('#comments').val(),
		},
			function(data){
				document.getElementById('message').innerHTML = data;
				$('#message').slideDown('slow');
				$('#submit').removeAttr('disabled');
				if(data.match('success') != null) $('#contactform').slideUp('slow');

			}
		);

		});

		return false;

	});
	
	if($("#gallery").length > 0 )gallery();
	
	
})

function gallery(){
	$("#content #right_col #gallery .gal_left .box a").preloadify({ imagedelay:50, }); //load image after page
	if ($("a.fancybox").length > 0)$("a.fancybox").fancybox();
	$('#content #right_col #gallery .gal_left .box a').click(function(){
		var	bigg = $(this).attr("rel");
		var	norm = $(this).find("img").attr("src");
		$('.gal_right a img').fadeOut(200,function(){
			//$(window).scrollTop($('#content #right_col #gallery .gal_right').position().top)
			$('html, body').animate({ scrollTop: $("#content #right_col #gallery .gal_right").offset().top }, 500);
			$('.gal_right a').attr("href", bigg);
			$('.gal_right a img').attr("src", norm);
			$("a.fancybox").fancybox();
			$('.gal_right a img').fadeIn(200);
		})
	});
	$("#content #right_col #gallery .gal_left .box a").hover(function() {
			$(this).addClass("tester");
			//$(this).find("img").animate({borderRadius: 20});
			$('#content #right_col #gallery .gal_left .box a:not(.tester)').stop(true, true).animate({opacity:"0.85"},800);
		}, function() {		
			$('#content #right_col #gallery .gal_left .box a:not(.tester)').stop(true, true).animate({opacity:"1"},800);
			//$(this).find("img").animate({borderRadius: 0});
			$(this).removeClass("tester");
})
}
