$(document).ready(function(){
	
	$(".lightbox").lightbox();
	
	$("#Rating input.star").rating();
	$("#Rating a").click(function(){
		if($("#YourVote").val()=="") {
			$("#YourVote").val( $(this).attr("title") );
			$.ajax({
				url: "/index.php?GoDo=GoRate&v="+$(this).attr("title")+"&p="+$("#ProvisionName").val(),
				cache: false
			});
		}
	});
	
	$("#Information").click(function(){
		$(this).animate({ height: 'hide', opacity: "hide"},"slow",null,function(){ $(this).remove(); });
	});
	
	$("h3.TextHeaderClick").click(function(){
		var id = $(this).attr("id").substr(8,($(this).attr("id").length-8));
		$("#HiddenRow"+id).animate({ height: 'toggle', opacity: "toggle"}, "fast");
	});
	
	$("#PCFtext").focus(function(){
		if($("#PCFtext").val()=="Komentarz") $("#PCFtext").val("");
	});
	$("#PCFtext").blur(function(){
		if($("#PCFtext").val()=="") $("#PCFtext").val("Komentarz");
	});
	$("#PCFnazw").focus(function(){
		if($("#PCFnazw").val()=="Twoje imię") $("#PCFnazw").val("");
	});
	$("#PCFnazw").blur(function(){
		if($("#PCFnazw").val()=="") $("#PCFnazw").val("Twoje imię");
	});
	
});

function ShowPopup(f,w,h) {
	$.nyroModalManual({
		closeButton: '<a href="#" class="nyroModalClose" id="closeBut" title="Zamknij" style="background: #777 url(/gfx/close2.gif) no-repeat center center;">Zamknij</a>',
		minHeight: 50,
		height: 50,
		modal: false,
		blocker: false,
		title: false,
		bgColor: 'transparent',
		processHandler: function() {
	   	$.nyroModalSettings({
		   	type: 'swf',
		      width: w,
		      height: h,
		      url: f
	      });
		}
   });
}

window.onload = function(){LoadCalc();}

function LoadCalc() {
	if( $("#Kalkulator").length>0 ) {
		var so = new SWFObject("/flash/kalkulator/kalkulator.swf", "Calculator", "990", "252", "8");
		so.addParam("scale", "noscale");
		so.addParam("wmode", "transparent");
		so.addParam("salign", "t");
		so.write("Kalkulator");
	}
}
	
function ProcSendProv2Firend(){
		var PPFFtext = $("#PPFFtext").val();
		var PPFFnazw = $("#PPFFnazw").val();
		var PPFFemail = $("#PPFFemail").val();
		var PPFFemailz = $("#PPFFemailz").val();
		
		if(PPFFtext=='') {
			return ShowError("Proszę wpisać informację.");
		}else if(PPFFnazw=='') {
			return ShowError("Proszę wpisać swoje imię lub nick.");
		}else if(PPFFemail=='') {
			return ShowError("Proszę wpisać swój email.");
		}else if(!checkEmail(PPFFemail)) {
			return ShowError("Proszę poprawnie wpisać swój email.");
		}else if(PPFFemailz=='') {
			return ShowError("Proszę wpisać email znajomego.");
		}else if(!checkEmail(PPFFemailz)) {
			return ShowError("Proszę poprawnie wpisać email znajomego.");
		}
		return true;
};
		
function ProcSendOdkr(){
		var PSOFtext = $("#PSOFtext").val();
		var PSOFnazw = $("#PSOFnazw").val();
		
		if(PSOFtext=='') {
			return ShowError("Proszę wpisać informację.");
		}else if(PSOFnazw=='') {
			return ShowError("Proszę wpisać swoje imię lub nick.");
		}
		return true;
};
	
function ProcSendProv() {
		var PPFnazwa = $("#PPFnazwa").val();
		var PPFsklad = $("#PPFsklad").val();
		var PPFopis = $("#PPFopis").val();
		var PPFczas = $("#PPFczas").val();
		var PPFnazw = $("#PPFnazw").val();
		
		if(PPFnazwa=='') {
			return ShowError("Proszę wpisać nazwę potrawy.");
		}else if(PPFsklad=='') {
			return ShowError("Proszę wpisać składniki potrawy.");
		}else if(PPFopis=='') {
			return ShowError("Proszę wpisać sposób przyrządzenia potrawy.");
		}else if(PPFczas=='') {
			return ShowError("Proszę wpisać orientacyjny czas przyżączania.");
		}else if(PPFnazw=='') {
			return ShowError("Proszę wpisać swoje imię.");
		}
		return true;
};

function ProcSendProvComment(){
		var PCFtext = $("#PCFtext").val();
		var PCFnazw = $("#PCFnazw").val();
		
		if(PCFtext==''||PCFtext=='Komentarz') {
			return ShowError("Proszę wpisać treść komentarza.");
		}else if(PCFnazw==''||PCFnazw=='Twoje imię') {
			return ShowError("Proszę wpisać swoje imię lub nick.");
		}
		return true;
};
	
function ProcSendComment(){
	var POFtext = $("#POFtext").val();
	var POFnazw = $("#POFnazw").val();
	
	if(POFtext=='') {
		return ShowError("Proszę wpisać treść komentarza.");
	}else if(POFnazw=='') {
		return ShowError("Proszę wpisać swoje imię lub nick.");
	}
	return true;
};

function ProcSendQuestion(){
	var ZPFtext = $("#ZPFtext").val();
	var ZPFnazw = $("#ZPFnazw").val();
	var ZPFemail = $("#ZPFemail").val();
	
	if(ZPFtext=='') {
		return ShowError("Proszę wpisać treść zapytania.");
	}else if(ZPFnazw=='') {
		return ShowError("Proszę wpisać swoje imię lub nick.");
	}if(!checkEmail(ZPFemail)) {
		return ShowError("Proszę poprawnie wpisać swój email.");
	}
	return true;
};

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

function ShowError(txt) {
	var content = '<div id="Question"><div class="txt">'+txt+'</div><div class="butt2"><input type="submit" name="" value="Zamknij" class="Button nyroModalClose" /></div></div>';
	$.nyroModalManual({
		closeButton: '',
		modal: true,
   	bgColor: '#000',
		minHeight: 100,
   	content: content
   });
	return false;
}

function Highter(ile) {
	document.getElementById("Calculator").style.height = ile+"px";
}
function Hightener(ile) {
	document.getElementById("Storage").style.height = ile+"px";
}
