
// zakaldka strona gwna

        function zakladka(num){
        
                switch(num){
                        case 1:
                        document.getElementById("zh1").className = 'zactv';
                        document.getElementById("zh2").className = 'zkl';
                        document.getElementById("ztxt1").className = 'odkryj';
                        document.getElementById("ztxt2").className = 'ukryj';
                        break;
                        case 2:
                        document.getElementById("zh2").className = 'zactv';
                        document.getElementById("zh1").className = 'zkl';
                        document.getElementById("ztxt2").className = 'odkryj';
                        document.getElementById("ztxt1").className = 'ukryj';
                        break;
                        default:
                        document.getElementById("zh1").className = 'zactv';
                        document.getElementById("zh2").className = 'zkl';
                        document.getElementById("ztxt1").className = 'odkryj';
                        document.getElementById("ztxt2").className = 'ukryj';
                        break;
                }
        }
        
        // submenu
        var time = 0;
        function submenu(men){
        clearTimeout(time);
        //document.rel.submenu.style.display = 'none';
        document.getElementById("menu_"+men).className = 'aktiw';
        document.getElementById(men).style.display = 'block';
        }
        
				
        function ukryj(men){
        document.getElementById("menu_"+men).className = '';
                document.getElementById(men).style.display = 'none';
        }
        
        function usunSubmenu(men){
                time = setTimeout("ukryj("+men+")",300);
        }
        function zmienstyl(men){
                document.getElementById("menu_"+men).className = 'aktiw';
        }
        function ukryjstyl(men){
                document.getElementById("menu_"+men).className = '';
        }
        
        // funkcja wywolujaca pliki pdf
        function dokpdf(num,adr){
        window.location="/generate_pdf.php?id="+num+"&adr="+adr;
                        //   window.open("/generate_pdf.php?id="+num,"okno","scrollbars=1,left=10,top=10,screenX=10,screenY=10,width=600,height=400,");
        }
        
      
        
         // funkcja wydruk z modulu aktualnosci
        
        function drukNews(num){
                window.open("/print_news.php?id="+num,"_blank","scrollbars=1,centerscreen=1,toolbar=no,screenX=10,screenY=10,width=600,height=400,");
        }
        
        // funkcja wydruk z modulu edytor html
        
        function drukHtml(num){

                window.open("/print_html.php?id="+num,"_blank","scrollbars=1,centerscreen=1,toolbar=no,screenX=10,screenY=10,width=600,height=400,");
        }
         function drukOsrodek(num){
                window.open("/print_osrodek.php?id="+num,"_blank","scrollbars=1,centerscreen=1,toolbar=no,screenX=10,screenY=10,width=600,height=400,");
        }
        
        function checkform(){
        if (document.getElementById("f1").value == "") {
              alert("Prosz poda nazw firmy.");
              document.getElementById('f1').style.borderColor='red';
              document.getElementById("f1").focus();
        return false;
        }
        else{
        document.getElementById('f1').style.borderColor='';
        }
        if (document.getElementById("f2").value == "") {
              alert("Prosz poda numer NIP, prawidowy format to: 1234567890.");
              document.getElementById('f2').style.borderColor='red';
              document.getElementById("f2").focus();
        return false;
        }
        else{
        document.getElementById('f2').style.borderColor='';
        }
       
        if (document.getElementById("f4").value == "") {
              alert("Prosz poda nazw miasta w ktrym siedzib ma Pastwa firma.");
              document.getElementById('f4').style.borderColor='red';
              document.getElementById("f4").focus();
        return false;
        }
        else{
        document.getElementById('f4').style.borderColor='';
        }
        if (document.getElementById("f5").value == "") {
              alert("Prosz poda nazw ulicy i nr przy jakiej znajduj si Pastwa firma.");
              document.getElementById('f5').style.borderColor='red';
              document.getElementById("f5").focus();
        return false;
        }
        else{
        document.getElementById('f5').style.borderColor='';
        }
        if (document.getElementById("f6").value == "") {
              alert("Prosz poda kod pocztowy.");
              document.getElementById('f6').style.borderColor='red';
              document.getElementById("f6").focus();
        return false;
        }
        else{
        document.getElementById('f6').style.borderColor='';
        }
    
       
       
        if (document.getElementById("f11").value == "") {
              alert("Prosz poda imi i nazwisko osoby kontaktowej.");
              document.getElementById('f11').style.borderColor='red';
              document.getElementById("f11").focus();
        return false;
        }
        else{
        document.getElementById('f11').style.borderColor='';
        }
        if (document.getElementById("f12").value == "") {
              alert("Prosz poda adres e-mail osoby kontaktowej.");
              document.getElementById('f12').style.borderColor='red';
              document.getElementById("f12").focus();
        return false;
        }
        else{
        document.getElementById('f12').style.borderColor='';
        }
        if (document.getElementById("f13").value == "") {
              alert("Prosz poda nr telefonu osoby kontaktowej.");
              document.getElementById('f13').style.borderColor='red';
              document.getElementById("f13").focus();
        return false;
        }
        else{
        document.getElementById('f13').style.borderColor='';
        }
        }
        
        function otworz(url, w, h){
        window.open(url,"okno","scrollbars=1,left=10,top=10,screenX=10,screenY=10,resizable=1,width="+w+",height="+h+",");
        }
        
        function rezerwacjaSzkolenia(idsz,nip,os){
      
        window.open("/rezerwacja.php?id="+idsz+"&nip="+nip+"&os="+os,"okno","scrollbars=1,left=10,top=10,screenX=10,screenY=10,width=500,height=600,");
        }
        
        
function JSClock() {
   var time = new Date()
   var hour = time.getHours()
   var minute = time.getMinutes()
   var second = time.getSeconds()
   var temp = "" + ((hour > 12) ? hour - 12 : hour)
   if (hour == 0)
      temp = "12";
   temp += ((minute < 10) ? "0" : "") + minute
   temp += ((second < 10) ? "0" : "") + second
   //temp += (hour >= 12) ? " P.M." : " A.M."
   return temp
}


// personalizacja


function selPowiat(){
	
 p = document.getElementById("wybranypwt").value;
  num = document.getElementById("woj").value;
	getData('/ajax/powiat.php?id='+num+'&wp='+p, 'Spowiat');
}

function podkategoria(id,licznik,ile){

	num = document.getElementById("kategoria_"+id).value;

	
		getData('/ajax/podkategoria.php?id='+num+'&licznik='+licznik+'&ile='+ile+'&ktore='+id, 'podkat_'+id+'_'+licznik);

}

function IleWynikow(){
	
		woj = document.getElementById("id_woj").value;
		pow = document.getElementById("id_powiat").value;
		kat = document.getElementById("id_kat").value;
		miast = document.getElementById("miasto").value;
		firm = document.getElementById("firma").value;
		sl = document.getElementById("slowo").value;
		podkat = document.getElementById("podkategoria").value;
		
	getData2('/ajax/IleFirm.php?woj='+woj+'&powiat='+pow+'&kat='+kat+'&miasto='+miast+'&firma='+firm+'&slowo='+sl+'&pk='+podkat+'&t='+JSClock(), 'ileWynikow');

}


// ogłoszenia

function IleWynikow2(){
	
		woj = document.getElementById("id_woj").value;
		pow = document.getElementById("id_powiat").value;
		slowoogl = document.getElementById("id_slowo").value;
		rodzajogl = document.getElementById("id_rodzaj").value;

		
	getData2('/ajax/IleOgloszen.php?woj='+woj+'&powiat='+pow+'&slowo='+slowoogl+'&rodzaj='+rodzajogl+'&t='+JSClock(), 'ileWynikow');
}

function firmaDodajDoKontakt(num){

	getData2('/ajax/addKontakt.php?Id='+num+'&t='+JSClock(), 'komWpis');
	
	setTimeout("ukryj('komWpis')",4000);

}

function ukryj(men){
			document.getElementById(men).innerHTML = '';
}


function adZestawienie(num){
	getData2('/ajax/addZestawienie.php?Id='+num+'&t='+JSClock(), 'zestawienie_'+num);
	PokazZestawienie();
	setTimeout("ukryj('zestawienie_"+num+"')",4000);
}


function adZestawienieWpis(num){
	getData2('/ajax/addZestawienie.php?Id='+num+'&t='+JSClock(), 'komWpis');
	PokazZestawienie();
	setTimeout("ukryj('komWpis')",4000);
}



function PokazZestawienie(){
	getData('/ajax/pokazZestawienie.php?t='+JSClock(), 'pZestaw');
}



function sprawdz() {
			 wartosc = "&pk="; 
			 j = 0;
			 podkategorie = document.getElementsByName("branza[]");
			 for (i=0;i<podkategorie.length;i++) {
					if (podkategorie[i].checked==true) {
						 if (j > 0)
								wartosc += ",";  
						 wartosc += podkategorie[i].value;
						 j++;
					}
			 }                         
			 //alert(wartosc);
			 document.getElementById("podkategoria").value=wartosc;
			IleWynikow();
}

function sprawdzaj(){

				if(confirm("Jeste¶ pewien, że chcesz usun±ć zaznaczone pozycje?"))
          {
          return true;
          }
					else{
					return false;
					}

}

function markAllRows( container_id ) {
    var rows = document.getElementById(container_id).getElementsByTagName('input');
    var unique_id;
    var checkbox;

    for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
         
            if ( checkbox.disabled == false ) {
                checkbox.checked = true;
               
            }
        }
    }

    return true;
}

function pokazDiv(num){
        if(document.getElementById(num).style.display == 'block'){
         document.getElementById(num).style.display = 'none';
        }
        else{
         document.getElementById(num).style.display = 'block';
        }
}

