function CheckForm(aSender)
	{
	var Element;

	if(!CheckNip(document.getElementById("Nip").value))
	  {
		alert("Należy podać prawidłowy numer NIP.");
		return false;
	  }

	Element = document.getElementById("AcceptContract");
	if((Element != undefined) && (!Element.checked))
		{
		alert("Aby wysłać formularz należy zaakceptować warunki umowy serwisowej.");
		return false;
		}
		
	return true;
	}
	


function AcceptContract(aSender)
	{
//	alert("OK");
	}
	
	
	
function Popup(aSender, aUrl)
	{
	if((aUrl == undefined) && (aSender.tagName == "A"))
	  {
		aUrl = aSender.href;
	  }
	window.open(aUrl, "Umowa", "status=0,toolbar=0,location=0,menubar=0,scrollbars=1,resizable=1");
	return false;
	}
	
	
	
function ContractAccepted(aSender, aState)
	{
	if(gMode == 1)
	  {
	  var OwnerWindow;
	  OwnerWindow = aSender.ownerDocument.parentWindow;
	  if(!OwnerWindow) OwnerWindow = aSender.ownerDocument.defaultView;
	  OwnerWindow = OwnerWindow.opener;
	  if(aState)
	    {
		  var Element = OwnerWindow.document.getElementById("AcceptContract");
		  Element.checked = true;
		  }
		else
		  {
		  OwnerWindow.location = aSender.href;
		  }
		window.close();
		return false;
	  }
	return true;
	}



function CheckNip(aValue)
	{
  aValue = aValue.replace(/[\s-]/g,'');
  if(aValue.search(/x$/i) != -1) return true;
  if(aValue.length != 10) return false;
  var lWeights = "657234567";
  var lSum = 0;
  for(var i=0;i<9;++i)
    {
    lSum += (parseInt(lWeights.charAt(i)) * parseInt(aValue.charAt(i)));
    }
	return ((lSum % 11) == aValue.charAt(9));
	}