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('Digite a "Identificação do Usuáriuo" e "Senha" para acessar sua conta');
		return false;
	}
	else if ( uid !="" & pwd !="" & tempval =="") {
		alert('Escolha uma opção');
		return false;
	}
	else if ((uid =="" | pwd=="") & tempval =="") {
		alert('Para acessar os Serviços Online American Express, digite sua "Identificação de Usuário" e "Senha" e escolha uma opção.');
		return false;
	}
	else if (uid =="" & pwd=="" & tempval =="") {
		alert('Para acessar os Serviços Online American Express, digite sua "Identificação de Usuário" e "Senha" e escolha uma opção.');
		return false;
	}
	else if (uid.length < 4) {
		alert('A sua Identifica‡o de Usu rio ou sua Senha esto incorretas.');
		return false;
	}
	else if ((pwd.length < 5) || (pwd.length > 8)) {
		alert('A sua Identifica‡o de Usu rio ou sua Senha esto incorretas.');
		return false;
	}
	else {
		loginNow(tempval);
	}
}

function loginNow(tempval) {
	var dc=window.document.ssoform;
	

	if(tempval == "cards") {
		var loc=location.hostname;
		var targeturl;
		var actionurl;
    targeturl = 'https://www99.americanexpress.com/myca/estatement/canlac/action?request_type=authreg_CardsList&Face=pt_BR';
    dc.action	=	"https://www99.americanexpress.com/myca/logon/canlac/action";
		dc.USERID.value = dc.UserID.value;
		dc.PWD.value = dc.Password.value;
		dc.DestPage.value = targeturl;
		dc.submit();
	}

	if(tempval == "corp") {
		var loc=location.hostname;
		var targeturl;
		var actionurl;

		  if(loc=='lpdww001.dev.ipc.us.aexp.com' || loc=='lpdww002.dev.ipc.us.aexp.com')	{
			targeturl = 'https://qwww136.americanexpress.com/myca/estatement/canlac/action?request_type=authreg_CardsList&Face=pt_BR';
			dc.action = "https://qwww136.americanexpress.com/myca/logon/canlac/action";
		}
		else if(loc=='qwww.americanexpress.com'|| loc=='qhome.americanexpress.com' ) {
			targeturl = 'https://qwww136.americanexpress.com/myca/estatement/canlac/action?request_type=authreg_CardsList&Face=pt_BR';
			dc.action = "https://qwww136.americanexpress.com/myca/logon/canlac/action";
		}
		else {
			targeturl = 'https://www99.americanexpress.com/myca/estatement/canlac/action?request_type=authreg_CardsList&Face=pt_BR_corp';
			dc.action	=	"https://www99.americanexpress.com/myca/logon/canlac/action";
		}
		dc.USERID.value = dc.UserID.value;
		dc.PWD.value = dc.Password.value;
		dc.DestPage.value = targeturl;
		dc.Face.value = "pt_BR_corp";
		dc.submit();
	}


	if(tempval == "oms") {
		dc.USERID.value = dc.UserID.value;
		dc.PWD.value = dc.Password.value;
		dc.brandname.value = "singlesignon";
		dc.TARGET.value = 'https://sso.americanexpress.com/SSO/request?request_type=auth_ssopush&ssobrand=SEWOLINT&ssolang=br_BR&SSOURL=https%3A%2F%2Fwww66.americanexpress.com%2Foms%2FsewBRZ%2FFrontServlet%3Frequest_type%3Dauthreg_mainmenu%26ssoremove%3Dyes%26ssobrand%3DSEWOLINT%26ssolang%3Dbr_BR';
		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 = "singlesignon";
     	//dc.TARGET.value = 'https://sso.americanexpress.com/SSO/request?request_type=auth_ssopush&ssobrand=ATWORK&ssolang=br_BR&SSOURL=https%3A%2F%2Fwww65.americanexpress.com%2Fiatworkpoa%2Fbrazil%2Fpe%2Fat_home_index.jsp%26ssoremove%3Dyes%26ssobrand%3DATWORK%26ssolang%3Dbr_BR';
		//dc.action = "https://sso.americanexpress.com/SSO/logon.fcc";
		dc.brandname.value = "singlesignon";
     	dc.TARGET.value = 'https://sso.americanexpress.com/SSO/request?request_type=auth_ssopush&ssobrand=ATWORK&ssolang=br_BR&SSOURL=HTTPS%3A%2F%2Fwww140.americanexpress.com%2FATWORK%2Fpt_BR%2Fatwork.do%3FpageAction%3Dinitialize%26ssoremove%3Dyes%26ssobrand%3DATWORK%26ssolang%3Dbr_BR';
		dc.action = "https://sso.americanexpress.com/SSO/logon.fcc";
		dc.submit();
	}
}

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

function Secure() {
window.open ("secure.shtml", "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()
		}
	}
}
