function EnvVarsSetUp()
{
	//Operating System
	var IS_WIN = (navigator.userAgent.indexOf("Win") >= 0);
	var IS_MAC = (navigator.userAgent.indexOf("Mac") >= 0);
	var IS_UNIX = (navigator.userAgent.indexOf("X11") >= 0);

	//Browser Info
	var IS_IE = (navigator.appName == "Microsoft Internet Explorer");
	var IS_FF = (navigator.userAgent.indexOf("Firefox") >= 0);
	var IS_NS = (navigator.vendor != "undefined" && 
			navigator.vendor == "Netscape");
	var IS_MOZ = (navigator.userAgent.indexOf("Mozilla/5") >= 0);
	var IS_NEW = ((IS_MOZ && parseInt(navigator.appVersion) >= 5) ||
				(IS_IE && parseInt(navigator.appVersion) >= 4));

	//Object Support
	var SUPPORTS_IMAGES = (typeof document.images != "undefined");

	//Cookies
	var COOKIES_ON = navigator.cookieEnabled;
}

function goToURL(url) { window.location = url; }


function okno(nazwa,plik,szer,wys) 
{     
     config='left=0,top=0,width='+szer+',height='+wys+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no';
     tvop=window.open("/kasy/kasy.php?id="+nazwa+"&obraz="+plik,"",config);
     tvop.creator=self;
     tvop.focus();
}

function piszTekst()
{     
     napis = new Array(7);     
     napis[0] = "Niedziela";     
     napis[1] = "Poniedziałek";     
     napis[2] = "Wtorek";     
     napis[3] = "Środa";
     napis[4] = "Czwartek";
     napis[5] = "Piątek";
     napis[6] = "Sobota";
     now = new Date();     
     document.write(napis[now.getDay()]);
}


function pokaz_r() 
{
     o = document.getElementById("realizacja1");
     if (o.style.display=="block") 
          o.style.display="none";
     else o.style.display="block";
     o = document.getElementById("realizacja2");
     if (o.style.display=="block") 
          o.style.display="none";
     else o.style.display="block";
}

function displaySection (secNum)
{
  if (secNum.style.display=="none")
  {
    secNum.style.display="";
  }
  else
  {
    secNum.style.display="none";
  }
}

function hideSection (secNum)
{
  if (secNum.style.display!="none")
  {
    secNum.style.display="none";
  }
}



function displaySectionID (id)
{
  if (document.getElementById(id).style.display=="none")
  {
    document.getElementById(id).style.display='';
  }
  else
  {
    document.getElementById(id).style.display = "none";
  }
}
 
function hideSectionID (id)
{
  document.getElementById(id).style.display="none";
}


function ShowSectionID (id)
{
  document.getElementById(id).style.display='';
}

//CenterSectionID ('news',500,150,'imgfornew',300,'imgfornewX','imgfornewY');
function CenterSectionID (id,breite,topniveau,idg,imgbreite,imgx,imgy)
{
	secNum = document.getElementById(id);
	DspWidth = screen.width;
	DspHeight = screen.height;

	XPos = (DspWidth-breite)/2;
	if (XPos<0)
	{
		XPos=0;
		breite=DspWidth;
	}

	secNum.style.left=XPos;
	secNum.style.width=breite;
	secNum.style.top=topniveau;

	x=document.getElementById(idg).width;
	y=document.getElementById(idg).height;

	document.getElementById(imgx).value=document.getElementById(idg).width;
	document.getElementById(imgy).value=document.getElementById(idg).height;

	
	scale=imgbreite/document.getElementById(imgx).value;

	document.getElementById(idg).width=scale*document.getElementById(imgx).value;
	document.getElementById(idg).height=scale*document.getElementById(imgy).value;
}






//                      'divimgfornew','imgfornewmax','imgfornewX','imgfornewY','2.5','imgfornew','news'

function imgdivfornewShow(DivID,ImgDivID,ImgX,ImgY,ImgMaxSkala,ImgIDStart,DivIDMain)
{
	document.getElementById(DivID).style.display	=	"block";

	DspWidth = screen.width;				// bez jednostek

	wd = DspWidth - 30;
	wm = document.getElementById(ImgX).value;
//	alert('wm='+wm);				// bez jednostek
	wis = document.getElementById(ImgIDStart).width;
//	alert('wis='+wis);				// bez jednostek
	
	if(wm>wd)
	{
		MaxScala = wd / wis;
	}
	else
	{
		MaxScala = wm / wis;
	}
	
	if(ImgMaxSkala>0)
	{
		if(ImgMaxSkala<MaxScala) MaxScala=ImgMaxSkala;
	}

	document.getElementById(ImgDivID).width				=	document.getElementById(ImgIDStart).width * MaxScala;
	document.getElementById(ImgDivID).height			=	document.getElementById(ImgIDStart).height * MaxScala;
	
	x1 = document.getElementById(DivIDMain).style.width;
	x2 = document.getElementById(ImgDivID).width;
	x3 = (parseInt(x1)-parseInt(x2))/2;
	
	document.getElementById(DivID).style.left = x3;
}


function imgdivfornewHide(DivID)
{
	document.getElementById(DivID).style.display="none";
}







function setCookie(c_name,value,expiredays)
{var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
	if (document.cookie.length>0)
  {
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1)
    { 
			c_start=c_start + c_name.length+1; 
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}

function checkCookie()
{
	username=getCookie('username');
	if (username!=null && username!="")
	{
		alert('Welcome again '+username+'!');
	}
	else 
	{
		username=prompt('Please enter your name:',"");
		if (username!=null && username!="")
		{
			setCookie('username',username,365);
		} 
	}
}

function information1 (tlo,breite,hoeche) 
{
	DspWidth = screen.width;
	DspHeight = screen.height;
	XPos = (DspWidth-breite)/2;
	YPos = (DspHeight-hoeche)/2;
	KeksIstDa = getCookie('information1');
	if (KeksIstDa!=null && KeksIstDa!="")
	{
	}
	else
	{
		document.cookie='information1'+ "=" +'1;';
		WinObj = window.open('', 'INFORMACJA', 'menubar=no, toolbar=no, location=no, scrollbars=no, resizable=no, status=no, width='+breite+', height='+hoeche);
		WinObj.document.write('<body style="background-image: url('+tlo+');">');
		WinObj.document.write('</body>');
		WinObj.moveTo(XPos,YPos);
	}
	
	return "";
}


function information2 (tlo,breite,hoeche) 
{
	DspWidth = screen.width;
	DspHeight = screen.height;
	XPos = (DspWidth-breite)/2;
	YPos = (DspHeight-hoeche)/2;
		WinObj = window.open('', 'INFORMACJA', 'menubar=no, toolbar=no, location=no, scrollbars=no, resizable=no, status=no, width='+breite+', height='+hoeche);
		WinObj.document.write('<body style="background-image: url('+tlo+');">');
		WinObj.document.write('</body>');
		WinObj.moveTo(XPos,YPos);
	return "";
}




function notes_show (Ident,niveau,width) 
{
  o = document.getElementById(Ident);
	DspWidth = screen.width;
	DspHeight = screen.height;
	XPos = (DspWidth-width)/2+width;
	YPos = niveau;
	o.style.top = YPos;
	o.style.right = YPos;
	o.style.visibility = visible;
	return "";
}


function imposeMaxLength(Object, MaxLen)
{
  return (Object.value.length <= MaxLen);
}




function TextAreaMaxLength(id,MaxL) 
{ 
  var elem 				= document.getElementById(id);// identyfikacja elementu id 
  var tekst 			= elem.value; 								// cały text z pola textarea 
  var dl_tresc 		= elem.value.length; 					// długoś tekstu z textarea 
	var prawdziwa 	= 0; 													// licznik znaków 
  var entery 			= 0; 
        
  for (i=0; i<dl_tresc; i++) 
	{ 
    if (tekst.charAt(i) == "\n") 
		{ 
      prawdziwa++; 
      entery++;
      if (navigator.appName != "Netscape") i++; 
    } 
		prawdziwa++; 
  } // koniec for i 

  if (prawdziwa>MaxL) 
	{ 
    if (navigator.appName != "Netscape") 
        elem.value = elem.value.substring(0,MaxL);
      else 
        elem.value = elem.value.substring(0,MaxL-entery);
  } 
} 




//	ImgById ('InfoDetailImg','InfoDetail',400,'InfoDetailImg_X','InfoDetailImg_Y')
function ImgById (IdImg,Id,ImgWidth,IdImgX,IdImgY)
{
	if(ImgWidth<document.getElementById(IdImgX).value)
	{
		i=ImgWidth/document.getElementById(IdImgX).value;
		document.getElementById(IdImg).height=i*document.getElementById(IdImgY).value;
		document.getElementById(IdImg).width=ImgWidth;
	}
	
}

// ImgByIdm ('InfoDetailImgMnu','<?php echo $okimg;?>','InfoDetailImgMnu_X','InfoDetailImgMnu_Y',150)
function ImgByIdm (Id,AnzahlAddr,Idx,Idy,MinWidth)
{
	var Anzahl = document.getElementById(AnzahlAddr).value;

	if (Anzahl>1)
	{
		for ( j=1;j<=Anzahl;j++)
		{
			if(MinWidth<document.getElementById(Idx+j).value)
			{
				i=MinWidth/document.getElementById(Idx+j).value;
				document.getElementById(Id+j).height=i*document.getElementById(Idy+j).value;
				document.getElementById(Id+j).width=MinWidth;
			}
		}
	}
	
}


//ShowImgById (	'<?php echo "InfoDetailImgMnu".$i;?>',
//							'<?php echo echo $fileG[$i];?>',
//							'<?php echo "InfoDetailImgMnu_X".$i;?>',
//							'<?php echo "InfoDetailImgMnu_Y".$i;?>',
//							'InfoDetailImgDiv',
//							'InfoDetailImg',
//							'InfoDetailImg_X',
//							'InfoDetailImg_Y',
//							 400)
function ShowImgById (IdWhat,SrcWhat,IdXWhat,IdYWhat,IdImgDivWhere,IdWhere,IdXWhere,IdYWhere,ImgWidth)
{
	
	document.getElementById(IdXWhere).value = document.getElementById(IdXWhat).value;
	document.getElementById(IdYWhere).value = document.getElementById(IdYWhat).value;
	document.getElementById(IdWhere).src    = document.getElementById(IdWhat).src;

	var i = 1;
	if(ImgWidth<document.getElementById(IdXWhere).value)
	{
		i=ImgWidth/document.getElementById(IdXWhere).value;
	}
	document.getElementById(IdWhere).height=i*document.getElementById(IdYWhere).value;
	document.getElementById(IdWhere).width=i*document.getElementById(IdXWhere).value;

}




//MoveSectionIdOnLeft ('InfoDetail',20);
function MoveSectionIdOnLeft (id0,id1,id2,DistToRightSite)
{
//	alert('id0='+id0+', id1='+id1+', id2='+id2);
//	alert('id0 ex.='+document.getElementById(id0)+', id1 ex.='+document.getElementById(id1)+', id2 ex.='+document.getElementById(id2));
	
	ID0_left = parseInt(document.getElementById(id0).style.left);
	ID0_width = parseInt(document.getElementById(id0).style.width);
	
	if(!document.getElementById(id1))
	{
		ID1_left = 0;
		ID1_width = 0;
	}
	else
	{
		ID1_left = parseInt(document.getElementById(id1).style.left);
		ID1_width = parseInt(document.getElementById(id1).style.width);
	}
//	ID1_left = parseInt(document.getElementById(id1).style.left);

	
	if(!document.getElementById(id2))
	{
		ID2_left = 0;
		ID2_width = 0;
	}
	else
	{
		ID2_left = parseInt(document.getElementById(id2).style.left);
		ID2_width = parseInt(document.getElementById(id2).style.width);
	}
//	ID2_left = parseInt(document.getElementById(id2).style.left);

//	ID1_width = parseInt(document.getElementById(id1).style.width);
//	ID2_width = parseInt(document.getElementById(id2).style.width);
	DspWidth = parseInt(screen.width);
	DspHeight = parseInt(screen.height);
//	alert('DspWidth='+DspWidth+', ID0_left='+ID0_left+', ID1_left='+ID1_left+', ID2_left='+ID2_left+'||| ID0_width='+ID0_width);

	dist = DspWidth-ID1_left-ID2_left-ID0_width-DistToRightSite;
	distL = ID0_left+ID1_left+ID2_left;
	if (distL<0)
	{
		dist=0;
	}
//	alert('Dist='+dist);
	
	
//	dist = DspWidth-IDm_left-ID_width-DistToRightSite;
//	if(dist<parseInt((ID_width-DspWidth)/2))
//	{
//		dist = parseInt((ID_width-DspWidth)/2);
//	}
	document.getElementById(id0).style.left=dist;
	
}


//ShowMaxImgByIdMouseOver('InfoDetail','InfoDetailImgDiv','InfoDetailImg','InfoDetailImgHid','InfoDetailImg_X','InfoDetailImg_Y',650,'<?php echo $okimg;?>',650,200,60)
function ShowMaxImgByIdMouseOver (Id,IdImgDiv,IdImgHidDiv,IdImg,IdImgHid,IdImgX,IdImgY,IdMnuQty,DivWidth, Col2Width,SeitenRand)
{

	DspWidth = screen.width;
	var i = document.getElementById(IdMnuQty).value;

	if(document.getElementById(IdMnuQty).value>1) 													// Col1Width - szer. 1-szej kolumny
	{
		Col1Width=DivWidth-Col2Width;
	} 
	else 
	{
		Col1Width=DivWidth;
	}

	W0 = document.getElementById(IdImgX).value;															// wymiary grafiki oryginalnej
	H0 = document.getElementById(IdImgY).value;
	
	if(W0>document.getElementById(IdImg).width)
	{
	
	
	
	document.getElementById(IdImgHidDiv).style.display = '';
	document.getElementById(IdImgHidDiv).style.left = 0;
	document.getElementById(IdImgHid).src = document.getElementById(IdImg).src;
	document.getElementById(IdImgHid).width = W0;
	document.getElementById(IdImgHid).height = H0;

	Left0 = parseInt(document.getElementById(Id).style.left);
	Left1 = parseInt(document.getElementById(IdImgDiv).style.left);

	if(W0>=(Left0+Left1+Col1Width-SeitenRand))
	{
		scale = (Left0+Left1+Col1Width-SeitenRand)/W0;
		LeftHid = -1*(Left0+Left1-SeitenRand);
	}
	else
	{
		if(W0<Col1Width)
		{
			scale = W0/document.getElementById(IdImg).width;
			LeftHid = (Col1Width-W0)/2;
		}
		else
		{
			scale = 1;
			LeftHid = Col1Width-W0;
		}
	}
	
	AAA = W0*scale;
	BBB = H0*scale;
	document.getElementById(IdImgHid).width = W0*scale;
	document.getElementById(IdImgHid).height = H0*scale;
	document.getElementById(IdImgHidDiv).style.left = LeftHid;

	}
}


function ImagePreloading(id)
{

	var Obj = document.getElementById(id);
	if (!Obj.complete)
	{
		setTimeout("ImagePreloading('"+id+"')",100);
	}
	if (!Obj.onload)
	{
		setTimeout("ImagePreloading('"+id+"')",100);
	}

}





// Niniejszy skrypt pochodzi z serwisu "JavaScript w przykladach"     
// Copyright (C) 1999 Maciej Szczepaniak <maciek@wls1.ch.pwr.wroc.pl> 
                                                                      
// Skrypt objety jest licencja GNU General Public License.            
// Koniecznie przeczytaj pelna informacje o licencji pod adresem:     
//     http://javascript.jest.o.k.pl/archiwum.html#l                  
                                                                      
                                                                      
var Imgi = new Array(); // Tablica obrazków                           
var Bledy = 0;          // Liczba błędów                              
var preloadTimer;       // Timer używany dalej                        
var preloadOK = ''      // Kod do wykonania po zakończeniu ładowania  
var preloadBlad = ''    // j.w., ale jeśli wystąpi jakiś błąd         
                                                                      
// rozpoczyna ścišganie obrazka                                       
function preload(url) 
{                                               
	if (document.images) 
	{                                             
    var i = Imgi.length;                                            
    Imgi[i] = new Image();                                          
    Imgi[i].onerror = preloadOnError;                               
    Imgi[i].src = url;                                              
  }                                                                  
}                                                                     
                                                                      
// wywyoływana, jeśli wystąpił jakiś błąd - ustawia flagę Blad        
function preloadOnError() 
{                                           
  Bledy++;                                                           
}                                                                     
                                                                      
// ustala, co należy zrobić po zakończeniu preloadu, uruchamia pętlę  
function preloadStart(ok, blad) 
{                                     
  preloadOK = ok;                                                    
  preloadBlad = blad;                                                
  preloadCheck();                                                    
}                                                                     
                                                                      
// sprawdza, czy ładowanie się już zakończyło                         
function preloadCheck() 
{                                             
  var i=0;                                                           
  var l=Imgi.length;                                                 
  var b = Bledy;                                                     
   // Trochę zagęszczonego kodu:                                      
  while (i<l && Imgi[i].complete || b-->0) i++;                      
  if (i>=l) // to już wszystkie (wyjście z pętli na 1. warunku)      
    if (Bledy==0)                                                   
      eval(preloadOK)                                              
    else                                                            
      eval(preloadBlad)                                            
  else // któryś nie był ukończony                                   
    preloadTimer = setTimeout('preloadCheck()',100);                
}                                                                   


function preloadinit() 
{                                             
	var ImgMenge = document.images.length;
	var Meldung = '';
//	alert('ilosc obrazów'+ImgMenge);
	for ( var j=0; j<ImgMenge; j++)
	{
		Meldung+=document.images[j].src+' | ';
		preload(document.images[j].src);
	}
//	alert('Obrazki= '+Meldung);
	preloadCheck();
//	alert('Obrazki= '+Meldung);
}                                                                   
