<!-- 
// (c) 2000-2005 Live365.com.  All rights reserved.
// This file needs to be munged


var gWebServer = 'http://www.live365.com';
var gStoreServer = 'https://store.live365.com';

//gWebServer = 'http://devweb02.nanocosm.com';
//gStoreServer = 'https://devstore01.nanocosm.com';


// HelpPopUpFunction()
//  will popup window with header and footer formating.
//  middleframe = required = the file that you want to show up in the window.
//  topframe = optional = override the header file
//  bottomframe = optional = override the footer file
function HelpPopUpFunction(middleframe, topframe, bottomframe, height, width, windowName, advert, features, middlescroll)
{
	if (HelpPopUpFunction.arguments.length < 9 || HelpPopUpFunction.arguments[8] == "")
		middlescroll = "auto";
	if (HelpPopUpFunction.arguments.length < 8 || HelpPopUpFunction.arguments[7] == "")
		features = "";
	if (HelpPopUpFunction.arguments.length < 7 || HelpPopUpFunction.arguments[6] == "")
		advert = false;
	if (HelpPopUpFunction.arguments.length < 6 || HelpPopUpFunction.arguments[5] == "")
		windowName = "Live365Help";
	if (HelpPopUpFunction.arguments.length < 5 || HelpPopUpFunction.arguments[4] == "")
		width = 472;
	if (HelpPopUpFunction.arguments.length < 4 || HelpPopUpFunction.arguments[3] == "")
		height = 280;

	if (middleframe.indexOf('?') != -1)	// hack around IE 5.0 JS bug
		middleframe = escape(middleframe);

	var URL = buildArgString(middleframe, topframe, bottomframe, advert, middlescroll);
	
	//Mac IE5 doesn't suport window.print so we'll turn on the toolbar here to provide the built-in print button.
	if (!window.print)
		features += ",toolbar=yes";
	
	var win = openWindow(height,width,URL,windowName, features);		// launch window with height then width and then window name
}

function PopUpProfile(name, url) 
{
	var tmd = new Date();
	var tm = tmd.getTime();
	var numArgs = PopUpProfile.arguments.length + 1;

	if (numArgs < 2 || !url || url == "")
		url = '/broadcast/profiles/index.live?membername=' + name + '&' + tm;

	var profileWin = window.open(url, 'popUpDJWin', 'resizeable=no,scrollbars=no,width=580,height=450');

	if (profileWin.focus)
		profileWin.focus();
}

// popUp()
//   to be used for simply popups where formating should not be used (for flash presentations)
//   URL = required = pass in the page that you want to display
//   height = optional = pass in height of popup window
//   width = optional = pass in wdith of popup window
function popUp(URL, height, width, windowName, features) {

	if (popUp.arguments.length < 5 || popUp.arguments[4] == "")
		features = "";
	if (popUp.arguments.length < 4 || popUp.arguments[3] == "")
		windowName = "Live365popUp";

	var lHeight	= (height) ? height : "280";
	var lWidth	= (width) ? height : "472";
	openWindow (lHeight, lWidth, URL, windowName, features);
}

// openWindow()
//   supports popUp() & HelpPopUpFunction() = actually launches window and allows you to have both open at same time.
//   height = optional = pass in height of popup window
//   width = optional = pass in wdith of popup window
//   URL = required = pass in the page that you want to display
//   windowName = to allow multiple windows

var gPopUp = null;
var gPopUpName = '';

function openWindow(height, width, URL, windowName, features) 
{
	var win = null;

	if (openWindow.arguments.length < 5 || openWindow.arguments[4] == "")
		features = "resizeable=no,scrollbars=no,menubar=no";

	var name = windowName + width + "x" + height;

	if (window.location.protocol != "https:")
		name += "xhttps";

	if (gPopUp != null && !gPopUp.closed && name == gPopUpName) {
		gPopUp.location.replace(URL);
		win = gPopUp;
	} 
	else {
		features += ',width=' + width + ',height=' + height;
		win = window.open(URL, name, features);

		if(win==null)
		{
			throw(1);
		}

		gPopUp = win;
		gPopUpName = name;
	}
		
	if (win && win.focus)
	{
		try
		{
			win.focus();
		}
		catch(e)
		{
			throw(2);
		}
	}
}
/*
function popUpBlockerAlert()
{
	alert("Unable to launch the Live365 player,\ndo you have a popup blocker running?\n\nIf so, temporarily turn it off, and try again.")
}
*/
function buildArgString(middleframe, topframe, bottomframe, advert, middlescroll)
{
	var URL, serverURL;
	serverURL = gWebServer;
	
	if (window.location.protocol == "https:")
		serverURL = gStoreServer;	

	URL = serverURL + "/popup/frameset.live?topframe=";

	if (advert) {
		URL = URL + serverURL + "/popup/top-advert.html";
		URL = URL + "&middleframe=";
	} 
	else {
		if (topframe)
			URL = URL + topframe;
		else
			URL = URL + serverURL + "/popup/top_default.html";
		URL = URL + "&middleframe=";
	}
		
	if (middleframe)
		URL = URL + middleframe;
	else
		URL = URL + serverURL + "/popup/404.html";		
	URL = URL + "&bottomframe=";

	if (bottomframe)
		URL = URL + bottomframe;
	else
		URL = URL + serverURL + "/popup/bottom_default.html";
	URL = URL + "&advert=" + advert;

	if (middlescroll)
		URL += "&middlescroll=" + middlescroll;

	return URL;
}


// printPage()
//	IE5 on the Mac doesn't support window.print().  This function works in conjunction with 
//  openWindow()'s ability to display the browser's toolbar if window.print() isn't supported,
//	and directs the user to print via their browser's built-in print button.

var pr = (window.print) ? 1 : 0;

function printPage(mywindow) 
{
	if (pr)
		mywindow.print();
	else
		alert("Sorry, your browser doesn't support this feature.\n Please use your browser's print button.");

	return false;
}

function ShowAlbumDetails(cover_img, artist, album, web_url, ecomm_url, width, height)
{
	var gCoverWin	  = null;
	var gCoverWinName = '';
	var win = null;
	var name = "Live365_cover" + width + "x" + height;
	var url = "/listening/library_popup.live?img=" + escape(cover_img) + "&artist=" + escape(artist) + "&album=" + escape(album);

	if (web_url)
		url += "&web_url=" + escape(web_url);

	if (ecomm_url)
		url += "&ecomm_url=" + escape(ecomm_url);

	if (gCoverWin != null && !gCoverWin.closed && name == gCoverWinName) {
	gCoverWin.location.replace(url);
		win = gCoverWin;
	} 
	else {
		win = window.open(url, name, 'resizable=yes,scrollbars=auto,menubar=no,width=' + width + ',height=' + height);
		gCoverWin = win;
		gCoverWinName = name;
	}

	if (win && win.focus)
		win.focus();		
}

//-->