    var http_request = false;

    function makeRequest(url,gdzie,zm_ster) {

        http_request = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // Przeczytaj o tym wierszu poniżej
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Poddaję się :( Nie mogę stworzyć instancji obiektu XMLHTTP');
            return false;
        }
        http_request.onreadystatechange = function() { alertContents(http_request,gdzie,zm_ster); };
        http_request.open('GET', url, true);
        http_request.send(null);

    }

    function alertContents(http_request,gdzie2,zm_ster2) {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                 if(zm_ster2==3)
                 {
                      document.getElementById(gdzie2).innerHTML="";
                 }
                 else{
                   document.getElementById(gdzie2).innerHTML= http_request.responseText;
                      }
            } else {
                alert('Wyst±pił problem z zapytaniem.');
            }
        }

    }


    function czysc(gdzie3) {
        document.getElementById(gdzie3).innerHTML="";
    }
	
	function spr_wymagane(form){
		//sprawdza czy pola formularza z id="wymagane" nie sa puste
		if (form==null){
			form=0;
		}
		var tab = document.forms[form].elements;
		var spr=0;
		for (var i = 0; i < tab.length; i++) {
			if(tab[i].id=='wymagane'){
				if((tab[i].value=='') || (tab[i].value==' ')|| (tab[i].value==null)){
					document.forms[form].elements[i].style.backgroundColor='#FFE6E6';
					alert('Nie wypelniono wymaganego pola!');
					spr++;
					break;
				}
				else {
					document.forms[form].elements[i].style.backgroundColor='';	
				}				
			}
  			
		}
		if(spr==0){
			document.forms[form].submit();
		}
		
	}

function komunikat(tresc, typ, fatal) {
    //Wyświetla komunikat z przesłoną
    var wymiary = getPageSize();
    var wys = wymiary[1];//jQuery('body').outerHeight();//document.getElementById('main').offsetHeight;
    var styl = '';

    if(typ == 'good') {
        styl = 'style="background: #383838; color: #b8b8b8;"';
    }
    else if(typ == 'warning') {
        styl = 'style="background: #FEEFB3;color: #9F6000;"';
    }

    jQuery('body').append('<div class="komunikat_tlo" style="height: ' + wys + 'px;"></div><div class="komunikat_tresc" ' + styl + '>' + tresc + '<br><br><button type="button" onclick="komunikat_zamknij();" style="border: 1px solid #fff; padding: 5px 15px; background: #ba7905; color: #fff; cursor: pointer;">OK</button><br><br></div>');
    jQuery('.komunikat_tlo').fadeTo(600, 0.55, function() {jQuery('.komunikat_tresc').slideDown(400);});//.delay(1600).fadeOut(500, function() { jQuery('.komunikat_tlo').remove(); jQuery('.komunikat_tresc').remove(); if(fatal) { location.href = root_dir; } });
}


function komunikat_zamknij() {
    jQuery('.komunikat_tresc').slideUp(400, function() { jQuery('.komunikat_tlo').fadeTo(600, 0, function() { jQuery('.komunikat_tlo').remove(); jQuery('.komunikat_tresc').remove();}); });
}


function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

//	console.log("xScroll " + xScroll)
//	console.log("windowWidth " + windowWidth)

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
//	console.log("pageWidth " + pageWidth)

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
