function onLoad() {
	var sStoreCode = cookieCrumb('DealerUpsStoreCode');
	var sLoginName = cookieCrumb('DealerUpsLoginName');
	var oFld = document.form1.storecode;
	oFld.value = sStoreCode;
	if (sStoreCode != '') {
		oFld = document.form1.loginname;
		oFld.value = sLoginName;
	}
	oFld.select();
	oFld.focus();
}

function cookieCrumb(sName) {
	var sCookie = document.cookie;
	var sCrumb = sCookie.split(sName + '=')[1];
	return typeof sCrumb != 'string' ? '' : sCrumb.split(';')[0];
}

function hitReturn() {
	if (window.event.keyCode == 13) {
		window.event.returnValue = false;
		readyToSubmit();
	}
}

function readyToSubmit() {
// check that window is big enough to display everything
// 979 x 610 is unmaximized window size when Office shortcut bar open and 1024 x 768, give 17 pixels more for Windows XP
// 979 x 570 is when radio or links toolbar is open, too, and buttons are large format
	var strWarning = '';
	var objFrameset = document.body;
	if (typeof objFrameset == 'undefined') {
		alert('You must have Internet Explorer 5.0 or better to log in.');
		return;
	}
	var intPix;
	if ((intPix = 962 - objFrameset.clientWidth) > 0) strWarning = intPix + ' pixels wider';
	if ((intPix = 570 - objFrameset.clientHeight) > 0) strWarning = (strWarning == '' ? '' : strWarning + ' and ') + intPix + ' pixels taller';
	if (strWarning != '') {
		strWarning = 'The window should be ' + strWarning + ' to see everything.';
		if (screen.width < 1024 || screen.height < 768) strWarning +=
'\n\nThe screen resolution is now ' + screen.width + ' x ' + screen.height +
' but should be at least 1024 x 768. To change this, close all windows and' +
' right-click your mouse on the desktop screen area.  Choose "Properties"' +
' from the drop-down menu.  Click on the "Settings" tab at the top of the' +
' new dialog box.  Adjust the "Screen area" to 1024 by 768 pixels.'
		if (!confirm(strWarning + '\n\nDo you still want to log in now? Click OK to log in or Cancel to enlarge the window first.'))
			return;
	}
// make sure they filled in StoreCode, LoginName, and Password
	if (document.form1.storecode.value == '') {
		alert('Please type a store code.');
		document.form1.storecode.focus();
		return;
	}
	if (document.form1.loginname.value == '') {
		alert('Please type a user name.');
		document.form1.loginname.focus();
		return;
	}
	if (document.form1.password.value == '') {
		alert('Please type a password.');
		document.form1.password.focus();
		return;
	}
	var datExpire = new Date();
	datExpire.setMonth(datExpire.getMonth() + 24);
	document.cookie = "DealerUpsStoreCode=" + document.form1.storecode.value + "; expires=" + datExpire.toGMTString();
	document.cookie = "DealerUpsLoginName=" + document.form1.loginname.value + "; expires=" + datExpire.toGMTString();
	document.form1.submit();
}