var popWin = null;
var lastMouseX;
var lastMouseY;
var isIE = navigator.appName.indexOf("Microsoft") != -1;

function calculator() {
	openWin("calculator.aspx", "C", 298, 275, 0, 0, 0); 
}

function closingcost() {
	openWin("closingcost.aspx", "C", 650, 600, 1, 0, 1); 
}

function salesummary() {
	openWin("salesummary.aspx", "C", 750, 600, 1, 0, 1); 
}

function transtracker() {
	openWin("transtracker.aspx", "C", 750, 600, 1, 0, 1); 
}

function experts(typ) {
	openWin("experts.aspx?type=" + typ, "C", 600, 550, 1, 0, 1); 
}

// Open Popup Window
function openWin(url, pos, width, height, scrollbar, toolbar, resize)
{
	var top = 0;
	var left = 0;
	if (pos == "C")
	{
		top = ((screen.height - 100) - height) / 2;
		left = ((screen.width - 100) - width) / 2;
	}
	else if (pos == "R")
	{
		top = 0;
		left = (screen.width - width + 25);
	}
	else // Snap to Mouse Position
	{
        if (lastMouseX - width < 0) lastMouseX = width;
        if (lastMouseY + height > screen.height) lastMouseY -= (lastMouseY + height + 50) - screen.height;
        lastMouseX -= width;
        lastMouseY += 10;
        top = lastMouseY;
        left = lastMouseX;
        moreFeat = ",screenX=" + lastMouseX + ",screenY=" + lastMouseY;
	}
	var sFeatures = "top=" + top + ",left=" + left + ",width=" + width + ",height=" + height + ",scrollbars=" + scrollbar + ",toolbars=" + toolbar + ",resizable=" + resize;
	if (popWin && !popWin.closed) popWin.close();
	popWin = window.open("", "", sFeatures);
	if (url != "") popWin.location.href = url;
}

function setLastPos(e) 
{
    if (isIE) e = window.event;
    lastMouseX = e.screenX;
    lastMouseY = e.screenY;
}

function initPage()
{
	window.status = "";
}

function exitPage() 
{
	if (popWin && !popWin.closed) popWin.close();
}

window.onload = initPage;
window.onunload = exitPage;
// End of Script
