$(function(){
	
	$("#Menu li").has("ul").addClass("Arrow");
	$("#Menu ul").css({display: "none"});
	$("#Menu li").hover(function(){
		$(this).addClass("Hover").find('ul:first').css({visibility: "visible",display: "none"}).show(200);
	},function(){
		$(this).removeClass("Hover").find('ul:first').css({visibility: "hidden"});
	});
	
	Cufon.replace('#Slider a',{ hover: true });
	Cufon.replace('#Main .Text h1, #Main .Text h2, #Main .Text h3, #Motto h3',{ textShadow: '2px 2px #eee' });
	Cufon.replace('#SubMenu h3 a',{ hover: true }); // , textShadow: '1px 1px #474747'
	Cufon.replace('#List .Row h2 a',{ hover: true, textShadow: '1px 1px #eee' });
	
	$("#Slider").timeSlide();
	$(".fancybox").fancybox();
	
	$(".Text img[align=left]").addClass("marginRight");
	$(".Text img[align=right]").addClass("marginLeft");
	
	$("#GoCheck").click(function(){
		$.getJSON('/check.json?url='+escape($(this).attr("href")), ShowResult);
		return false;
	})
	
	$("#Product .ProdDetail").each(function(index) {
		$(this).find("tr:odd").addClass("np");
		$(this).find("tr").find("td:first").addClass("f");
	});
});

function ShowResult(data, textStatus) {
	$("#Result").text(data[0].quant).animate({opacity: "show",width: "show"}, "slow");
}
function CheckContactForm() {
	
	var name = $("#CFName").val();
	var phone = $("#CFPhone").val();
	var email = $("#CFEmail").val();
	var text = $("#CFText").val();
	
	if(!name.length) return ShowError("Proszę wpisać swoje imię i nazwisko.");
	if(!phone.length) return ShowError("Proszę wpisać telefon kontaktowy.");
	if(!email.length) return ShowError("Proszę wpisać kontaktowy adres email.");
	if(!checkEmail(email)) return ShowError("Proszę wpisać PRAWIDŁOWY adres email.");
	if(!text.length) return ShowError("Proszę wpisać treć wiadomoci.");
	
	return true;
}


function checkEmail(x){return/^[\w\.-]+@([\w-]+\.)*[a-z]{2,4}$/.test(x);}

function ShowError(txt) {
	$.fancybox({
		'autoScale'			: true,
		'content'			: '<div id="Question"><div class="txt">'+txt+'</div></div>'
	});
	return false;
}

function ShowMessage(txt) {
	$.fancybox({
		'autoScale'			: true,
		'content'			: '<div id="Question"><div class="txt">'+txt+'</div></div>'
	});
	return false;
}

