var ns6 = document.getElementById&&!document.all
var optionArray = new Array();

optionArray['OnlineBanking'] = '<select name="cboSubCategory" id="cboSubCategory" class="ComboBox" style="width: 100%">';
optionArray['OnlineBanking'] += '<option value="Online Banking - Online Banking sign on">Sign on to China Bank Online Banking</option>';
optionArray['OnlineBanking'] += '<option value="Online Banking - Online Banking registration">Difficulties in online registration</option>';
optionArray['OnlineBanking'] += '<option value="Online Banking - Others">Others</option>';
optionArray['OnlineBanking'] += '</select>';

optionArray['Account'] = '<select name="cboSubCategory" id="cboSubCategory" class="ComboBox" style="width: 100%">';
optionArray['Account'] += '<option value="Account Inquiry - Service fees">Service fees</option>';
optionArray['Account'] += '<option value="Account Inquiry - Transaction inquiry">Transaction inquiry</option>';
optionArray['Account'] += '<option value="Account Inquiry - Wire transfers">How to send or receive wire transfers</option>';
optionArray['Account'] += '<option value="Account Inquiry - Others">Others</option>';
optionArray['Account'] += '</select>';

optionArray['Request'] = '<select name="cboSubCategory" id="cboSubCategory" class="ComboBox" style="width: 100%">';
optionArray['Request'] += '<option value="Request Updates and Changes - Application status">Check the status of an application</option>';
optionArray['Request'] += '<option value="Request Updates and Changes - Others">Others</option>';
optionArray['Request'] += '</select>';

optionArray['Fraud'] = '<select name="cboSubCategory" id="cboSubCategory" class="ComboBox" style="width: 100%">';
optionArray['Fraud'] += '<option value="Online and E-mail Fraud">Report Online or E-mail Fraud</option>';
optionArray['Fraud'] += '</select>';

optionArray['Others'] = '<select name="cboSubCategory" id="cboSubCategory" class="ComboBox" style="width: 100%">';
optionArray['Others'] += '<option value="Other - Commercial banking">Commercial Banking</option>';
optionArray['Others'] += '</select>';

optionArray['noSelection'] = '<select name="cboSubCategory" id="cboSubCategory" class="ComboBox" style="background-color: #CCCCCC;" designtimesp=31153>';
optionArray['noSelection'] += '<option value="">Select an option from the list above</option>';
optionArray['noSelection'] += '</select>';

function SubCatShow(catID)
{
	if(catID == '')	{
		catID = 'noSelection';			
	}
	GetElement("categoryDisplay").innerHTML = optionArray[catID];
}

function ValidateForm()
{
	var blnNoError = true;
	var strFields = '';
	if (ValidateString("ctl00_Body_txtComment")) {
		if (GetElement("cboLOBCategory").value == '') {
			GetElement("1").className = "LabelRequired";
			strFields += "- Step 1 \n";
			blnNoError = false;
		} else {
			GetElement("1").className = "Label";
		}
		if (GetElement("cboSubCategory").value == '') {
			GetElement("2").className = "LabelRequired";
			strFields += "- Step 2 \n";
			blnNoError = false;
		} else {
			GetElement("ctl00_Body_txtSubject").value = GetElement("cboSubCategory").value;
			GetElement("2").className = "Label";
		}
		if (GetElement("ctl00_Body_txtName").value == '') {
			GetElement("3").className = "LabelRequired";
			strFields += "- Step 3 \n";
			blnNoError = false;
		} else {
			GetElement("3").className = "Label";
		}
		if ((GetElement("ctl00_Body_txtEmailAdd").value == '') && (GetElement("ctl00_Body_txtEmailAdd").value == '')) {
			GetElement("4").className = "LabelRequired";
			strFields += "- Step 4 \n";
			blnNoError = false;
		} else {
			if ((!CheckMail(GetElement("ctl00_Body_txtEmailAdd"))) && (GetElement("ctl00_Body_txtEmailAdd").value == '')) {
				GetElement("4").className = "LabelRequired";
				strFields += "- Step 4 - Invalid email address \n";
				blnNoError = false;
			}
			if (blnNoError)
				GetElement("4").className = "Label";
		}
		if (GetElement("ctl00_Body_txtComment").value == '') {
			GetElement("5").className = "LabelRequired";
			strFields += "- Step 5 \n";
			blnNoError = false;
		} else {
			GetElement("5").className = "Label";
		}
		if (!blnNoError) {
			alert("Please fill-out the following field(s) below.\n" + strFields);
		}
	} else {
		blnNoError = false;
	}
	return blnNoError;
}

function CheckMail(e)
{
	var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
	var returnval=emailfilter.test(e.value)
	return returnval
}

function restrictinput(maxlength,e,placeholder)
{
	if (window.event&&event.srcElement.value.length>=maxlength)
		return false
	else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength)
	{
		var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
		if (pressedkey.test(String.fromCharCode(e.which)))
			e.stopPropagation()
	}
}

function countlimit(maxlength,e,placeholder)
{
	var theform=eval(placeholder)
	var lengthleft=maxlength-theform.value.length
	var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
	if (window.event||e.target&&e.target==eval(placeholder))
	{
		if (lengthleft<0)
			theform.value=theform.value.substring(0,maxlength)
		placeholderobj.innerHTML=lengthleft
	}
}

function displaylimit(thename, theid, thelimit)
{
	var theform=theid!=""? document.getElementById(theid) : thename
	var limit_text='<b><span id="'+theform.toString()+'">'+thelimit+'</span></b> characters remaining'
	if (document.all||ns6)
		document.write(limit_text)
	if (document.all)
	{
		eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
		eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
	}
	else if (ns6){
		document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
		document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
	}
}