function validateform() {
	var tempval;
	var uid;
	var pwd;
	uid = window.document.ssoform.UserID.value;
	pwd = window.document.ssoform.Password.value;
	tempval = document.ssoform.manage.options[document.ssoform.manage.options.selectedIndex].value;
	if(tempval=="advisor") {
		loginNow(tempval);
		return false;
	}
	if ((uid =="" |  pwd=="") & tempval !="" ) {
		alert('Please fill in both the "User ID" and "Password" fields to Log In to your Account successfully.');
		return false;
	}
	else if ( uid !="" & pwd !="" & tempval =="") {
		alert('Please select an Account to Log In.');
		return false;
	}
	else if ((uid =="" | pwd=="") & tempval =="") {
		alert('To Log In successfully, please fill in both the "User ID" and "Password" fields and select an Account.');
		return false;
	}
	else if (uid =="" & pwd=="" & tempval =="") {
		alert('To Log In successfully, please fill in both the "User ID" and "Password" fields and select an Account.');
		return false;
	}
	else if (uid.length < 4) {
		alert('Your User ID or Password is incorrect.');
		return false;
	}
	else if ((pwd.length < 5) || (pwd.length > 8)) {
		alert('Your User ID or Password is incorrect.');
		return false;
	}
	else {
		loginNow(tempval);
	}
}

function loginNow(tempval) {
	var dc=window.document.ssoform;
	if(tempval == "cards") {
		dc.submit();
	}
	if(tempval == "oms") {
		dc.USERID.value = dc.UserID.value;
		dc.PWD.value = dc.Password.value;
		dc.brandname.value = "sewolint_en_nz";
		dc.TARGET.value = 'https://www66.americanexpress.com/oms/sewNZ/FrontServlet?request_type=authreg_mainmenu&location=nz_pre_merch';
		dc.action = "https://sso.americanexpress.com/SSO/logon.fcc";
		dc.submit();
	}
	if(tempval == "atwork") {
		dc.USERID.value = dc.UserID.value;
		dc.PWD.value = dc.Password.value;
		dc.brandname.value = "atwork_en_NZ";
    dc.TARGET.value = 'https://sso.americanexpress.com/SSO/request?request_type=auth_ssopush&ssobrand=ATWORK&ssolang=en_JP&SSOURL=http://www.americanexpress.co.nz/atwork&ssoremove=yes&ssobrand=ATWORK&ssolang=en_JP';
		dc.action = "https://sso.americanexpress.com/SSO/logon.fcc";
		dc.submit();
	}
}

function Help() {
window.open ("help.asp", "winHelp", "width=452,height=460,scrollbars=no,location=no,dependent=yes,resizable=no top=20,left=300");
}

function Secure() {
window.open ("secure.asp", "winSecure", "width=452,height=460,scrollbars=no,location=no,dependent=yes,resizable=no top=20,left=300");
}

function clearElements(){
	//window.document.ssoform.UserID.value="";
	window.document.ssoform.Password.value="";
	window.document.ssoform.UserID.focus();
}

window.onresize=resizeFix
if (document.layers) {
	origWidth = window.innerWidth
	origHeight = window.innerHeight
}
function resizeFix() {
	if (document.layers) {
		if (window.innerWidth != origWidth || window.innerHeight != origHeight) {
			window.location.reload()
		}
	}
}