var customizations = new Array();

function CustomTuner() {
    customizations[customizations.length] = this;
}

function callCustom(proc) {
    var result = null;
    for (var i = 0; i < customizations.length; i++) {
	var f = customizations[i][proc];
	if (f != null) {
	    var status = f();
	    if (status != null)
		result = status;
	}
    }
    return result;
}

function callCustom1(proc, v1) {
    var result = null;
    for (var i = 0; i < customizations.length; i++) {
	var f = customizations[i][proc];
	if (f != null) {
	    var status = f(v1);
	    if (status != null)
		result = status;
	}
    }
    return result;
}

function Custom_Init() {
    callCustom("Init");
}

function Custom_GetAdUrl(v) {
    return callCustom1("GetAdUrl", v);
}

function Custom_ProcessAdResult(v) {
    return callCustom1("ProcessAdResult", v);
}

function Custom_PlayerEvent(v) {
    callCustom1("PlayerEvent", v);
}

function Custom_PlayerButton(v) {
    return callCustom1("PlayerButton", v);
}

function Custom_UpdateDocumentTitle() {
    return callCustom("UpdateDocumentTitle");
}

function Custom_DrawNowPlaying() {
    return callCustom("DrawNowPlaying");
}

function Custom_DrawCommercial() {
    return callCustom("DrawNowPlaying");
}

function Custom_DrawAd() {
    return callCustom("DrawNowPlaying");
}

function Custom_DrawNextSong() {
    return callCustom("DrawNextSong");
}

function Custom_GetCoverArtClickUrl() {
    return callCustom("GetCoverArtClickUrl");
}

function Custom_ChannelChange(s) {
    var result = s;
    for (var i = 0; i < customizations.length; i++) {
	var f = customizations[i].ChannelChange;
	if (f != null)
	    s = f(s);
    }
    return result;
}

function Custom_ChannelChanged() {
    return callCustom("ChannelChanged");
}

function Custom_AdClick() {
    return callCustom("AdClick");
}

function Custom_AlbumClick() {
    return callCustom("AlbumClick");
}

function Custom_PlayStateChanged(v) {
    return callCustom1("PlayStateChanged", v);
}

function Custom_PlayAd(v) {
    return callCustom1("PlayAd", v);
}

function Custom_TunerEvent(snx,evType,properties) {
    var result = null;
    for (var i = 0; i < customizations.length; i++) {
	var f = customizations[i].TunerEvent;
	if (f != null) {
	    var status = f(snx,evType,properties);
	    if (status != null)
		result = status;
	}
    }
    return result;
}

function Custom_LoadAdElement(req) {
    var result = null;
    for (var i = 0; i < customizations.length; i++) {
	var f = customizations[i].LoadAdElement;
	if (f != null) {
	    var status = f(req);
	    if (status != null)
		result = status;
	}
    }
    return result;
}

