// JavaScript Document
// JavaScript Document
// Loads a new window per supplied specs from a link
// Sample of useage:
// <a name="details" href="" onclick="return loadBasicWin('DirectoryDetails.cfm', 'Details', 340, 260, 100)"><i>details</i></a>

var dtWindow;
function loadBasicWin(dtLink, dtTitle, dtW, dtH, dtL)
{
	if (typeof(dtWindow) == "undefined" || dtWindow.closed == true)
	{
		var winLeft = (screen.width / 2) + dtL;
		var size = "resizable=yes," + "width=" + dtW + ",height=" + dtH + ",left=" + winLeft;
				
		dtWindow = window.open(dtLink, dtTitle, size);
		dtWindow.focus();
		return false;
	}
		else
	{	
		var w = (dtW + 10);
		var h = (dtH + 30);
		dtWindow.resizeTo(w, h);
		dtWindow.location.replace(dtLink);
		dtWindow.focus();
		return false;
	}
}

// This function accepts width, height and horizontal position off center //
function loadSubWindow(subLink, subTitle, subW, subH, subP)
{
	if (typeof(subWindow) == "undefined" || subWindow.closed == true)
	{
		var winLeft = ((screen.width / 2) - (subW / 2)) + subP;
		var size = "scrollbars=yes,resizable=yes," + "width=" + subW + ",height=" + subH + ",left=" + winLeft;
		
		subWindow = window.open(subLink, subTitle, size);
		subWindow.focus();
		return false;
	}
		else
	{	
		subWindow.close();
		var winLeft = ((screen.width / 2) - (subW / 2)) + subP;
		var size = "scrollbars=yes,resizable=yes," + "width=" + subW + ",height=" + subH + ",left=" + winLeft;
		
		subWindow = window.open(subLink, subTitle, size);
		subWindow.focus();
		return false;
	}
}

// This function accept both a left and a top position and makes window resizable //
function loadPosWin(dtLink, dtTitle, dtW, dtH, dtL, dtT)
{
	if (typeof(dtWindow) == "undefined" || dtWindow.closed == true)
	{
		var winTop = dtT;
		var winLeft = dtL;
		var size = "resizable=yes," + "width=" + dtW + ",height=" + dtH + ",left=" + winLeft + ",top=" + winTop;
				
		dtWindow = window.open(dtLink, dtTitle, size);
		dtWindow.focus();
		return false;
	}
		else
	{	
		var w = (dtW + 10);
		var h = (dtH + 30);
		dtWindow.resizeTo(w, h);
		dtWindow.location.replace(dtLink);
		dtWindow.focus();
		return false;
	}
}

// This function accept both a left and a top position, makes window resizable and includes a scroll bar //
function loadPosScrollWin(dtLink, dtTitle, dtW, dtH, dtL, dtT)
{
	if (typeof(dtWindow) == "undefined" || dtWindow.closed == true)
	{
		var winTop = dtT;
		var winLeft = dtL;
		var size = "scrollbars=yes,resizable=yes," + "width=" + dtW + ",height=" + dtH + ",left=" + winLeft + ",top=" + winTop;
				
		dtWindow = window.open(dtLink, dtTitle, size);
		dtWindow.focus();
		return false;
	}
		else
	{	
		var w = (dtW + 10);
		var h = (dtH + 30);
		dtWindow.resizeTo(w, h);
		dtWindow.location.replace(dtLink);
		dtWindow.focus();
		return false;
	}
}
