$(window).load(function(){
	if($("#lewa").outerHeight(true) < $("#prawa").outerHeight(true))
	{
		$("#lewa").height($("#prawa").outerHeight());
		$("#loga_dol").css({"position":"absolute"});
	}
})

$(document).ready(function(){
	
	$(".youtube").click(function() {
		$.fancybox({
				'padding'		: 0,
				'autoScale'		: false,
				'transitionIn'	: 'none',
				'transitionOut'	: 'none',
				'title'			: this.title,
				'width'			: 680,
				'height'		: 495,
				'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
				'type'			: 'swf',
				'swf'			: {
					 'wmode'		: 'transparent',
					'allowfullscreen'	: 'true'
				}
			});

		return false;
	});	
	
	$(".lightbox").lightBox_old();
 	$("a.fancybox").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	false
	}); 
    $("html").css({"overflow-y":"scroll"});
	$(".cal_info tbody tr:even").addClass("even");
	
	$(".slider").nivoSlider({
		effect:			'fold'
		,effectOrder:	false
		,pauseTime:		4000
		,animSpeed:		1000
	});
	
	$("#menu_right a").click(function(){
		if($(this).attr("href")=="#")
		{
			$(this).next("ul").slideToggle(500);
			$(this).parent().parent().children("li").children("ul").not($(this).next("ul")).slideUp(500);
			//objekt.find(options.handler).next().not($(this).next()).slideUp(options.slideTime);
			return false;
		}
	})
	
	$("a.zglos").click(function(){
		var id_akt = $(this).attr("href");
		var tytul = $(this).closest("table").find("thead th").text();
		$.fancybox({
			href : "/formularz_zapytania.php",
			ajax : {
				//url		: "formularz_zapytania.php",
				type	: "POST",
				data	: {
					id_akt:		id_akt,
					tytul:		tytul
				}
			}
		});
		return false;
	})

	$(".zap_rez").live('submit', function() {
		zweryfikowano_frm=false;
		$(this).pk_sprawdzForm();
		if(zweryfikowano_frm)
		{
			$(this).ajaxSubmit(options_zap_rez);
			return false;
		}
		else
		{
			alert('wypełnij prawidłowo adres e-mail i telefon');
			return false;
		}			
	});	
	
    var options_zap_rez = {
          //target:        '#myList',   // target element(s) to be updated with server response
          //beforeSubmit:  showRequest,  // pre-submit callback
          url: '/ajax.php',
		  resetForm: false,
          success:       showResponse_tekst_rez
    };	
	function showResponse_tekst_rez(responseText, statusText)  {
		$.fancybox.close();
		alert(responseText);
	}


	
	var options_wyslij = {
          //target:        '#myList',   // target element(s) to be updated with server response
          //beforeSubmit:  showRequest,  // pre-submit callback
          url: 'ajax.php',
		  resetForm: true,
          success:       showResponse_tekst
    };
	function showResponse_tekst(responseText, statusText)  {
		alert(responseText);
	};
	$(".ajax_ver").submit(function(){
		
		zweryfikowano_frm=false;
		$(this).pk_sprawdzForm();
		/* $.each(zmienna, function(i,item){
                    alert(i+" "+item)
                }); */ 
		if(zweryfikowano_frm)
		{
			$(this).ajaxSubmit(options_wyslij);
			//alert('zweryfikowano_frm true');
			return false;
		}
		else
		{
			alert('wypełnij prawidłowo formularz');
			return false;
		}		
    });	
	
	$("#MiniCal table tr.nav td.nagls a").live('click',function(){
		var date = $(this).attr("name");
		$.ajax({
			type: "POST",
			url: "/modules/kalendarz.php",
			data: "date="+date,
			success: function(data){
				//$('#load_kalendarz').html(data);
				$('#load_kalendarz').replaceWith(data);
			}
		});
		return false;
	})	
	
	$("#newsletter").bind('submit', function() {
		zweryfikowano_frm=false;
		$(this).pk_sprawdzForm();
		if(zweryfikowano_frm)
		{
			$(this).ajaxSubmit(options_wyslij);
			return false;
		}
		else
		{
			alert('wpisz prawidłowy adres e-mail');
			return false;
		}			
	});		
	
	/*
	Cufon.replace('#menu_bar > ul > li > a',{
		fontFamily: 'pf din b',
		color:	'#e2e4e5',
		hover: true
	});	
	Cufon.replace('#menu_bar > ul > li > a:hover, #menu_bar > ul > li > a.h, #menu_bar > ul > li.sub_over > a',{
		fontFamily: 'pf din b',
		color:	'#01245c',
		hover: true
	});	
	*/
	Cufon.replace('.dinb,.telefony,h2.big,#prawa .box h2,#menu_bar ul li ul li h3,#menu_bar > ul > li > a,h3.nagl,#menu_right > ul > li > a,.calendar thead th',{
		fontFamily: 'pf din b',
		hover: true
	});	
	Cufon.replace('.dinl,#slider_box h2',{
		fontFamily: 'pf din l',
		hover: true
	});
	Cufon.replace('#top h2,.menuHP h2',{
		fontFamily: 'PF Agora Serif Pro Medium',
		hover: true
	});
	
})
