﻿var test;
function checkContact(){

var    form=document.getElementById('form_kontakt');
var    opis=document.getElementById('form_kont_textarea');    
var    name=document.getElementById('nazwa');
var    dzial=document.getElementById('dzial');
var    email=document.getElementById('email');
    
    if(dzial.value=='0'){
	alert ("Wybierz Dzial !");
	return false;
    }
    if (name.value=='' || name.value=='Podaj imię i nazwisko'){
	alert('Podaj imię i nazwisko !');
	return false;
    }
    if(!checkemail(email.value))
	return false;
    if(opis.value=='' || opis.value=='Zadaj pytanie'){
	alert('Zadaj pytanie !');
	return false;
    }
	
var wysylanie=document.getElementById('wysylanie_kon');
wysylanie.style.visibility = 'visible';
	
	form.submit();
}


function checkContact2(){

var    form=document.getElementById('form_kontakt');
var    opis=document.getElementById('form_kont_textarea');    
var    name=document.getElementById('nazwa');
var    email=document.getElementById('email');
var    regulamin=document.getElementById('regulamin');
var    zgoda=document.getElementById('zgoda');
    
    if (name.value=='' || name.value=='Podaj imię i nazwisko'){
	alert('Podaj imię i nazwisko !');
	return false;
    }
    if(!checkemail(email.value))
	return false;
    if(opis.value=='' || opis.value=='Twoja propozycja hasła dla British School'){
	alert('Podaj swoją propozycję hasła dla British School');
	return false;
    }
    if(!regulamin.checked){
	alert('Musisz zaakceptować regulamin');
	return false;
    }
    if(!zgoda.checked){
	alert('Musisz wyrazić zgodę na otrzymywanie informacji handlowych');
	return false;
    }
    
	
var wysylanie=document.getElementById('wysylanie_kon');
wysylanie.style.visibility = 'visible';
	
	form.submit();
}

function checkKurs(){

var    form=document.getElementById('form_kontakt');
var    kod=document.getElementById('kod');    
var    gg=document.getElementById('gg');    
var    name=document.getElementById('nazwa');
var    email=document.getElementById('email');
    

    if (name.value=='' || name.value=='Podaj imię i nazwisko'){
	alert('Podaj imię i nazwisko !');
	return false;
    }
    if(!checkemail(email.value))
	return false;

    if(kod.value!='Kod Pocztowy' && !chceckKod(kod.value))
	return false;
	
    if(gg.value!='GG' && !chceckGG(gg.value))
	return false;
    if(!checkemail(email.value))
	return false;


var wysylanie=document.getElementById('wysylanie_kon');
wysylanie.style.visibility = 'visible';
	
	form.submit();
}

function checkKod(src){
 var regex = /^[0-9]{2}\-[0-9]{3}$/;
 if(regex.test(src)){
    return true;
 }else{
    alert("Podaj poprawny kod");
    return false;
 }
}

function checkGG(src){
  var regex = /^[0-9]{1,10}$/;
  if(regex.test(src)){
    return true;
  }else{
    alert("Podaj poprawny numer GG");
    return false;
  }
}

function checkemail(email){

var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(email))
    test=true;
else{
    alert("Podaj poprawny adres email !");
    test=false;
}
return (test);
}

function checkPolec(){

var form=document.getElementById('polec_form_id');
var your_email=document.getElementById('your_email');
var email=document.getElementById('email');



if(!checkemail(your_email.value))
    return false;
if(!checkemail(email.value))
    return false;
    
  
var wysylanie=document.getElementById('wysylanie');
wysylanie.style.visibility = 'visible';
    
form.submit();
    
    

}



