﻿$(function() {
    initHomePageFlash();
    initHomePageImageRollover();
});

// Take each instance of an element labelled "flash" and loads the information in the "data-flash" attribute.
initHomePageFlash = function() {
    $('div.flash').each(function() {
        flashembed($(this).attr('id'), { src: $(this).attr('data-flash'), wmode: 'opaque' }, { themeID: $(this).attr('data-theme') });
    });
};

initHomePageImageRollover = function() {

    try {
        $('[data-hover-image]')
        .bind('mouseover', function(event) {
            var $this = $(this);

            if (!$this.data('original-image')) {
                $this.data('original-image', $this.attr('src'));
            }

            $this.attr('src', $this.attr('data-hover-image'));
        })
        .bind('mouseout', function(event) {
            var $this = $(this),
                original = $this.data('original-image');

            if (original) {
                $this.attr('src', original);
            }
        });
    } catch (e) {
        trace(e);
    }

};

playingMusic = function(isMusicOn) {
    _gaq.push(['_trackEvent', 'Music', 'Mute', isMusicOn ? 'Unmute' : 'Mute']);
};
