function Login() {
	document.forms.LOGIN.submit();
}

function Logoff() {
	document.forms.LOGIN.LOGOFF.value = '1';
	document.forms.LOGIN.submit();
}

function LoginHelp() {
	alert('If you forgot your password then please login with ANY password (at least 1 character), you will then be able to request a new password.');
}

function CreditCard(amount) 
{
	result = confirm("Your credit card will now be charged USD " + amount + ", continue?");
	if (result == true) {
		document.forms[1].submit();
	}
}

function AddToCart(id)
{
	document.forms.PURCHASE.ACTION.value = 'ADD';
	document.forms.PURCHASE.ID.value = id;
	
	document.forms.PURCHASE.action = 'purchase_1.html';
	document.forms.PURCHASE.submit();
}

function RemoveFromCart(id, type)
{
	if (type == 'PRODUCT') 
		{ document.forms.PURCHASE.ACTION.value = 'REMOVE_PRODUCT'; }
	else
		{ document.forms.PURCHASE.ACTION.value = 'REMOVE_SUPPORT'; }
	
	document.forms.PURCHASE.ID.value = id;
	
	document.forms.PURCHASE.action = 'purchase_1.html';
	document.forms.PURCHASE.submit();
}

function CopyContactInformation()
{
	document.forms.PURCHASE2.CC_NAME.value = document.forms.PURCHASE2.FIRSTNAME.value + ' ' + document.forms.PURCHASE2.LASTNAME.value;
	
	document.forms.PURCHASE2.CC_STREET.value = document.forms.PURCHASE2.STREET.value;
	document.forms.PURCHASE2.CC_STREET2.value = document.forms.PURCHASE2.STREET2.value;
	
	document.forms.PURCHASE2.CC_CITY.value = document.forms.PURCHASE2.CITY.value;
	document.forms.PURCHASE2.CC_STATE.value = document.forms.PURCHASE2.STATE_SHORT.value;
	document.forms.PURCHASE2.CC_ZIPCODE.value = document.forms.PURCHASE2.ZIPCODE.value;
	
	document.forms.PURCHASE2.CC_PHONE.value = document.forms.PURCHASE2.PHONE.value;
	document.forms.PURCHASE2.CC_EMAIL.value = document.forms.PURCHASE2.EMAIL.value;
}

function CopyContactInformationToShipping()
{
	document.forms.PURCHASE.SHIP_NAME.value = document.forms.PURCHASE.FIRSTNAME.value + ' ' + document.forms.PURCHASE.LASTNAME.value;
	document.forms.PURCHASE.SHIP_COMPANY.value = document.forms.PURCHASE.COMPANY.value;
	
	document.forms.PURCHASE.SHIP_STREET.value = document.forms.PURCHASE.STREET.value;
	document.forms.PURCHASE.SHIP_STREET2.value = document.forms.PURCHASE.STREET2.value;
	
	document.forms.PURCHASE.SHIP_CITY.value = document.forms.PURCHASE.CITY.value;
	document.forms.PURCHASE.SHIP_STATE_SHORT.selectedIndex = document.forms.PURCHASE.STATE_SHORT.selectedIndex;
	document.forms.PURCHASE.SHIP_ZIPCODE.value = document.forms.PURCHASE.ZIPCODE.value;
}

function PurchaseHelp(product)
{
	myFile = 'purchasehelp_eventsentry.htm';
	
	x = 400;
	y = 300;
	
	if (product == 'EventSentry') {
		myFile = 'purchasehelp_eventsentry.htm';
		x = 740;
		y = 600;
	}
	else if (product == 'EventSentry Maintenance') {
		myFile = 'purchasehelp_eventsentry_maintenance.htm';
	}
	else if (product == 'EventSentry Heartbeat-Only') {
		myFile = 'purchasehelp_eventsentry_heartbeat.htm';
		y = 510;
	}
	else if (product == 'Gateway IP Monitor') {
		myFile = 'purchasehelp_gatewayipmonitor.htm';
	}
	else if (product == 'AutoAdministrator') {
		myFile = 'purchasehelp_autoadministrator.htm';
	}
	else if (product == 'EventSentry Hat') {
		myFile = 'purchasehelp_eventsentryhat.htm';
	}
	else if (product == 'EventSentry Mug') {
		myFile = 'purchasehelp_eventsentrymug.htm';
	}
	else if (product == 'Temperature and Humidity Sensor (US only)') {
		myFile = 'purchasehelp_eventsentry_humidtemp.htm';
		y = 400;
	}
	else if (product == 'Temperature Sensor (US only)') {
		myFile = 'purchasehelp_eventsentry_temp.htm';
		y = 500;
	}
	
	openWindow(myFile, 'PURCHASE_HELP', x, y);
}

function SubmitPurchase()
{
	if (document.forms.PURCHASE.FAX2.value != '' && document.forms.PURCHASE.FAX3.value != '')
	{
		document.forms.PURCHASE.FAX.value = '+' + document.forms.PURCHASE.FAX1.value + ' (' + document.forms.PURCHASE.FAX2.value + ') ' + document.forms.PURCHASE.FAX3.value;
	}
	
	document.forms.PURCHASE.PHONE.value = '+' + document.forms.PURCHASE.PHONE1.value + ' (' + document.forms.PURCHASE.PHONE2.value + ') ' + document.forms.PURCHASE.PHONE3.value;
	
	if (document.forms.PURCHASE.FIRSTNAME.value.toUpperCase() == 'PRIVATE' || document.forms.PURCHASE.LASTNAME.value.toUpperCase() == 'PRIVATE')
	{
		alert('Please specify your real name to continue, "PRIVATE" is not valid.');
		return;
	}
	
	document.forms.PURCHASE.submit();
}

function SubmitTrial()
{
	MyEmail = document.forms.CONTACT.EMAIL.value;
	
	if (MyEmail.lastIndexOf("@") == -1) {
		alert('Your trial license will be sent to your email address. Please specify a valid email address.');
		return;
	}
	if (MyEmail.lastIndexOf("hotmail.com") >= 0 || MyEmail.lastIndexOf("yahoo.com") >= 0 || MyEmail.lastIndexOf("mail.ru") >= 0) {
		alert('We are sorry, but we currently do not accept trial applications from email domains where the account is not verifyable, including hotmail.com. Please submit your request using a different email domain, and please note that we do not share your email address with anybody else and will only use it during your trial period. Thank you for your understanding.');
		return;
	}
	
	document.forms.CONTACT.DONE.value = 1;
	document.forms.CONTACT.submit();
}
