function displayError(msg, el)
	{
	msg = "You must " + msg + " before continuing. Please try again."
	alert(msg)
	if (el != null) el.focus()
	return false
	}
	
function validEmail(val)
	{
	RE = /^[A-Z0-9\.\_\-]+@([A-Z0-9\.\-]+\.)+[A-Z0-9\.\-]{2,4}$/i
	return RE.test(val)
	}
	
function validZipCode(val)
	{
	RE = /^[\d]{5}(-[\d]{4})?$/
	return RE.test(val)
	}
	
function validInteger(val)
	{
	RE = /^\-?\d+$/
	return RE.test(val)
	}
	
function validNumber(val)
	{
	RE = /^(\d{1,3}\,?(\d{3},?)*\d{3}(\.\d{0,2})?|\d{1,3}(\.\d{0,2})?|\.\d{1,2}?)$/
	return RE.test(val)
	}
	
function validDate(val)
	{
	var Test = new Date(val)
	if (isNaN(Test))
		return false
	else
		return true
	}
	
function validYear(val)
	{
	Now = new Date()
	if (! validInteger(val))
		return false
	else if (val < 2004 || val > Now.getFullYear() + 1)
		return false
	else
		return true
	}
	
function Trim(Str)
	{
	Str = LeftTrim(Str)
	return RightTrim(Str)
	}

function LeftTrim(Str)
	{
	for (i = 0; i < Str.length; i++)
		{
		if (Str.charAt(i) != " ")
			break
		}
	return Str.substring(i, Str.length)
	}
	
function RightTrim(Str)
	{
	for (i = Str.length - 1; i >= 0; i--)
		{
		if (Str.charAt(i) != " ")
			break
		}
	return Str.substring(0, i + 1)
	}
	
function testLength(el, len)
	{
	val = el.value
	if (val.length > len)
		{
		msg = "Your input exceeds the " + len + " character limit for this field. "
			+ "Please adjust your input and try again."
		alert(msg)
		el.focus()
		return false
		}
	return true
	}

function LogOut()
	{
	document.cookie = "UserID="
	document.location = "default.asp"
	}
	
/*-------------------------------------------------
SHOW PROMPT

Shows a Prompt box containing the specified message
and returns the user's input. RetVal will either be
a string or a null (if Cancel was clicked).
-------------------------------------------------*/
function showPrompt(msg, deflt, maxLen)
	{
	retVal = prompt(msg, deflt)
	if (retVal == "")
		{
		mMsg = "You must enter a value and then click the OK button. To exit without "
			+ "entering a value, click the Cancel button."
		alert(mMsg)
		showPrompt(msg, deflt)
		}
	else if (retVal != null && retVal.length > maxLen)
		{
		tmpVal = retVal.substring(0, maxLen)
		mMsg = "The maximum length for this value is " + maxLen + " characters. Your "
			+ "input exceeds this limit. To automatically truncate your input to the "
			+ "proper length, i.e. \"" + tmpVal + "\", click OK. To return and shorten "
			+ "your input, click Cancel."
		if (confirm(mMsg))
			retVal = tmpVal
		else
			showPrompt(msg, retVal, maxLen)
		}
	return(retVal)
	}

var nWin = ""

function showTerms(which)
	{
	if (nWin == "")
		{
		switch (which)
			{
			case 1:
				Page = "TermsDealer.asp"
				break
			case 2:
				Page = "TermsUser.asp"
				break
			}
		nWin = window.open(Page, "Terms", "width=400,height=600,scrollbars=yes,titlebar=no,menubar=no,toolbar=no,location=no,resizable=yes,status=yes")
		}
	else
		{
		nWin.close()
		nWin = ""
		showTerms(which)
		}
	}

function showPrivacy()
	{
	if (nWin == "")
		{
		nWin = window.open("Privacy.cfm", "Privacy", "width=400,height=600,scrollbars=yes,titlebar=no,menubar=no,toolbar=no,location=no,resizable=yes,status=yes")
		}
	else
		{
		nWin.close()
		nWin = ""
		showPrivacy()
		}
	}