// JavaScript Document
var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbars=1,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

var popUpGall=0;
function popUpGallery(URLStr, left, top, width, height)
{
  if(popUpGall)
  {
    if(!popUpGall.closed) popUpGall.close();
  }
  popUpGall = open(URLStr, 'popUpGall', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbars=1,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

var popUpGallPict=0;
function popUpGalleryPicture(URLStr, left, top, width, height)
{
  if(popUpGallPict)
  {
    if(!popUpGallPict.closed) popUpGallPict.close();
  }
  popUpGallPict = open(URLStr, 'popUpGallPict', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbars=1,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}





function popUpProdukt(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'produkt', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbars=1,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function popUpMoreOrder(URLStr, left, top, width, height)	{
  
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'MoreOrder', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function popUpForgotEmail(URLStr, left, top, width, height)	{
  
  if(popUpWin)	{

    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'ForgotEmail', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function check()	{

	if(document.forma.dodatek && document.forma.dodatek.value == "")	{
	
		document.forma.dodatek.focus();
		alert('Wybierz dane produktu z listy!');
		return false;
	}
	if(document.forma.rozmiar && document.forma.rozmiar.value == "")	{
	
		document.forma.rozmiar.focus();
		alert('Wybierz dane produktu z listy!');
		return false;
	}
	if(document.forma.kolor && document.forma.kolor.value == "")	{
	
		document.forma.kolor.focus();
		alert('Wybierz dane produktu z listy!');
		return false;
	}
	
	if(document.forma.saya && document.forma.saya.value == "")	{
	
		document.forma.saya.focus();
		alert('Wybierz dane produktu z listy!');
		return false;
	}
	if(document.forma.samegawa && document.forma.samegawa.value == "")	{
	
		document.forma.samegawa.focus();
		alert('Wybierz dane produktu z listy!');
		return false;
	}
	if(document.forma.tsuba && document.forma.tsuba.value == "")	{
	
		document.forma.tsuba.focus();
		alert('Wybierz dane produktu z listy!');
		return false;
	}
	if(document.forma.hamon && document.forma.hamon.value == "")	{
	
		document.forma.hamon.focus();
		alert('Wybierz dane produktu z listy!');
		return false;
	}
	if(document.forma.tsukaito && document.forma.tsukaito.value == "")	{
	
		document.forma.tsukaito.focus();
		alert('Wybierz dane produktu z listy!');
		return false;
	}

	if (document.forma.user_info && !document.forma.user_info.value.length)	{
		document.forma.user_info.value = "Wypełnij również to pole!";
		document.forma.user_info.focus();
		alert('Ten produkt wymaga jeszcze dodatkowych informacji. Wypełnij wszystkie niezbędne pola!!!');
		return false;
	}
	
	return true;
}

function CheckNewUserForm()	{
	
	if (!document.form.login.value.length)	{

		document.form.login.focus();
		alert('Podaj swój login!');
		return false;
	}

	if (!document.form.passwd.value.length)	{

		document.form.passwd.focus();
		alert('Podaj swoje hasło!');
		return false;
	}

	if (!document.form.passwd2.value.length)	{

		document.form.passwd2.focus();
		alert('Podaj potwierdzenie hasła!');
		return false;
	}

	if (!document.form.imie.value.length)	{

		document.form.imie.focus();
		alert('Podaj swoje imię!');
		return false;
	}

	if (!document.form.nazwisko.value.length)	{

		document.form.nazwisko.focus();
		alert('Podaj swoje nazwisko!');
		return false;
	}
	
	var emailRegExp = /^[A-Za-z0-9._\-]+@(([A-Za-z]\.)|([A-Za-z0-9][A-Za-z0-9\-]+\.))+[A-Za-z]+$/;
	
	if (!emailRegExp.test(document.form.email.value))	{

		document.form.email.focus();
		alert('Podaj prawidłowo swój adres email!');
		return false;
	}

	if (!document.form.ulica.value.length)	{

		document.form.ulica.focus();
		alert('Podaj ulicę!');
		return false;
	}

	if (!document.form.numer.value.length)	{

		document.form.numer.focus();
		alert('Podaj numer domu/mieszkania!');
		return false;
	}
	if (!document.form.miasto.value.length)	{

		document.form.miasto.focus();
		alert('Podaj nazwę miejscowości!');
		return false;
	}
	if (!document.form.kod.value.length)	{

		document.form.kod.focus();
		alert('Podaj kod pocztowy!');
		return false;
	}
	if (!document.form.kraj.value.length)	{

		document.form.kraj.focus();
		alert('Podaj nazwę kraju!');
		return false;
	}
	return true;
}

function ConfirmOperation(text)	{

	if(!document.form.zgoda.checked)
		return confirm(text);
}

function CheckRecommendForm()	{

	if (!document.forma.imie.value.length)	{

		document.forma.imie.focus();
		alert('Podaj swoje imię!');
		return false;
	}
	
	var emailRegExp = /^[A-Za-z0-9._\-]+@(([A-Za-z]\.)|([A-Za-z0-9][A-Za-z0-9\-]+\.))+[A-Za-z]+$/;
	
	if (!emailRegExp.test(document.forma.email.value))	{

		document.forma.email.focus();
		alert('Podaj prawidłowo swój adres email!');
		return false;
	}

	if (!document.forma.email_1.value.length)	{

		document.forma.email_1.focus();
		alert('Podaj przynajmniej jeden adres email!');
		return false;
	}

	if (document.forma.email_1.value != ""	&& !emailRegExp.test(document.forma.email_1.value))	{

		document.forma.email_1.focus();
		alert('Podany adres email jest nieprawidłowy!');
		return false;
	}

	if (document.forma.email_2.value != ""	&& !emailRegExp.test(document.forma.email_2.value))	{

		document.forma.email_2.focus();
		alert('Podany adres email jest nieprawidłowy!');
		return false;
	}

	if (document.forma.email_3.value != ""	&& !emailRegExp.test(document.forma.email_3.value))	{

		document.forma.email_3.focus();
		alert('Podany adres email jest nieprawidłowy!');
		return false;
	}
	
	return true;
}

function CheckMailingListForm()	{

	if (!document.forma.imie.value.length)	{

		document.forma.imie.focus();
		alert('Podaj swoje imię!');
		return false;
	}
	
	if (!document.forma.nazwisko.value.length)	{

		document.forma.nazwisko.focus();
		alert('Podaj swoje nazwisko!');
		return false;
	}
	
	var emailRegExp = /^[A-Za-z0-9._\-]+@(([A-Za-z]\.)|([A-Za-z0-9][A-Za-z0-9\-]+\.))+[A-Za-z]+$/;
	
	if (!emailRegExp.test(document.forma.email.value))	{

		document.forma.email.focus();
		alert('Podaj prawidłowy adres e-mail!');
		return false;
	}
	
	if(document.forma.zrodlo.value == "")	{
	
		document.forma.zrodlo.focus();
		alert('Skąd dowiedziałe(a)ś się o Budostuff?');
		return false;
	}
	
	if(document.forma.zainteresowania.value == "")	{
	
		document.forma.zainteresowania.focus();
		alert('Jaką sztukę uprawiasz, lub interesujesz się?');
		return false;
	}
	
	return true;
}

function CheckMoreOrderForm()	{

	if (!document.forma.imie.value.length)	{

		document.forma.imie.focus();
		alert('Podaj swoje imię!');
		return false;
	}
	
	var emailRegExp = /^[A-Za-z0-9._\-]+@(([A-Za-z]\.)|([A-Za-z0-9][A-Za-z0-9\-]+\.))+[A-Za-z]+$/;
	
	if (!emailRegExp.test(document.forma.email.value))	{

		document.forma.email.focus();
		alert('Podaj prawidłowo swój adres email!');
		return false;
	}

	if (!document.forma.shipping.value.length)	{

		document.forma.shipping.focus();
		alert('Podaj kraj wysyłki!');
		return false;
	}

	if (!document.forma.produkty.value.length)	{

		document.forma.produkty.focus();
		alert('Podany interesujące Cię produkty!');
		return false;
	}
	
	return true;
}



/*	strona z dodawanie linkow	*/

function CheckLinkForm()	{


	if (!document.form.nazwa.value.length)	{

		document.form.nazwa.focus();
		alert('Podaj nazwę strony.');
		return false;
	}
	/*
	var GifRegExp = /^(.)+(\.)(gif|GIF)+$/;
	var JpgRegExp = /^(.)+(\.)(jpg|JPG)+$/;

	if (!GifRegExp.test(document.form.plik.value) && !JpgRegExp.test(document.form.plik.value))	{

		document.form.plik.focus();
		alert('Podaj ścieżkę dostępu do pliku gif lub jpg!');
		return false;
	}
	*/
	if (!document.form.link.value.length)	{

		document.form.link.focus();
		alert('Podaj adres strony.');
		return false;
	}
	
	var emailRegExp = /^[A-Za-z0-9._\-]+@(([A-Za-z]\.)|([A-Za-z0-9][A-Za-z0-9\-]+\.))+[A-Za-z]+$/;
	
	if (!emailRegExp.test(document.form.email.value))	{

		document.form.email.focus();
		alert('Podaj prawidłowo swój adres email!');
		return false;
	}
	
	return true;
}
