// Copyright Sentry Login http://www.sentrylogin.com

	isUntouchedEmail = true;  // global
	isUntouchedPass = true;  // global
	hidePW = true; // global
	alignment = "RIGHT"; // global
	manner = "POP"; // global
	url = ""; // global
	Sentry_ip = ""; // global
	isIE8 = false; // global
	isOpen = false; // global
	
	isPro = false;	
	if (typeof isProtected === 'undefined') {
		// isProtected is undefined
	}
	else{
		isPro = isProtected;
	}
	if(isPro == false){
		// in Weebly, prot code is placed in footer, so check querystring
		var ms = querySt("ms");
		if(ms){
			if(ms != ""){
				isPro = true;
			}
		}
	}
	
	function initializeSentry(){
		//initialize Sentry Login aspects
		
		// turn off Sentry_noJSLogin
		document.getElementById("Sentry_noJSLogin").style.display = "none";
		
		
		// color fixes
		document.getElementById("Sentry_label_span").style.color = "black";
		document.getElementById("myProfile").style.color = "black";
		if(document.getElementById("signUp")){
			document.getElementById("signUp").style.color = "black";
		}
		if(document.getElementById("logOut")){
			document.getElementById("logOut").style.color = "black";
		}
		if(document.getElementById("goInsideSpan")){
			document.getElementById("goInsideSpan").style.color = "black";
		}
		
		// get ip address
		var ipUrl = "http://www.sentrylogin.com/sentry/ip.asp?ippw=2112hsur" + "&ms=" + new Date().getTime();
		invIP = createCrossDomainRequest();
		
		if(invIP){
			if(isIE8){
				invIP.onload = doIP;
				invIP.open("GET", ipUrl, false);
				invIP.send();
				
				// set some ie8 stuff
			}
			else{
				invIP.open("GET", ipUrl, false);
				invIP.send();
				Sentry_ip = invIP.responseText;
			}		
		}
		else{
			alert("No ip Invocation Took Place");
		}
			
		var a = document.getElementById("Settings");
		var result = a.getAttribute('ALIGNMENT');
		if(result == "RIGHT" || result == ""){
			alignment = "RIGHT";
		}
		else if(result == "CENTER"){
			alignment = "LEFT";
			document.getElementById("Sentry_label").style.textAlign = "center";
		}
		else{
			alignment = "LEFT";
			document.getElementById("Sentry_label").style.textAlign = "left";
		}
		
		
		manner = a.getAttribute('MANNER');
		if(manner == "GROW" || manner == "OPEN"){
			
			document.getElementById("magicGroup").style.position = "static";
			document.getElementById("magicGroup").style.left = "0px";
			document.getElementById("magicGroup").style.display = "none";
		}
		if(manner == "OPEN"){
			document.getElementById("xbox").style.display = "none";
			document.getElementById("magicGroup").style.left = "0px";
			document.getElementById("magicGroup").style.display = "block";
		}
				
		var fp = querySt("fromProt");
		var bnc = querySt("bnc");
		if(bnc){
			if(bnc == "1" && fp != "1"){
				// this is a bounce from bounce.asp
				var msg = "";
				var rsn = querySt("rsn");
				if(rsn){
					if(rsn == "noOb" || rsn == "mtCk"){
						msg = "Please Log In";
					}
					else if(rsn == "ppal"){
						msg = "You're not a member of that subscription.";
					}
					else if(rsn == "lvlo"){
						msg = "Your member access level isn't high enough to view that page.";
					}
					else if(rsn == "sgOt"){
						msg = "That page is reserved for another member only.";
					}
					else if(rsn == "regFail" || rsn == "regSpoof"){
						msg = "Login expired. Please log in again.";
					}
					if(msg != ""){
						// show messages div
						document.getElementById("messages").style.display="block";
						// load msg into messages div
						document.getElementById("messages").innerHTML = msg;
						// open the login
						Sentry_onClick("TopBar");
					}
				}
			}
		}
		// are they already logged in?
		Sentry_loginTkn = getCookie('Sentry_loginTkn');
		if(Sentry_loginTkn){
			if(Sentry_loginTkn != ""){
				Sentry_firstName = getCookie('Sentry_firstName');
				Sentry_showWelcome();
			}
		}
	} // end function initializeSentry
	
	function Sentry_showWelcome(){
		document.getElementById("Sentry_outermost").style.display="block";		
		// change id="Sentry_label_span" inner html
		document.getElementById("Sentry_label_span").innerHTML = "Hi, " +  Sentry_firstName;
		// hide stuff
		document.getElementById("Sentry_emailDiv").style.display="none";
		document.getElementById("Sentry_passwordDiv").style.display="none";
		document.getElementById("Sentry_HIDpasswordDiv").style.display="none";
		document.getElementById("unHideDiv").style.display="none";  
		document.getElementById("Sentry_button").style.display="none";  
		document.getElementById("psistDiv").style.display="none";  
		document.getElementById("signUp").style.display="none";
		// show other stuff
		// show goInside only if there is a landing page and if login is not already on a protected page
		Sentry_sendEmTo = getCookie('Sentry_sendEmTo');
		if(Sentry_sendEmTo){
			if(Sentry_sendEmTo != "" && isPro != true){
				document.getElementById("goInside").style.display="block"
				var e = Sentry_sendEmTo.indexOf("?");
				if(e != -1 ){
					var url = Sentry_sendEmTo + "&ms=" + new Date().getTime();
				}
				else{
					var url = Sentry_sendEmTo + "?ms=" + new Date().getTime();
				}
				document.getElementById("goInsideSpan").innerHTML = '<a href="' + url + '">Enter Member Area</a>';
				document.getElementById("Sentry_label_span").innerHTML = "Welcome, " +  Sentry_firstName;
			}
		}
		document.getElementById("logOut").style.display="block"
		if(alignment == "LEFT"){
			document.getElementById("logOut").style.textAlign="left";
			document.getElementById("myProfile").style.textAlign="left";
			document.getElementById("goInside").style.textAlign="left";
		}		
	} // end function Sentry_showWelcome
	
	function doIP(){
		Sentry_ip = invIP.responseText;
	}
	
	function getEl(){
		var ev = arguments[0] || window.event,
		origEl = ev.target || ev.srcElement;
		//alert(origEl.tagName);
		//alert(origEl.id);
		// called thusly: document.onclick = getEl;
	}
	
	function querySt(lookFor) {
		var wholeQS = window.location.search.substring(1);
		var nvPairs = wholeQS.split("&");
		var r;
		for (i=0;i<nvPairs.length;i++) {
			r = nvPairs[i].split("=");
			if (r[0] == lookFor) {
				return r[1];
			}
		}
		// call thusly: var koko = querySt("koko");
	}
		
	function createCookie(name,value,days){
		// call thusly: createCookie('username','testcookie',7);
		// 0.021 of a day is about 30 minutes
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		value = escape(value);
		document.cookie = name+"="+value+expires+"; path=/";
	}
	
	function eraseCookie(name){
		// call thusly: eraseCookie('username');
		createCookie(name,"",-1);
	}
	
	function getCookie(cookie_name){
		// call thusly: x = getCookie('username');
	  	var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
	  	if(results){
			return (unescape(results[2]));
		}
	  	else{
			return null;
		}
	}
	
	function LogOut(goto){
		eraseCookie('Sentry_loginTkn');
		eraseCookie('Sentry_memberPpl_ID');
		eraseCookie('Sentry_member_ID');
		eraseCookie('Sentry_memberAccessLvl');
		eraseCookie('Sentry_firstName');
		eraseCookie('Sentry_lastName');
		eraseCookie('Sentry_psist');
		eraseCookie('Sentry_sendEmTo');
		
		eraseCookie('Sentry%5FloginTkn'); // for ASP and PHP interconnectivity
		
		if(goto){
			if(goto != ""){
				// go to url
				if(isPro != true){
					window.location = goto;
				}
				else{
					// this login form is on a protected page
					var e = goto.indexOf("?");
					if(e != -1 ){
						window.location = goto + "&fromProt=1";
					}
					else{
						window.location = goto + "?fromProt=1";
					}
				}
			}
			else{
				if(isPro != true){
					//re-browse to this page
					// was: window.location.reload();
					
					// this gets rid of red msg if logging out
					var thisPage = window.location.href;
					// first get rid of it so we don't double it
					rplc = "&fromProt=1";
					thisPage = thisPage.replace(rplc, "");
					rplc = "?fromProt=1";
					thisPage = thisPage.replace(rplc, "");
					var rplc = "&fromProt=";
					thisPage = thisPage.replace(rplc, "");
					rplc = "?fromProt=";
					thisPage = thisPage.replace(rplc, "");
					// now put it in
					var e = thisPage.indexOf("?");
					if(e != -1 ){
						window.location = thisPage + "&fromProt=1";
					}
					else{
						window.location = thisPage + "?fromProt=1";
					}
				}
				else{
					//re-browse to this page with added qs
					var thisPage = window.location.href;
					var e = thisPage.indexOf("?");
					if(e != -1 ){
						window.location = thisPage + "&fromProt=1";
					}
					else{
						window.location = thisPage + "?fromProt=1";
					}
				}			
			}
		}
		else{
			if(isPro != true){
				//re-browse to this page
				// was: window.location.reload();
				
				// this gets rid of red msg if logging out
				var thisPage = window.location.href;
				// first get rid of it so we don't double it
				rplc = "&fromProt=1";
				thisPage = thisPage.replace(rplc, "");
				rplc = "?fromProt=1";
				thisPage = thisPage.replace(rplc, "");
				var rplc = "&fromProt=";
				thisPage = thisPage.replace(rplc, "");
				rplc = "?fromProt=";
				thisPage = thisPage.replace(rplc, "");
				// now put it in
				var e = thisPage.indexOf("?");
				if(e != -1 ){
					window.location = thisPage + "&fromProt=1";
				}
				else{
					window.location = thisPage + "?fromProt=1";
				}
			}
			else{
				//re-browse to this page with added qs
				var thisPage = window.location.href;
				var e = thisPage.indexOf("?");
				if(e != -1 ){
					window.location = thisPage + "&fromProt=1";
				}
				else{
					window.location = thisPage + "?fromProt=1";
				}
			}			
		}
	}
			
	function wipeOrNot(theID){
		if(theID == "Sentry_email" && isUntouchedEmail == true){
			document.getElementById(theID).value = ""; //wipe it	
		}
		if(theID == "Sentry_password" && isUntouchedPass == true){
			document.getElementById(theID).value = ""; //wipe it	
		}
		if(theID == "Sentry_HIDpassword" && isUntouchedPass == true){
			document.getElementById(theID).value = ""; //wipe it	
		}
	}
	
	function removeSpaces(string, theID){
		var str = "";
		// do not act upon a message string
		if(string != "E-mail is required" && string != "Password is required"){
 			str = string.split(' ').join('');
		}
		return str;
	}
		
	function Sentry_onfocus(theID) {
		wipeOrNot(theID);
		if(theID == "Sentry_password"){
			if(hidePW == true){
				// hide the Sentry_passwordDiv
				var h = document.getElementById("Sentry_passwordDiv");
				h.style.display = "none";
				// show the Sentry_HIDpasswordDiv
				var s = document.getElementById("Sentry_HIDpasswordDiv");
				s.style.display = "block";
				// switch focus to Sentry_HIDpassword
				document.getElementById("Sentry_HIDpassword").focus();
			}
		}
	}
	
	function Sentry_onkeydown(theEvent, theID){
		// only using onkeydown to handle IE because it beeps when you hit Enter key
		
		// listen for Enter Key
		if(!(theEvent.which)){ // filter out Chrome, etc.
			var keynum
			if(window.event){ // IE
				keynum = theEvent.keyCode;
				if(keynum == "13"){ // 13 is Enter Key
					// first, blur the calling field by focusing elsewhere
					document.getElementById("Sentry_button").focus();
					sentryLogin(); // try to submit the form
				}
			}
		}	
	}
	
	function Sentry_onkeyup(theValue, theID, theEvent){
	
		// listen for Enter Key
		var keynum
		if(theEvent.which){ // Netscape/Firefox/Opera
			keynum = theEvent.which;
		}
		if(keynum == "13"){ // 13 is Enter Key
			// first, blur the calling field by focusing elsewhere
			document.getElementById("Sentry_button").focus();
			sentryLogin(); // try to submit the form
		}
		else{ // it's some other key
			if(theID == "Sentry_email"){
				isUntouchedEmail = false;
			}
			if(theID == "Sentry_password"){
				if(document.getElementById("Sentry_password").value != ""){
					isUntouchedPass = false;
				}
				else{
					isUntouchedPass = true;
				}
			}
			if(theID == "Sentry_HIDpassword"){
				if(document.getElementById("Sentry_HIDpassword").value != ""){
					isUntouchedPass = false;
				}
				else{
					isUntouchedPass = true;
				}
			}
		}
	}
	
	function Sentry_onblur(theValue, theID){
		var str = removeSpaces(theValue, theID);
		document.getElementById(theID).value = str;
		if (str == ""){
			if(theID == "Sentry_email"){
				isUntouchedEmail = true;
				document.getElementById("Sentry_email").style.color = "";
				document.getElementById("Sentry_email").value = "E-mail Address";
			}
			if(theID == "Sentry_password"){
				isUntouchedPass = true;
				//clear the pw fields
				document.getElementById("Sentry_HIDpassword").value = "";
				document.getElementById("Sentry_password").style.color = "";
				document.getElementById("Sentry_password").value = "Password";
			}
			if(theID == "Sentry_HIDpassword"){
				//clear the pw fields
				document.getElementById("Sentry_password").style.color = "";
				document.getElementById("Sentry_password").value = "Password";
				document.getElementById("Sentry_HIDpassword").value = "";
				//swap out the pw divs again
				// show the Sentry_passwordDiv
				var h = document.getElementById("Sentry_passwordDiv");
				h.style.display = "block";
				// hide the Sentry_HIDpasswordDiv
				var s = document.getElementById("Sentry_HIDpasswordDiv");
				s.style.display = "none";
				isUntouchedPass = true;
			}
		}
	}
	
	function Sentry_onClick(theID){
		if(theID == "unHideSpan"){
			// toggle the checked state of unHide checkbox
			if(document.getElementById("unHide").checked == true){
				document.getElementById("unHide").checked = false;
				//change the wording shown
				document.getElementById("unHideSpan").innerHTML = "Show" ;
				// hide the password by swapping the password div visibilities
				hidePW = true; // so onfocus shows the bullets not words
				// preserve the pw already entered, if any, but NOT if it just contains "Password"
				var str = document.getElementById("Sentry_password").value;
				if(str == "Password"){
					str = "";
				}
				// clear Sentry_password
				document.getElementById("Sentry_password").value = "";
				// hide the Sentry_passwordDiv
				var h = document.getElementById("Sentry_passwordDiv");
				h.style.display = "none";				 
				// update and show the Sentry_HIDpasswordDiv
				var s = document.getElementById("Sentry_HIDpasswordDiv");
				s.style.display = "block";
				// switch focus to Sentry_HIDpassword
				document.getElementById("Sentry_HIDpassword").focus();
				// assign value last to put caret at end
				document.getElementById("Sentry_HIDpassword").value = str;
			}
			else{
				document.getElementById("unHide").checked = true;
				//change the wording shown
				document.getElementById("unHideSpan").innerHTML = "Hide" ;
				// reveal the password by swapping the password div visibilities
				hidePW = false; // so onfocus shows the words not bullets
				// preserve the pw already entered, if any
				var str = document.getElementById("Sentry_HIDpassword").value;
				// clear Sentry_HIDpassword
				document.getElementById("Sentry_HIDpassword").value = "";
				// hide the Sentry_HIDpasswordDiv
				var h = document.getElementById("Sentry_HIDpasswordDiv");
				h.style.display = "none";
				// update and show the Sentry_passwordDiv
				var s = document.getElementById("Sentry_passwordDiv");
				s.style.display = "block";
				// switch focus to Sentry_password
				document.getElementById("Sentry_password").focus();
				// assign value last to put caret at end
				document.getElementById("Sentry_password").value = str;
			}
		}
		else if(theID == "psistSpan"){
			// toggle the checked state of psist checkbox
			if(document.getElementById("psist").checked == true){
				document.getElementById("psist").checked = false;
				document.getElementById("psist").focus();
			}
			else{
				document.getElementById("psist").checked = true;
				document.getElementById("psist").focus();
			}
		}
		else if(theID == "psist"){
			document.getElementById("psist").focus();
		}
		else if(theID == "TopBar"){
			if(isOpen == false){
				//if closed, open the magicGroup
				var d = document.getElementById("magicGroup");
				var x = document.getElementById("xbox");
				if(alignment == "RIGHT"){
					if(manner == "POP"){
						d.style.left = "0px";
						x.style.textAlign = "left";
					}
					else if(manner == "GROW"){
						// manner is GROW must push open
						d.style.left = "0px";
						d.style.display = "block";
						x.style.textAlign = "left";
					}
				}
				else{
					if(manner == "POP"){
						d.style.left = "0px";
						x.style.textAlign = "right";
					}
					else if(manner == "GROW"){
						// manner is GROW must push open
						d.style.left = "0px";
						d.style.display = "block";
						x.style.textAlign = "right";
					}
				}
				isOpen = true;
			}
			else{
				// if open, close the magicGroup
				if(manner == "POP"){
					var d = document.getElementById("magicGroup");
					d.style.left = "-9999px";
					isOpen = false;
				}
				else if(manner == "GROW"){
					// manner is GROW must push closed
					var d = document.getElementById("magicGroup");
					d.style.left = "0px";
					d.style.display = "none";
					isOpen = false;
				}
			}			
		}
		else if(theID == "myProfile"){
			var Sentry_ID = document.getElementById("Sentry_ID").value;
			var univ = document.getElementById("univ").value;
			var url = "http://www.sentrylogin.com/sentry/member_myAccount.asp?Site_ID=" + Sentry_ID + "&univ=" + univ; // univ will only be 1 in PayPal accounts			
			// if token is set, send it also
			Sentry_loginTkn = getCookie('Sentry_loginTkn');
			if(Sentry_loginTkn){
				if(Sentry_loginTkn != ""){
					// get Sentry_member_ID too
					Sentry_member_ID = getCookie('Sentry_member_ID');
					Ppl_ID = getCookie('Sentry_memberPpl_ID');
					if(Ppl_ID == 0){
						Ppl_ID = "";
					}
					url = url + "&ajax=1&m=" + Sentry_member_ID + "&Ppl_ID=" + Ppl_ID + "&tk=" + Sentry_loginTkn;
				}
			}
			window.location = url;
		}
		else if(theID == "xout"){
			// xout was clicked
			// close the magicGroup
			if(manner == "POP"){
				var d = document.getElementById("magicGroup");
				d.style.left = "-9999px";
				isOpen = false;
			}
			else{
				var d = document.getElementById("magicGroup");
				d.style.left = "0px";
				d.style.display = "none";
				isOpen = false;
			}
		}
		else if(theID == "forgotSpan"){
			// Forgot was clicked
			var Sentry_ID = document.getElementById("Sentry_ID").value;
			var f = "http://www.sentrylogin.com/sentry/sentry_remind_pw.asp?Sentry_ID=" + Sentry_ID;
			window.location = f;
		}
	}
		
	function Sentry_onmouseover(theID){
		//if(theID == "magicGroup"){
			//open the magicGroup
		//	var d = document.getElementById("magicGroup");
		//	if(alignment == "RIGHT"){
		//		d.style.left = "-60";
		//	}
		//	else{
		//		d.style.left = "0";
		//	}
		//}
	}
	
	function Sentry_onmouseout(theID){
		//if(theID == "magicGroup"){
			//close the magicGroup, but only if no text fields have focus
			//act = document.activeElement.id;
			//if(act != "Sentry_email" && act != "Sentry_password" && act != "Sentry_HIDpassword" && act != "psist"){
			//	var d = document.getElementById("magicGroup");
			//	d.style.left = "-9999px";
			//}
		//}
	}
			
	// was: function createCrossDomainRequest(url, handler){
	function createCrossDomainRequest(url){
		var request;
		isIE8 = window.XDomainRequest ? true : false;
		if (isIE8){
			request = new window.XDomainRequest();
		}
		else{
			if (window.XMLHttpRequest){
				request = new XMLHttpRequest();
			}
			else{
				// code for IE6, IE5
				request = new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		return request;
	}

	function callOtherDomain(){
		if (invocation){
			if(isIE8){
				invocation.onload = outputResult;
				invocation.open("GET", url, true);
				invocation.send();
			}
			else{
				invocation.open('GET', url, true);
				invocation.onreadystatechange = handler;
				invocation.send();
			}
		}
		else{
			alert("No Invocation Took Place");
		}
	}

	function handler(evtXHR){
		if (invocation.readyState == 4){
			if (invocation.status == 200){
				outputResult();
			}
			else{
				alert("Invocation Errors Occured. Status is: " + invocation.status + "and URL contains: " + url);
			}
		}
	}

	function outputResult(){
		var response = invocation.responseText;
		rspArray = response.split('~');	
		if(rspArray[0]){
			if(rspArray[0] == "newLogin"){
				//login succeeded
				Sentry_loginTkn = rspArray[1];
				Sentry_sendEmTo = rspArray[2];  		// could be space
				Sentry_memberPpl_ID = rspArray[3]; 		// could be 0
				Sentry_member_ID = rspArray[4];
				Sentry_memberAccessLvl = rspArray[5];  	// could be 0
				Sentry_firstName = rspArray[6];
				Sentry_lastName = rspArray[7];
				Sentry_psist = rspArray[8];				// could be 0
				
				var duration;
				if(Sentry_psist == "1"){
					duration = 30; // 30 days
				}
				else{
					//duration = .021;  // about 30 minutes
					duration = ""; // lasts only the session
				}
				
				createCookie("Sentry_loginTkn", Sentry_loginTkn, duration);
				createCookie("Sentry_memberPpl_ID", Sentry_memberPpl_ID, duration);
				createCookie("Sentry_member_ID", Sentry_member_ID, duration);
				createCookie("Sentry_memberAccessLvl", Sentry_memberAccessLvl, duration);
				createCookie("Sentry_firstName", Sentry_firstName, duration);
				createCookie("Sentry_lastName", Sentry_lastName, duration);
				createCookie("Sentry_psist", Sentry_psist, duration);
				
				// hide Sentry_loggingIn
				document.getElementById("Sentry_loggingIn").style.display="none";						
				
				// if Sentry_sendEmTo isn't space, redirect to landing page
				if(Sentry_sendEmTo != " "){
					createCookie("Sentry_sendEmTo", Sentry_sendEmTo, duration);
					var e = Sentry_sendEmTo.indexOf("?");
					if(e != -1 ){
						window.location = Sentry_sendEmTo + "&ms=" + new Date().getTime();
					}
					else{
						window.location = Sentry_sendEmTo + "?ms=" + new Date().getTime();
					}
				}
				else{
					//not being redirected
					// call Sentry_showWelcome() function
					Sentry_showWelcome();
				}								
			}
			else if(rspArray[0] == "FAIL"){
				// rspArray[0] contained FAIL
				// hide wait animation
				document.getElementById("Sentry_loggingIn").style.display="none";
				
				// get values						
				var Members_ID = rspArray[1]; // could be space
				var Site_ID = rspArray[2]; // never empty
				var Reason = rspArray[3];  // never empty
				var deactReason = rspArray[4];  // could be space
				
				var msg = "";
				if(Reason == "pastLoginLimit"){
					msg = "You've reached your login limit.";
				}
				else if(Reason == "MbrExpired"){
					msg = "Your account is expired.";
				}
				else if(Reason == "MbrInact"){
					msg = "Your account is not active.";
				}
				else if(Reason == "PWnoMatch" || Reason == "noMbr"){
					msg = "Username or Password was incorrect.";
				}
				else if(Reason == "SitePastLoginLimit"){
					msg = "Our Sentry account has reached its login limit.";
				}
				else if(Reason == "SiteExpired"){
					msg = "Our Sentry account has expired.";
				}
				else if(Reason == "StInact"){
					msg = "Our Sentry account is not active.";
				}
				else if(Reason == "noSite"){
					msg = "Our Sentry account not found.";
				}
				// open the login
				document.getElementById("Sentry_outermost").style.display="block";
				// show messages div
				document.getElementById("messages").style.display="block";
				// load msg into messages div
				document.getElementById("messages").innerHTML = msg;
			}
			else{
				// rspArray[0] contained an unauthorized value
				// hide wait animation
				document.getElementById("Sentry_loggingIn").style.display="none";
				// open the login
				document.getElementById("Sentry_outermost").style.display="block";
				// show messages div
				document.getElementById("messages").style.display="block";
				// load msg into messages div
				document.getElementById("messages").innerHTML = "An error occurred. Error code: unauthResponse rspArray[0] contained: " + rspArray[0];
			}
		} // end if(rspArray[0])
		else{
			// rspArray[0] did not exist, could be server error
			// hide wait animation
			document.getElementById("Sentry_loggingIn").style.display="none";
			// open the login
			document.getElementById("Sentry_outermost").style.display="block";
			// show messages div
			document.getElementById("messages").style.display="block";
			// load msg into messages div
			document.getElementById("messages").innerHTML = "An error occurred. Error code: noArray";
		}
		
		//document.getElementById("Sentry_In").style.display="block";
		
		// for testing:
		//var curStr = document.getElementById("Sentry_In").innerHTML;
		//document.getElementById("Sentry_In").innerHTML = curStr + " " + response;
				
		//curStr = document.getElementById("Sentry_In").innerHTML;
		//document.getElementById("Sentry_In").innerHTML = curStr;
		
	}  // end function outputResult	
		
	function sentryLogin(){
		// clear msgs if any
		document.getElementById("messages").innerHTML = ".";
		// hide messages div if open
		document.getElementById("messages").style.display="none";
		var doSend = true;
		var Sentry_email = document.getElementById("Sentry_email").value;
		var Sentry_password = document.getElementById("Sentry_password").value;
		var Sentry_HIDpassword = document.getElementById("Sentry_HIDpassword").value;
		var psist;
		if(document.getElementById("psist").checked == true){
			psist = "1";
		}
		else{
			psist = "0";
		}
		var Sentry_ID = document.getElementById("Sentry_ID").value;
		var s = Sentry_email.indexOf("@");	
		if(s == -1){
			if (Sentry_email.length==0 || isUntouchedEmail == true){
				document.getElementById("Sentry_email").value = "E-mail is required";
				document.getElementById("Sentry_email").style.color = "red";
				//other validation here
				doSend = false;
			}
		}
		if ((Sentry_password.length==0 || isUntouchedPass == true) && (Sentry_HIDpassword.length==0 || isUntouchedPass == true)){
			document.getElementById("Sentry_password").value = "Password is required";
			document.getElementById("Sentry_password").style.color = "red";
			document.getElementById("Sentry_HIDpassword").value = "";
			doSend = false;
		}
		if(doSend == true){	
			// hide outermost
			document.getElementById("Sentry_outermost").style.display="none";
			// show Sentry_loggingIn
			document.getElementById("Sentry_loggingIn").style.display="block";
		
			if(Sentry_HIDpassword != ""){
				pwStr = Sentry_HIDpassword;
			}
			else{
				pwStr = Sentry_password;
			}
						
			invocation = createCrossDomainRequest();
			url = "http://www.sentrylogin.com/sentry/NoSockets/loginActionAJAX.asp?Sentry_ID=" + Sentry_ID + "&e=" + Sentry_email + "&p=" + pwStr + "&psist=" + psist + "&ip=" + Sentry_ip + "&ms=" + new Date().getTime();   
			callOtherDomain();
		} // end if(doSend == true)
	} //  end function sentryLogin()
