function KeyDownHandler(evt, btnId)
{
     if (evt.keyCode == 13)
     {
		  var btn = document.getElementById(btnId)
          evt.returnValue = false;
          evt.cancel = true;
          btn.click();
     }
}

function SetOnKeyDown(btnID, inputType)
{
    if (!document.getElementById || !document.createTextNode) { return; }

    var inputs = document.getElementsByTagName('input');
    var str_event = 'KeyDownHandler(event, ' + btnID + ');';
    for (i=0; i < inputs.length; i++)
    {
        if (inputs[i].getAttribute('type').toLowerCase() != inputType)
        {
            continue;
        }
        inputs[i].setAttribute('onkeydown', str_event);
    }
}

function clearText(thefield)
{
	var btn = document.getElementById(thefield)
	if (btn.defaultValue==btn.value)
		btn.value = ""
} 

function confirmToProceed(msg)
{
	if (needToConfirm)
	{
		var confirmOK = confirm(msg);
		if (confirmOK)
		{
			// Added by Karine Liu 04/07/2010
			// set the isExitPage flag to show if user is trying to leaving the Account Profile page.
			isExitPage = false;
		}
		return confirmOK;
	}
}

function accountAddEdit_UnLoad()
{
	// Added by Karine Liu 04/07/2010
	// set the isExitPage flag to show if user is trying to leaving the Account Profile page.
	// Confirm message is only display when user is trying to leave Account Profile page and has applied changes to the fields
	if (isExitPage)
	{
		if (needToConfirm)
		{
			return 'If you have made any changes to the fields without clicking the Save button, your changes will be lost.';
		}
	}
}

// Allow number only in textbox
function isNumberKey(event)
{
	try
	{
		if (enableInternationPhoneRule)
			return true;
	}
	catch(ex) {}
		
	var e = event || evt; // for browser compatibility
	var charCode = e.which || e.keyCode;
	if (charCode > 31 && (charCode < 48 || charCode > 57))
		return false;

	return true;
}
	

