/*
*
*  Author: Damien Bolger
*  Date: August 2011
*  Written for: Amalgamated Helicopters, Reusable by Damien Bolger
*  
*
*  Just the one function changeimage() to increment through the array of image objects.
*  function is called from the script in the html every 5 seconds.  The timer is also in that script.
*  the increment variable i is global and resets to zero once it reaches the end of the array
*  In the html file just add to the image object list in the same format keeping the [array index] in order or take 
*  away images or swap in new ones.  Whatever you do keep the array index going 0,1,2,3,4,5... none missing or duplicates
*  Very important to keep that same format or browers might not know what is going on.  Especially Internet Explorer haha
*  
*/



function changeImage()
{

   var txt="";

   if(document.getElementById)
   {
      try
      {
         document.getElementById("main_img").src = main_image[i].src;
         document.getElementById("main_img").alt = main_image[i].alt;
         document.getElementById("main_img_caption").innerHTML = main_image[i].alt;
      }
      catch(err)
      {
         txt="Error description: " + err.description + "\n\n";
         txt+="Click OK to continue.\n\n";
         alert(txt);
      }
   }

   // Checks if we are at the end of the array, if not increment to next index if we are, reset to the start
   if (i < (num_images-1))
      i++;
   else
      i=0;


   return;
}


// Just a couple of debuging functions, no longer needed, fingers crossed

function imagepreload()
{
   document.getElementById("debug").innerHTML += "preload of images<br />";

   return;
}


function imagepostload()
{
   document.getElementById("debug").innerHTML += "images now loaded<br />";

   return;
}
