if (window.XMLHttpRequest) 
	ObiektXMLHttp = new XMLHttpRequest();  
else if (window.ActiveXObject) { 
	ObiektXMLHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
}

function showFoto(id) {
	window.open(dirPath+'_foto_window.php?id='+id+'&sze='+screen.width+'&wys='+screen.height, 'Foto', 'menubar=no, toolbar=no, location=no, scrollbars=no, resizable=yes, status=no, width=800, height=60, left=100, top=50');
	return void(0);
}

function goLang(webPath,lang) {
	location.href = webPath+'?lang='+lang;	
}

function goMod(webPath,mod,id) {
	location.href = webPath+mod+'/?id='+id;	
}

function hideS() {
	var h = document.getElementById('global').clientHeight;
	document.getElementById('hideScreen').style.height = h+'px';
	document.getElementById('hideScreen').style.display = 'block';
	document.getElementById('msg').style.display = 'block';
}

function getWindowHeight() {
	if( typeof( window.innerWidth ) == 'number' ) {
	   	return window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		return document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		return document.body.clientHeight;
	} else {
		return 0;
	}
}

var Imgi = new Array();                           
var Bledy = 0;                                        
var preloadTimer;                             
var preloadOK = ''       
var preloadBlad = ''     

function hideFoto() {
	document.getElementById('hideScreen').style.display = 'none';
	document.getElementById('fotoScreen').style.display = 'none';
	document.getElementById('fotoScreen').style.padding = '0';
	document.getElementById('msg').style.display = 'none';
	var e = document.getElementById('fotoScreen');
	e.innerHTML = '';
}

function showFoto(webPath,id) {
	document.getElementById('msg').style.display = 'block';
	preload(webPath+'foto/'+id+'.jpg');
	preloadCheck();
	var h = document.getElementById('global').offsetHeight;
	
	var t = getWindowHeight(); if (h < t) h = t;
	
	var e1 = document.getElementById('hideScreen');
	e1.style.height = h + 'px';
	e1.style.display = 'block';
	
	var e2 = document.getElementById('fotoScreen');
	e2.style.marginTop = ((-320)+getScrollY())+'px';
	e2.style.display = 'block';
	e2.style.padding = '10px';

}
                                      
function preload(url) {                                               
   if (document.images) {                                             
      var i = Imgi.length;                                            
      Imgi[i] = new Image();                                                                       
      Imgi[i].src = url;                                              
   }                                                                  
}                                                                     
                                                                                           
function preloadCheck() {                                             
   var i=0;                                                           
   var l=Imgi.length;                                                                                                     
                                     
   while (i<l && Imgi[i].complete) i++;                      
   if (i>=l) {    
	var e = document.getElementById('fotoScreen');
	e.innerHTML = '<center><img src=\"'+Imgi[(i-1)].src+'\" alt=\"\" class=\"loadedFoto\" /></center>';
   } else                               
      preloadTimer = setTimeout('preloadCheck()',100);                
}    

function getScrollY() {
	if( typeof( window.pageYOffset ) == 'number' ) {
		return window.pageYOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		return document.body.scrollTop;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		return document.documentElement.scrollTop;
	} else {
		return 0;	
	}
}

function getSpeed(a, b) {
	var j = (a-b) / 5;
	if (j < 1) j = 1;
	
	return Math.round(j);
}

function getFormData() {
	var imie_nazwisko = document.getElementById('reqName').value;
	var dane_kontaktowe = document.getElementById('reqData').value;
	var tresc = document.getElementById('reqContent').value;
	
	document.getElementById('resDiv').innerHTML = '...wysyłanie formularza';
	
	sendReq(imie_nazwisko,dane_kontaktowe,tresc);
	
	document.getElementById('reqName').value = '';
	document.getElementById('reqData').value = '';
	document.getElementById('reqContent').value = '';
}

function sendReq(reqName,reqData,reqContent) { 
 if(ObiektXMLHttp) 
  {
   ObiektXMLHttp.open("GET", webPath+'act/sendReq.php?reqName='+reqName+'&reqData='+reqData+'&reqContent='+reqContent);

ObiektXMLHttp.onreadystatechange = function() 
{
 if (ObiektXMLHttp.readyState == 4)
   { 
   	var resDiv = document.getElementById('resDiv');
	resDiv.innerHTML = ObiektXMLHttp.responseText;
	fitGlobalH();
   }
}  
ObiektXMLHttp.send(null); } 
}

function webPath(index) {
	if(index == '3')
		location.href = dirPath+'gal/';
	else if(index == '4')
		location.href = dirPath+'art/?cat=3';	
	else if(index == '5')
		location.href = dirPath+'art/?cat=4';
	else if(index == 'goHome')
		location.href = dirPath;
	else
		location.href = dirPath+'art/?cat='+index;	
}

function ulubione(nazwa,url) {
	var ver = navigator.appName;
	
	if ((ver == "Microsoft Internet Explorer")) {
		if (window.external) window.external.AddFavorite(url, nazwa);
	} else {
		if (window.sidebar) window.sidebar.addPanel(nazwa, url, "");
	}
}

