﻿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", {}, {wmode:"transparent"}, 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;
    });
    
    $("#unsub-type input").each(function(){this.checked = false;});
});

function openExternalWin(product, url) {
    if(! confirm("You Are About to Leave " + product + ".com.\n\nThis link will take you to a Web site maintained by a third party, who is responsible for its content and privacy policy. Our privacy policy does not apply to this site. We encourage you to read the privacy policy of every Web site you visit. \n\nClick Cancel to return to " + product + ".com or OK to continue."))
        return;

    var externalWin = window.open(url,null,"toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=600,height=500");
    if (externalWin.opener == null)
        externalWin.opener=window;
        externalWin.opener.name="opener";
}
