/*
legacy stuff
TODO: handle events with jquery
*/
function enableToolbox() {
    var _el = document.getElementById(arguments[1][0]);
    _el.onclick=function(){fontsize.change(['contentMain'],'-1'); return false;}
    _el = document.getElementById(arguments[1][1]);
    _el.onclick=function(){fontsize.change(['contentMain'],'0'); return false;}
    _el = document.getElementById(arguments[1][2]);
    _el.onclick=function(){fontsize.change(['contentMain'],'+1'); return false;}
    _el = document.getElementById(arguments[1][3]);
    _el.onclick=function(){if (window.print) window.print(); return false;}
    _el = document.getElementById(arguments[0]);
    _el.style.display = "block"
}

$(document).ready(function() {
    /* init legacy stuff */
    enableToolbox('toolbox',['fontSizeDecreaseA','fontSizeResetA','fontSizeIncreaseA','printA']);
    fontsize.init(['contentMain']);

    /* handle events */
    $('input.focusandselect').click(function() {
        $(this).focus();
        $(this).select();
    });

    /* handle onclick */
    $('img.mediaThumb').click(function() {
        // split id of clicked element (e.g.: "mediaThumb-belotero-5-123-45")
        var mediaId = this.id;
        var v = this.id.split('-');
        var mediaName = v[1];
        var castId = v[2];
        var width  = v[3];
        var height = v[4];

        //console.log(castId);

        // fetch player markup for insertion
        $.ajax({
            type: 'GET',
            url: '/webcasts/get.php',
            data: 'name='+mediaName+'&cast_id='+castId+'&width='+width+'&height='+height,
            success: function(msg){
                var par = $('#'+mediaId).parent();
                $('#'+mediaId).parent().html(msg);
                $('#'+mediaId).remove();
            }
        });
    });
});

