/*Paste the main object DivOpacityObj with all its wrapped in methods above the '//Main Program' comment between script tags in the head and use the main program as an example. The paragraphs refer to id's of divs in the body of your document, set to opacity 0 in css.*/ function DivOpacityObj(DivIdImgArr,Direction,Rate,OpacStart,OpacEnd,Pause){ /* position 0 in images is a counter default 1; direction is 0 for both ways and 1 for one way; rate is an array for speed of fade (1-100) do not choose 0 OpacStart is an array of starting opacity (0-100) default 0 OpacEnd is an array of target opacity (0-100) default 25 Pause is time image is displayed at fixed opacity (0-infinity) whole numbers flag is a boolean value used to indicate the animation is stopped PointerSet ensures the method isn't run on setting pointers Always ensure arrays are all the same length */ this.DivIdImgArr=new Array();//images go here first position given value 1 this.Direction=new Array();//first position null then 1 or 0 this.Rate=new Array();//first position null then (1-100) this.OpacStart=new Array();//first position null this.OpacEnd=new Array();//first position null this.Pause=new Array();//first position null this.flag=true; this.PointerSet=true; this.milisec=200; this.movie=-1; this.Left='100px'; this.Top='50px'; this.Height='400px'; this.Width='400px'; //----------------------------------------------------------------------------- this.display=function(){ this.rnd=Math.random(); this.rnd=Math.floor(this.rnd*100+0.5); this.str=new String(this.DivIdImgArr[1]); this.rand=new String(this.rnd); this.index=this.str.lastIndexOf('.'); newImage=document.createElement('img'); newImage.setAttribute('src','Images/'+this.str);// new folder this.strg=this.str.substring(0,this.index); this.strg=this.strg+this.rand; oldDiv=document.getElementsByTagName('body')[0]; newDiv=document.createElement('div'); newImage.setAttribute('id',this.strg+'i'); newDiv.setAttribute('id',this.strg); newDiv.style.height=this.Height; newDiv.style.width=this.Width; newDiv.style.position='absolute'; newDiv.style.left=this.Left; newDiv.style.top=this.Top; newDiv.style.backgroundColor='transparent'; newDiv.style.border='none'; newDiv.style.opacity='0'; newDiv.style.filter='alpha(opacity=0)'; newDiv.style.MozOpacity='0'; newDiv.style.KhtmlOpacity='0'; oldDiv.appendChild(newDiv); newDiv.appendChild(newImage); } } //Wrapped in functions-------------------------------------------------------- //Timing---------------------------------------------------------------------------------------------------------------------------------------- DivOpacityObj.prototype.autoCall=function(objet,micro){ var call=objet.ImagesFader(objet); return setInterval(call,micro); } //change the opacity for different browsers----------------------------------------------------------------------------------------- DivOpacityObj.prototype.changeOpac=function(opac,id){ var obj = document.getElementById(id).style; obj.opacity = (opac / 100); obj.MozOpacity = (opac/ 100); obj.KhtmlOpacity = (opac/ 100); obj.filter = "alpha(opacity=" + opac + ")"; } //Swap function???????????????????????????-------------------------------------------------------------------------------------- DivOpacityObj.prototype.swapImage=function(id,cur){ var oldIm=document.getElementById(id+'i');//image id document.getElementById(id).removeChild(oldIm); var newIm=document.createElement('img'); newIm.setAttribute('src','Images/'+current);//new image newIm.setAttribute('id',id+'i'); document.getElementById(id).appendChild(newIm); return; } //Fader----------------------------------------------------------------------------- DivOpacityObj.prototype.ImagesFader= function(objet){ return (function(){ if(objet.PointerSet){objet.PointerSet=false;return;} var currentImage=objet.DivIdImgArr[0]; var Id=objet.DivIdImgArr[currentImage]; if(objet.index>-1){Id=objet.strg;} var Name=document.getElementById(Id); if(Name.style.filter>=0) var currentOpacity=Name.style.filter; if(Name.style.opacity<1.5) var currentOpacity=Math.floor(100*Name.style.opacity); if(Name.style.MozOpacity<1.5) var currentOpacity=Math.floor(100*Name.style.MozOpacity); if(Name.style.KhtmlOpacity<1.5) var currentOpacity=Math.floor(100*Name.style.KhtmlOpacity); var pause=objet.Pause[currentImage]; var length=objet.DivIdImgArr.length; var direction=objet.Direction[currentImage]; var target=objet.OpacEnd[currentImage]; var difference=target-currentOpacity; var rate=objet.Rate[currentImage] if(difference>=0){ if(difference==0){ if(pause>0){objet.Pause[currentImage]=pause-1;return ;} if(direction==0){objet.Direction[currentImage]=1;objet.OpacStart[currentImage]=currentOpacity;objet.OpacEnd[currentImage]=0;return ;} if((length-1)-currentImage==0){objet.flag=false;clearInterval(objet.movie);return ;}//Routine should end here else{objet.DivIdImgArr[0]=currentImage+1;if(objet.index>-1){current=objet.DivIdImgArr[objet.DivIdImgArr[0]];objet.changeOpac(currentOpacity,Id);objet.swapImage(Id,current);}return;} } currentOpacity=currentOpacity+rate; if(currentOpacity>target){currentOpacity=target;} objet.changeOpac(currentOpacity,Id); return ; } else{ currentOpacity=currentOpacity-(rate); if(currentOpacity