var popupWin = null;

function openPopup() {
    var url = "mp/mplayer.php";	
    popupWin = open("", "popupWin", "width=765,height=600");
    if(!popupWin || popupWin.closed || !popupWin.appendToList || !popupWin.playAllSongs || !popupWin.playCharts || !popupWin.playFanList) {
	popupWin = window.open(url, "popupWin", "width=765,height=600");
    } else { 
	popupWin.focus(); 
    }
}
var type = null;
var id = null;
var mediatype = null;
var artist_id = null;
var fan_id = null;
var video = null;

function play(newtype, newid) {
    type = newtype || null;
    id = newid || null;
    openPopup();
    if(type != null && id != null) {
	popupWin.appendToList(type, id);
    } else {
	popupWin.playCharts();
    }
}

function playAllSongs(partist_id, pmediatype) {
    artist_id = partist_id || null;
    mediatype = pmediatype || null;
    openPopup();
    if(artist_id != null && mediatype != null) popupWin.playAllSongs(artist_id, mediatype);
}

function playFanList(pfan_id) {
    fan_id = pfan_id || null;
    openPopup();
    if(fan_id != null) popupWin.playFanList(fan_id);
}

function playEventVideos(vid) {
    video = vid || null;
    openPopup();
    popupWin.playEventVideos(video);
}

function init() {
    if(type != null && id != null) { 
	popupWin.appendToList(type, id); 
    } else if(artist_id != null && mediatype != null) {
	popupWin.playAllSongs(artist_id, mediatype);
    } else if(fan_id != null) {
	popupWin.playFanList(fan_id);
    } else if(video != null) {
	popupWin.playEventVideos(video);
    } else { 
	popupWin.playCharts(); 
    }
}
