        var speed = 7000
//wstawione do dokumentu
/*var Pic = new Array();

Pic[0] = '1.jpg'
Pic[1] = '2.jpg'*/
var t
var j = 0
var p = Pic.length

var preLoad = new Array()
for (i = 0; i < p; i++){
   preLoad[i] = new Image()
   preLoad[i].src = Pic[i]
}
cOpacity=0;
flaga=1;
function changeBg(id1, id2) {
   if (document.body){
   //cOpacity=0.5;
   
   /* if(cOpacity>0.1 && flaga==0)	{cOpacity-=0.1;}
   
   if(cOpacity<=0.1) {
           flaga=1;
           document.getElementById(id1).style.background='url('+Pic[j]+') no-repeat';
           j = j + 1;
           if (j > (p-1)) j=0;
   }
   if(cOpacity<=1 && flaga==1) {cOpacity+=0.1;} 

   
   if(cOpacity>=1) {
   		flaga=0;
		t=setTimeout("changeBg('"+id1+"', '"+id2+"')",speed);
	} else {
		setOpacity(document.getElementById(id1), cOpacity);
		t=setTimeout("changeBg('"+id1+"', '"+id2+"')",50);
	} */
   
   if(cOpacity>0 && flaga==0)	{cOpacity-=0.05;}
   if(cOpacity<=0 && flaga==0)
       {
       	  document.getElementById(id1).style.background='url('+Pic[j]+') no-repeat';
       	   j = j + 1;
           if (j > (p-1)) j=0;
          cOpacity=1.0;
          setOpacity(document.getElementById(id1), cOpacity);
       }
   //wchodzi tylko za pierwszym razem
   if(cOpacity<=0 && flaga==1) {
           document.getElementById(id1).style.background='url('+Pic[j]+') no-repeat';
           j = j + 1;
           if (j > (p-1)) j=0;
   }
   if(cOpacity<=1 && flaga==1) {cOpacity+=0.05;}  
  
   if(cOpacity>=1) {
   		flaga=0;
   		document.getElementById(id2).style.background='url('+Pic[j]+') no-repeat';
		t=setTimeout("changeBg('"+id1+"', '"+id2+"')",speed);
	} else {
		setOpacity(document.getElementById(id1), cOpacity);
		t=setTimeout("changeBg('"+id1+"', '"+id2+"')",10);
	} 

   }
}
function setOpacity(obj, xOpacity) {
		if(xOpacity>.95) {
			xOpacity = 1;
		}
		obj.style.opacity = xOpacity;
		obj.style.MozOpacity = xOpacity;
		obj.style.filter = "alpha(opacity=" + (xOpacity*100) + ")";
	}
