var nonAlphaChars = '!%\'*+-.0123456789=@^_`~#$&(),/:;<>?[\]{|}' + String.fromCharCode(34);
function hasInvalidChars(fieldName, invalidChars)
{ 
	for(var i=0;i<fieldName.length;i++)
	{
		if(invalidChars.indexOf(fieldName.charAt(i)) != -1)
		{
		    return true;
		}
	}
	return false;
}

function displayErrors(errElements) {
		document.getElementById('error_block').style.display = 'block';
		for(allErrorIndex = 0; allErrorIndex < allErrorElements.length; allErrorIndex ++){
		var found = false;
		for(errorIndex = 0; errorIndex < errElements.length; errorIndex ++){
		     if (errElements[errorIndex] == allErrorElements[allErrorIndex]) {
		     found = true;
		     break;
		     }
		}
		if (found) {
            document.getElementById(allErrorElements[allErrorIndex]).style.display = 'block';
		}
		else {
            document.getElementById(allErrorElements[allErrorIndex]).style.display = 'none';
		}
		}
}

function hasAlphaChars(name)
{ 
	for(var i=0;i<name.length;i++)
	{
		if(nonAlphaChars.indexOf(name.charAt(i)) == -1)
		{
		    return true;
		}
	}
	return false;
}

function setFocusToFirstComponent(compName)
{
	var firstComp = document.getElementsByTagName('input')[compName];
	if (firstComp != null){
		firstComp.focus();
		firstComp.value = firstComp.value;
	}
}