/******************************************************************/
//Show and hide toggles...with the use of hotspots...
//Usage: <body onload="visibilitytoggle();">
//		 <a href="#" id="hotspot" name="hotspot" class="hotspot">When the user click here it will toggle the next element that has a id of 'toggle'</a>
//		 <div id="toggle" name="toggle">Show and hide this content</div>

var hotspots = document.getElementsByName('hotspot');
var toggles = document.getElementsByName('toggle');

function visibilitytoggle()
{
  //set all the hotspots onclick events
  for (var i = 0; i < hotspots.length; i++)
  {
  hotspots[i].someProperty = i;
  hotspots[i].onclick = function() {toggle(this.someProperty)};
  }
  //Hide all the toggles
  for (var i = 0; i < toggles.length; i++)
  {
  toggles[i].style.display = 'none';
  }
  //Show the first toggle as this is the Whats hot
  toggles[0].style.display = '';
  //toggles[0].innerHTML = WhatsHot; //To change the whats hot section...
}

function toggle(i)
{
  if (toggles[i].style.display == 'none')
  {toggles[i].style.display = ''
  }
  else
  toggles[i].style.display = 'none';
  for (var x = 0; x < toggles.length; x++)
  {
    if (x != i)
	{
     toggles[x].style.display = 'none';
	}
  } 
} 

function showall()
{
  for (var i = 0; i < toggles.length; i++)
  {
  toggles[i].style.display = '';
  }
}

function hideall()
{
  for (var i = 0; i < toggles.length; i++)
  {
  toggles[i].style.display = 'none';
  }
}
//End of the toggle show/hide code...

/******************************************************************/

//Preloads a list of images... 
//Usage: simplePreload('01.gif','02.gif'); in the body tag
//var PreloadList = []

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];
  }
}
//End of Preload list of images function

/******************************************************************/

//Create a slid show of images for the glass beads page
//Usage: mySlideShow1.play(); in the body tag
function switchImage(imgName, imgSrc) 
{
  if (document.images)
  {
    if (imgSrc != "none")
    {
      document.images[imgName].src = imgSrc;
    }
  }
}

var mySlideList1 = ['_images/slides/beads/image5.jpg', '_images/slides/beads/image6.jpg', '_images/slides/beads/image7.jpg', '_images/slides/beads/image8.jpg', '_images/slides/beads/image9.jpg'];
var mySlideShow1 = new SlideShow(mySlideList1, 'slide1', 5000, "mySlideShow1");

var mySlideList2 = ['_images/slides/trophies/image1.jpg', '_images/slides/trophies/image2.jpg', '_images/slides/trophies/image3.jpg', '_images/slides/trophies/image4.jpg', '_images/slides/trophies/image5_thumb.jpg', '_images/slides/trophies/image6_thumb.jpg', '_images/slides/trophies/image7_thumb.jpg'];

var mySlideShow2 = new SlideShow(mySlideList2, 'slide2', 5000, "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);
  }
}
//End of slide show code
/******************************************************************/