Cufon.replace('.cufon', { fontFamily: 'Adobe Garamond Pro Regular' });
Cufon.replace('#topNav #rezerwacje a', { fontFamily: 'Adobe Garamond Pro Regular', hover: true });
Cufon.replace('#main_menu a', { fontFamily: 'Adobe Garamond Pro Regular', hover: true });
Cufon.replace('h1,h2,h3,h4', { fontFamily: 'Adobe Garamond Pro Regular' });

$(document).ready( function() {
	
	$("input[type=text], input[type=password], textarea").focus( function() {
		if ( $(this).val() == $(this).attr("title") ) {
			$(this).val("")
		}
	}).blur( function() {
		if ( $(this).val() == '' ) {
			$(this).val( $(this).attr("title") );
		}
	});
	
	$("#nextFoto").click( function() {
		showPreviev( $(this).attr("href") );
		return false;
	});
	
	$("#prevFoto").click( function() {
		showPreviev( $(this).attr("href") );
		return false;
	});
	
	//
	$(".turniejSignUp").click( function() {
		//var formstr = $(this).parent().serialize();
		$.ajax({
			url: "/_ajax/turniej.php",
			data: $(this).parent().serialize(),
			dataType: 'json',
			type: "POST",
			cache: false,
			success: function( data ) {
				if ( data != '' ) {
					if ( data.akcja  == 'zapis' ) {
						$("#turniej_"+data.id+" .action").val("wypis");
						$("#turniej_"+data.id+" .zapis").hide();
						$("#turniej_"+data.id+" .wypis").show();
					} else if ( data.akcja  == 'wypis' ) {
						$("#turniej_"+data.id+" .action").val("zapis");
						$("#turniej_"+data.id+" .wypis").hide();
						$("#turniej_"+data.id+" .zapis").show();
					}
				}
			}
		});	
	});
	
});


$.fn.equalHeights = function(px) {
	var currentTallest = 0;
	$(this).each(function() {
		var currentHeight = $(this).height();
		if ( currentHeight > currentTallest) {
			currentTallest = currentHeight;
		}
	});
	$(this).css({"position":"relative"});
	$(this).children("p.more").css({"width":"100%", "position":"absolute", "bottom":"0"});
	currentTallest += 'px';
	// for ie6, set height since min-height isnt supported
	if ($.browser.msie && $.browser.version == 6.0) {
		$(this).css({'height': currentTallest});
	}
	$(this).css({'min-height': currentTallest}); 
	
	return this;
};

function showPreviev( cur ) {
	var prev = parseInt(cur)-1;
	var next = parseInt(cur)+1;
	
	if ( fotki[cur] != '' ) {
		$("#pic img").attr( 'src', $("#thumb_"+fotki[cur]).attr("src").replace(/thumb_76_/, "thumb_713_") );
	}
	$("#nextFoto").attr("href",next);
	$("#prevFoto").attr("href",prev);
	
	if ( typeof fotki[next] == 'undefined' ) {
		$("#nextFoto").hide();
	} else {
		$("#nextFoto").show();
	}
	if ( typeof fotki[prev] == 'undefined' ) {
		$("#prevFoto").hide();
	} else {
		$("#prevFoto").show();
	}
	return false;
}

function SendCalRequest(mnth,yer,lang)
{
	$.ajax({
		url: "/_ajax/kalendarz.php?rok="+yer+"&miesiac="+mnth+"&lang="+lang,
		type: "GET",
		cache: false,
		success: function( data ) {
			$("#ajax_cal").html( data );
		}
	});	
}

function calendarSetMonth(mnth,yer,lang)
{
	SendCalRequest(mnth,yer,lang);
}
/*
function fotoPreviev( id, dir, file ) {
	$("#pic_"+id).attr("href",dir+'/'+file);
	$("#pic_"+id+" img").attr("src",dir+'/thumb_713_'+file);
	tb_init("pic_"+id);
	return false;
}
*/
