function iniciaTeclado( RndX , RndY )
{
vshift = false;
vcaps = false;
campodestino = "";
vCaracter = "";
vCaracterAnt = "";

document.write("<STYLE>");
document.write(".drag{position:absolute;background-color:white;top:" + RndY + ";left:" + RndX + "}" );
document.write("</STYLE>")

document.write("<map name=\"Teclado\">");

document.write("<area shape=\"rect\" coords=\"2,1,21,18\"        style=\"cursor:hand\" onMouseDown=\"digitou('\\'')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"24,1,43,18\"      style=\"cursor:hand\" onMouseDown=\"digitou('1');\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"46,1,65,18\"      style=\"cursor:hand\" onMouseDown=\"digitou('2')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"68,1,87,18\"      style=\"cursor:hand\" onMouseDown=\"digitou('3')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"90,1,109,18\"    style=\"cursor:hand\" onMouseDown=\"digitou('4')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"112,1,131,18\" style=\"cursor:hand\" onMouseDown=\"digitou('5')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"134,1,153,18\" style=\"cursor:hand\" onMouseDown=\"digitou('6')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"156,1,175,18\" style=\"cursor:hand\" onMouseDown=\"digitou('7')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"178,1,197,18\" style=\"cursor:hand\" onMouseDown=\"digitou('8')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"200,1,219,18\" style=\"cursor:hand\" onMouseDown=\"digitou('9')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"222,1,241,18\" style=\"cursor:hand\" onMouseDown=\"digitou('0')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"244,1,263,18\" style=\"cursor:hand\" onMouseDown=\"digitou('-')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"266,1,285,18\" style=\"cursor:hand\" onMouseDown=\"digitou('=')\" href=\"#\">");

document.write("<area shape=\"rect\" coords=\"2,20,21,37\"     style=\"cursor:hand\" onMouseDown=\"digitou('q')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"24,20,43,37\"   style=\"cursor:hand\" onMouseDown=\"digitou('w')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"46,20,65,37\" style=\"cursor:hand\" onMouseDown=\"digitou('e')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"68,20,87,37\" style=\"cursor:hand\" onMouseDown=\"digitou('r')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"90,20,109,37\" style=\"cursor:hand\" onMouseDown=\"digitou('t')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"112,20,131,37\" style=\"cursor:hand\" onMouseDown=\"digitou('y')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"134,20,153,37\" style=\"cursor:hand\" onMouseDown=\"digitou('u')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"156,20,175,37\" style=\"cursor:hand\" onMouseDown=\"digitou('i')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"178,20,197,37\" style=\"cursor:hand\" onMouseDown=\"digitou('o')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"200,20,219,37\" style=\"cursor:hand\" onMouseDown=\"digitou('p')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"222,20,241,37\" style=\"cursor:hand\" onMouseDown=\"digitou('´')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"244,20,263,37\" style=\"cursor:hand\" onMouseDown=\"digitou('[')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"266,20,285,37\" style=\"cursor:hand\" onMouseDown=\"digitou('backspace')\" href=\"#\">");

document.write("<area shape=\"rect\" coords=\"2,39,21,56\"    style=\"cursor:hand\" onMouseDown=\"digitou('a')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"24,39,43,56\"    style=\"cursor:hand\" onMouseDown=\"digitou('s')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"46,39,65,56\"    style=\"cursor:hand\" onMouseDown=\"digitou('d')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"68,39,87,56\"    style=\"cursor:hand\" onMouseDown=\"digitou('f')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"90,39,109,56\"    style=\"cursor:hand\" onMouseDown=\"digitou('g')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"112,39,131,56\"    style=\"cursor:hand\" onMouseDown=\"digitou('h')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"134,39,153,56\"    style=\"cursor:hand\" onMouseDown=\"digitou('j')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"156,39,175,56\"    style=\"cursor:hand\" onMouseDown=\"digitou('k')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"178,39,197,56\"    style=\"cursor:hand\" onMouseDown=\"digitou('l')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"200,39,219,56\"    style=\"cursor:hand\" onMouseDown=\"digitou('ç')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"222,39,241,56\"    style=\"cursor:hand\" onMouseDown=\"digitou('~')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"244,39,263,56\"    style=\"cursor:hand\" onMouseDown=\"digitou(']')\" href=\"#\">");



document.write("<area shape=\"rect\" coords=\"2,58,21,75\"      style=\"cursor:hand\" onMouseDown=\"digitou('\\\\')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"24,58,43,75\"    style=\"cursor:hand\" onMouseDown=\"digitou('z')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"46,58,65,75\"  style=\"cursor:hand\" onMouseDown=\"digitou('x')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"68,58,87,75\"  style=\"cursor:hand\" onMouseDown=\"digitou('c')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"90,58,109,75\"  style=\"cursor:hand\" onMouseDown=\"digitou('v')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"112,58,131,75\"  style=\"cursor:hand\" onMouseDown=\"digitou('b')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"134,58,153,75\"  style=\"cursor:hand\" onMouseDown=\"digitou('n')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"156,58,175,75\"  style=\"cursor:hand\" onMouseDown=\"digitou('m')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"178,58,197,75\"  style=\"cursor:hand\" onMouseDown=\"digitou(',')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"200,58,219,75\"  style=\"cursor:hand\" onMouseDown=\"digitou('.')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"222,58,241,75\"  style=\"cursor:hand\" onMouseDown=\"digitou(';')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"244,58,263,75\"  style=\"cursor:hand\" onMouseDown=\"digitou('/')\" href=\"#\">");

document.write("<area shape=\"rect\" coords=\"266,39,285,75\"  style=\"cursor:hand\" onMouseDown=\"digitou('enter')\" href=\"#\">");

document.write("<area shape=\"rect\" coords=\"2,77,65,94\"      style=\"cursor:hand\" onMouseDown=\"digitou('caps')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"68,77,131,94\"      style=\"cursor:hand\" onMouseDown=\"digitou('shift')\" href=\"#\">");
document.write("<area shape=\"rect\" coords=\"134,77,285,94\"  style=\"cursor:hand\" onMouseDown=\"digitou(' ')\" href=\"#\">");

document.write("</map>");

}

function digitou( letra )
{
if( letra != 'backspace' )
	{ document.getElementById("tecladoV").style.visibility = "hidden"; }
vCaracter = "";

if( letra == "shift" )
{
 if( vshift )
vshift = false;
else
vshift = true;
}
else if( letra == "caps" )
{
 if( vcaps )
vcaps = false;
else
vcaps = true;
}else if(letra == "backspace"){
	if( vCaracterAnt != "")
		vCaracterAnt = "";
	else
		campodestino.value = campodestino.value.slice(0 , -1);
} else if( letra == "enter")
{
	document.forms[0].submit();
}else
{
if( letra == "'" )
 {
 if( vshift )
vCaracter = "\"";
else
vCaracter = letra;
} else if( letra == "1" )
{
if( vshift )
vCaracter = "!";
		          else
                	               vCaracter = letra;
		     }else if( letra == "2" )
		     {
		          if( vshift )
                                	vCaracter = "@";
		          else
                	               vCaracter = letra;
		     }else if( letra == "3" )
		     {
		          if( vshift )
                                	vCaracter = "#";
		          else
                	               vCaracter = letra;
		     } else if( letra == "4" )
		     {
		          if( vshift )
	                                vCaracter = "$";
		          else
                	               vCaracter = letra;
		     } else if( letra == "5" )
		     {
		          if( vshift )
                	                vCaracter = "%";
		          else
                	               vCaracter = letra;
		     } else	     if( letra == "6" )
		     {
		          if( vshift )
                	                vCaracter = "¨";
		          else
	                               vCaracter = letra;
		     } else	     if( letra == "7" )
		     {
		          if( vshift )
	                                vCaracter = "&";
		          else
	                               vCaracter = letra;
		     } else if( letra == "8" )
		     {
		          if( vshift )
	                                vCaracter = "*";
		          else
	                               vCaracter = letra;
		     } else if( letra == "9" )
	     	{
		          if( vshift )
                	                vCaracter = "(";
		          else
	                               vCaracter = letra;
		     } else if( letra == "0" )
		     {
		          if( vshift )
	                                vCaracter = ")";
		          else
                	               vCaracter = letra;
		     } else if( letra == "-" )
	     	{
	          		if( vshift )
	                                vCaracter = "_";
		          else
	                               vCaracter = letra;
		     } else if( letra == "=" )
		     {
		          if( vshift )
	                                vCaracter = "+";
		          else
	                               vCaracter = letra;
		     }  else if( letra == "´" )
		     {
		          if( vshift )
                                	vCaracter = "`";
		          else
                	               vCaracter = letra;
		     } else if( letra == "[" )
		     {
		          if( vshift )
                                	vCaracter = "{";
		          else
                	               vCaracter = letra;
		     } else if( letra == "~" )
		     {
		          if( vshift )
                                	vCaracter = "^";
		          else
                	               vCaracter = letra;
		     } else if( letra == "]" )
		     {
		          if( vshift )
	                                vCaracter = "}";
		          else
	                               vCaracter = letra;
		     } else  if( letra == "\\" )
		     {
		          if( vshift )
                                	vCaracter = "|";
		          else
                	               vCaracter = letra;
		     } else if( letra == "," )
		     {
		          if( vshift )
                                	vCaracter = "<";
		          else
                	               vCaracter = letra;
		     } else if( letra == "." )
		     {
		          if( vshift )
	                                vCaracter = ">";
		          else
	                               vCaracter = letra;
		     } else if( letra == ";" )
		     {
		          if( vshift )
	                                vCaracter = ":";
		          else
	                               vCaracter = letra;
		     } else if( letra == "/" )
		     {
		          if( vshift )
	                                vCaracter = "?";
		          else
	                               vCaracter = letra;
		     } else
		    {
			if( vshift || vcaps)
			{
				vCaracter = letra.toUpperCase();
			}else
				vCaracter = letra;
		    }
	}


if( vCaracter == "¨" || vCaracter == "´" || vCaracter == "`" || vCaracter == "~" || vCaracter == "^")
{
	if( vCaracterAnt != "" )
	{
		vCaracter = vCaracterAnt + vCaracter;
		vCaracterAnt = "";
	}else
	{
		vCaracterAnt = vCaracter;
		vCaracter = "";
	}
} else if( vCaracterAnt != "" && letra != "shift")
{
	if( vCaracterAnt == "´")
	{
		if( vCaracter == "a")
			vCaracter = "á";
		else if( vCaracter == "A" )
			vCaracter = "Á";
		else if( vCaracter == "e" )
			vCaracter = "é";
		else if( vCaracter == "E" )
			vCaracter = "É";
		else if( vCaracter == "y" )
			vCaracter = "ý";
		else if( vCaracter == "Y" )
			vCaracter = "Ý";
		else if( vCaracter == "u" )
			vCaracter = "ú";
		else if( vCaracter == "U" )
			vCaracter = "Ú";
		else if( vCaracter == "i" )
			vCaracter = "í";
		else if( vCaracter == "I" )
			vCaracter = "Í";
		else if( vCaracter == "o" )
			vCaracter = "ó";
		else if( vCaracter == "O" )
			vCaracter = "Ó";
		else if( vCaracter == " " )
			vCaracter = vCaracterAnt;
		else 
			vCaracter = "´" + vCaracter;
	}else if( vCaracterAnt == "¨")
	{
		if( vCaracter == "a")
			vCaracter = "ä";
		else if( vCaracter == "A" )
			vCaracter = "Ä";
		else if( vCaracter == "e" )
			vCaracter = "ë";
		else if( vCaracter == "E" )
			vCaracter = "Ë";
		else if( vCaracter == "y" )
			vCaracter = "ÿ";
		else if( vCaracter == "u" )
			vCaracter = "ü";
		else if( vCaracter == "U" )
			vCaracter = "Ü";
		else if( vCaracter == "i" )
			vCaracter = "ï";
		else if( vCaracter == "I" )
			vCaracter = "Ï";
		else if( vCaracter == "o" )
			vCaracter = "ö";
		else if( vCaracter == "O" )
			vCaracter = "Ö";
		else if( vCaracter == " " )
			vCaracter = vCaracterAnt;
		else
			vCaracter = "¨" + vCaracter;
	}else if( vCaracterAnt == "`")
	{
		if( vCaracter == "a")
			vCaracter = "à";
		else if( vCaracter == "A" )
			vCaracter = "À";
		else if( vCaracter == "e" )
			vCaracter = "è";
		else if( vCaracter == "E" )
			vCaracter = "È";
		else if( vCaracter == "u" )
			vCaracter = "ù";
		else if( vCaracter == "U" )
			vCaracter = "Ù";
		else if( vCaracter == "i" )
			vCaracter = "ì";
		else if( vCaracter == "I" )
			vCaracter = "Ì";
		else if( vCaracter == "o" )
			vCaracter = "ò";
		else if( vCaracter == "O" )
			vCaracter = "Ò";
		else if( vCaracter == " " )
			vCaracter = vCaracterAnt;
		else
			vCaracter = "`" + vCaracter;
	}else if( vCaracterAnt == "~")
	{
		if( vCaracter == "a")
			vCaracter = "ã";
		else if( vCaracter == "A" )
			vCaracter = "Ã";
		else if( vCaracter == "n" )
			vCaracter = "ñ";
		else if( vCaracter == "N" )
			vCaracter = "Ñ";
		else if( vCaracter == "o" )
			vCaracter = "õ";
		else if( vCaracter == "O" )
			vCaracter = "Õ";
		else if( vCaracter == " " )
			vCaracter = vCaracterAnt;
		else
			vCaracter = "~" + vCaracter;
	}else if( vCaracterAnt == "^")
	{
		if( vCaracter == "a")
			vCaracter = "â";
		else if( vCaracter == "A" )
			vCaracter = "Â";
		else if( vCaracter == "e" )
			vCaracter = "ê";
		else if( vCaracter == "E" )
			vCaracter = "Ê";
		else if( vCaracter == "i" )
			vCaracter = "î";
		else if( vCaracter == "I" )
			vCaracter = "Î";
		else if( vCaracter == "o" )
			vCaracter = "ô";
		else if( vCaracter == "O" )
			vCaracter = "ô";
		else if( vCaracter == "u" )
			vCaracter = "û";
		else if( vCaracter == "U" )
			vCaracter = "û";
		else if( vCaracter == " " )
			vCaracter = vCaracterAnt;
		else 
			vCaracter = "^" + vCaracter;
	}
	vCaracterAnt = "";
}

if( vshift && letra != "shift" )
	vshift = false;

campodestino.value = campodestino.value + vCaracter;

if( vshift && vcaps )
	{document.forms[0].tec.src ="teclado4.jpg?OpenImageResource";}
else if( vshift )
	{document.forms[0].tec.src ="teclado3.jpg?OpenImageResource";}
else if( vcaps )
	{document.forms[0].tec.src ="teclado2.jpg?OpenImageResource";}
else
	{document.forms[0].tec.src ="teclado1.jpg?OpenImageResource";}


t = setTimeout( "document.getElementById('tecladoV').style.visibility = 'visible'" , 1);
}