﻿function moveToNextField( obj ) {
	if( window.event.keyCode != 9 ) {
		if( getElementById( id ).value.length == 3 ) {
			if( id == "PHONE_AREA_CODE" ) {
				getElementById( "PHONE_LOCAL_CODE" ).focus();
			}
			else if( id == "PHONE_LOCAL_CODE" ) {
				getElementById( "PHONE_NUMBER" ).focus();
			}
		}
	}
}

function allowKeys( obj, keys ) {
	var bAllowKey = false;
	for( var i = 0; i < keys.length; i++ ) {
		if( keys.charAt( i ) == String.fromCharCode( window.event.keyCode ) ) {
			bAllowKey = true;
			break;
		}
	}
	if( !bAllowKey ) {
		window.event.cancelBubble = true;
		window.event.keyCode = 0;
	}
}

function validateInput( obj, keys ) {
	if( typeof( window.clipboardData ) != "undefined" ) {
		var sData = window.clipboardData.getData( "Text" )
		var sTemp = "";
		if( typeof( sData ) != "undefined" ) {
			for( var i = sData.length; --i >= 0; ) {
				for( var j = keys.length; --j >= 0; ) {
					if( sData.charAt( i ) == keys.charAt( j ) ) {
						sTemp += sData.charAt( i );
					}
				}
			}
		}
	
		window.clipboardData.setData( "Text", sTemp );
	}
}

function Capitalize()
{
	var el = window.event.srcElement;
	if( el == null ) return;
	
	if( el.getAttribute( "CAP" ) == null )
	{
		el.setAttribute( "CAP", "1" );
		if( el.value == "" ) {
			var nUCharCode = String.fromCharCode( window.event.keyCode ).toUpperCase().charCodeAt(0);
			window.event.keyCode = nUCharCode;
		}
	}
}
