var lastMouseX;
var lastMouseY;
var curPopupWindow = null;

function setLastMousePosition(e) {
	if (navigator.appName.indexOf("Microsoft") != -1) e = window.event;
	lastMouseX = e.screenX;
	lastMouseY = e.screenY;
}

function openPopup(url, name, pWidth, pHeight, features, snapToLastMousePosition) {
	openPopupFocus(url, name, pWidth, pHeight, features, snapToLastMousePosition, true);
}

function openPopupFocus(url, name, pWidth, pHeight, features, snapToLastMousePosition, closeOnLoseFocus) {
	closePopup();

	if (snapToLastMousePosition) {
		if (lastMouseX - pWidth < 0) {
			lastMouseX = pWidth;
		}
		if (lastMouseY + pHeight > screen.height) {
			lastMouseY -= (lastMouseY + pHeight + 50) - screen.height;
		}
		lastMouseX -= pWidth;
		lastMouseY += 10;
		features += "screenX=" + lastMouseX + ",left=" + lastMouseX + "screenY=" + lastMouseY + ",top=" + lastMouseY;
	}

	if (closeOnLoseFocus) {
		curPopupWindow = window.open(url, name, features, false);
		curPopupWindow.focus();
	} else {
		win = window.open(url, name, features, false);
		win.focus();
	}
}

function closePopup() {
	if (curPopupWindow != null) {
       
		if (!curPopupWindow.closed)
			curPopupWindow.close();
		
		curPopupWindow = null;
	}
}

function showDate(baseURL, fld, frm) {
	var str = "/lookup/cal.cfm?frm=" + frm + "&fld=" + fld;
	if (eval("document." + frm + "." + fld).value.length > 0)
		str = str + "&cdate=" + eval("document." + frm + "." + fld).value;
	
	openPopup(str, "calwin", 170, 190, "width=170,height=190,toolbar=no,status=no,directories=no,menubar=no,resizable=no,scrollable=no", true);
}

function openWindow(url) {
	var popupWin = window.open(url, 'newWin',  'status,scrollbars,resizable,menubar,toolbar,dependent,width=750,height=550,left=50,top=50');
	popupWin.focus();
}

function openPrint(url) {
	var popupWin = window.open(url, 'printWin',  'status,scrollbars,resizable,menubar,toolbar,dependent,width=660,height=440,left=50,top=50');
	popupWin.focus();
}

function openEmail(url) {
	var popupWin = window.open(url, 'emailWin',  'status,scrollbars,resizable,dependent,width=450,height=350,left=50,top=50');
	popupWin.focus();
}


function ptWin() {
	var photoWin = window.open('http://www.neworleanscvb.com/phototour/phototour/index.cfm', 'photoWin',  'status=no,scrollbars=no,resizable=no,menubar=no,toolbar=no,dependent,width=760,height=480,left=50,top=50');
	photoWin.focus();
}

function ptWinURL(url) {
	var photoWin = window.open(url, 'photoWin',  'status=no,scrollbars=no,resizable=no,menubar=no,toolbar=no,dependent,width=760,height=480,left=50,top=50');
	photoWin.focus();
}

function openMap(url) {
	var mapwin = window.open(url, 'cvbmapwin', 'status=0,scrollbars=0,resizable=1,dependent,width=770,height=440,left=50,top=50');
	mapwin.focus();
}			

function openIPIX(url) {
 	var popupWin = window.open(url, 'ipixWin',  'status,scrollbars=no,resizable=no,dependent,width=620,height=450,left=50,top=50');
	popWin.focus();
}
