String.prototype.trim = function() {
    a = this.replace(/^\s+/, '');
    return a.replace(/\s+$/, '');
};

var MP3flashvars = {};
var FLVflashvars = {};

function doClick(buttonName, e) {
    //the purpose of this function is to allow the enter key to 
    //point to the correct button to click.
    var key;

    if (window.event)
        key = window.event.keyCode;     //IE
    else
        key = e.which;     //firefox

    if (key == 13) {
        //Get the button the user wants to have clicked
        var btn = document.getElementById(buttonName);
        if (btn != null) { //If we find the button click it
            btn.click();
            event.keyCode = 0
        }
    }
}


function ShowCredits(p) {
    if (p) {
        document.getElementById('Credits').style.display = 'block';
    } else {
        document.getElementById('Credits').style.display = 'none';
    }
}

function ShowMP3PlayerObject(n, w, h, t, f, c1, c2, c3, a, b1, b2, v, e) {

    MP3flashvars.mp3 = f;
    MP3flashvars.title = t;
    MP3flashvars.color = c2;
    MP3flashvars.textcolor = c1;
    MP3flashvars.buttoncolor = c3;
    MP3flashvars.width = w;
    MP3flashvars.height = h;
    if (b1) {
        MP3flashvars.loop = "yes";
    } else {
        MP3flashvars.loop = "no";
    }
    if (b2) {
        MP3flashvars.lma = "yes";
    } else {
        MP3flashvars.lma = "no";
    }
    if (e) {
        MP3flashvars.hideeq = "yes";
    } else {
        MP3flashvars.hideeq = "no";
    }
    MP3flashvars.vol = v;
    if (a == '0') {
        //alert('stop');
        MP3flashvars.action = "stop";
    } else {
        //alert('play');
        MP3flashvars.action = "play";
    }

    swfobject.embedSWF("/swf/PWMP3Player.swf", n, MP3flashvars.width, MP3flashvars.height, "7", "", MP3flashvars, { wmode: "transparent" });
}

function ChangeMP3Object(n, t, f, c1, c2, c3) {
    MP3flashvars.mp3 = f;
    MP3flashvars.title = t;
    if (c2) MP3flashvars.color = c2;
    if (c1) MP3flashvars.textcolor = c1;
    if (c3) MP3flashvars.buttoncolor = c3;
    swfobject.embedSWF("/swf/PWMP3Player.swf", n, MP3flashvars.width, MP3flashvars.height, "7", "", MP3flashvars, { wmode: "transparent" });
}

function ShowFLVPlayerObject(n, w, h, t, f, c1, c2, c3, a, b1, b2, v, e, p) {

    FLVflashvars.flv = f;
    FLVflashvars.title = t;
    FLVflashvars.color = c2;
    FLVflashvars.textcolor = c1;
    FLVflashvars.buttoncolor = c3;
    FLVflashvars.width = w;
    FLVflashvars.height = h;
    if (b1 == '0') {
        FLVflashvars.format = "4:3";
    } else {
        FLVflashvars.format = "16:9";
    }
    if (b2) {
        FLVflashvars.hideController = "yes";
    } else {
        FLVflashvars.hideController = "no";
    }
    if (e) {
        FLVflashvars.hideeq = "yes";
    } else {
        FLVflashvars.hideeq = "no";
    }
    FLVflashvars.vol = v;
    if (a == '0') {
        //alert('stop');
        FLVflashvars.action = "stop";
    } else {
        //alert('play');
        FLVflashvars.action = "play";
    }
    FLVflashvars.preview = p;

    swfobject.embedSWF("/swf/PWFLVPlayer.swf", n, FLVflashvars.width, FLVflashvars.height, "7", "", FLVflashvars, { wmode: "transparent" });
}

function ChangeFLVObject(n, t, f, c1, c2, c3) {
    FLVflashvars.flv = f;
    FLVflashvars.title = t;
    if (c2) FLVflashvars.color = c2;
    if (c1) FLVflashvars.textcolor = c1;
    if (c3) FLVflashvars.buttoncolor = c3;
    swfobject.embedSWF("/swf/PWFLVPlayer.swf", n, FLVflashvars.width, FLVflashvars.height, "7", "", FLVflashvars, { wmode: "transparent" });
}

