// JavaScript Document

function AllWindow(lokalizacja,nazwa,scroll){
var okno = null;
Szerokosc = (screen.width) ? (screen.width-10) : 780;
Wysokosc = (screen.height) ? (screen.height-120) : 540;
parametry ='height='+Wysokosc+',width='+Szerokosc+',status='+scroll+',toolbar=yes,scrollbars=yes'
okno = window.open(lokalizacja,nazwa,parametry);
okno.moveTo(0,0);
okno.focus();
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function FullWindow(theURL,winName,features) { //v2.0
  window.open('mapa_zg/fullwindow.htm', 'mapa', 'fullscreen=1');
}

var win = null;
function CenterWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-(h+40))/2 : 0;
settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+''
win = window.open(mypage,myname,settings)
}

function openPopUpWindow(theURL,winName,features){
   window.open(theURL,winName,features);
 }
//openPopUpWindow('informacje/gabaryty_wiosna2004_popup.htm','Odpady','toolbar=no,scrollbars=no,width=480,height=300,left=180,top=150');

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function actFloatLayer(Margin, slideTime, layerName, Type, browser)
{  
   //===== initial the properties ===== begin =====
   
   switch(browser)
   {
      case (1):
                  find = (Type < 3) ? document.body.clientHeight : document.body.clientWidth;
                  current = (Type < 3) ? eval(layerName + ".style.pixelTop") : eval(layerName + ".style.pixelLeft");
                  scrollAt = (Type < 3) ? document.body.scrollTop : document.body.scrollLeft;
                  break;

      case (2): 
                  find = (Type < 3) ? window.innerHeight : window.innerWidth;
                  current = (Type < 3) ? eval("document." + layerName + ".top") : eval("document." + layerName + ".left");
                  scrollAt = (Type < 3) ? window.pageYOffset : window.pageXOffset;
                  break;

      case (3): 
                  find = (Type < 3) ? window.innerHeight : window.innerWidth;
                  current = (Type < 3) ? parseInt(eval("document.getElementById('" + layerName + "').style.top")) : parseInt(eval("document.getElementById('" + layerName + "').style.left")); 
                  scrollAt = (Type < 3) ? window.scrollY : window.scrollX;
                  break;
   }

   //===== initial the properties ===== end =====
 

   //========== Main Trigger ========== begin =====
   
   switch(Type)
   {
      case (1): case (3): //Type : top and left
         newTarget = scrollAt + Margin;
         break;
      case (2): case (4): //Type : bottom and right
         newTarget = scrollAt + find - Margin;
         break;
   }
   
   if ( current != newTarget ) 
   {        
      if (newTarget !=  this.target ) 
      { 
         //========== Start Float ========== begin =====

         target = newTarget;

         now = new Date();
         Mul = target - current;
         Wave = Math.PI / ( 2 * slideTime );
         Pass = now.getTime();

         if (Math.abs(Mul) > find) 
         { 
            
            Dis = (Mul > 0) ? target - find : target + find ;
            Mul = (Mul > 0) ? find : -find ;
         }
   
         else 	 
            Dis = current 

         //========== Start Float ========== end =====
      } 
      
      //========== Animator ========== begin =====

      now = new Date();
      newPosition = Mul * Math.sin( Wave * ( now.getTime() - Pass ) ) + Dis;

      newPosition = Math.round(newPosition);

      if (( Mul > 0 && newPosition > current ) || ( Mul < 0 && newPosition < current )) 
      { 
         switch(browser)
         {
            case (1):
                        (Type < 3) ? eval(layerName + ".style.pixelTop = newPosition;") : eval(layerName + ".style.pixelLeft = newPosition;");
                        break;
            case (2):
                        (Type < 3) ? eval("document." + layerName + ".top = newPosition;") : eval("document." + layerName + ".left = newPosition;");
                        break;
            case (3):
                        (Type < 3) ? eval("document.getElementById('" + layerName + "').style.top = newPosition + 'px';") : eval("document.getElementById('" + layerName + "').style.left = newPosition + 'px';");
                        break;
         }         
      }       

      //========== Animator ========== end =====
   } 

   //========== Main Trigger ========== end =====
}

function startFloatLayer(layerName, x, Margin, slideTime, Type) 
{
   //===== verify the Type ===== begin =====
   var browser;

   if (document.all)
      browser = 1;  //ie4

   if (document.layers)
      browser = 2;  //ns4

   if (!document.all && document.getElementById)
      browser = 3 ; //ns6
   
   setInterval("actFloatLayer(" + Margin + ", " + slideTime + ", '" + layerName + "', " + Type + ", " + browser + ")", 10);
}

function BW_reload() {location.reload();}

function BW_centerLayers() { //v4.1.1
	if (document.layers || document.all || document.getElementById){
		var winWidth, winHeight, i, horz, vert, width, height, offsetX, offsetY, negX, negY, group, x, y, args;
		args = BW_centerLayers.arguments;
		
		onresize = BW_reload;

				
		winWidth = (document.all)?document.body.clientWidth:window.innerWidth;
		winHeight = (document.all)?document.body.clientHeight:window.innerHeight;
				
		for (i=0; i<(args.length-9); i+=10) {
			horz    = args[i+1];
			vert    = args[i+2];
			width   = parseInt(args[i+3]);
			height  = parseInt(args[i+4]);
			offsetX = parseInt(args[i+5]);
			offsetY = parseInt(args[i+6]);
			negX    = args[i+7];
			negY    = args[i+8];
		
			x = ((winWidth - width)/2) + offsetX;
			y = ((winHeight - height)/2) + offsetY;
						
			x = (negX=='false' && (x < 0))?0:x;
			y = (negY=='false' && (y < 0))?0:y;
				
			layerObj = (document.getElementById)?document.getElementById(args[i]):MM_findObj(args[i]);
			
			if (layerObj!=null) {
				layerObj = (layerObj.style)?layerObj.style:layerObj;
				layerObj.left = (horz=="true")?x:layerObj.left;
				layerObj.top = (vert=="true")?y:layerObj.top;
			}
		}
	}
}

function WriteClock(data)
{
     var myclock=data;
	 
	 if (document.layers){
            document.layers.liveclock.document.write(myclock)
            document.layers.liveclock.document.close()
			return
         }
        else if (document.all)
		{
             liveclock.innerHTML=myclock
			 return
		}
		else if(document.getElementById)
			{
				document.getElementById("liveclock").innerHTML=myclock;
				return
			 }	 
   }

function PolandClock()
 {
    var Digital=new Date()
    var hours=Digital.getHours()
    var minutes=Digital.getMinutes()
    var seconds=Digital.getSeconds()
	
	poland=" godz.: "+(hours<10?"0":" ")+hours;
    poland+=(minutes<10?":0":":")+minutes;
    poland+=(seconds<10?":0":":")+seconds;
	WriteClock(poland);
} 

