function play()
{
	bodyContent = $.ajax({
		url: "include/wai.php",
		type: "POST",
		data: ({can : true}),
		dataType: "text/html",
		success: function(msg){
			$("#contactFormCaptcha").append(msg);
		}
	}).responseText;
}
function playToken()
{
	$("#contactFormCaptcha").append("<a href=\"javascript: play();\" name=\"czytajKod\" id=\"czytajKod\" title=\"Wprowadź usłyszane numery\"><img src=\"images/shared/accessibility.gif\" alt=\"Wprowadź usłyszane numery\" align=\"absmiddle\" /></a>");
}
$(document).ready(function() {
     if($("#contactFormCaptcha")) playToken();
});

$(function() {
	if($("body.index").length)
		swfobject.embedSWF("images/index/anim_top_922x176px.swf", "flash", "922", "176", "9.0.0", "", {}, {wmode: "opaque"});

	var homeLeft = 700;
	if($("nav#main li.active").length)
		if($("nav#main li.active").position().left == 0)
			homeLeft = $("nav#main li.active").position().left;
		else
			homeLeft = $("nav#main li.active").position().left-13;
	$("header.index nav ul").lavaLamp({fx: "easeOutExpo", speed: 500, homeTop: 0, homeLeft: homeLeft, homeHeight: 23, homeWidth: 88, returnHome: true});
	$("header.page nav ul").lavaLamp({fx: "easeOutExpo", speed: 500});
	
	//$("section.page nav li#"+s2+" a").trigger("mouseenter");

	var url = String(window.location).split("/");
	url = url[url.length-1];
	
	$("#menu li, nav li").each(function() {
		if($(this).children("a").attr("href") == url)
			$(this).addClass("active").children("a:first-child").addClass("active");
	});
	
	$("section#promo nav li a").hover(function() {
		$(this).children("span").stop().animate({left: "-=30px"}, 3500, "easeOutExpo");
		$(this).children("strong").stop().animate({left: "-=55px"}, 3500, "easeOutExpo");
	}, function() {
		$(this).children("span").stop().animate({left: "65px"}, 1500, "easeOutExpo");
		$(this).children("strong").stop().animate({left: "65px"}, 1500, "easeOutExpo");
	});
	
	$("section#promo nav li a footer").hover(function() {
		$(this).stop().animate({right: "-=5px"}, 200, "easeOutExpo");
	}, function() {
		$(this).stop().animate({right: "30px"}, 200, "easeOutExpo");
	});
	
	$("section#main-section article footer a").hover(function() {
		$(this).animate({paddingRight: "35px"}, 200);
	}, function() {
		$(this).animate({paddingRight: "30px"}, 200);
	});
	
	$("section.page nav a[class!=active]").hover(function() {
		$(this).stop().animate({"color": "#4d7f00"}, 200);
		$(this).parent().stop().animate({"padding-left": "25px"}, 200);
	}, function() {
		$(this).stop().animate({"color": "#333"}, 200);
		$(this).parent().stop().animate({"padding-left": "20px"}, 200);
	});
	
	$("a#archive-handle").click(function() {
		$(this).parent().prev().html("Archiwum wydarzeń");
		Cufon.replace("section.page h1");
		$(this).parent().slideUp().next().slideDown();
	});
	
	$("a#news-handle").click(function() {
		$(this).parent().prev().prev().html("Wydarzenia");
		Cufon.replace("section.page h1");
		$(this).parent().slideUp().prev().slideDown();
	});
	
	//console.log(window.location.hash);
	if(window.location.hash == "#archiwum")
		$("#archive-handle").click();
	
});
