function random_generate() {
	aux = 'N&uacute;meros: ';
	for (i=0; i<document.random_form.numbers.value; i++) {
		if (i>0) {
			aux += ', ';
		}
		//PEND: convertir n? no validos y negativos y no repetir
		rand1 =  Math.random() * (parseInt(document.random_form.to.value) - parseInt(document.random_form.from.value));
		rand1 += parseInt((document.random_form.from.value));
		aux += Math.round(rand1);
	}
	document.getElementById('random_result').innerHTML=aux;
}
function show_divs_text_trans() {
	lang = document.text_trans.hl.value;
	/*document.getElementById('text_voice_es').style.visibility = (lang == 'es' ? "visible" : "hidden");
	document.getElementById('text_voice_en').style.visibility = (lang == 'en' ? "visible" : "hidden");
	document.getElementById('text_voice_de').style.visibility = (lang == 'de' ? "visible" : "hidden");
	document.getElementById('text_voice_fr').style.visibility = (lang == 'fr' ? "visible" : "hidden");*/
	document.getElementById('text_voice_es').style.display = (lang == 'es' ? "block" : "none");
	document.getElementById('text_voice_en').style.display = (lang == 'en' ? "block" : "none");
	document.getElementById('text_voice_fr').style.display = (lang == 'fr' ? "block" : "none");
	document.getElementById('text_voice_de').style.display = (lang == 'de' ? "block" : "none");

}
function finishingLoad() {
var div = AJS.$('tit');
AJS.fx.highlight(div);
var div = AJS.$('tit2');
AJS.fx.highlight(div);
}
function translate() {
	//word_trans = document.forms["word_trans"];
	var worda = escape(document.forms["word_trans"].elements["word"].value);
	var from = document.forms["word_trans"].elements["from"].value;
	var to = document.forms["word_trans"].elements["to"].value;
	if (from == 'es' && to == 'en') {
		popitup('http://www.wordreference.com/es/en/translation.asp?spen=' + worda)
	} else if (from == 'en' && to == 'es') {
		popitup('http://www.wordreference.com/es/translation.asp?tranword=' + worda)
	} else if (to == 'en' && from == 'it' ||
				to == 'en' && from == 'fr' ||
				to == 'es' && from == 'fr' ||
				to == 'es' && from == 'pt' ||
				to == 'pt' && from == 'es' ||
				to == 'it' && from == 'en' 
				) {
		popitup('http://www.wordreference.com/' + document.forms["word_trans"].elements["from"].value + word_trans.elements["to"].value + '/' + worda)
	} else {
		//usar google aunque es peor, ver si hay que escapar caracteres
		langpair = from + '%7C' + to;
		popitup('http://www.google.com/translate_t?hl=' + from + '&langpair=' + langpair + '&ie=UTF8&text=' + worda);
	}
}
function popitup2(url) {
	GB_showFullScreen("",url);
}
function popitup(url) {
	//TODO: validate first
	var sFeatures = "resizable=yes,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes";

	sFeatures += ",width=" + screen.availWidth * 0.80;
	sFeatures += ",height=" + screen.availHeight * 0.80;
	sFeatures += ",left=" + screen.availWidth * 0.10;
	sFeatures += ",top=" + screen.availHeight * 0.10;

	popup=window.open(url,"popup",sFeatures);
	if (window.focus) {popup.focus()}
}
function submitpopitup(name) {
	document.forms[name].txt.value=document.forms['text_trans'].text.value;
	popitup('');
}
function popitupSubmitForm(name) {  //used for POST
	//TODO: validate first
	var sFeatures = "resizable=yes,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes";

	sFeatures += ",width=" + screen.availWidth * 0.80;
	sFeatures += ",height=" + screen.availHeight * 0.80;
	sFeatures += ",left=" + screen.availWidth * 0.10;
	sFeatures += ",top=" + screen.availHeight * 0.10;

	var f = document.forms[name];
	if (f) {
		window.newWindowHtml = [
			'<html><head><title></title></head>',
			'<body onload="',
			'var w;',
			'if ((w = window.opener) &&',
			'(w = w.document) &&',
			'(w = w.forms) &&',
			'(w = w[\'' + name + '\'])) {',
			'w.submit();',
			'}',
			'window.focus();',
			'">',
		'</body></html>'
		].join('\n');
		window.open('javascript:opener.newWindowHtml',f.target,sFeatures);
	}
}