/**
* Displays content in a sized popup window.
*/
function launchPopup(path, filename){

	// NB: If dimensions are defined, they won't be part of 
	// the filename argument.  Dimensions will be arguments[2]
	// and arguments[3].
	fileExtension = filename.substr(filename.indexOf("."));
	if (fileExtension.toLowerCase() == ".jpg"){
		assetType = "image";	
	} else if (fileExtension.toLowerCase() == ".mov"){
		assetType = "movie";
	} else if (fileExtension.toLowerCase() == ".html" || fileExtension.toLowerCase() == ".php"){
		assetType = "html";
	}

	// If there's only two arguments to this method, the dimensions of
	// the asset to be displayed in the popup window will be acquired
	// by the getID3 PHP module.  If there are three or more arguments,
	// the third and fourth arguments are the width and height of 
	// the asset.  To insure that there's a buffer around the asset in
	// the popup window, add the value of the buffer variable to the
	// width and height provided by the client.
	if (arguments.length == 2){
		var windowWidth = 100;
		var windowHeight = 100;
	} else {
		var winWidth = arguments[2];
		var winHeight = arguments[3];
		if (assetType != "html"){
			var windowWidth = winWidth + 40;
			var windowHeight = winHeight + 30;
			if (assetType == "movie"){
				windowHeight += 25;
			} else {
				windowHeight += 15;
			}
		} else {
			var windowWidth = winWidth;
			var windowHeight = winHeight;
		}
	}

	var windowName = "assetwindow";
	if (document.all || safari) {
		iW = document.body.clientWidth; 
		iH = document.body.clientHeight; 
		iL = window.screenLeft;
		iT = window.screenTop;
	} else if (document.layers || document.getElementById) {
		iW = window.outerWidth; 
		iH = window.outerHeight; 
		iL = screenX;
		iT = screenY; 
	} else {
		iW = screen.availWidth;
		iH = screen.availHeight;
		iL = 0;
		iT = 0; 
	}

	var initXPos = iL + ((iW - windowWidth)/2);
	var initYPos = iT + ((iH - windowHeight)/2);
	var windowOptions = "toolbar=0,menubar=0,location=0,directories=0,status=0,scrollbars=0,resizable=1,copyhistory=0,width=" + windowWidth + ",height=" + windowHeight + ",top=" + initYPos + ",left=" + initXPos + ",screeny=" + initYPos + ",screenx=" + initXPos;
	if (arguments.length == 2){
		remote = window.open("render_popup.php?layout=auto&assetType="+assetType+"&path=" + path + "&URI=" + filename + "&topXPos=" + iL + "&topYPos=" + iT + "&topW=" + iW + "&topH=" + iH,windowName,windowOptions);
	} else {
		if (assetType != "html"){
			remote = window.open("render_popup.php?layout=custom&assetType="+assetType+"&path=" + path + "&URI=" + filename + "&width="+arguments[2]+"&height="+arguments[3],windowName,windowOptions);
		} else {
			var windowOptions = "toolbar=0,menubar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,width=" + windowWidth + ",height=" + windowHeight + ",top=" + initYPos + ",left=" + initXPos + ",screeny=" + initYPos + ",screenx=" + initXPos;
			remote = window.open(path+filename, windowName, windowOptions);
		}
	}
	if (parseInt(navigator.appVersion) >= 4){
		remote.window.focus();
	}
}
