var bugs_numero = new Array("cero", "uno", "dos", "tres", "cuatro", "cinco", "seis", "siete", "ocho");
var bugs_n1;
var bugs_n2;

function bugs_enviar() {
	var url = "http://www.jonijnm.es/all/php/mail.php";
	url += "bugs=1&text="+encodeURIComponent(document.forms.bugs.text.value)+"&email="+document.forms.bugs.email.value;
	location = url;
}

function bugs_open() {
	document.getElementById('bugs').style.display = 'block';
}

function bugs_check() {
	var n = document.forms.bugs.check.value.toString().toLowerCase();
	if (n == bugs_numero[bugs_n1 + bugs_n2]) {
		bugs_enviar();
		bugs_init();
		document.forms.bugs.check.value = "";
		document.getElementById('respuesta').innerHTML = "Gracias por enviar el mensaje, será leido lo antes posible.";
	}
	else {
		document.getElementById('respuesta').innerHTML = "Número incorrecto.";
		bugs_init();
	}
}

function bugs_init() {
	bugs_n1 = Math.round(Math.random() * 4);
	bugs_n2 = Math.round(Math.random() * 4);
	document.getElementById('bugs_n1').innerHTML = bugs_numero[bugs_n1];
	document.getElementById('bugs_n2').innerHTML = bugs_numero[bugs_n2];
}

//document.write('<p style="position: absolute; top: 0px; right: 15px; font-family Arial; font-weight: bold; font-size: x-small"><a href="javascript:void(0)" onclick="bugs_open()"><span style="color: red">Sugerencias - Bugs encontrados</span></a></p>');
document.write('<div id="bugs" style="color: black; top: 50px; right: 47%; position: absolute; padding: 5px 15px 15px 15px; border: medium inset #009900; height: 330px; width: 480px; background-color: #FFCC99; display: none; overflow: hidden;" align="center">');
document.write('	<form method="get" name="bugs" action="" onsubmit="bugs_check(); return false">');
document.write('		<div style="text-align: right; height: 1px;"><input type="button" value="X" onclick="document.getElementById(\'bugs\').style.display = \'none\'" style="border: thin double #FF0000; background-color: #FFFFFF; font-weight: bold;" /></div>')
document.write('		<p style="font-family: Cambria; font-size: large; font-weight:bold; text-align: center">Opiniones</p>');
document.write('		<textarea name="text" onblur="if (this.value==\'\')this.value=\'Escribe aquí tus sugerencias, comentarios o errores encontrados\'" onfocus="if (this.value==\'Escribe aquí tus sugerencias, comentarios o errores encontrados\')this.value=\'\'" style="height:130px;width:350px">Escribe aquí tus sugerencias, comentarios o errores encontrados</textarea>');
document.write('		<p>Escribe con letras cuanto es <span id="bugs_n1"></span> más <span id="bugs_n2"></span>&nbsp;<input type="text" name="check" size="6" /></p>');
document.write('		<p>e-mail (si quieres recibir respuesta) <input type="text" name="email" /></p>')
document.write('		<span id="respuesta" style="font-family: \'Courier New\'; color: #FF0000; font-size: small; font-weight: bold"></span><br />');
document.write('		<input type="submit" value="Enviar" style="border: thin double #FF0000; width:95px; font-family: \'Courier New\', Courier, \'espacio sencillo\'; color: #008080; font-weight: bold; background-color: #FFFFFF;" />');
document.write('	</form>');
document.write('</div>');


bugs_init();