﻿$(document).ready(function () {
    $('a.track_broadcast').mousedown(function (ev) {
        var ib = $(this).attr('id');
        var dismissed = $(this).parent().hasClass('broadcastClose');
        track(ib, dismissed);
        if (dismissed) {
            $('.broadcast').slideUp();
            ev.preventDefault();
        }
        else {
            $('.broadcast').slideUp();
            var url = $(this).attr('href');
            if (url != "") {
                window.location = url;
            }
        }
    });

    function track(bcuuid, declined) {
        try {
            if (bcuuid == "") { return; }
            $.ajax({
                type: "POST",
                async : false,
                url: "/WebServices/TrackBroadcast.asmx/Track",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                data: "{'uuid':" + JSON.stringify(bcuuid) + " , 'declined':" + JSON.stringify(declined) + " }",
                cache: false
            });
        }
        catch (ex) {
            console.log(ex);
        }
    }
});

