function up(divId)
{ state=typeof topPos;
if(state=='undefined') topPos=-260;
if(topPos > -260)
{ topPos-=9;
if (document.layers) document.layers[divId].top = topPos;
else if (document.all) document.all[divId].style.top = topPos;
else if (document.getElementById) document.getElementById(divId).style.top = topPos;
setTimeout("up('algo');",25);
}
}
function down(divId)
{ 
state=typeof topPos;
if(state=='undefined') topPos=-260;
if(topPos < 120)
{ topPos+=6;
if (document.layers) document.layers[divId].top = topPos;
else if (document.all) document.all[divId].style.top = topPos;
else if (document.getElementById) document.getElementById(divId).style.top = topPos;
setTimeout("down('algo');",25);
}
}
function ch(divId,f)
{ 
var i,v2='';
for (i=0;i<=f;i++) {
      e='r'+i;
    v2= v2 + '<tr><td> '+ document.getElementById(e).innerHTML + '</td></tr>';
} 
document.getElementById('algo').innerHTML = '<form name=m1 id=m1><table bgcolor=#add7ff style="border: rgb(241, 87, 0) 2px dotted;"><tr><td>Copia el texto y pegalo en tu web</td><td><td><a href="javascript:void(0)" onclick="up(\'algo\')">Cerrar</a></td></tr><tr><td colspan=2><textarea rows=10 cols=60 id=e1 name=e1 readonly><form action='+ window.location.href + ' method=post>' + document.getElementById('p').innerHTML + '<table border=0>' + v2 + '<tr><td colspan=3 bgcolor=#ffffff><center> ' +document.getElementById('fin').innerHTML +'</center></td></tr><tr><td colspan=3><center><a href=' + window.location.href + '>Ver Resultados</a></center></td></tr></table></form></textarea></td></tr></table></form>';
}
function ch2(numero)
{ 
document.getElementById('algo').innerHTML = '<table bgcolor=#add7ff style=\'border: rgb(241, 87, 0) 2px dotted;\'><tr><td><td><a href=\'javascript:void(0)\' onclick="up(\'algo\')">Cerrar</a></td></tr><tr><td><table><tr><td>Enviar esta encuesta por email<form action=./encuestasweb.php?pregunta=' + numero +' method=post id=formulario name=formulario><input type=text name=email><input  type=hidden  name=res value="Agregar Email"><input type=button name=res value="Agregar Email" onClick="javascript:validar(this.form)"></form>Rellene un email para empezar</td></tr></table>';
}

function vivo() {
vivo2(document.m1.e1);
}
function vivo2(object)
{
var text ='ÁÀÇÉÈÍÌÑÓÒÚÙÜáà¦ç¢©éè½¼¾í¡ì¿«ñóò±£»®²³úùüï';
fromTo=new Array('&Aacute;','&Agrave;','&Ccedil;','&Eacute;','&Egrave;','&Iacute;','&Igrave;','&Ntilde;','&Oacute;','&Ograve;','&Uacute;','&Ugrave;','&Uuml;','&aacute;','&agrave;','&brvbar;','&ccedil;','&cent;','&copy;','&eacute;','&egrave;','&frac12;','&frac14;','&frac34;','&iacute;','&iexcl;','&igrave;','&iquest;', '&laquo;','&ntilde;','&oacute;','&ograve;','&plusmn;','&pound;','&raquo;','&reg;','&sup2;', '&sup3;','&uacute;','&ugrave;','&uuml;','&iuml');
for (t=0; t < 20; t=t+1)
{
for (i=0; i < text.length; i=i+1)
{
object.value=object.value.replace(text.charAt(i),fromTo[i]);
}
}
}

 function validar(formulario) {
if (formulario.email.value == "")
{
alert("E-Mail esta vacio e-mail.Debes rellenarlo.");
return false;
}
if(checkEmail(formulario.email)==false)
{
 return false;
}
document.formulario.e1;
document.forms['formulario'].submit();
}
 function checkEmail(valor) {
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor.value))
  {
   return true;
  } else {
     alert("El email " + valor.value    + " es incorrecto.") 
valor.focus();
   return (false);
  }
 }
