function Post(pPage) {
	var url = pPage;
	// window.alert("Posting to page '" + url + "'");
	document.forms[0].method = "post";
	document.forms[0].action = url;
	document.forms[0].submit();
}

function Navigate(url) {
	if (window.navigator.appName == "Netscape") {
		window.parent.location.href = url;
		window.parent.location.reload;
	}
	else {
		window.parent.window.navigate(url);
	}
}

function textCounter(val, maxLimit, span) {
	if (val.length > maxLimit) { // if too long...trim it! 
		val = val.substring(0, maxLimit);
	} else { // otherwise, update 'characters left' counter
/*
		// alert(span + '.innerText: ' + document.getElementById(span).innerText);
		var avail = maxLimit - val.length;
		document.getElementById(span).innerText = avail.toString;
*/
	}
} 

function maxLength(val, maxLimit, label) {
	var entryLength = val.length;
	var entryOverflow = entryLength - maxLimit;
	if (entryLength > maxLimit) {
		var msg = "You have entered " + entryLength + " characters for '" + label +
		 "', but this field can only hold " + maxLimit + " characters.\n\nPlease abbreviate " +
		 "your entry by at least " + entryOverflow + " characters.";
		alert(msg);
	}
}

function Instruct(pMode, pPage, pHeader) {
	var msg = "Instructions for " + pMode + "ing your Agency\'s Red Books Listing\n";  // + pHeader
	msg += "================================================\n";
	
	// Agency
	if (pPage == "1") {
		msg += "Please enter details about your agency on this form.\n\n";
		if (pMode == "Add") {
			msg += "If your agency doesn't already appear in the Red Books, you can submit information for possible inclusion by completing this form.  ";
		}
		msg += "Agencies must report a minimum of $200,000 in Gross Annual Billings to be listed in the Red Books.\n\n";
		msg += "Please note:\n  - all of the required fields for submission are on the first page of the form\n";
		msg += "  - the Submit button is on the last page of the form\n";
	}
	
	// Media Specialization
	if (pPage == "2") { 
		msg += "Please select all Media Specializations that apply to your agency on this form.";
	}
	
	// Billing Breakdown
	if (pPage == "3") { 
		msg += "Please enter a Breakdown of your Gross Annual Billings in this form.\n";
		msg += "Please select either percentages or dollar numbers uniformly for each entry.";
	}
	
	// Personnel
	if (pPage == "4") { 
		msg += "Please enter your Key Personnel in this form.\n";
		msg += "If you have more than title per person, specify the multiple values by entering each one on its own line.";
	}
	
	// Accounts
	if (pPage == "5") { 
		msg += "Please enter your details about your Accounts/Clients in this form.\n";
		msg += "If you have more than one location or product per account, specify the multiple values by entering each one on its own line.";
	}
	
	alert(msg);
}

function checkEmail(strVal) {
	var atIndex    = strVal.lastIndexOf("@");
	var dotIndex   = strVal.lastIndexOf(".");
	var atInPlace  = (atIndex > 0) ? true : false;
	var dotInPlace = ((dotIndex > (atIndex+1)) && (dotIndex < (strVal.length-1))) ? true : false;
	return (atInPlace && dotInPlace);
}

function testPassword() {
	var strValTemp = TrimIt(document.formInput.txtPassword.value);
	if (strValTemp.length < 6) {
		window.alert("Please enter at least 6 characters in the 'Self-update Password' field.");
		return false;
	}
	return true;
}

function chkEnterPressed(event, action) {
//  Usage: <input type="text" onKeyPress="chkEnterPressed(event)" id=text1 name=text1>
//	Use this function to act on a keypress of Enter in a text box, i.e., submit a form
	var code = 0;
	if (document.layers) { // NS4
		code = event.which;
	} else { // IE
		code = event.keyCode;
	}
	if (code == 13) {
		if (TrimIt(action) == "") {
			action = "SubmitForm()";
		}
		eval(action); // execute the code specified by the "action" parameter
	}
}

function goEditPending(mode1,mode2) {
	if (document.getElementById) { // IE >=5, Netscape, >=6, Firefox, Safari
		parent.frameInput.document.getElementById("spanPageLink").style.display = mode1;
		parent.frameInput.document.getElementById("spanEditPending").style.display = mode2;
		parent.frameInput.document.getElementById("spanEditPendingSuppl").style.display = mode2;
	} else if (document.all) { // use for IE4
		parent.frameInput.spanPageLink.style.display = mode1;
		parent.frameInput.spanEditPending.style.display = mode2;
		parent.frameInput.spanEditPendingSuppl.style.display = mode2;
	}
}

