/*  Auto-Tab function...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function autoTab(what,max,nextf) {
	if (document.layers) {
		if (event.target.value.length >= max)
			eval('document.' + nextf + '.focus();');
	}
	else if (document.all) {
		if (what.value.length > (max-1))
			eval('document.' + nextf + '.focus();');
	}
}


/*  Perform on Internet Explorer KeyPress event...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function microsoftKeyPress() {
	if (window.event.keyCode == 27) {
		if ("<% = Left(Filename,1) %>" == "+") {	// Close popup windows on ESC keypress...
			window.close();
		}
	}
	
	if (window.event.keyCode == 13) {
		if ("<% = Filename %>" == "contact.asp") {	// If sFilename ASP variable equals 'contact.asp'
			document.contact.submit();
		}
		if ("<% = Filename %>" == "login.asp") {	// If sFilename ASP variable equals 'login.asp'
			document.loginform.submit();
		}
		if ("<% = Filename %>" == "campaign_process.asp") {	// If sFilename ASP variable equals 'campaign_process.asp'
			document.login.submit();
		}
	}
}


/*  Declaration & Init for KeyPress events in Netscape...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if (navigator.appName == 'Netscape') {
	window.captureEvents(Event.KEYPRESS);
	window.onKeyPress = netscapeKeyPress;
}


function netscapeKeyPress(e) {
	if (e.which == 27) {
		if ("<% = Left(Filename,1) %>" == "+") {	// Close popup windows on ESC keypress...
			window.close();
		}
	}
	
	if (e.which == 13) {
		if ("<% = Filename %>" == "contact.asp") {	//ds If sFilename ASP variable equals 'contact.asp'
			document.campaign.submit();
		}
		if ("<% = Filename %>" == "login.asp") {	// If sFilename ASP variable equals 'login.asp'
			document.login.submit();
		}
		if ("<% = Filename %>" == "campaign_process.asp") {	// If sFilename ASP variable equals 'campaign_process.asp'
			document.campaign.submit();
		}
	}
}


/*  This is the nav menu plus minus replacement...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
plusminus1 = new Image(9,9);
plusminus1.src = "bImages/sub_minus.gif";
plusminus2 = new Image(9,9);
plusminus2.src = "bImages/sub_plus.gif";


/*  HiLite image change function...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function hiLite(imgDocID,imgObjName) {
	document.images[imgDocID].src = eval(imgObjName + ".src")
}


/*  This opens external links from the nav menu items...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function openLink(linkHref) {
	if (screen.width >= 1024) {				// 1024x768 (or higher)...
		iW = "800";
		iH = "600";
	} else if (screen.width == 800) {		// 800x600...
		iW = "760";
		iH = "500";
	} else {								// 640x480...
		iW = "620";
		iH = "350";
	}
	window.open(linkHref,"LinkWindow","width=" + iW + ",height=" + iH + ",menubar=no,toolbar=no,scrollbars=yes,statusbar=yes,resizable=yes,location=no,directories=no")
}


/*  This is the nwindow (new window) function...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function nwindow(load,w,h,wstate,attrib,name,x,y) {
	// Defaults...
	var wname = "nwindow";
	var toolbar = "no";
	var scrollbars = "yes";
	var resizeable = "no";
	var alwaysraised = "yes";
	var menubar = "no";
	var status = "no";
	var location = "no";
	var directories = "no";
	
	if (name != "") { wname = name; }
	
	if (window.openwin) { openwin.close(); }
	
	if (x == "") { x = 0 }
	if (y == "") { y = 0 }
	
	// Set size & position...
	var parms = "width=" + w + ",height=" + h + ",screenX=" + x + ",screenY=" + y + ",left=" + x + ",top=" + y;
	
	if (wstate == "max") { resizeable = "yes"; }
	
	if (attrib == "toolbar") {
		toolbar = "yes";
	} else if (attrib == "noscroll") {
		scrollbars = "no";
	}
	
	parms += ",resizable=" + resizeable;
	parms += ",toolbar=" + toolbar;
	parms += ",location=" + location;
	parms += ",directories=" + directories;
	parms += ",scrollbars=" + scrollbars;
	parms += ",menubar=" + menubar;
	parms += ",status=" + status;
	
	openwin = window.open(load,wname,parms);
}


/* OLD NWINDOW FUNCTION
///////////////////////////////////////////////////////////////
//// ORIGINAL BY JHELMS / REPLACED: MAY 23, 2002 BY JHELMS ////
///////////////////////////////////////////////////////////////
function nwindow(load,w,h,wstate,attrib,name,x,y) {
	if (name == "") {
		var wname = 'nwindow';
	} else {
		var wname = name;
	}
	
	if (x == "") {
	//	x = (screen.availWidth - w) / 2;
		x = 0;
	}
	if (y == "") {
	//	y = (screen.availHeight - h) / 2;
		y = 0;
	}
	
	if (!window.openwin || openwin.closed) {
		if (wstate == "max") {
			if (attrib == "toolbar") {
				var size = 'width=' + w + ',height=' + h + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + ',alwaysraised=yes,menubar=no,toolbar=yes,scrollbars=yes,statusbar=no,resizable=yes';
				openwin = window.open(load,wname,size);
			} else if (attrib == "noscroll") {
				var size = 'width=' + w + ',height=' + h + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + ',alwaysraised=yes,menubar=no,toolbar=no,scrollbars=no,statusbar=no,resizable=no';
				openwin = window.open(load,wname,size);
			} else {
				var size = 'width=' + w + ',height=' + h + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + ',alwaysraised=yes,menubar=no,scrollbars=yes,statusbar=no,resizable=yes';
				openwin = window.open(load,wname,size);
			}
		} else {
			if (attrib == "toolbar") {
				var size = 'width=' + w + ',height=' + h + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + ',alwaysraised=yes,menubar=no,toolbar=yes,scrollbars=yes,statusbar=no,resizable=no';
				openwin = window.open(load,wname,size);
			} else if (attrib == "noscroll") {
				var size = 'width=' + w + ',height=' + h + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + ',alwaysraised=yes,menubar=no,toolbar=no,scrollbars=no,statusbar=no,resizable=no';
				openwin = window.open(load,wname,size);
			} else {
				var size = 'width=' + w + ',height=' + h + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + ',alwaysraised=yes,menubar=no,scrollbars=yes,statusbar=no,resizable=no';
				openwin = window.open(load,wname,size);
			}
		}
	} else {
		openwin.close();
		if (wstate == "max") {
			if (attrib == "toolbar") {
				var size = 'width=' + w + ',height=' + h + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + ',alwaysraised=yes,menubar=no,toolbar=yes,scrollbars=yes,statusbar=no,resizable=yes';
				openwin = window.open(load,wname,size);
			} else if (attrib == "noscroll") {
				var size = 'width=' + w + ',height=' + h + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + ',alwaysraised=yes,menubar=no,toolbar=no,scrollbars=no,statusbar=no,resizable=no';
				openwin = window.open(load,wname,size);
			} else {
				var size = 'width=' + w + ',height=' + h + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + ',alwaysraised=yes,menubar=no,scrollbars=yes,statusbar=no,resizable=yes';
				openwin = window.open(load,wname,size);
			}
		} else {
			if (attrib == "toolbar") {
				var size = 'width=' + w + ',height=' + h + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + ',alwaysraised=yes,menubar=no,toolbar=yes,scrollbars=yes,statusbar=no,resizable=no';
				openwin = window.open(load,'nwindow',size);
			} else if (attrib == "noscroll") {
				var size = 'width=' + w + ',height=' + h + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + ',alwaysraised=yes,menubar=no,toolbar=no,scrollbars=no,statusbar=no,resizable=no';
				openwin = window.open(load,wname,size);
			} else {
				var size = 'width=' + w + ',height=' + h + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + ',alwaysraised=yes,menubar=no,scrollbars=yes,statusbar=no,resizable=no';
				openwin = window.open(load,wname,size);
			}
		}
	}
}
*/


/*  This is the pwindow (parent window) function...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function pwindow(load) {
	opener.location.href = load;
	window.close();
}


/*  Validate e-mail address...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function validateProWeb(){
	if (document.form.email.value == ""){
		alert("Please enter a valid email address.");
		document.form.email.focus();
		document.form.email.select();
		return false;
	}
	if (document.form.email.value == "your e-mail addr."){
		alert("You must enter your e-mail address.");
		document.form.email.focus();
		document.form.email.select();
		return false;
	}
	if (!ValidLength(document.form.email.value,6)){
		alert("Your e-mail address was found invalid.");
		document.form.email.focus();
		document.form.email.select();
		return false;
	}
	if (document.form.fname.value == "first name"){
		alert("Please enter your first name.");
		document.form.fname.focus();
		document.form.fname.select();
		return false;
	}
	if (document.form.fname.value == ""){
		alert("Please enter your first name.");
		document.form.fname.focus();
		document.form.fname.select();
		return false;
	}
	if (document.form.lname.value == "last name"){
		alert("Please enter your last name.");
		document.form.lname.focus();
		document.form.lname.select();
		return false;
	}
	if (document.form.lname.value == ""){
		alert("Please enter your last name.");
		document.form.lname.focus();
		document.form.lname.select();
		return false;
	}
}


/*  Validate length
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function ValidLength(item, len) {
   return (item.length >= len);
} 


/*  Printer Dialog popup
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function printer_friendly(printpage) {
	
	if (window.print != null) {
		window.print();
	} else {
		alert('Unfortunately, your browser does not support this shortcut. Press "Ctrl + P" to manually invoke the print dialogue.');
	}
	
	  /*----------------------------------------\
	 /  PRINT CODE THAT IS A WORK IN PROGRESS... \
	/---------------------------------------------\
	
		var pwindow
		
		var pagetoprint = "Includes/Content/Help/" + printpage
		
		pwindow = window.open('','PageToPrint','screenX=0,screenY=0,top=0,left=0,width=400,height=400,alwaysraised=no,menubar=yes,toolbar=yes,scrollbars=yes,statusbar=yes,resizable=yes,minimized=yes');
		
		pwindow.location.href = pagetoprint;
		
		if (pwindow.print != null) {
			pwindow.print();
			setTimer('pwindow.close()',2000);
		} else {
			alert('Unfortunately, your browser does not support this shortcut. Please select Print from the File menu.');
		}
	\--------------------------------------------*/
}