/**
 * Created on 23/08/2007
 *
 * Author: Oscar Cantero Lopez
 * Email: oscar@instant-ideas.com
 * 
 */
var word = null;
var input = null;
var hint = 0;
var message_ayuda = new Array();
message_ayuda[0] = "Put the cursor in the box and press the HINT button to get a clue.";
message_ayuda[1] = "Debes seleccionar un campo para solucitar una ayuda.";

function corregir(){
//alert("hint:"+document.exercise.hint.value);
   document.exercise.submit()
}
function ayuda(idioma){
	if(word == null){ alert(message_ayuda[idioma]);}
	else{ 
		var temp_value = '';
		//alert("Ayuda pedida en:"+focusAyuda.name)
		//input.value = word;
		if(input.value.length == 0) { 
			temp_value = word.charAt(0);
			hint++;
		}
		else{
			var contador = 0;
			for(contador; contador<input.value.length; contador++){
				if(input.value.charAt(contador)==word.charAt(contador)){
					temp_value = temp_value + word.charAt(contador);
				}else{ break; }
			}
			if(temp_value.length < word.length ){
				temp_value = temp_value + word.charAt(temp_value.length);
				hint++;				
			}
		}
		input.value = temp_value;
		document.exercise.hint.value = hint;
	}
}
function setfocus(objeto,palabra){
	word = palabra;
	input = objeto;
}