﻿$(document).ready(init);

function init(){
    $("ul.contact:last").css("border-right-width", "0px");
    
    var totalWidth = 0;
    $("ul.contact").each(function(i){
        totalWidth+=$(this).outerWidth();
    });
    $("#contactPersons").width(totalWidth);//.css("visibility", "visible");
}

function init_jplayer() {
    //SHOW AFTER DOCUMENT IS READY. PREVENTS DISPLAY BEFORE LAYOUT IS READY
    $("#player-container").css("display", "block");

    $("#jpId").jPlayer({
        ready: function() {
            $("#volBarContainer").click(function(e) {
                setVolumeBarValue($("#jpId").jPlayerGetInfo("volume"));
            });

            $("#volMin").click(function(e) {
                setVolumeBarValue($("#jpId").jPlayerGetInfo("volume"));
            });
            $("#volMax").click(function(e) {
                setVolumeBarValue($("#jpId").jPlayerGetInfo("volume"));
            });

            $("#jpId").setFile($("#__songUrl").val());
            $("#jpId").play();
            $("#pause").css("display", "block");

            setVolumeBarValue($("#jpId").jPlayerGetInfo("volume"));
        },
        swfPath: 'scripts'
    });

    $("#jpId").jPlayerId("play", "play");
    $("#jpId").jPlayerId("pause", "pause");
    $("#jpId").jPlayerId("stop", "stop");
    $("#jpId").jPlayerId("loadBar", "loadBar");
    $("#jpId").jPlayerId("playBar", "playBar");
    $("#jpId").jPlayerId("volumeBar", "volBarContainer");
    $("#jpId").jPlayerId("volumeMin", "volMin");
    $("#jpId").jPlayerId("volumeMax", "volMax");

    $("#jpId").onProgressChange(function(loadPercent, ppr, playedPercentAbsolute, playedTime, totalTime) {
        $("#player-container span.playTime").text(toMMSS(playedTime));
        $("#player-container span.totalTime").text(toMMSS(totalTime));

        if (playedTime == totalTime && totalTime != "0")
            $("#jpId").stop();
    });
}