/**
	*       Javascript Library
	* -------------------------------
	* www.avatec.pl / biuro@avatec.pl
**/

	function SprawdzFormularz(f) 
	{ 
		if (f.email.value=='') { alert('Nie podałeś/aś adresu e-mail.'); return false; } 
		if ( ((f.email.value.indexOf('@',1))==-1)||(f.email.value.indexOf('.',1))==-1 ) { alert('Podałeś/aś błędny adres e-mail'); return false; } 
		if (f.imie.value=='') { alert('Nie podałeś/aś swojego imienia'); return false; } 
		if (f.pp.checked == false ) { alert('Musisz zgodzić się z Polityką Prywatności.'); return false; } else { return true; } 
	} 
	
	function checkEmail(email)
	{
		var x = email;
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(x)) { return true; }
		else { return false; }
	}

	function checkContactForm(form)
	{
		var msg='';
		if(form.imie.value=='') { msg+='* Wpisz swoje imię\n'; }
		if(form.email.value=='') { msg+='* Podaj swój adres e-mail\n'; }
		if(checkEmail(form.email.value)==false) { msg+='* Składnia adresu e-mail jest nieprawidłowa\n'; }
		if(form.temat.value=='') { msg+='* Podaj temat wiadomości\n'; }
		if(form.wiadomosc.value=='') { msg+='* Pole wiadomość musi zawierać treść\n'; }
		if(msg)
		{
			alert('Wystąpiły błędy\n\n'+msg);
			return false;
		} else { return true; }
	}

/**
	* Sprawdzanie formularza szkoleniowego
**/

	function checkTrainingForm(form)
	{
		var msg='';
		if(form.imie.value=='') { msg+='* Wpisz swoje imię\n'; }
		if(form.nazwisko.value=='') { msg+='* Wpisz swoje nazwisko\n'; }
		if(form.email.value=='') { msg+='* Podaj swój adres e-mail\n'; }
		if(checkEmail(form.email.value)==false) { msg+='* Składnia adresu e-mail jest nieprawidłowa\n'; }
		if(form.telefon.value=='') { msg+='* Wpisz swój numer telefonu\n'; }
		if(isNaN(form.telefon.value)) { msg+='Numer telefonu nie może zawierać liter ani znaków specjalnych\n'; }
		if(form.firma.value==1) {
			if(form.firma_nazwa.value=='') { msg+='* Musisz podać nazwę firmy\n'; }
			if(form.firma_adres.value=='') { msg+='* Musisz podać adres do faktury\n'; }
			if(form.firma_kodpocztowy.value=='') { msg+='* Musisz podać kod pocztowy do faktury\n'; }
			if(form.firma_miejscowosc.value=='') { msg+='* Musisz podać miejscowość do faktury\n'; }
			if(form.firma_nip.value=='') { msg+='* Musisz podać numer NIP twojej firmy\n'; }
			if(form.firma_kodpocztowy.value=='') { msg+='* Kod pocztowy nie może zawierać liter\n'; }
			if(isNaN(form.firma_nip.value)) { msg+='* Nip nie może zawierać liter ani znaków specjalnych\n'; }
		}
		if(msg)
		{
			alert('Wystąpiły błędy\n\n'+msg);
			return false;
		} else { return true; }
	}
	
/**
	* Sprawdzanie formularza szkoleniowego
**/

	function checkPlatnosciForm(form)
	{
		var msg='';
		if(form.first_name.value=='') { msg+='* Musisz podać swoje imię\n'; }
		if(form.last_name.value=='') { msg+='* Musisz podać swoje nazwisko\n'; }
		if(form.email.value=='') { msg+='* Musisz podać swój adres e-mail\n'; }
		if(checkEmail(form.email.value)==false) { msg+='* Składnia adresu e-mail jest nieprawidłowa\n'; }
		if(form.phone.value=='') { msg+='* Musisz podać swój numer telefonu\n'; }
		if(isNaN(form.phone.value)) { msg+='* Numer telefonu nie może zawierać liter ani znaków specjalnych\n'; }
		if(form.pay_type.value=='') { msg+='* Musisz wybrać forme płatności\n'; }
		if(msg)	{
			alert('Wystąpiły błędy w formularzu:\n\n'+msg);
			return false;
		} else { return true; }
	}
	
/**
	* Pokaż/ukryj Layer
**/
	
	function showLayer(id) 
	{
		if (document.all) { eval( "document.all."+id+".style.display = 'block'");	}
		if (document.layers) { 	document.layers[id].display = 'block'; }
		if (document.getElementById &&!document.all) { var hza = document.getElementById(id); hza.style.display = 'block'; }
	}
	
	function hideLayer(id) 
	{
		if (document.all) { eval( "document.all."+id+".style.display = 'none'");	}
		if (document.layers) { 	document.layers[id].display = 'none'; }
		if (document.getElementById &&!document.all) { var hza = document.getElementById(id); hza.style.display = 'none'; }
	}

	function showPodgladKomentarza() 
	{

		if (document.all) { eval( "document.all.podglad.style.display = 'block'");	}
		if (document.layers) { 	document.layers['podglad'].display = 'block'; }
		if (document.getElementById &&!document.all) { hza = document.getElementById('podglad'); hza.style.display = 'block'; }

		if (document.all) { eval( "document.all.komentarz_p.style.display = 'none'");	}
		if (document.layers) { 	document.layers['komentarz_p'].display = 'none'; }
		if (document.getElementById &&!document.all) { hza = document.getElementById('komentarz_p'); hza.style.display = 'none'; }
		
		document.getElementById('tekst_komentarza').innerHTML=document.getElementById('komentarz_input').value;
	
	}
	
	function hidePodgladKomentarza() 
	{
		if (document.all) { eval( "document.all.podglad.style.display = 'none'");	}
		if (document.layers) { 	document.layers['podglad'].display = 'none'; }
		if (document.getElementById &&!document.all) { hza = document.getElementById('podglad'); hza.style.display = 'none'; }

		if (document.all) { eval( "document.all.komentarz_p.style.display = 'block'");	}
		if (document.layers) { 	document.layers['komentarz_p'].display = 'block'; }
		if (document.getElementById &&!document.all) { hza = document.getElementById('komentarz_p'); hza.style.display = 'block'; }
	
	}
	
	
	/*
	function showtime() {
		today = new Date();
		timeLeft = (BigDay.getTime() - today.getTime());
		e_daysLeft = timeLeft / msPerDay;
		daysLeft = Math.floor(e_daysLeft);
		tdays = Math.floor(e_daysLeft);
		e_hrsLeft = (e_daysLeft - daysLeft)*24;
		hrsLeft = Math.floor(e_hrsLeft);
		minsLeft = Math.floor((e_hrsLeft - hrsLeft)*60);
	}

	function Liczebnik( ile, rdzen, konc1, konc2, konc5 ) { 
		var N0, N1, N2, R0;
			N0 = Math.floor( Math.abs( ile ) );
			N1 = N0 % 10;
			N2 = N0 % 100;
			R0 = konc1;
			if (N0 == 1)   R0 = konc1
			else if ((N2 > 4) && (N2 < 22))   R0 = konc5
				else if ((N1 > 1) && (N1 <= 4))   R0 = konc2
					else R0 = konc5;
			return rdzen + R0;
	}
	

	function imascroller() {

		var i, k;
		showtime();
		
		var msg= "   "+Liczebnik( daysLeft, "Został"," ","y ","o " )  +
		daysLeft+Liczebnik( daysLeft, " ","dzien, ","dni, ","dni, " ) +
		hrsLeft +Liczebnik( hrsLeft," godzin", "a","y","" ) +" i "+
		minsLeft+Liczebnik( minsLeft," minut",  "a ","y ","  " )+" do trzeciego tysiąclecia!"+
		"                             ";

		k=(150/msg.length)+1;
		for(i=0;i<=k;i++) msg+=" "+msg;


		document.forms[0].imascroller.value=msg.substring(position,position+300);
	 // set new position
		if (position ++== 300) position = 0;
	 // repeat at entered speed
		id = setTimeout( "imascroller()", 200 ); 
	}
	*/
