String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };
var ogolny_wskaznik=0;
function change_color(type){
	if(type==1){
		document.getElementById('1').style.color='#69698c';
		document.getElementById('2').style.color='#69698c';
		document.getElementById('3').style.color='#69698c';
	} else {
		document.getElementById('1').style.color='#FFFFFF';
		document.getElementById('2').style.color='#FFFFFF';
		document.getElementById('3').style.color='#FFFFFF';
	}
}

function change_color2(type){
    var i;
	if(type==1 && (document.getElementById('radio').checked || document.getElementById('radio4').checked)){
	   ogolny_wskaznik=1;
       for(i=1;i<4;i++)
	   {
		document.getElementById(i).style.color='#69698c';
	   }
	} else if(!(document.getElementById('radio').checked || document.getElementById('radio4').checked)){
	   ogolny_wskaznik=0;
       for(i=1;i<4;i++)
	   {
		document.getElementById(i).style.color='#FFFFFF';
       }
	}
}

function ckckform()
{
	var brakuje_danych = false;
	var napis='';
	if((document.getElementById('imie').value).trim()=='')
	{
		brakuje_danych = true;
		napis+='Nie wpisano imienia Klienta\n';
	}
	if((document.getElementById('nip').value).trim()=='')
	{
		brakuje_danych = true;
		napis+='Nie wpisano NIP\n';
	}
	if(!document.getElementById('radio5').checked){
		if((document.getElementById('ulica').value).trim()==''){
			brakuje_danych = true;
			napis+="Nie wpisano nazwy ulicy\n";
		}
		if((document.getElementById('miasto').value).trim()==''){
			brakuje_danych = true;
			napis+="Nie wpisano nazwy miasta\n";
		}
		if((document.getElementById('kod').value).trim()==''){
			brakuje_danych = true;
			napis+="Nie wpisano kodu pocztowego\n";
		}
	}
	if((document.getElementById('nazwisko').value).trim()=='')
	{
		brakuje_danych = true;
		napis+='Nie wpisano nazwiska Klienta\n';
	}
	if((document.getElementById('firma').value).trim()=='')
	{
		brakuje_danych = true;
		napis+='Nie wpisano nazwy firmy\n';
	}
	if((document.getElementById('mail').value).trim()=='')
	{
		brakuje_danych = true;
		napis+='Nie wpisano adresu e-mail\n';
	}
	else
	{
		if(check_email(document.getElementById('mail').value)==false)	
		{
			brakuje_danych = true;
			napis+='Niepoprawna forma adresu e-mail\n';
		}
	}

	if (!brakuje_danych)
		return true;
	else
	{
		alert (napis);
		return false;
	}
	
		
}

function aquasermo_visit()
{
	var brakuje_danych = false;
	var napis='';
	var i;
	var pola = new Array('imie','nazwisko2','stanowisko2','firma2','branza2','ulica2','miasto2','kod2','telefon','telefon_kom','mail','www2','info2');
	for(i=0;i<pola.length;i++)
	{
        if((document.getElementById(pola[i]).value).trim()=='')
    	{
    		brakuje_danych = true;
    		napis+='Prosimy o wypełnienie wszystkich pól formularza.\n';
    		break;
    	}    
    }
    if(!document.getElementById('08').checked && !document.getElementById('09').checked && !document.getElementById('10').checked)
    {
        brakuje_danych = true;
        napis+='Prosimy zaznaczyć co najmniej jeden dzień odwiedzin.\n';
    }
    if (!brakuje_danych)
		return true;
	else
	{
		alert (napis);
		return false;
	}
}

function ckckform2()
{
	var brakuje_danych = false;
	var napis='';
	if((document.getElementById('imie').value).trim()=='')
	{
		brakuje_danych = true;
		napis+='Nie wpisano imienia Klienta\n';
	}
	if((document.getElementById('ulica').value).trim()==''){
			brakuje_danych = true;
			napis+="Nie wpisano nazwy ulicy\n";
	}
	if((document.getElementById('nip').value).trim()=='')
	{
		brakuje_danych = true;
		napis+='Nie wpisano NIP\n';
	}
	if((document.getElementById('miasto').value).trim()==''){
			brakuje_danych = true;
			napis+="Nie wpisano nazwy miasta\n";
	}
	if((document.getElementById('kod').value).trim()==''){
			brakuje_danych = true;
			napis+="Nie wpisano kodu pocztowego\n";
	}
	
	if((document.getElementById('nazwisko').value).trim()=='')
	{
		brakuje_danych = true;
		napis+='Nie wpisano nazwiska Klienta\n';
	}
	if((document.getElementById('firma').value).trim()=='')
	{
		brakuje_danych = true;
		napis+='Nie wpisano nazwy firmy\n';
	}
	if((document.getElementById('mail').value).trim()=='')
	{
		brakuje_danych = true;
		napis+='Nie wpisano adresu e-mail\n';
	}
	else
	{
		if(check_email(document.getElementById('mail').value)==false)	
		{
			brakuje_danych = true;
			napis+='Niepoprawna forma adresu e-mail\n';
		}
	}

	if (!brakuje_danych)
		return true;
	else
	{
		alert (napis);
		return false;
	}
	
		
}

function ckckform3()
{
	var brakuje_danych = false;
	var napis='';
	if((document.getElementById('imie').value).trim()=='')
	{
		brakuje_danych = true;
		napis+='Nie wpisano imienia Klienta\n';
	}
	if((document.getElementById('nip').value).trim()=='')
	{
		brakuje_danych = true;
		napis+='Nie wpisano NIP\n';
	}
	
	if((document.getElementById('nazwisko').value).trim()=='')
	{
		brakuje_danych = true;
		napis+='Nie wpisano nazwiska Klienta\n';
	}
	if((document.getElementById('firma').value).trim()=='')
	{
		brakuje_danych = true;
		napis+='Nie wpisano nazwy firmy\n';
	}
	if((document.getElementById('telefon').value).trim()=='')
	{
		brakuje_danych = true;
		napis+='Nie podano numeru telefonu\n';
	}
	if((document.getElementById('mail').value).trim()=='')
	{
		brakuje_danych = true;
		napis+='Nie wpisano adresu e-mail\n';
	}
	else
	{
		if(check_email(document.getElementById('mail').value)==false)	
		{
			brakuje_danych = true;
			napis+='Niepoprawna forma adresu e-mail\n';
		}
	}
	if(!document.getElementById('radio').checked && !document.getElementById('radio4').checked 
        && !document.getElementById('radio5').checked && !document.getElementById('radio6').checked
        && !document.getElementById('radio7').checked)
    {
        brakuje_danych = true;
        napis += 'Proszę wybrać co najmniej jeden kontakt w sprawie produktu\n';
    }
    if(ogolny_wskaznik)
    {
        	if((document.getElementById('ulica').value).trim()==''){
    			brakuje_danych = true;
    			napis+="Nie wpisano nazwy ulicy\n";
        	}
        	if((document.getElementById('miasto').value).trim()==''){
        			brakuje_danych = true;
        			napis+="Nie wpisano nazwy miasta\n";
        	}
        	if((document.getElementById('kod').value).trim()==''){
        			brakuje_danych = true;
        			napis+="Nie wpisano kodu pocztowego\n";
        	}
    }
	if (!brakuje_danych)
		return true;
	else
	{
		alert (napis);
		return false;
	}
	
		
}

function check_email(email) 
{
   if (email.match(/^[_.a-zA-Z0-9]+([\.%!][_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$/))
   		return true;
   else
    	return false;
	
}
		


