function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}


	
	function crearBocadillo(num_mensaje, idElemento, posicion, offset){
	// posicion: left, top

	if ($("#wizard-input").val() > 0 )
	{



	var lang = readCookie('lang');

		var salirAsistente = "<br/><br/><small style='font-size:0.7em;'><a style='color:white;' href='#' title='' onclick='  $(\".wizard-input\").val(0);  $(\"#bocadillo\").fadeOut(); return(false);' > para detener el asistente clica aqu&iacute; </a></small>"
		if (lang == 'en')
			salirAsistente = "<br/><br/><small style='font-size:0.7em;'><a style='color:white;' href='#' title='' onclick='  $(\".wizard-input\").val(0);  $(\"#bocadillo\").fadeOut(); return(false);' > to stop the wizard click here</a></small>"

		if (lang == 'es')
		
		textos = new Array(
			"Hola, este es el asistente para entender, en 4 r&aacute;pidos pasos, como funciona esta aplicaci&oacute;n. Vamos a comenzar. Para ello, pulse en 'siguiente'   <br/>  <a style='color:white;' href='#' title='' onclick='crearBocadillo(1, \"tituloarticulo\", \"top\") ;return false;' > siguiente </a>  ",
			"Muy bien, comencemos a usar la aplicaci&oacute;n. Queremos rellenar el primer campo, vamos a empezar escribiendo en ingles.<br/>Teclea por ejemplo <br/><em>'Real Madrid was able to win once again despite the referee, and gets closer to the title '</em> "		,
			"<em>'Real Madrid was able to win once again despite the referee, and gets closer to the title '</em><br/>Como ves, el asistente intenta traducir el texto para asegurarse de que lo traduces bien. Adem&aacute;s te propone ejemplos sacados del corpuis que se parezcan a lo que escribes. Al acabar la frase, espera a que el traductor acabe de traducir, y haz doble click en la palabra '&aacute;rbitro' de la traducci&oacute;n",
			"La aplicaci&oacute;n intenta sacar traducciones posibles y alternativas, como ves en estas 4 opciones (2 de ellas aun sin generar). <br/><b>Ahora vamos a ver las alternativas</b> a la palabra '&aacute;rbitro'. <b>Puls 'siguiente'</b> <br/>  <a style='color:white;' href='#' title='' onclick='crearBocadillo(4, \"selectingles-div\", \"left\", 20) ;return false;' > siguiente </a>",
			"La aplicaci&oacute;n busca palabras especificas del campo sem&aacute;ntico para la entrada '&aacute;bitro'. Clica en la segunda de ellas y ver&aacute;s como una de propuestas de traducci&oacute;n se actualiza ",
			"Con la palabra seleccionada, te ofrece una nueva propuesta de traducci&oacute;n, m&aacute;s apropiada. Puedes seleccionar la cuarta y darle a aceptar..",
			"Y esto es el final de esta pequena demostraci&oacute;n. Ahora puedes probar a escribir un texto en castellano para comprobar que tambi&eacute;n te ayuda a traducirlo al ingl&eacute;s. Puedes teclear 'el equipo fue capaz de ganar una vez m&aacute;s a pesar del &aacute;rbitro.'"
		);
		else
		textos = new Array(
			"Hi, this is the wizard that helps you to understand the meaning of this application y 5 fast steps. Let's start. Click on 'next' <br/>  <a style='color:white;' href='#' title='' onclick='crearBocadillo(1, \"tituloarticulo\", \"top\") ;return false;' > next </a>",
			"Very well, let's start. We want to fill the first field 'header'. we strart by writing in English.<br/>Write <br/><em>'Real Madrid was able to win once again, despite the referee and gets closer to the title '</em>",
			"<em>'Real Madrid was able to win once again despite the referee, and gets closer to the title '</em><br/>As you can see, the wizard tries to translate the text to make sure that you are writing it right. Also, it gives you more examples (extracted by the linguistic corporea) close to what you are writing. Wait until the real time translator finishes the translation, and make double click on the word '&aacute;rbitro'",
			"The application tries to set several alternatives to this translation. You can see these 4 options.<br/><b>Now we can see the alternatives to the word '&aacute;rbitro'. Click in 'next' to go on. <br/>  <a style='color:white;' href='#' title='' onclick='crearBocadillo(4, \"selectingles-div\", \"left\", 20) ;return false;' > next </a>",
			"The application looks for specific words in the semantic field for the word '&aacute;bitro'. Make a click on the second one of them and you'll see how one of the proposals is updated.",
			"With the word selected, the application offers a new proposal for the translation, more appropiated. You can sleect tit (the 4th one) and click 'Aceptar'",
			"And this is the end of this demonstation. You can now try to write a text in Spanish to check that it is also translated automatically. Write 'el equipo fue capaz de ganar una vez m&aacute;s a pesar del &aacute;rbitro.'"
		);


		texto = textos[num_mensaje]+salirAsistente;


		vv = "<div id='bocadillo' class='bocadillo-posicion-"+posicion+"'> <div id='bocadillo-titulo'>Wizard</div><div id='texto-wizard'> "+texto+" </div> <div class='flecha-bocadillo'></div></div>";

		$("#bocadillo").remove();

		$('body').append(vv);

		if (idElemento)
		{
			Jel = $("#"+idElemento);
			if (Jel.attr('type') == 'text' ) Jel.focus();
		}



		// ahora posicionamos el bocadillo
		if (posicion == "top")
		{

			ll = Jel.offset().left;
			tt = Jel.offset().top - $("#bocadillo").height() - 100;
			if (offset != undefined) tt += offset;
			$("#bocadillo").css({ left: ll+"px", top: tt+"px" });
		}else
		if (posicion == "left")
		{

			ll = Jel.offset().left - 450;
			tt = Jel.offset().top - $("#bocadillo").height() + 50;
			if (offset != undefined) tt += offset;
			$("#bocadillo").css({ left: ll+"px", top: tt+"px" });
		}else $("#bocadillo").css({ left: "100px", top: "100px" });
	 }//de si se crea bocadillo
	} //de la fcion




