// 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+'');
}

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('Select product details from list!');
		return false;
	}
	if(document.forma.rozmiar && document.forma.rozmiar.value == "")	{
	
		document.forma.rozmiar.focus();
		alert('Select product details from list!');
		return false;
	}
	if(document.forma.kolor && document.forma.kolor.value == "")	{
	
		document.forma.kolor.focus();
		alert('Select product details from list!');
		return false;
	}
	if(document.forma.kolor && document.forma.kolor.value == "")	{
	
		document.forma.kolor.focus();
		alert('Select product details from list!');
		return false;
	}
	if(document.forma.tsukaito && document.forma.tsukaito.value == "")	{
	
		document.forma.tsukaito.focus();
		alert('Select product details from list!');
		return false;
	}
	if(document.forma.samegawa && document.forma.samegawa.value == "")	{
	
		document.forma.samegawa.focus();
		alert('Select product details from list!');
		return false;
	}
	if(document.forma.saya && document.forma.saya.value == "")	{
	
		document.forma.saya.focus();
		alert('Select product details from list!');
		return false;
	}
	if(document.forma.tsuba && document.forma.tsuba.value == "")	{
	
		document.forma.tsuba.focus();
		alert('Select product details from list!');
		return false;
	}
	if(document.forma.hamon && document.forma.hamon.value == "")	{
	
		document.forma.hamon.focus();
		alert('Select product details from list!');
		return false;
	}


	if (document.forma.user_info && !document.forma.user_info.value.length)	{
		document.forma.user_info.value = "Fill this box, too!";
		document.forma.user_info.focus();
		alert('We need some more information from you! Go back to product and fill all required fields!!!');
		return false;
	}
	
	return true;
}

function CheckNewUserForm()	{
	
	if (!document.form.login.value.length)	{

		document.form.login.focus();
		alert('We need your login!');
		return false;
	}

	if (!document.form.passwd.value.length)	{

		document.form.passwd.focus();
		alert('We need your password!');
		return false;
	}

	if (!document.form.passwd2.value.length)	{

		document.form.passwd2.focus();
		alert('We need your password confirm!');
		return false;
	}

	if (!document.form.imie.value.length)	{

		document.form.imie.focus();
		alert('We need your first name!');
		return false;
	}

	if (!document.form.nazwisko.value.length)	{

		document.form.nazwisko.focus();
		alert('We need your last name!');
		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('We need your corect email address!');
		return false;
	}

	if (!document.form.ulica.value.length)	{

		document.form.ulica.focus();
		alert('We need your street name!');
		return false;
	}

	if (!document.form.numer.value.length)	{

		document.form.numer.focus();
		alert('We need your house/flat number!');
		return false;
	}
	if (!document.form.miasto.value.length)	{

		document.form.miasto.focus();
		alert('We need your city name!');
		return false;
	}
	/*
	if (!document.form.state.value.length)	{

		document.form.state.focus();
		alert('We need your state/territory name!');
		return false;
	}
	*/
	if (!document.form.kod.value.length)	{

		document.form.kod.focus();
		alert('We need your post code!');
		return false;
	}
	if (!document.form.kraj.value.length)	{

		document.form.kraj.focus();
		alert('We need your country name!');
		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('We need your name!');
		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('We need your correct email address!');
		return false;
	}

	if (!document.forma.email_1.value.length)	{

		document.forma.email_1.focus();
		alert('We need email address to your friend!');
		return false;
	}

	if (document.forma.email_1.value != ""	&& !emailRegExp.test(document.forma.email_1.value))	{

		document.forma.email_1.focus();
		alert("This email addres isn't correct!");
		return false;
	}

	if (document.forma.email_2.value != ""	&& !emailRegExp.test(document.forma.email_2.value))	{

		document.forma.email_2.focus();
		alert("This email addres isn't correct!");
		return false;
	}

	if (document.forma.email_3.value != ""	&& !emailRegExp.test(document.forma.email_3.value))	{

		document.forma.email_3.focus();
		alert("This email addres isn't correct!");
		return false;
	}
	
	return true;
}

function CheckMailingListForm()	{

	if (!document.forma.imie.value.length)	{

		document.forma.imie.focus();
		alert('We need your first name!');
		return false;
	}
	
	if (!document.forma.nazwisko.value.length)	{

		document.forma.nazwisko.focus();
		alert('We need your last name!');
		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('We need your correct email address!');
		return false;
	}
	
	if(document.forma.zrodlo.value == "")	{
	
		document.forma.zrodlo.focus();
		alert('How did you find us?');
		return false;
	}
	
	if(document.forma.zainteresowania.value == "")	{
	
		document.forma.zainteresowania.focus();
		alert('What interests you?');
		return false;
	}
	
	return true;
}

function CheckMoreOrderForm()	{

	if (!document.forma.imie.value.length)	{

		document.forma.imie.focus();
		alert('We need your name!');
		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('We need your correct email address!');
		return false;
	}

	if (!document.forma.shipping.value.length)	{

		document.forma.shipping.focus();
		alert('Write country of shipping!');
		return false;
	}

	if (!document.forma.produkty.value.length)	{

		document.forma.produkty.focus();
		alert('Write the list of products and quantity!');
		return false;
	}
	
	return true;
}
