﻿var  Images = new Array();
     Images[0] = "<a href=\"Whats-new-at-King-David.asp\"><img src=\"../images/whats-new.jpg\" width=\"747\" height=\"250\" border=\"0\" ></a>";
     Images[1] = "<a href=\"Send-a-rosh-hashanah-ecard.asp\"><img src=\"../images/rosh-hasana.jpg\" width=\"747\" height=\"250\" border=\"0\"  ></a>";
       
    var restore1 = new Array();
    restore1[0] = "opacity:1,2000";
    
    var restore2 = new Array();
    restore2[0] = "opacity:0::setImage():1000,1000";

    var randomnumber =0;
    


//Read more: http://www.webdesign.org/web-programming/javascript/jquery-fade-in-fade-out.16979.html#ixzz0oHLPDsAi
//setInterval("Fadeout()",15000);
//setInterval("randomnumber=Math.floor(Math.random()*5);$(\"#RandomTestimonails\").html(Testimonials[randomnumber]);",6000);
//setInterval("$(\"#RandomTestimonails\").fadeTo(\"slow\", 1);",6050);
    
    function setImage()
        {
          //randomnumber=Math.floor(Math.random()*Images.length);
          $("#BannerFade").html(Images[randomnumber]); 
          move( 0,restore1,'#BannerFade'); 
          
          if(randomnumber ==0) randomnumber = 1;
          else if(randomnumber ==1) randomnumber = 0;
        }
       
    
     var defaultEasing = "swing";

    function move(theIndex, TheAnimationSequence, objectToAnimate, Loop,LoopTime) {

                    
        if (theIndex < TheAnimationSequence.length) {
        
            var anim = {}; 
            var theEasing = defaultEasing;
            var theParams = TheAnimationSequence[theIndex].split(",")
            for (i = 0; i < theParams.length - 1; i++) {
                execParamaters = theParams[i].split(":");
             
              anim[execParamaters[0]] = execParamaters[1];
              if (execParamaters.length > 2) {
                        if(execParamaters[2] != ""){
                            theEasing = execParamaters[2];
                        }
                        if (execParamaters.length == 5) {
                            setTimeout(execParamaters[3], execParamaters[4]);
                        }
                        else
                        {
                            if (execParamaters.length == 4) {
                                eval(execParamaters[4]);
                            }
                        }
                    }
            }
            
            // grab the last index of the array to get the time to execute the animation
            var theTime = theParams[theParams.length - 1];
            $(objectToAnimate).animate(anim, parseInt(theTime),theEasing, function() {
                move(theIndex + 1,TheAnimationSequence,objectToAnimate,Loop,LoopTime);
            });
        }
        else
        {
            if(Loop){
               move(0,TheAnimationSequence,objectToAnimate,Loop,LoopTime);
            }
        }
}
  
    
    
    
    
$(document).ready(function(){
setImage();
setInterval("move( 0,restore2,'#BannerFade')",6000); 

//setInterval("move( 0,restore3,'#RandomBanners')",15000); 

});

