﻿var d = new Date();
var attributes = { id: "playSoundSWF", name: "playSoundSWF" };
swfobject.embedSWF("/flash/play_sound.swf?" + d.getTime(), "flashContent", "1", "1", "8", "/Assets/flash/expressInstall", {}, {}, attributes);

function playSound(path) {
    var swf = document.getElementById('playSoundSWF');
    swf.playSound(path);
};

function onSoundComplete() {
    setTimeout("$('#utility-nav a#audio').removeClass('playing')", 750);
};

$(function() {
    // vyvanse pronunciation
    $('#utility-nav a#audio').click(function() {
        if ($('#playSoundSWF').length) {
            $('#utility-nav a#audio').addClass('playing');
            playSound('/mp3/vyvanse.mp3');
        }
    });
    
    // confirm overlay
    var extHref = '';
    $.modal.close();
    $('a.modal').click(function(e) {
        extHref = $(this).attr('rel');
        $('#confirm-overlay').modal({
            overlayClose: true,
            overlayCss: { backgroundColor: "#000" }
        });

        return false;
    });

    $('#confirm-overlay .btn-continue-overlay').click(function() {
        $.modal.close();
        window.open(extHref);
        return false;
    });
    $('#left-nav ul > li:has(ul)').not('.on').hover(navMouseIn, navMouseOut);
});
function navMouseIn(){
	if($(this).hasClass('open')){
		return false;
	}else{
		$(this).addClass('open').children('ul').slideDown();
	};
};
function navMouseOut(){
	$(this).children('ul').delay(500).slideUp(400,function(){
		$(this).removeClass('open');
		$(this).parent().removeClass('open');
	});
};
