jQuery(document).ready(function($) {
    
    $('#home-slider').nivoSlider({
        effect:     'random',
        slices:     10,
        animSpeed:  500,
        pauseTime:  8000
    });
    
    $('#mycarousel').jcarousel({
        "scroll": 2,
        "wrap": "circular"
    });

    $('ul#main-menu')
    .supersubs({
        maxWidth:    35,
        minWidth:    15
    })
    .superfish({
        animation:   {opacity:'show',height:'show'},
        easing:      'easeOutBack'
    })
    .find('ul').bgIframe({opacity:false});


    $("a[href*=.flv]").flowplayer(
        {
            src: "site_addons/flowplayer/flowplayer.swf",
            wmode: "transparent"
        },
        {
            clip: {
                autoPlay: false
            }
        }
    );
    
/*
    var pageload = 0;                   /* remove ~trueblue when going live //
    var player = flowplayer("player", "site_addons/flowplayer/flowplayer.swf", {
            onLoad: function () {
                this.mute();
            },
            clip: {
                autoPlay: true
            }
        });

    player.onCuepoint(100, function(clip) {
        if( pageload === 0 )
        {
            player.pause();
            pageload = 1;
        }
        player.unmute();
    });
*/
});

soundManager.url = 'site_addons/templates/truebluepools.com/assets/soundmanager/soundmanager2.swf';
soundManager.onready(function(oStatus) {
  if (oStatus.success) {
    var mySound = soundManager.createSound({
      id: 'waterdrop',
      url: 'site_addons/templates/truebluepools.com/assets/files/water_drop.mp3'
    });
    
    $('#main-menu a').click(function(){
        mySound.play();
    });
    
    $('.faq-question').click(function(){
        mySound.play();
    });
    
  } else {
    // There was an error. No worries.
  }
})

jQuery(document).ready(function($) {
 
  showMarkup = '<span class="question-toggle show"><span>[+]</span></span>';
  hideMarkup = '<span class="question-toggle show"><span>[&ndash;]</span></span>';
 
  explanationMarkup = '<div class="faq-explanation">' + 
    '<p class="faq-explanation-info">Click on a question to expand the answer.</p>' +
    '<span class="faq-show-all">Show All</span>' +
    '<span class="faq-hide-all">Hide All</span>' +
    '</div>';
 
  questions = $('.faq-question');
  $(questions).eq(0).before(explanationMarkup);
 
  answers = $(questions).next('.faq-answer');
  $(answers).hide();  
 
  $(questions).prepend(showMarkup);
  $(questions).toggle(showAnswer, hideAnswer);
  
  showAllButton = $('.faq-show-all');
  hideAllButton = $('.faq-hide-all');
  
  $(showAllButton).click(showAllAnswers);
  $(hideAllButton).click(hideAllAnswers);
});
 
function hideAllAnswers()
{
  $(hideAllButton).addClass('faq-hide-all-active');
  $(showAllButton).removeClass('faq-show-all-active');
    
  $(answers).slideUp('fast');
  $(questions).find('.question-toggle').replaceWith(showMarkup);
}
 
function showAllAnswers()
{
  $(showAllButton).addClass('faq-show-all-active');
  $(hideAllButton).removeClass('faq-hide-all-active');
    
  $(answers).slideDown('fast');
  $(questions).find('.question-toggle').replaceWith(hideMarkup);
}
function showAnswer()
{
  $(showAllButton).removeClass('faq-show-all-active');
  $(hideAllButton).removeClass('faq-hide-all-active');
    
  $(this).next('.faq-answer').slideDown('fast');
  $(this).find('.question-toggle').replaceWith(hideMarkup);
}
 
function hideAnswer()
{
  $(showAllButton).removeClass('faq-show-all-active');
  $(hideAllButton).removeClass('faq-hide-all-active');
 
  $(this).next('.faq-answer').slideUp('fast');
  $(this).find('.question-toggle').replaceWith(showMarkup);
}
