var min=8;
var max=18;
function increaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}
function decreaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }   
}

//poleć dokument
var xmlHttp = createXmlHttpRequestObject(); 
function createXmlHttpRequestObject() 
{
  var xmlHttp;
  if(window.ActiveXObject)
  {
    try
    {
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (e) 
    {
      xmlHttp = false;
    }
  }
  else
  {
    try 
    {
      xmlHttp = new XMLHttpRequest();
    }
    catch (e) 
    {
      xmlHttp = false;
    }
  }
  if (!xmlHttp)
    alert("Błąd podczas tworzenia obiektu XMLHttpRequest.");
  else 
    return xmlHttp;
}

function success_handler(o) {
			replace_html('ddwyslijdoz', o.responseText);
}

function failure_handler(o) {
			replace_html('ddwyslijdoz', 'Brak połączenia z serwerem.');
}


function dokalendarza(id) {
show_progressbar('callendar');
  if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
  {
	xmlHttp.open("GET", "web/php/phpjs.php?ic=kalendarzyk&idd=" + id, true);  
    xmlHttp.onreadystatechange = function() {
		
	  if (xmlHttp.readyState == 4) 
  {
    if (xmlHttp.status == 200) 
    {
      helloMessage = xmlHttp.responseText;
      document.getElementById("callendar").innerHTML = helloMessage;
    } 
    else 
    {
      alert("Wystapil blad podczas uzyskiwania dostepu do serwera: " + xmlHttp.statusText);
    }
  }	
	}
	
    xmlHttp.send(null);	
  }
}

function dokalendarzapoziom(nnr,id,komm) {
show_progressbar("kalendarzpoziom"+nnr);
  if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
  {
	xmlHttp.open("GET", "web/php/phpjs.php?ic=kalendarzpoziom&nnr=" + nnr + "&idd=" + id + "&komm=" + komm, true);  
    xmlHttp.onreadystatechange = function() {
		
	  if (xmlHttp.readyState == 4) 
  {
    if (xmlHttp.status == 200) 
    {
      helloMessage = xmlHttp.responseText;
      document.getElementById("kalendarzpoziom"+nnr).innerHTML = helloMessage;
    } 
    else 
    {
      alert("Wystapil blad podczas uzyskiwania dostepu do serwera: " + xmlHttp.statusText);
    }
  }	
	}
	
    xmlHttp.send(null);	
  }
}

function wyslijdokdo(id) {
document.getElementById('wyslijdoz').style.display='block';
show_progressbar('ddwyslijdoz');
  if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
  {
    xmlHttp.open("GET", "web/polec/send1.php?id=" + id, true);  
    xmlHttp.onreadystatechange = handleServerResponse;
    xmlHttp.send(null);
  }
  else {
    setTimeout('wyslijdokdo(id)', 1000);
}
}

function handleServerResponse() 
{
  if (xmlHttp.readyState == 4) 
  {
    if (xmlHttp.status == 200) 
    {
      helloMessage = xmlHttp.responseText;
	  //replace_html('ddwyslijdoz', helloMessage);
      document.getElementById("ddwyslijdoz").innerHTML = helloMessage;
    } 
    else 
    {
      alert("Wystąpił błąd podczas uzyskiwania dostępu do serwera: " + xmlHttp.statusText);
    }
  }
}
function zamknijdd(jakisd) {
document.getElementById(jakisd).style.display='none';
}
function replace_html(coz, content) {
document.getElementById(coz).innerHTML = content;
}
function show_progressbar(coz) {
replace_html(coz, '<img src="../img/loader4.gif" border="0" alt="Trwa ładowanie danych..." />');
}
function zamknijdd() {
document.getElementById('wyslijdoz').style.display='none';
}
var progress_bar = new Image();
progress_bar.src = '../img/loader4.gif';

function senddokdo(id,dzial,tytul,imie,nadawca,odbiorca,tresc) {
document.getElementById('wyslijdoz').style.display='block';
show_progressbar('ddwyslijdoz');
if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
  {
	
xmlHttp.open("GET", "web/polec/send2.php?id=" + id + "&dzial=" + dzial + "&tytul=" + tytul + "&imie=" + imie + "&nadawca=" + nadawca + "&odbiorca=" + odbiorca + "&tresc=" + tresc, true);
    xmlHttp.onreadystatechange = sendServerResponse;
    xmlHttp.send(null);
  }
  else {
    setTimeout('senddokdo()', 1000);
}
}

function sendServerResponse() 
{
  if (xmlHttp.readyState == 4) 
  {
    if (xmlHttp.status == 200) 
    {
      helloMessage = xmlHttp.responseText;
	  //replace_html('ddwyslijdoz', helloMessage);
      document.getElementById("ddwyslijdoz").innerHTML = helloMessage;
    } 
    else 
    {
      alert("Wystąpił błąd podczas uzyskiwania dostępu do serwera: " + xmlHttp.statusText);
    }
  }
}


function pokazpaging(nnr,uss,id,querry) {
show_progressbar('listapaging'+nnr);
  if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
  {
	xmlHttp.open("GET", "web/php/phpjs.php?ic=paginacja&idd=" + id + "&komm=" + querry + "&nnr=" + nnr + "&uss=" + uss, true);  
    xmlHttp.onreadystatechange = function() {
		
	  if (xmlHttp.readyState == 4) 
  {
    if (xmlHttp.status == 200) 
    {
      helloMessage = xmlHttp.responseText;
      document.getElementById("listapaging"+nnr).innerHTML = helloMessage;
    } 
    else 
    {
      alert("Wystapil blad podczas uzyskiwania dostepu do serwera: " + xmlHttp.statusText);
    }
  }	
	}
	
    xmlHttp.send(null);	
  }
}

function pokazpagingsearch(nnr,uss,id,querry) {
show_progressbar('listapaging'+nnr);
  if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
  {
	xmlHttp.open("GET", "web/php/phpjs.php?ic=paginacjasearch&idd=" + id + "&komm=" + querry + "&nnr=" + nnr + "&uss=" + uss, true);  
    xmlHttp.onreadystatechange = function() {
		
	  if (xmlHttp.readyState == 4) 
  {
    if (xmlHttp.status == 200) 
    {
      helloMessage = xmlHttp.responseText;
      document.getElementById("listapaging"+nnr).innerHTML = helloMessage;
    } 
    else 
    {
      alert("Wystapil blad podczas uzyskiwania dostepu do serwera: " + xmlHttp.statusText);
    }
  }	
	}
	
    xmlHttp.send(null);	
  }
}

function ShowHide(layer_open, layer_close) {
        if (layer_open != '') {
            expandLayer(layer_open);
        }
        if (layer_close != '') {
            expandLayer(layer_close);
        }
    }

function expandLayer(name) {
        var itm = null;

        if (document.getElementById) {
            itm = document.getElementById(name);
        } else if (document.all) {
            itm = document.all[name];
        } else if (document.layers) {
            itm = document.layers[name];
        }

        if (!itm) {
        // Just don't panik, it's ok
        } else if (itm.style) {
            if (itm.style.display == "none") {
                itm.style.display = "";
            } else {
                itm.style.display = "none";
            }
        } else {
            itm.visibility = "show";
        }
    }
	

