$(function() {
	//ajax example
	//$.post('?test', {email:'email',user:'user'}, function(response) {
	//	alert(response);
	//});
	
	//ajax example
	//$.get('?get_featured_rant', function(response) {
		//alert(response);
	//});
	
	$("#phonce_check input[@type=text]").keyup(MoveToNextField);
})

function MoveToNextField(){
	field_id = $(this).attr('id').substr(5);
	field_maxlength = $(this).attr('maxlength');
	field_length = $(this).val().length;
	
	is_numeric = IsNumeric($(this).val());
	
	//test if field is numeric and if maxlength has been reached
	if( (field_length == field_maxlength) && (is_numeric == true) ){
		for(j = 1; j<=3; j++){
						
			//focus on next input field that is blank or with a false value (string instead of numeric or not a sufficient length)
			if(j != field_id){
				field_m = $("#input" + j).attr('maxlength');
				field_l = $("#input" + j).val().length;
												
				is_n = IsNumeric($("#input" + j).val());
				
				if( (field_l < field_m) || (is_n == false) ){
					$("#input" + j).focus();
					break;
				}
			}
		}
	}
	
}

function IsNumeric(sText){
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
}


