﻿var		  bLoaded = false;

function fnLoader()
{
  bLoaded = true;
}

function ShowEach(oObject, sIDSound, sURLOver, sURLOut, bOver)
{
  if (bOver)
  {
	oObject.style.backgroundImage = sURLOver;
	PlaySound(sIDSound);
  }
  else
  {
	oObject.style.backgroundImage = sURLOut;
	StopSound(sIDSound);
  }
}

function ShowBurst(oObject, bOver) 
{	
  ShowEach(oObject, "soundflame", "url(images/burst.gif)", "url(images/flames.gif)", bOver);
}

function ShowBike(oObject, bOver) 
{	
  ShowEach(oObject, "soundbike", "url(images/bike_go.gif)", "url(images/bike_waiting.gif)", bOver);
}

function ShowRoll(oObject, bOver) 
{	
  ShowEach(oObject, "soundcheer", "url(images/roll.gif)", "url(images/bakerymoon.gif)", bOver);
}	

function ShowKayak(oObject, bOver) 
{	
  ShowEach(oObject, "soundkayak", "url(images/kayak_go.gif)", "url(images/kayak_steady.gif)", bOver);
}	

function ShowTaco(oObject, bOver) 
{	
  ShowEach(oObject, "soundtaco", "url(images/shakayum.gif)", "url(images/shakanormal.gif)", bOver);
}	

function PlaySound(sID) 
{
  var		oSound = fnSoundReady(sID);
  
  if (oSound)
  {
	oSound.Play();
  }
}    

function StopSound(sID) 
{
  var		oSound = fnSoundReady(sID);
  
  if (oSound)
  {
	oSound.Stop();
  }
}  

function fnSoundReady(sID)
{
  var		oSound = document.getElementById(sID);
  
  if ((!oSound) || (!bLoaded))
  {
    return (null);
  }
  
  if (oSound.document)
  {
	if (oSound.document.readyState != "complete")
	{
	  return (null);
	}
  }
  
  return (oSound);  
}
