function check_mail()
{
	Wzor=/^[0-9a-zA-Z._-]+\@[0-9a-zA-Z._-]+\.[0-9a-zA-Z.]+$/;
	OK=(Wzor.test(document.email.email.value)==true);
	if (!OK)
	{
		alert ("Niepoprawny adres e-mail!");
		return false;
	}
}

function checkGuestBook_name()
{
	if (document.guest_book.name.value.length < 5)
	{
		formMessage = "Twoje imię / nick powinno zawierać conajmniej 5 znaków!";
		return true;
	}
}
function checkGuestBook_essence()
{
	if (document.guest_book.essence.value.length < 5)
	{
		formMessage = "Treść wpisu powinna składać się z conajmniej 5 znaków!";
		return true;
	}
}
function checkGuestBook()
{
	if ( (checkGuestBook_name()) || (checkGuestBook_essence()) )
	{
		alert(formMessage);
		return false;
	}
	else
	{
		return true;
	}
}

function checkSearch()
{
	if (document.search.search_string.value.length < 3)
	{
		alert ("Wyszukiwana fraza musi zawierać conajmniej 3 znaki!");
		return false;
	}
	else
	{
		return true;
	}
}

function checkSearch_ext()
{
	if (document.search_ext.search_string.value.length < 3)
	{
		alert ("Wyszukiwana fraza musi zawierać conajmniej 3 znaki!");
		return false;
	}
	else
	{
		return true;
	}
}

function displayImage(url,width,height)
{
	newWindow=window.open(url,'newWinidow','width=' + width + ',height='+ height + ',resizable=no, scrollbars=no, menubar=no,status=no,toolbar=no');
	newWindow.focus();
}

function displayWindow(url, width, height)
{
	var Win = window.open(url,'displayWindow','width=' + width + ',height=' + height + ',resizable=no, scrollbars=yes, menubar=no,status=no,toolbar=no');
}

function checkSend_mail_name()
{
	if (document.send_email.name.value.length < 8)
	{
		formMessage = "Proszę podać imię lub nazwiako!";
		return true;
	}
}

function checkSend_mail_name()
{
	if (document.send_email.name.value.length < 8)
	{
		formMessage = "Proszę podać imię lub nazwiako!";
		return true;
	}
}

function checkSend_mail_email()
{
	Wzor=/^[0-9a-zA-Z._-]+\@[0-9a-zA-Z._-]+\.[0-9a-zA-Z.]+$/;
	OK=(Wzor.test(document.send_email.email.value)==true);
	if (!OK)
	{
		formMessage = "Niepoprawny adres e-mail!";
		return true;
	}
}

function checkSend_mail_phone()
{
	if (document.send_email.phone.value.length > 0)
	{
		Wzor=RegExp("^[0-9-+() ]{8,}$");
		OK=(Wzor.test(document.send_email.phone.value)==true); 
		if (!OK)  
		{ 
			formMessage = "Niepoprawny numer telefonu!";
			return true; 
		}
	}
}

function checkSend_mail_message()
{
	if (document.send_email.message.value.length < 20)
	{
		formMessage = "Treść pyania powinna składać się z conajmniej 20 znaków!";
		return true;
	}
}

function checkSend_mail()
{
	if ( (checkSend_mail_name()) || (checkSend_mail_email()) || (checkSend_mail_phone()) || (checkSend_mail_message()) )
	{
		alert(formMessage);
		return false;
	}
	else
	{
		return true;
	}
}

function check_reservation_name()
{
	if (document.reservation.name.value.length < 7)
	{
		formMessage = "Proszę podać imię i nazwisko!";
		return true;
	}
}

function check_reservation_phone()
{
	Wzor=RegExp("^[0-9-() ]{8,}$");
	OK=(Wzor.test(document.reservation.phone.value)==true); 
	if (!OK)  
	{ 
		formMessage = "Niepoprawny lub brak numeru telefonu!\nNumer telefonu najlepiej podać w formacie:\nStacjonarny +48 74 111 11 11\nKomórki +48 501 11 11 11";
		return true; 
	}
}

function check_reservation_mail()
{
	Wzor=/^[0-9a-zA-Z._-]+\@[0-9a-zA-Z._-]+\.[0-9a-zA-Z.]+$/;
	OK=(Wzor.test(document.reservation.email.value)==true);
	if (!OK)
	{
		formMessage = "Brak lub niepoprawny adres e-mail!";
		return true;
	}
}

function check_reservation_from()
{
	Wzor=RegExp("^[0-9-./]{10,10}$");
	OK=(Wzor.test(document.reservation.from_date.value)==true); 
	if (!OK)  
	{ 
		formMessage = "Proszę określić termin rozpoczęcia pobytu!\nData w formacie dd-mm-rrrr";
		return true; 
	}
}

function check_reservation_to()
{
	Wzor=RegExp("^[0-9-./]{10,10}$");
	OK=(Wzor.test(document.reservation.to_date.value)==true); 
	if (!OK)  
	{ 
		formMessage = "Proszę określić termin zakończenia pobytu!\nData w formacie dd-mm-rrrr";
		return true; 
	}
}

function check_reservation_room()
{
	if (document.reservation.room.value.length < 5)
	{
		formMessage = "Proszę określić rodzaj pokoju do rezerwacji!";
		return true;
	}
}

function check_reservation_persons()
{
	Wzor=RegExp("^[0-9]{1,3}$");
	OK=(Wzor.test(document.reservation.persons.value)==true); 
	if (!OK)  
	{ 
		formMessage = "Proszę podać liczbę osób, tylko cyfry!";
		return true; 
	}
}
function check_reservation_code()
{
	sample=RegExp("^[0-9]{6}$");
	if (!sample.test(document.reservation.code.value))
	{ 
		formMessage = "Przepisz kod z obrazka!\nKod zabezpieczający powinien zawierać 6 cyfr.";
		return true;
	} 
}
function check_reservation()
{
	if ( (check_reservation_name()) || (check_reservation_phone()) || (check_reservation_mail()) || (check_reservation_from()) || (check_reservation_to()) || (check_reservation_room()) || (check_reservation_persons()) || (check_reservation_code()))
	{
		alert(formMessage);
		return false;
	}
	else
	{
		return true;
	}
}

function flash(id, kolor, czas, kolor2, czas2)
{
	document.getElementById(id).style.color = kolor;
	setTimeout('flash("' + id + '","' + kolor2 + '",' + czas2 + ',"' + kolor + '",' + czas + ')', czas);
}

function randValue(){
	var rand_value = Math.round(Math.random() * 10000000000000000);
	return rand_value;
}

function webcamDisplay(){
	//return false;
	var webcamImageSrc = 'webcam/skispa_webcam.jpg?' + randValue();
	$('skispa_webcam_img').src = webcamImageSrc;
	$('skispa_webcam_anchor').href = webcamImageSrc;
	initLightbox();
	setTimeout("webcamDisplay();", 50000);
}

