
$(document).ready(function(){
	
	$(".lightbox").lightbox();
	
	$("#czas1").datepicker();
	$("#czas2").datepicker();
	
})

function CheckRes(lang) {
	
	errors_pl = new Array(
		"Proszę wpisać swoje imię i nazwisko.",
		"Proszę wpisać swój adres.",
		"Proszę wpisać swój adres email.",
		"Proszę POPRAWNIE wpisać swój email.",
		"Proszę podać czas pobytu.",
		"Data początkowa musi być późniejsza od dzisiejszej.",
		"Data końcowa musi być późniejsza od początkowej.",
		"Proszę wpisać ilość osób.",
		"Proszę wpisać POPRAWNIE ilość osób."
	);
	errors_en = new Array(
		"Please fill in your name and surname",
		"Please fill in your address",
		"Please fill in your e-mail",
		"Please fill in correctly your e-mail",
		"Please fill in how long do you want stay",
		"The entered date occurs after the finish date",
		"The finished date occurs after the enter date",
		"Please fill in the number of adults",
		"Please fill in correctly number of adults" 
	);
	
	if(lang=="en") e = errors_en;
	else e = errors_pl;
	
	var n = $("#name");
	var a = $("#adres");
	var p = $("#phone");
	var m = $("#mail");
	var c1 = $("#czas1").val().split("-");
	var c2 = $("#czas2").val().split("-");
	var o = $("#osoby");
	
	if(n.val().length==0) return ShowError(e[0]);
	if(a.val().length==0) return ShowError(e[1]);
	if(m.val().length==0) return ShowError(e[2]);
	if(!checkEmail(m.val())) return ShowError(e[3]);
	if(c1.length!=3 || c2.length!=3) return ShowError(e[4]);
	var dzis = new Date();
	var d1 = new Date();
	d1.setFullYear(c1[2],(c1[1]-1),c1[0]);
	var d2 = new Date();
	d2.setFullYear(c2[2],(c2[1]-1),c2[0]);
	if(dzis>=d1) return ShowError(e[5]);
	if(d1>=d2) return ShowError(e[6]);
	if(o.val().length==0) return ShowError(e[7]);
	if(isNaN(o.val())) return ShowError(e[8]);
	
	return true;
}

function CheckGB(lang) {

	errors_pl = new Array(
		"Please fill in your name, nick",
		"Please fill in correctly your e-mail",
		"Please fill in message",
		"Please fill in your name",
		"Please fill in your e-mail",
		"Please fill in correctly your e-mail",
		"Please fill in message"
	);
	errors_en = new Array(
		"Proszę wpisać swoje imię, nick.",
		"Proszę POPRAWNIE wpisać swój email.",
		"Proszę wpisać treść.",
		"Proszę wpisać swoje imię.",
		"Proszę wpisać swój email.",
		"Proszę POPRAWNIE wpisać swój email.",
		"Proszę wpisać treść zapytania."
	);
	
	if(lang=="en") e = errors_en;
	else e = errors_pl;
	
	var n = $("#name");
	var m = $("#mail");
	var w = $("#www");
	var t = $("#txt");
	
	if(n.val().length==0) return ShowError(e[0]);
	if(m.val().length>0 && !checkEmail(m.val())) return ShowError(e[1]);
	if(t.val().length==0) return ShowError(e[2]);
	
	return true;
}
function CheckPytanieForm() {
	var i = $("#Name");
	var e = $("#Email");
	var t = $("#Text");
	
	if(i.val().length==0) return ShowError(e[3]);
	if(e.val().length==0) return ShowError(e[4]);
	if(!checkEmail(e.val())) return ShowError(e[5]);
	if(t.val().length==0) return ShowError(e[6]);
	
	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 ShowQuest(txt,who) {
	var content = '<div id="Question"><div class="txt">'+txt+'</div><div class="butt2"><input type="button" value="Tak" class="Button nyroModalClose" onclick="'+who+'()" /> <input type="submit" name="" value="Nie" class="Button nyroModalClose" /></div></div>';
	$.nyroModalManual({
		closeButton: '',
		modal: true,
   	bgColor: '#000',
		minHeight: 100,
   	content: content
   });
	return false;
}

/* ================================================================== */
