Help me... please

Discussion in 'JavaScript' started by dvdmovie29, Aug 2, 2006.

  1. #1
    Im trying to make a game for my site. It involves images randomly rolling from the right to the left and once it has done that it starts again. The problem is that i want the picture to change to a different picture when clicked and change back to the origanol when it exits and re-enters. (problem area at the bottom of script).

    <html>
    <head>
    </head>
    <body bgcolor="white">
    <style type="text/css">


    #sDiv0, #sDiv1, #sDiv2, #sDiv3, #sDiv4, #sDiv5, #sDiv6, #sDiv7, #sDiv8, #sDiv9
    {
    position:absolute; z-index:10;
    }

    </style>

    <SCRIPT LANGUAGE="JavaScript1.2">
    <!--


    var ns=(document.layers);
    var ie=(document.all);
    var w3=(document.getElementById && self.innerWidth && (window.pageXOffset>-1));
    //my way of making sure the browser will have what I need

    var allDivs = new Array(3);
    var documentWidth,documentHeight;

    function initAll(){
    if(!ns && !ie && !w3) return;

    for(dNum=0; dNum<3; ++dNum){
    if(ie) allDivs[dNum]=eval('document.all.sDiv'+dNum+'.style');
    else if(ns) allDivs[dNum]=eval('document.layers["sDiv'+dNum+'"]');
    else if(w3) allDivs[dNum]=eval('document.getElementById("sDiv'+dNum+'").style');
    moveTo(dNum,0,0);
    }
    }

    function moveTo(i,tempx,tempy){
    if (ie){
    documentWidth =document.body.offsetWidth+document.body.scrollLeft-20;
    randomy=Math.floor(Math.random()*document.body.offsetHeight)+document.body.scrollTop-20;
    }
    else if (ns){
    documentWidth=window.innerWidth+window.pageXOffset-20;
    randomy=Math.floor(Math.random()*window.innerHeight)+window.pageYOffset-20;
    }
    else if (w3){
    documentWidth=self.innerWidth+window.pageXOffset-20;
    randomy=Math.floor(Math.random()*self.innerHeight)+window.pageYOffset-20;
    }

    if(tempx>-50){
    tempx-=45;
    allDivs.left=tempx;
    allDivs.top =tempy;
    setTimeout("moveTo("+i+","+tempx+","+tempy+")",300)
    }
    else
    setTimeout("moveTo("+i+",documentWidth-10,randomy)",10000/i+40);
    }
    window.onload=initAll;

    //End-->
    </script>
    <script>
    <!-- Begin
    function movepic(img_name,img_src) {
    document[img_name].src=img_src;
    }
    // End -->
    </SCRIPT>


    <div id="sDiv0"><a href="javascript:top.controls_frame.count1();" onClick="movepic('button','chocolatewrap.jpg')"
    onmouseout="movepic('button','http://javascript.internet.com/img/change-image/guestbook.gif')"><img name="button" src="chocolate.jpg" border="0"></a></div>
    <div id="sDiv1"><a href="javascript:top.controls_frame.count1();"><img src="chocolatewrap.gif" border="0"></a></div>
    <div id="sDiv2"><a href="javascript:top.controls_frame.count1();"><img src="chocolatewrap.gif" border="0"></a></div>
    </html>

     
    dvdmovie29, Aug 2, 2006 IP