 function getXMLHttpRequestObject()
  {
   if (window.XMLHttpRequest)
   {
    return new XMLHttpRequest();
   }
   else if (window.ActiveXObject)
   {
    try
    {
     return new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
     try
     {
      return new ActiveXObject("Microsoft.XMLHTTP");
     }
     catch (e)
     {
      return false;
     }
    }
   }
  }
  
 function sprawdz(theForm)
{
  var error="";
  
  if (theForm.imie.value.length <2)
  {
    theForm.imie.style.backgroundColor='#FF6666';
    error=true;
  }
  else{theForm.imie.style.backgroundColor='';}

  if (theForm.nazwisko.value.length <2)
  {
    theForm.nazwisko.style.backgroundColor='#FF6666';
    error=true;
  }
  else{theForm.nazwisko.style.backgroundColor='';}
  
  
  if(theForm.tema.value=="4" && theForm.tema1.value=="7"){
    if(theForm.pesel.value.length<11)
    {
     theForm.pesel.style.backgroundColor='#FF6666';
     error=true;
    }
    else{theForm.pesel.style.backgroundColor='';}

    if(theForm.pesel.value!=""){
     if(isNaN(theForm.pesel.value)==true){
      theForm.pesel.style.backgroundColor='#FF6666';
      error=true;
     }else{
      theForm.pesel.style.backgroundColor='';
     }
    }
  }
  

 if (theForm.ulica.value.length <3)
  {
    theForm.ulica.style.backgroundColor='#FF6666';
    error=true;
  }
  else{theForm.ulica.style.backgroundColor='';}

if (theForm.budynek.value.length <1)
  {
    theForm.budynek.style.backgroundColor='#FF6666';
    error=true;
  }
  else{theForm.budynek.style.backgroundColor='';}


  if (theForm.miasto.value.length <3)
  {
    theForm.miasto.style.backgroundColor='#FF6666';
    error=true;
  }
  else{theForm.miasto.style.backgroundColor='';}



  if (theForm.mail.value.length <2)
  {
    theForm.mail.style.backgroundColor='#FF6666';
    error=true;
  }
 else{theForm.mail.style.backgroundColor='';}


   if (theForm.mail.value != "")
   {
     if (theForm.mail.value.indexOf('@', 0) == -1)
     {
      theForm.mail.style.backgroundColor='#FF6666';
      alert("Prosze poda poprawny adres e-mail.");
      return (false);
     }
   }
 
   
if(theForm.tema.value=="4" && theForm.tema1.value=="7"){

  if (theForm.tel.value.length <3)
  {
    theForm.tel.style.backgroundColor='#FF6666';
    error=true;
  }
  else{theForm.tel.style.backgroundColor='';}

 if (theForm.symbol_klienta.value.length <3)
  {
    theForm.symbol_klienta.style.backgroundColor='#FF6666';
    error=true;
  }
  else{theForm.symbol_klienta.style.backgroundColor='';}


 if(theForm.adres_swiadczenia_uslugi.checked==false){

  if (theForm.ulica_umowa.value.length <3)
  {
    theForm.ulica_umowa.style.backgroundColor='#FF6666';
    error=true;
  }
  else{theForm.ulica_umowa.style.backgroundColor='';}


  if (theForm.budynek_umowa.value.length <1)
  {
    theForm.budynek_umowa.style.backgroundColor='#FF6666';
    error=true;
  }
  else{theForm.budynek_umowa.style.backgroundColor='';}

  if (theForm.miasto_umowa.value.length <3)
  {
    theForm.miasto_umowa.style.backgroundColor='#FF6666';
    error=true;
  }
  else{theForm.miasto_umowa.style.backgroundColor='';}
  
 }
  
  
  if (theForm.dzien_umowa.value=="")
  {
    theForm.dzien_umowa.style.backgroundColor='#FF6666';
    error=true;
  }
  else{theForm.dzien_umowa.style.backgroundColor='';}
  
  if(theForm.dzien_umowa.value!=""){
     if(isNaN(theForm.dzien_umowa.value)==true || theForm.dzien_umowa.value.length <2){
       theForm.dzien_umowa.style.backgroundColor='#FF6666';
       error=true;
     }
     else{theForm.dzien_umowa.style.backgroundColor='';}
  }
  
  
 if (theForm.miesiac_umowa.value=="")
  {
    theForm.miesiac_umowa.style.backgroundColor='#FF6666';
    error=true;
  }
  else{theForm.miesiac_umowa.style.backgroundColor='';}

  if(theForm.miesiac_umowa.value!=""){
     if(isNaN(theForm.miesiac_umowa.value)==true || theForm.miesiac_umowa.value.length <2){
       theForm.miesiac_umowa.style.backgroundColor='#FF6666';
       error=true;
     }
     else{theForm.miesiac_umowa.style.backgroundColor='';}
  }

  if (theForm.rok_umowa.value=="")
  {
    theForm.rok_umowa.style.backgroundColor='#FF6666';
    error=true;
  }
  else{theForm.rok_umowa.style.backgroundColor='';}

  if(theForm.rok_umowa.value!=""){
     if(isNaN(theForm.rok_umowa.value)==true || theForm.rok_umowa.value.length <4){
       theForm.rok_umowa.style.backgroundColor='#FF6666';
       error=true;
     }
     else{theForm.rok_umowa.style.backgroundColor='';}
  }


 if(theForm.telewizja_reklamacja.checked==false && theForm.internet_reklamacja.checked==false && theForm.telefon_reklamacja.checked==false && theForm.inne_reklamacja.value=="")
  {
    document.getElementById("err_reklamacja").style.display='';
    document.getElementById("err_reklamacja").value='Musisz wybrać którąś z poniższych opcji.';
    error=true;
  }
  else{
    document.getElementById("err_reklamacja").style.display='none';
    document.getElementById("err_reklamacja").value='';
  }

  //////////////////////////////////////////////////////////////////////
 if (theForm.dzien_reklamacja.value=="")
  {
    theForm.dzien_reklamacja.style.backgroundColor='#FF6666';
    error=true;
  }
  else{theForm.dzien_reklamacja.style.backgroundColor='';}

  if(theForm.dzien_reklamacja.value!=""){
     if(isNaN(theForm.dzien_reklamacja.value)==true || theForm.dzien_reklamacja.value.length <2){
       theForm.dzien_reklamacja.style.backgroundColor='#FF6666';
       error=true;
     }
     else{theForm.dzien_reklamacja.style.backgroundColor='';}
  }


  if (theForm.miesiac_reklamacja.value=="")
  {
    theForm.miesiac_reklamacja.style.backgroundColor='#FF6666';
    error=true;
  }
  else{theForm.miesiac_reklamacja.style.backgroundColor='';}

  if(theForm.miesiac_reklamacja.value!=""){
     if(isNaN(theForm.miesiac_reklamacja.value)==true || theForm.miesiac_reklamacja.value.length <2){
       theForm.miesiac_reklamacja.style.backgroundColor='#FF6666';
       error=true;
     }
     else{theForm.miesiac_reklamacja.style.backgroundColor='';}
  }


  if (theForm.rok_reklamacja.value=="")
  {
    theForm.rok_reklamacja.style.backgroundColor='#FF6666';
    error=true;
  }
  else{theForm.rok_reklamacja.style.backgroundColor='';}
  
  if(theForm.rok_reklamacja.value!=""){
     if(isNaN(theForm.rok_reklamacja.value)==true || theForm.rok_reklamacja.value.length <4){
       theForm.rok_reklamacja.style.backgroundColor='#FF6666';
       error=true;
     }
     else{theForm.rok_reklamacja.style.backgroundColor='';}
  }
  
  
  if (theForm.opis_reklamacja.value.length <4)
  {
    theForm.opis_reklamacja.style.backgroundColor='#FF6666';
    error=true;
  }
  else{theForm.opis_reklamacja.style.backgroundColor='';}
  
  if (theForm.oczekiwania_reklamacja.value.length <4)
  {
    theForm.oczekiwania_reklamacja.style.backgroundColor='#FF6666';
    error=true;
  }
  else{theForm.oczekiwania_reklamacja.style.backgroundColor='';}

  if(document.getElementById("zaliczenie_odszk").checked==false && document.getElementById("rach_przelew").checked==false && document.getElementById("adr_przekazu").checked==false)
  {
    document.getElementById("err_przelew").style.display='';
    document.getElementById("err_przelew").value='Musisz wybrać którąś z poniższych opcji.';
    error=true;
  }
  else{
    document.getElementById("err_przelew").style.display='none';
    document.getElementById("err_przelew").value='';
  }


  if(theForm.wybor_przelew.value=="1"){
  
     if (theForm.nazwa_banku.value.length <4)
     {
     theForm.nazwa_banku.style.backgroundColor='#FF6666';
     error=true;
     }
     else{theForm.nazwa_banku.style.backgroundColor='';}
  
    if (theForm.nr_konta.value.length <4)
    {
      theForm.nr_konta.style.backgroundColor='#FF6666';
      error=true;
     }
     else{theForm.nr_konta.style.backgroundColor='';}
     
  }else if(theForm.wybor_przelew.value=="2"){
  
    if (theForm.ulica_przekaz.value.length <4)
    {
      theForm.ulica_przekaz.style.backgroundColor='#FF6666';
      error=true;
     }
     else{theForm.ulica_przekaz.style.backgroundColor='';}
     
     if (theForm.budynek_przekaz.value.length <4)
    {
      theForm.budynek_przekaz.style.backgroundColor='#FF6666';
      error=true;
     }
     else{theForm.budynek_przekaz.style.backgroundColor='';}
     
     if (theForm.miasto_przekaz.value.length <4)
    {
      theForm.miasto_przekaz.style.backgroundColor='#FF6666';
      error=true;
     }
     else{theForm.miasto_przekaz.style.backgroundColor='';}

  }
  
  if(theForm.wyrazam_zgode.checked==false)
  {
     theForm.wyrazam_zgode.style.backgroundColor='#FF6666';
     error=true;
  }else{
    theForm.wyrazam_zgode.style.backgroundColor='';
  }

}else{

if(theForm.tema.value=="3")
{ 
 var liczba=theForm.abonent.value;
  if (isNaN(liczba)==true || liczba=="" || liczba.length <3)
  {
    theForm.abonent.style.backgroundColor='#FF6666';
    document.getElementById('er').style.display='';
    theForm.err.value='Prosze wypelnic pole nr ewidencyjny. Numer widnieje na fakturze pod danymi osobowymi.';        
    error=true;
  }
  else{theForm.abonent.style.backgroundColor=''; document.getElementById('er').style.display='none';}
}


 if (theForm.tresc.value.length <2)
  {
    theForm.tresc.style.backgroundColor='#FF6666';
    error=true;
  }
  else{theForm.tresc.style.backgroundColor='';}

}

  if(error==true)
  {
   alert("Pola oznaczone na czerwono musza zostac wypelnione!");
   return (false);
  }
  else
  {
   return (true);
  }

}

  function select()
  {
  var t=document.getElementById('t').value;
  var e2=document.getElementById('e2').value;
 /* if(t=="1" && e2=="1")
  {
   //document.location.href='http://www.vectra.pl/vectra.php?i=10&j=0&k=0';
   window.open('http://www.vectra.pl/vectra.php?i=10&j=0&k=0','','toolbar=yes,status=yes,location=yes,directories=yes,menubar=yes,scrollbars=yes,resizable=yes,fullscreen=yes,channelmode=yes');
  }
  else
  {  */
      var XMLHttpRequestObject = getXMLHttpRequestObject();
      if(XMLHttpRequestObject)
      {
       var url='';
       var div=null;

       var e3=document.getElementById('e3').value;
       var imie=document.getElementById('im').value;
       var nazwisko=document.getElementById('na').value;
       var mail=document.getElementById('ma').value;
       var tresc=document.getElementById('tr').value;

        if(imie!=0 && nazwisko!=0 && mail!=0 && tresc!=0)
        {
         url="inc/opcja1.php?temat="+t+"&temat1="+e2+"&temat2="+e3+"&imie="+imie+"&nazwisko="+nazwisko+"&mail="+mail+"&tresc="+tresc;
        }
        else
        {
          url="inc/opcja1.php?temat="+t+"&temat1="+e2+"&temat2="+e3;
        }
          var div=document.getElementById('opcja1');
        /* }
         else
         {
          delete XMLHttpRequestObject;
          return;
         }*/

      XMLHttpRequestObject.open("GET",url);
            //XMLHttpRequestObject.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

      XMLHttpRequestObject.onreadystatechange= function()
      {
        if(XMLHttpRequestObject.readyState == 1)
        {
           document.getElementById('komunikat').value="ladowanie...";
        }
        else if(XMLHttpRequestObject.readyState == 4)
        {
          if(XMLHttpRequestObject.status == 200)
          {
           div.innerHTML = XMLHttpRequestObject.responseText;
           document.getElementById('komunikat').value="";

          }
          else
          {
           document.getElementById('komunikat').value="Wystpi problem z zapytaniem.";
          }
         // delete XMLHttpRequestObject;
          XMLHttpRequestObject = false;
        }
      }
     XMLHttpRequestObject.send(null);
    }

  }


function sprawdzOnline(theForm)
{
  var error="";

  if (theForm.imie.value.length <2)
  {
    theForm.imie.style.backgroundColor='#FF6666';
    error=true;
  }
  else{theForm.imie.style.backgroundColor='';}

  if (theForm.nazwisko.value.length <2)
  {
    theForm.nazwisko.style.backgroundColor='#FF6666';
    error=true;
  }
  else{theForm.nazwisko.style.backgroundColor='';}


  if (theForm.miasto.value.length <3)
  {
    theForm.miasto.style.backgroundColor='#FF6666';
    error=true;
  }
  else{theForm.miasto.style.backgroundColor='';}

  if (theForm.telefon.value.length <1)
  {
    theForm.telefon.style.backgroundColor='#FF6666';
    error=true;
  }
  else{theForm.telefon.style.backgroundColor='';}

  if (theForm.mail.value.length <2)
  {
    theForm.mail.style.backgroundColor='#FF6666';
    error=true;
  }
  else{theForm.mail.style.backgroundColor='';}


   if (theForm.mail.value != "")
   {
     if (theForm.mail.value.indexOf('@', 0) == -1)
     {
      theForm.mail.style.backgroundColor='#FF6666';
      alert("Prosze podac poprawny adres e-mail.");
      return (false);
     }
   }

  nazwa = theForm.plik.value;
  nazwa = nazwa.toLowerCase();
  if(nazwa=="") {
    document.getElementById('coment1').style.color='#FF6666';
    error=true;
  }
  if (nazwa.lastIndexOf(".pdf")<0 && nazwa.lastIndexOf(".doc")<0  && nazwa.lastIndexOf(".docx")<0) {
    document.getElementById('coment1').style.color='#FF6666';
    error=true;
  }



   if(error==true)
   {
    //alert("Pola oznaczone na czerwono musza zostac wypelnione!");
     document.getElementById('coment').value='Uwaga! Wszystkie pola musza zostac wypelnione';
     return (false);
   }
   else
   {
    return (true);
   }
}

function pokaz(rok)
{
      var XMLHttpRequestObject = getXMLHttpRequestObject();
      if(XMLHttpRequestObject)
      {
          var r=rok;
          var url='';
          var div=null;
          url="inc/aktualnosci.php?rok="+r;
          var div=document.getElementById('trescAkt');

      XMLHttpRequestObject.open("GET",url);
      XMLHttpRequestObject.onreadystatechange= function()
      {
        if(XMLHttpRequestObject.readyState == 1)
        {
           //document.getElementById('komunikatAkt').value="ladowanie...";
        }
        else if(XMLHttpRequestObject.readyState == 4)
        {
          if(XMLHttpRequestObject.status == 200)
          {
           div.innerHTML = XMLHttpRequestObject.responseText;
           //document.getElementById('komunikatAkt').value="";

          }
          else
          {
           //document.getElementById('komunikatAkt').value="Wystpi problem z zapytaniem.";
          }

          XMLHttpRequestObject = false;
        }
      }
      XMLHttpRequestObject.setRequestHeader('If-Modified-Since', 'Wed, 15 Nov 1995 00:00:00 GMT');
      XMLHttpRequestObject.send(null);
    }
}

function pokaz_spray(rok)
{
      var XMLHttpRequestObject = getXMLHttpRequestObject();
      if(XMLHttpRequestObject)
      {
          var r=rok;
          var url='';
          var div=null;
          url="inc/aktualnosci_spray.php?rok="+r;
          var div=document.getElementById('trescAkt');

      XMLHttpRequestObject.open("GET",url);
      XMLHttpRequestObject.onreadystatechange= function()
      {
        if(XMLHttpRequestObject.readyState == 1)
        {
           //document.getElementById('komunikatAkt').value="ladowanie...";
        }
        else if(XMLHttpRequestObject.readyState == 4)
        {
          if(XMLHttpRequestObject.status == 200)
          {
           div.innerHTML = XMLHttpRequestObject.responseText;
           //document.getElementById('komunikatAkt').value="";

          }
          else
          {
           //document.getElementById('komunikatAkt').value="Wystpi problem z zapytaniem.";
          }

          XMLHttpRequestObject = false;
        }
      }
      XMLHttpRequestObject.setRequestHeader('If-Modified-Since', 'Wed, 15 Nov 1995 00:00:00 GMT');
      XMLHttpRequestObject.send(null);
    }
}

function wiecej(id,w,h) {
	var winleft = (screen.width - w) / 2;
	var wintop = (screen.height - h) / 2;
window.open("inc/wiecej.php?id="+id+"","dane","left="+winleft+",top="+wintop+",width="+w+",height="+h+",scrollbars=0 ,toolbar=no, menubar=0");
}
/*
var NN, IE;

function recognizeBrowser()
        { NN=false;IE=false;
          var str = navigator.userAgent;
          NN = (str.indexOf("Netscape") != -1) ? true : false;
          if(NN)return;
          IE = (str.indexOf("MSIE") != -1) ? true : false;}

function blockMouseIE()
        { if(event.button == 2){return false;}}

function blockMouseNN(evt)
        { if(evt.which == 1){return false;}}

function blockMouseNN2(evt)
        { if(evt.which == 3){return false;}}

recognizeBrowser();
          if(NN){document.captureEvents(Event.MOUSEDOWN); document.onmousedown=blockMouseNN; document.onmouseup=blockMouseNN2;}
          if(IE){document.onmousedown=blockMouseIE;}

  function blockError(){return true;}
window.onerror = blockError;

function blockKeyDownNN(evt)
        { if(evt.which>0){return false}}

function blockKeyDownIE()
        { if(event.keyCode = 17){return false;}}

document.onkeypress=blockKeyDownNN;
if(navigator.userAgent.indexOf("MSIE")!=-1){document.onkeydown=blockKeyDownIE;}; */

function blokada(nr){

  if(nr==1){
    var bl=document.getElementById("adres_sw_usl").checked;
    if(bl==true){
       document.getElementById("ul_umowa").disabled=true;
       document.getElementById("bud_umowa").disabled=true;
       document.getElementById("miesz_umowa").disabled=true;
       document.getElementById("mia_umowa").disabled=true;
       
        document.getElementById("ul_umowa").style.backgroundColor='#FFFFFF';
        document.getElementById("bud_umowa").style.backgroundColor='#FFFFFF';
        document.getElementById("miesz_umowa").style.backgroundColor='#FFFFFF';
        document.getElementById("mia_umowa").style.backgroundColor='#FFFFFF';
        
       document.getElementById("ul_umowa").value=document.getElementById("ul").value;
       document.getElementById("bud_umowa").value=document.getElementById("bud").value;
       document.getElementById("miesz_umowa").value=document.getElementById("miesz").value;
       document.getElementById("mia_umowa").value=document.getElementById("mia").value;
    }else if(bl==false){
       document.getElementById("ul_umowa").disabled=false;
       document.getElementById("bud_umowa").disabled=false;
       document.getElementById("miesz_umowa").disabled=false;
       document.getElementById("mia_umowa").disabled=false;
       document.getElementById("ul_umowa").value='';
       document.getElementById("bud_umowa").value='';
       document.getElementById("miesz_umowa").value='';
       document.getElementById("mia_umowa").value='';
    }
  }else if(nr==2){
     var bl1=document.getElementById("zaliczenie_odszk").checked;
     if(bl1==true){
       document.getElementById("rach_przelew").disabled=true;
       document.getElementById("rach_przelew").checked=false;
       document.getElementById("n_banku").disabled=true;
       document.getElementById("n_konta").disabled=true;
       document.getElementById("n_banku").value='';
       document.getElementById("n_konta").value='';
    }else if(bl1==false){
       document.getElementById("rach_przelew").disabled=false;
       document.getElementById("n_banku").disabled=false;
       document.getElementById("n_konta").disabled=false;
    }
  }else if(nr==3){
     var bl2=document.getElementById("rach_przelew").checked;
     if(bl2==true){
       document.getElementById("n_banku").disabled=false;
       document.getElementById("n_konta").disabled=false;
       document.getElementById("ul_przekaz").disabled=true;
       document.getElementById("bud_przekaz").disabled=true;
       document.getElementById("miesz_przekaz").disabled=true;
       document.getElementById("mia_przekaz").disabled=true;
       document.getElementById("ul_przekaz").value='';
       document.getElementById("bud_przekaz").value='';
       document.getElementById("miesz_przekaz").value='';
       document.getElementById("mia_przekaz").value='';
    }
  }else if(nr==4){
     var bl3=document.getElementById("adr_przekazu").checked;
     if(bl3==true){
       document.getElementById("n_banku").disabled=true;
       document.getElementById("n_konta").disabled=true;
       document.getElementById("n_banku").value='';
       document.getElementById("n_konta").value='';
       document.getElementById("ul_przekaz").disabled=false;
       document.getElementById("bud_przekaz").disabled=false;
       document.getElementById("miesz_przekaz").disabled=false;
       document.getElementById("mia_przekaz").disabled=false;
    }
  }

}
