// JavaScript Document

var wimpyWindow;
var winOpen=0;

function wimpyPopPlayer(wimpyPopPage,theWidth,theHeight) {
	x = (screen.width) ? (screen.width-theWidth)/2 : 0;
	y = (screen.height) ? (screen.height-theHeight)/2 : 0;
	wimpyWindow = window.open(wimpyPopPage,'wimpyMP3player','width='+theWidth+',height='+theHeight+',top='+y+',left='+x);
	winOpen=1;
}

function wimpyPopPlayerWithFile(wimpyPopPage,initialFile,theWidth,theHeight) {
	x = (screen.width) ? (screen.width-theWidth)/2 : 0;
	y = (screen.height) ? (screen.height-theHeight)/2 : 0;
	wimpyWindow = window.open(wimpyPopPage+'?theFile='+initialFile,'wimpyMP3player','width='+theWidth+',height='+theHeight+',top='+y+',left='+x);
	winOpen=1;
}

function wimpyIsOpen(){
	if (winOpen==1){
		if (wimpyWindow.closed){
			return false;
		} else {
			return true;
		}
	} else {
		return false;
	}
}

function wimpyPopAndPlay(theFile, theArtist, theTitle, graphicURL, hotlinkURL){
	if(wimpyIsOpen()){
		wimpyWindow.focus();
		wimpyWindow.wimpy_loadAndPlay(theFile, theArtist, theTitle, graphicURL, hotlinkURL);
	} else {
		wimpyPopPlayerWithFile('wimpy/aplayer.html',theFile,'278','243');
	}
}
