// JavaScript Document
// Example:

// simplePreload( '01.gif', '02.gif' ); 

function simplePreload()

{ 

  var args = simplePreload.arguments;

  document.imageArray = new Array(args.length);

  for(var i=0; i<args.length; i++)

  {

    document.imageArray[i] = new Image;

    document.imageArray[i].src = args[i];

  }

}

// * Dependencies * 

// this function requires the following snippets:

// JavaScript/images/switchImage

//

// BODY Example:

// <body onLoad="mySlideShow1.play(); mySlideShow2.play();">

// <img src="originalImage1.gif" name="slide1">

// <img src="originalImage2.gif" name="slide2">

//

// SCRIPT Example:

// var mySlideList1 = ['image1.gif', 'image2.gif', 'image3.gif'];

// var mySlideShow1 = new SlideShow(mySlideList1, 'slide1', 3000, "mySlideShow1");

// var mySlideList2 = ['image4.gif', 'image5.gif', 'image6.gif'];

// var mySlideShow2 = new SlideShow(mySlideList2, 'slide2', 1000, "mySlideShow2");

function SlideShow(slideList, image, speed, name)          

{

  this.slideList = slideList;

  this.image = image;

  this.speed = speed;

  this.name = name;

  this.current = 0;

  this.timer = 0;

}

SlideShow.prototype.play = SlideShow_play;  

function SlideShow_play()       

{
  with(this)

  {

    if(current++ == slideList.length-1) current = 0;

    switchImage(image, slideList[current]);

    clearTimeout(timer);

    timer = setTimeout(name+'.play()', speed);

  }

}

function switchImage(imgName, imgSrc) 

{
  if (document.images)

  {

    if (imgSrc != "none")

    {
      document.images[imgName].src = imgSrc;

    }

  }

}

function randomNumber(limit){
  return Math.floor(Math.random()*limit);
}



function popUpWindow(URLStr, left, top, width, height)

{

  if(popUpWin)

  {

    if(!popUpWin.closed) popUpWin.close();

  }

  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');

}

function redirect(URLStr)
{
// Set the value of the href property of the 
//location object to the address to which we want to 
//redirect users_
document.location.href = URLStr;
}


