﻿var strErrMsg = new Array();


function initMsgArr() 
{
	strErrMsg[0]    = "Please agree with the agreement to proceed with downloading.";
	strErrMsg[1]    = "Please enter your information.";
	strErrMsg[2]    = "Please enter valid email address.";
	strErrMsg[3]    = "The User ID is already in use. Please try a different User ID.";
	strErrMsg[4]    = "The User ID has to be between 6 and 10 characters-long. Please try again.";
	strErrMsg[5]    = "The password has to be between 6 and 12 characters-long. Please try again.";
	strErrMsg[6]    = "The passwords do not match.\nPlease re-type the same password that you typed in the Password field.";
	strErrMsg[7]    = "Please choose if you would like to receive updates notice.";
	strErrMsg[8]    = "Please choose a version you would like to download.";
	strErrMsg[9]    = "";
	strErrMsg[10]   = "";
	strErrMsg[11]   = "";
	strErrMsg[12]   = "";
	strErrMsg[13]   = "";
	strErrMsg[14]   = "";
}


function confirmAggr() 
{
	if(document.getElementById("chkConfirmAggr").checked)
			document.getElementById("aggrNext").style.display="block" ;
	else
			document.getElementById("aggrNext").style.display="none" ;
}

function submitDWReg() 
{
	if (chkDW())
	{
		
		document.getElementById("frmDw").target = "htrgframe" ;
		document.getElementById("frmDw").action = "dw_regist_ok.asp" ;
		document.getElementById("frmDw").submit() ;
	}
}
function chkUserID(Chkobj)
{
	window.open('dw_regist_chk.asp?USER_ID='+Chkobj.value,'htrgframe','');
}



function chkDW() 
{
	if(!chkValFocus(document.getElementById("U_FNAME")) 	||
		 !chkValFocus(document.getElementById("U_LNAME")) 	||
		 !chkValFocus(document.getElementById("U_TITLE")) 	||
		 !chkValFocus(document.getElementById("U_DEPT")) 		||
		 !chkValFocus(document.getElementById("U_COMPNM"))	||
		 !chkValFocus(document.getElementById("U_EMAIL")) 	||
		 !chkValFocus(document.getElementById("U_MAILA")) 	|| 
		 !chkValFocus(document.getElementById("U_COUNTR")) 	|| 
		 !chkValFocus(document.getElementById("U_POSTAL"))	|| 
		 !chkValFocus(document.getElementById("U_PHONE")) 	||
		 !chkValFocus(document.getElementById("U_ID")) 			||
		 !chkValFocus(document.getElementById("U_PW"))
	)
	{
		return false ;
	}
	else if (!isEmail(document.getElementById("U_EMAIL") .value)) 
	{
		alert(strErrMsg[2]);
		document.getElementById("U_EMAIL").focus();
		return false ;
	}
	else if (document.getElementById("U_IDchk").value!="Y"  )
	{
		alert(strErrMsg[3]);
		document.getElementById("U_ID").focus();
		return false ;
	}	
	else if (document.getElementById("U_ID").value.length<6 || document.getElementById("U_ID").value.length>10  )
	{
		alert(strErrMsg[4]);
		document.getElementById("U_ID").focus();
		return false ;
	}
	else if (document.getElementById("U_PW").value.length<6 || document.getElementById("U_PW").value.length>12  )
	{
		alert(strErrMsg[5]);
		document.getElementById("U_PW").focus();
		return false ;
	}
	else if (document.getElementById("U_PW").value !=document.getElementById("U_PW2").value )
	{
		alert(strErrMsg[6]);
		document.getElementById("U_PW2").focus();
		return false ;
	}
	else if (!document.getElementById("U_RVROI") .checked && !document.getElementById("U_RVROI2") .checked ) 
	{
		alert(strErrMsg[7]);
		document.getElementById("U_RVROI").focus();
		return false ;
	}
	else if (!document.getElementById("U_FXSELE") .checked && !document.getElementById("U_FXSELE2") .checked ) 
	{
		alert(strErrMsg[8]);
		document.getElementById("U_FXSELE").focus();
		return false ;
	}
	else
	{
		return true ;
	}
}

function chkValFocus(trgObj)
{
	if (trgObj.value=="")
	{
		alert(strErrMsg[1]);
		
		trgObj.focus() ;
		return false;
	}	
	return  true;
}

function isEmail(str) {
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

initMsgArr() ;