
function sprawdz_form(){

 ok        = true;
 komunikat = ''
  
 nazwisko  = $('nazwisko_they').value;
 email     = $('email_they').value;
 tel       = $('tel_they').value;
 tresc     = $('tresc_they').value;                              
 
 if((tresc.length<1))
 {
  ok        = false
  komunikat = ($('wersjaJezykowa').value=='pl')?'Podaj treść wiadomości':'Enter your message';
 }
 
 if(!email.match(/@/) || (email.length>40))
 {
  ok        = false;
  komunikat = ($('wersjaJezykowa').value=='pl')?'Podaj e-mail':'Enter your e-mail';
 }
 
 if((nazwisko.length<1) || (nazwisko.length>30))
 {
  ok        = false;
  komunikat = ($('wersjaJezykowa').value=='pl')?'Podaj imię i nazwisko':'Enter your name';
 }
 
 if(tel.length>30){
 ok        = false; 
 komunikat = ($('wersjaJezykowa').value=='pl')?'Podaj poprawny telefon':'Please enter a valid phone';

 }
  
 if(!ok)
 {
   alert(komunikat)
 }
 
 return(ok)
}


function pokaz_info(id)
{
  Effect.SlideDown('ukryty_info_'+id, { queue: 'end' })
  

}

function zamknij_info(id)
{
 element = 'ukryty_info_'+id;
   Effect.Fold(element, { queue: 'end' });  
}

function wyslijFormKontakt(form){

	wynik	=	$A(form.getElementsByTagName('input'))
	var ok	=	true;
	wynik.each(function(element){
		if(element.className!='puste'){
			if(element.className=='regulamin' && !element.checked){
				$$('div.headerTop div.regulamin')[0].style.color='#f11111'
				regul	=	true
			}else{
				wyn	=	walidujPole(element.className,element.value)
				regul	=	false
				if($$('div.headerTop div.regulamin')[0]){
					$$('div.headerTop div.regulamin')[0].style.color='#000'
				}
			}
			element.style.border = (wyn)?"1px solid #d2d6d7":"1px solid #f11111";
			ok	=	ok && wyn
		}
	})
	if(!ok){
		if(regul){
			if($('wersjaJezykowa').value=='pl'){
				alert('Musisz zaakceptować regulamin')
			 }else{
				alert('You must accept the rules')
			 }
		}else{
		 if($('wersjaJezykowa').value=='pl'){
			alert('Popraw zaznaczone pola')
		 }else{
			alert('Please correct the fields marked')
		 }
		}
	}
	return ok;
}
function walidujPole(klasa, warto){
	ok	=	true
	switch(klasa){
		case 'niepuste':
			if(warto.length<2 || warto.length>30){
			 ok=false;
			}
		break;
		case 'email':
			 ok = (warto.match(/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/) != null);
		break;
		case 'telefon':
			ok = (warto.match(/^[0-9\-\+ ]{9,20}$/) != null);	
		break;
	}
	return ok
}

		 
