function audio_can_play()
{
  if($("#src_audio_1").length)
  {
    if($("#src_audio_1")[0].canPlayType("audio/mp3") != "")
      return true;
  }
  
  return false;
}

function audio_init_player()
{
    $("img[id*='audio_']").click( function() { audio_play(this); } );
    $("audio[id*='src_audio_']").bind("ended", function() { audio_stopped(this); } );
}

function audio_play(player_id)
{
  var src_id = "#src_" + $(player_id).attr("id");
  
  $("audio[id*='src_audio_']").each(function()
  {
    if(("#" + $(this).attr("id")) != src_id)
    {
      this.pause();
      this.currentTime = 0;
      $(("#" + $(this).attr("id").substr(4))).attr("src", "/img/playbutton01.gif");
    }
  });
  
  event.preventDefault();
  
  if(($(src_id)[0].ended == true) || ($(src_id)[0].paused == true) || ($(src_id)[0].currentTime == 0))
  {
    $(src_id)[0].play();
    $(player_id).attr("src", "/img/pausebutton01.gif");
  }
  else
  {
    $(src_id)[0].pause();
    $(player_id).attr("src", "/img/playbutton01.gif");
  }
}

function audio_stopped(src_id)
{
  $(("#" + $(src_id).attr("id").substr(4))).attr("src", "/img/playbutton01.gif");
}

function show_nav()
{
  var path = window.location.pathname;
  var loc  = path.split("/");
  var id   = "#menu_home";
  
  if(loc.length > 2)
    id = "#menu_" + loc[1];
    
  if(id != "#menu_inc")
  {
    var width  = $(id).width();
    var offset = $(id).position().left - $("#navbar").offset().left; 
    
    $("#navloc").width(width);
    $("#navloc").css("margin-left", offset);
  }
}

$(document).ready(function()
{
	show_nav();
  
  if(audio_can_play())
  {
    audio_init_player();
  }
});


