function drukuj() {
self.print();
}

var pkobp_print;
function pageToPrint(link) {
	if (window.open('','pulsbiznesu_print',"scrollbars=1,status=0,menubar=0,toolbar=0,resizable=0,directories=0,height=500,width=656"));
	document.parametrystrony.action=link;
	document.parametrystrony.print.value=1;
	document.parametrystrony.target='pulsbiznesu_print';
	document.parametrystrony.submit();
}

function checkmail (obj) 
{
	var field = obj;
	var str = field.value;
	if (window.RegExp) {
	  var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
	  var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
	  var reg1 = new RegExp(reg1str);
	  var reg2 = new RegExp(reg2str);
	  if (!reg1.test(str) && reg2.test(str)){

		//document.form.submit();
		return 1;
	  }
	  field.focus();
	  field.select();
	  window.alert('Adres e-mail jest nieprawid³owy');
	  return 0;
	} else {
	  if(str.indexOf("@") >= 0)
		return 1;
	  field.focus();
	  field.select();
	  window.alert('Adres e-mail jest nieprawid³owy');
	  return 0;
	}
}

//funkcja checktel zwraca 1 jesli numer telefonu jest ok  
function checktel (obj) 
{
	var field = obj;
	var str = field.value;
	if (window.RegExp) {
	  var reg1str = /^[0-9\+]+/;
	  var reg1 = new RegExp(reg1str);
	  if (reg1.test(str)){

		//document.form.submit();
		return 1;
	  }
	  else
		{
		  field.focus();
		  field.select();
		  window.alert('Podany numer telefonu jest nieprawid³owy');
		  return 0;
		}
	}
	return 0;
}


function verifyEmail(email) {
	emailchecker = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/i;
	return emailchecker.test(email);
}

function verForm()
{
	var imie=document.znajomy.name.value;
	var myemail=document.znajomy.myemail.value;
	var reemail=document.znajomy.reemail.value;
	
	
	if(imie=='' || imie==null)
	{
		window.alert("Wpisz swoje imie i nazwisko");
		document.znajomy.name.focus();
		return false;
	}
	
	if(verifyEmail(myemail)==false)
	{
		window.alert("Podaj prawid³owy swój adres e-mail.\n Poprawny format: uzytkownik@domena.tld ");
		document.znajomy.myemail.focus();
		return false;
	}
	if(verifyEmail(reemail)==false)
	{
		window.alert("Podaj prawid³owy adres e-mail odbiorcy.\n Poprawny format: uzytkownik@domena.tld ");
		document.znajomy.reemail.focus();
		return false;
	}
	return true;
}


/* funkcje do zliczania ilosci  literek w ciagu */

function opisAfter(event){
	a = 3000 - document.getElementById('idopis').value.length;
	
	if (a<0) {
		document.getElementById("idopis").value=document.getElementById('opistresc').value;
		a = 3000 - document.getElementById('idopis').value.length;
	} 
	
	document.getElementById("opistresc").value=document.getElementById('idopis').value;
	
	
	var obj = document.getElementById("opisLimit");
	obj.innerHTML = 'Pozosta³o znaków do wpisania: <b>' + a + '</b>';
	obj.className='';
	return a;
}
		
var checked = true;

function opisBefore(event) {		
	if (!checked) {
		a=opisAfter();
	}
	
	checked = false;
	
	return true;
		
}

	function SprawdzLogin(login)
	{
		if ( login.value.length == 0)
		{
			alert ( 'Nie wype³niono pola: Login');
			login.focus();
			return false;
		} else return true;
	}
	
	function SprawdzStareHaslo(haslo_old)
	{
		if ( haslo_old.value.length == 0)
		{
			alert ( 'Musisz podaæ stare has³o.');
			haslo_old.focus();
			return false;
		} else true;
	}

	function SprawdzHaslo(haslo, haslo_powt)
	{
		if ( haslo.value.length < 5)
		{
			alert ( 'Has³o musi sk³adaæ siê z minimum 5 znaków.');
			haslo.focus();
			return false;
		} else if (haslo.value!=haslo_powt.value) 
		{
			alert('Nie zgadza siê powtórzenie has³a');
			haslo_powt.select();
			return false;
		} else return true;
	}

		function Sprawdz2email(email, email2)
	{
		if (email.value!=email2.value) 
		{
			alert('Nie zgadza siê powtórzenie e-mail\'a');
			return false;
		} else return true;
	}
	
	
	function SprawdzPrenumerata()
	{
		if(document.prenumerata.elements['pb[imie]'].value=='')
		{
			window.alert("Proszê podaæ swoje imiê.");
			document.prenumerata.elements['pb[imie]'].focus();
			return false;
		}
		
		if(document.prenumerata.elements['pb[nazwisko]'].value=='')
		{
			window.alert("Proszê podaæ swoje nazwisko.");
			document.prenumerata.elements['pb[nazwisko]'].focus();
			return false;
		}
		
		if(document.prenumerata.elements['pb[email]'].value=='')
		{
			window.alert("Proszê podaæ adres email.");
			document.prenumerata.elements['pb[email]'].focus();
			return false;
		}
		
		if(verifyEmail(document.prenumerata.elements['pb[email]'].value)==false)
		{
			window.alert("Podaj prawid³owy swój adres e-mail.\n Poprawny format: uzytkownik@domena.tld ");
			document.prenumerata.elements['pb[email]'].focus();
			return false;
		}
		
		if(document.prenumerata.elements['pb[stanowisko]'].value=='')
		{
			window.alert("Proszê podaæ zajmowane stanowisko.");
			document.prenumerata.elements['pb[stanowisko]'].focus();
			return false;
		}
		
		if(document.prenumerata.elements['pb[telefon]'].value=='')
		{
			window.alert("Proszê podaæ nr telefonu.");
			document.prenumerata.elements['pb[telefon]'].focus();
			return false;
		}
		
		if(document.prenumerata.elements['pb[ulica_kontakt]'].value=='')
		{
			window.alert("Proszê podaæ ulicê adresu zamieszkania.");
			document.prenumerata.elements['pb[ulica_kontakt]'].focus();
			return false;
		}
		
		
		if(document.prenumerata.elements['pb[kod_kontakt]'].value=='')
		{
			window.alert("Proszê podaæ kod pocztowy adresu zamieszkania.");
			document.prenumerata.elements['pb[kod_kontakt]'].focus();
			return false;
		}
		
		if(document.prenumerata.elements['pb[miasto_kontakt]'].value=='')
		{
			window.alert("Proszê podaæ miasto adresu zamieszkania.");
			document.prenumerata.elements['pb[miasto_kontakt]'].focus();
			return false;
		}
		
		if(document.prenumerata.elements['pb[nazwa_firmy]'].value=='')
		{
			window.alert("Proszê podaæ nazwê firmy.");
			document.prenumerata.elements['pb[nazwa_firmy]'].focus();
			return false;
		}
		
		if(document.prenumerata.elements['pb[nip]'].value=='')
		{
			window.alert("Proszê podaæ numer NIP.");
			document.prenumerata.elements['pb[nip]'].focus();
			return false;
		}
		
		if(document.prenumerata.elements['pb[ulica]'].value=='')
		{
			window.alert("Proszê podaæ ulicê adresu kontaktowego.");
			document.prenumerata.elements['pb[ulica]'].focus();
			return false;
		}		
				
		if(document.prenumerata.elements['pb[kod]'].value=='')
		{
			window.alert("Proszê podaæ kod pocztowy adresu kontaktowego.");
			document.prenumerata.elements['pb[kod]'].focus();
			return false;
		}
		
		if(document.prenumerata.elements['pb[miasto]'].value=='')
		{
			window.alert("Proszê podaæ miasto adresu kontaktowego.");
			document.prenumerata.elements['pb[miasto]'].focus();
			return false;
		}
		
		if(document.prenumerata.elements['pb[papierowa6mcy]'].value=='0' && document.prenumerata.elements['pb[papierowa12mcy]'].value=='0' && document.prenumerata.elements['pb[elektroniczna6mcy]'].value=='0' && document.prenumerata.elements['pb[elektroniczna12mcy]'].value=='0')
		{
			window.alert("Musisz zamówiæ conajmniej jeden egzemplarz pisma.");			
			return false;
		}
		return true;
	}
	
	function sprawdzKontakt()
	{
		if(document.kontakt.elements['kontakt[subject]'].value=='')
		{
			window.alert("Proszê podaj tytu³ wiadomo¶ci");
			return false;			
		}
		
		if(document.kontakt.elements['kontakt[autor]'].value=='')
		{
			window.alert("Proszê podaj swoje imiê i nazwisko");
			return false;			
		}
		
		if(document.kontakt.elements['kontakt[email]'].value=='')
		{
			window.alert("Proszê podaj swoj adres email");
			return false;			
		}
		
		if(document.kontakt.elements['kontakt[body]'].value=='')
		{
			window.alert("Proszê podaj tre¶æ wiadomo¶ci");
			return false;			
		}
		return true;
	}

