 function changeMotivnaAvtomatskoPlesnik()
  {   
     changeMotivnaPlesnik(motivneslike, povezave, 1, motivnepath, steviloslik, 0);
     setTimeout("changeMotivnaAvtomatskoPlesnik()", 4000);
  }

  function changeMotivnaPlesnik(arr, arr2, kam, imgpath, steviloslik, showdirect)
  { 
        var blendtime = 1200;
        if (showdirect==0 && manual) return;
        
        var st = motivnacounter;
        // preklop naprej
        if (kam==1) if (st<steviloslik-1) st++; else st=0;
        // preklop nazaj
        if (kam==-1) if (st>0) st--; else st=steviloslik-1;
        

        if (showdirect>0)
        {
            st = showdirect-1;
            blendtime = 100;
            manual = true;
        }
        
        motivnacounter = st;
        
        if (arr[st]) 
        {
            blendimagePlesnik("motivna", "motivnaimg", imgpath + arr[st], blendtime);
        }
        
        var link = document.getElementById("motivnalink");
        if (link)
        {
            if (arr2[st])
                link.href = arr2[st];
            else
                link.href = ""; 
        
        }        
    }

function blendimagePlesnik(divid, imageid, imagefile, millisec) { 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 
     
    //set the current image as background 
    document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")"; 
     
    //make image transparent 
    changeOpacPlesnik(0, imageid); 
     
    //make new image 
    document.getElementById(imageid).src = imagefile; 

    //fade in image 
    for(i = 0; i <= 100; i++) { 
        setTimeout("changeOpacPlesnik(" + i + ",'" + imageid + "')",(timer * speed)); 
        timer++; 
    }     
} 


//change the opacity for different browsers 
function changeOpacPlesnik(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 



