<!--


//Javascript 

function clear_input() {
	document.login_form.client_usr_id.value = "";
	document.login_form.client_pwd.value = "";
	document.login_form.client_branch.checked = false;
	document.all("client_usr_id").focus();
}

function InvokeLoginIntranet() {
	var the_url, vlogin;

	the_url = "";
	vlogin = "";
		
	//vlogin = RSExecute("OOS/remotescript.asp", "VerifyLogin", document.all("username").value, document.all("userpwd").value );
	alert("Unrecognized login. Please try again.");
}

function InvokeLoginVerification() {
	var root_url, the_url, vlogin;
	
	root_url = "";
	the_url = "";
	vlogin = "";

	//GENERAL MAINTENACE
	//alert("We are installing several upgrades to our Online Ordering System.\n\nPlease don't save any work if the system let's you in to access your orders.\n\nThe system will be back online tomorrow morning, 9:00 AM.\n\nWe apologize for the inconvenience.\n\nThank you.");
	//return;
	
	//Check to see if Pennsauken checkbox is checked
	if (document.all("client_branch").checked == true)	
		root_url = "OOS_P/";
	else
		root_url = "OOS/";
		
	vlogin = RSExecute(root_url + "remotescript.asp", "VerifyLogin", document.all("client_usr_id").value, document.all("client_pwd").value );
		
	user_type = vlogin.return_value.substring(0,1);
	//alert(user_type);
	//return;

	/*
	user_type = vlogin.return_value;
	alert(user_type);
	return;
	*/
	  switch (user_type) {
		case "R": //ACTIVE REGULAR CUSTOMER
			the_url= root_url + "RBMainMenu.asp?";
			break;
		case "L": //ACTIVE LARGE CUSTOMER
			the_url= root_url + "RBMainMenu.asp?";
			break;
		case "J": //ACTIVE JOBBER CUSTOMER
			the_url= root_url + "RBMainMenu.asp?";
			break;
		case "T":
			the_url= root_url + "RBMainMenu.asp?";
			break;
		case "Z":
			the_url= root_url + "admin.asp?";
			break;
		case "I": //INACTIVE CUSTOMER
			alert("Account is marked 'inactive'. Access to online system denied. Please contact Rockland Bakery.");
			break;
		case "1":
			alert("Account number required. Please try again.");
			break;
		case "2":
			alert("Password required. Please try again.");
			break;
		case "3":
			msg = "Error connecting to database for login verification.\n\n";
			msg = msg + "ERROR: " + vlogin.return_value.substring(2,99) + "\n\n";
			msg = msg + "Please contact Rockland Bakery Web Master.";
			alert(msg);
			break;
		case "4":
			alert("Unrecognized login. Please try again.");
			break;
		case "5":
			alert("Unexpected account type. Login disallowed.");
			break;
		case "9":
			alert("Unrecognized login. Please try again.");
			break;
		default:
			alert("Unrecognized login. Please try again.");
			break;
	  }
	if (the_url != "") {
		var co = RSExecute(root_url + "remotescript.asp", "LoginUser", document.all("client_usr_id").value);
		if (co.return_value != 0) {
			alert("Error logging user into system. Contact Rockland Bakery Web Operator.");
			return;
		}
		if (user_type == "Z")
			enter_the_system(the_url,user_type);
		else
			// ONLY WARN ACTIVE CUSTOMER ACCOUNTS AND TEST ACCOUNTS IF ALREADY LOGGED ON
			if (validate_price_file(root_url)) {
				switch (vlogin.return_value.substring(2,3)) {
					case "0":	//CLEAN LOGOUT FROM LAST SESSION
						//enter_the_system();
						break;
					case "2":	//AUTO LOGOUT FROM LAST SESSION DUE TO SESSION INACTIVITY
						msg = "WARNING. ACCOUNT AUTO-LOGGED-OUT DURING LAST SESSION BECAUSE OF USER INACTIVITY.\n\n";
						msg = msg + "As a safety precaution, Rockland Bakery automatically logs out users when they're not actively using the system once logged in. Please understand, the system times out in 5 minutes if no key is pressed.\n\n";
						msg = msg + "IMPORTANT! Any unsaved changes to orders that may have been open during that time have been discarded.\n\n";
						msg = msg + "IT IS HIGHLY ADVISED THAT YOU CHECK YOUR PENDING DAILY AND STANDARD ORDERS FOR ACCURACY.";
						alert(msg);
						var logger = RSExecute(root_url + "remotescript.asp", "LogoutUser", document.all("client_usr_id").value);
						if (logger.return_value != 0)
							alert("Error occured resetting log status for account. Contact Rockland Bakery Web Operator.");
						break;
					default:	//ETIHER LOST CONNECTION, NOT LOGGED OUT PROPERLY OR MULTIPLE USERS
						msg = "WARNING. ACCOUNT IMPROPERLY LOGGED OUT FROM LAST SESSION. PRESS OK TO RESET ACCOUNT.\n\n";
						msg = msg + "As a safety precaution, Rockland Bakery warns its users when an account is improperly logged out from its last session which may have been caused by any of the following conditions:\n\n";
						msg = msg + "1) You did not log out of your last session by clicking on the 'Logout' button\n";
						msg = msg + "2) You lost your connection to or disconnected from the Internet before logging out of the system\n";
						msg = msg + "3) Someone other than yourself is logged into the system with your account credentials\n\n";
						msg = msg + "IMPORTANT! Any unsaved changes to orders that may have been open at that time may have been discarded.\n\n";
						msg = msg + "IT IS HIGHLY ADVISED THAT YOU CHECK YOUR PENDING DAILY AND STANDARD ORDERS FOR ACCURACY.";
						alert(msg);
						var logger = RSExecute(root_url + "remotescript.asp", "LogoutUser", document.all("client_usr_id").value);
						if (logger.return_value != 0)
							alert("Error occured resetting log status for account. Contact Rockland Bakery Web Operator.");
						break;
				}
				enter_the_system(the_url,user_type);

			}
			else {
				msg = "WARNING. ACCESS DENIED.\n\nProduct database is incomplete.\n\nPlease contact a Rockland Bakery Web Operator to resolve this.";
				alert(msg);
			}
	}
}





function enter_the_system(the_url,user_type) {
	var the_url, user_type;
	clear_input();
	

	//if (user_type == "R" || user_type == "L" || user_type == "J")

	//CHRISTMAS 2009 - NEW YEARS 2009
	//alert("Attention!\n\nOn Friday, December 25, 2009 and Friday, January 1, 2010, Rockland Bakery will be closed for Christmas and New Years. No routes will be going out for these holidays.\n\nPlease read carefully:\n\nAll orders for Saturday, December 26, 2009 and Saturday, January 2, 2010 have to be in before 2 PM on the Thurday prior to those dates.\n\n");


	//LABOR DAY
	//alert("Attention!\n\nOn Monday, September 6, 2010, Rockland Bakery will be closed.\nPlease make sure to get your order in by 2:00 PM Saturday for Monday and Tuesday.\n\nIMPORTANT CAKE ORDERS: All cake items must be ordered Friday for Tuesday.\n\nShould you have any questions or require any assistance, please do not hesitate to call us.");


	//MEMORIAL DAY 2008
	//alert("Attention!\n\nOn Monday, May 26, 2008, Rockland Bakery will closing early.\nPlease make sure to get your order in by 2:00 PM Monday for Tuesday.\n\nThere will be no commercial products available for delivery Monday. These include products from the following vendors: Acme, Angels, Hudson and Michelles.\n\nAll cake items must be ordered Friday for Tuesday.\n\nShould you have any questions or require any assistance, please do not hesitate to call us.");

	//NEW YEARS 2007
	//alert("Attention!\n\nOn Monday January 1st, Rockland Bakery will be closed for New Years. No routes will be going out.\n\nPlease read carefully:\n\nIf you currently get a Sunday delivery and need product for Monday, then double your Sunday order.\n\nIf you never get a Sunday delivery and need product for Monday, then adjust your Saturday order accordingly.\n\nAll orders for Saturday have to be in before 4 PM on Friday.\n\nAll orders for Sunday and Tuesday have to be in before 3 PM on Saturday.\n\n");
	
	//CHRISTMAS 2007 - NEW YEARS 2008
	//alert("Attention!\n\nOn Tuesday, December 25, 2007 and Tueday, January 1, 2008, Rockland Bakery will be closed for Christmas and New Years. No routes will be going out for these holidays.\n\nPlease read carefully:\n\nAll orders for Wednesday, December 26, 2007 and Wednesday, January 2, 2008 have to be in before 2 PM on the Monday prior to those dates.\n\n");

	//CHRISTMAS 2006
	//alert("Attention!\n\nOn Monday December 25th, Rockland Bakery will be closed for Christmas. No routes will be going out.\n\nPlease read carefully:\n\nIf you currently get a Sunday delivery and need product for Monday, then double your Sunday order.\n\nIf you never get a Sunday delivery and need product for Monday, then adjust your Saturday order accordingly.\n\nAll orders for Saturday have to be in before 4 PM on Friday.\n\nAll orders for Sunday and Tuesday have to be in before 3 PM on Saturday.\n\n");


	//JULY 4
	//alert("Attention!\n\nOn Monday, July 5, 2010, Rockland Bakery will be closing early.\nPlease make sure to get your order in by 2:00 PM Monday for Tuesday.\n\nIMPORTANT CAKE ORDERS: All cake items must be ordered Friday for Monday.\n\nShould you have any questions or require any assistance, please do not hesitate to call us.");

	//LABOR DAY
	//alert("Attention!\n\nOn Monday, August 3, 2007, Rockland Bakery will be closed.\nPlease make sure to get your order in by 2:00 PM Saturday for Monday and Tuesday.\n\nIMPORTANT CAKE ORDERS: All cake items must be ordered Friday for Tuesday.\n\nShould you have any questions or require any assistance, please do not hesitate to call us.");

	//LAOR DAY 2005
	//alert("Attention!\n\nOn Monday, September 5, 2005, Rockland Bakery will closing early.\nPlease make sure to get your order in by 1:30 PM Monday for Tuesday.\n\nIMPORTANT CAKE ORDERS: All cake items must be ordered Friday for Tuesday.\n\nShould you have any questions or require any assistance, please do not hesitate to call us.");

	//THANKSGIVING 2009
	//alert("Attention!\n\nOn Thursday, November 26, 2009, Rockland Bakery will closed for Thanksgiving.\n\nAll orders for Thursday, November 26th and Friday, November 27th must be placed online by 1:00 PM Wednesday, November 25th.\n\nNot all routes are going out Thursday. Please call the bakery to see if your route will be affected before placing your order. If your route is not going out, double your order for Wednesday.\n\nIMPORTANT CAKE ORDERS: All cake items must be called in no later than Tuesday, November 24th.\n\nShould you have any questions or require any assistance, please do not hesitate to call us.");
	
	window.location = the_url;
	//a_handle=window.open(the_url, "OrderMenu","height=650, width=768, resize=yes, left=0, top=0, align=center, titlebar=yes, location=no, toolbar=no, menubar=no, statusbar=no, scrollbars=yes");
	//a_handle.focus();
}

function validate_price_file(root_url) {
		var pricer = RSExecute(root_url + "remotescript.asp", "CheckPriceList", document.all("client_usr_id").value);
		return pricer.return_value;
}

function FocusLogin() {
	document.login_form.client_usr_id.focus();
}
-->