PDA

View Full Version : Anybody know how to tweak this code?


likegluelikecrew
10-27-2005, 10:04 PM
Ok, I'm using Ranjan's fade image script, it works awesomely, but what I would like it to do is fade and rotate into all 4 images and stop on the 4th one (and every time the user would go back to the page, the rotations would start again and stop on the last pic). Anybody know how I would tweak the code to do this? Here's the code, thanks...

<script type="text/javascript">
var Pic=new Array("../images/homepage/senses.jpg","../images/homepage/treat.jpg","../images/homepage/premium.jpg", "../images/homepage/rqseriousplay.jpg")
var picUrl=new Array("../products/default.asp","../products/default.asp","../products/default.asp","../products/default.asp")
var slideShowSpeed = 5000;
var t;
var r;
var f;
var j = 0;
var p = Pic.length;
var preLoad = new Array();
var globalOpacity = 0;
for (i = 0; i < p; i++) {
preLoad[i] = new Image();
preLoad[i].src = Pic[i];
}
function runSlideShow() {
document.images.SlideShow.src = preLoad[j].src;
if(document.getElementById){
ael=document.getElementById('SlideURL');
ael.setAttribute('href',picUrl[j]);
}
setalpha(0,"SlideShow");
r=window.setTimeout("reveal('0')", 100);
j = j + 1;
if (j > (p - 1)) j = 0;
t = window.setTimeout('runSlideShow()', slideShowSpeed);
}
function reveal(opacity) {
if (opacity <= 100 ){
setalpha(opacity,"SlideShow");
opacity += 5;
globalOpacity = opacity;
r = window.setTimeout("reveal("+opacity+")", 100);
}
else {
f=window.setTimeout("fade('100')",1000);
}
}
function fade(opacity) {
if (opacity >= 0 ){
setalpha(opacity,"SlideShow");
opacity -= 5;
globalOpacity = opacity;
r = window.setTimeout("fade("+opacity+")", 50);
}
}
function setalpha(opacity,t) {
var target=document.getElementById(t);
if (document.getElementById ) {
if (target.style.MozOpacity!=null) {
target.style.MozOpacity = (opacity/100) - 0.001; //patrick h. lauke (http://www.splintered.co.uk/) workaround for Mozilla 'flash' bug - I _never_ would have caught that
} else if (target.style.opacity!=null) {
target.style.opacity = opacity/100;
} else if (target.style.filter!=null) {
target.style.filter = "alpha(opacity=" + opacity + ")";
} else if (target.style.KhtmlOpacity!=null) {
target.style.KhtmlOpacity = opacity/100;
}
}
}
window.onload = runSlideShow;
</script>
<table width="600" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>../images/homepage/senses.jpg (../products/default.asp)</td>
</tr>
</table>



We Are 138