var mapWin = null;
var x=0;
var y=0;
var screenw = screen.availWidth;
var screenh = screen.availHeight;
var toShowLinks = false;

function printListing(strLocId, strType, strParm1, strParm2)
{
	var URL = "printloc_KS.jsp?loc_id=" + strLocId + "&type=" + strType;

	if (strType == "zip")
	{
		URL = URL + "&zip=" + strParm1 + "&dist=" + strParm2;
	}
	else if (strType == "dealer")
	{
		URL = URL + "&dname=" + strParm1;
	}
	else if (strType == "state")
	{
		URL = URL + "&state=" + strParm1;
	}
	else
	{
		window.alert("invalid search type");

		return false;
	}

	if (navigator.appName == 'Netscape')
	{
		if (!checkMinorVerNS6(navigator.userAgent))
		{
			URL = "locations/" + URL;
		}
	}
	else if (navigator.appName == 'Microsoft Internet Explorer')
	{
		if (navigator.platform.indexOf('Mac') != -1)
		{
			URL = "locations/" + URL;
		}
		else
		{
			if (navigator.userAgent.indexOf('Opera') != -1)
			{
				URL = "locations/" + URL;
			}
		}
	}

	if (mapWin != null)
	{
		if (mapWin.closed == false)
		{
			mapWin.focus();
		}
	}

	getWindowPostion(); 

	mapWin = window.open(URL, "mapwindow", "width=630,height=660,left="+x+",top="+y+",scrollbars=yes,menubar=no,directories=no,location=no,toolbar=no");
}

/*
 * Called when the browser used is Netscape. If the NS version is 6.1+ it returns true and the corresponding chaged URL is called.
 */

function checkMinorVerNS6(userAgent)
{
	var index  = userAgent.indexOf("Netscape");
	var browserver = userAgent.substring(index);
	var tempArr = browserver.split("/");
	var verArr = tempArr[1].split(".");

	if (verArr[0] == '6')
	{
		if (verArr[1] >= 1)
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	return false;
}

/*
 * Calculates the window position for the
 */
function getWindowPostion()
{
	if (x != 0 && y != 0)
	{
		x = x + 24;
		y = y + 24;
	}
	else
	{
		x   = (screenw - 555) / 2;
		y   = (screenh - 610) / 2;
	}

	if (((x + 555) > screenw) ||  ((y + 610) > screenh))
	{
		x=0;
		y=0;
	}
}

