function random_generate() {
	aux = 'Numbers: ';
	for (i=0; i<document.random_form.numbers.value; i++) {
		if (i>0) {
			aux += ', ';
		}
		//PEND: convertir n? no validos y negativos
		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 translate() {
	word_trans = document.word_trans;
	worda = escape(word_trans.word.value);
	if (word_trans.from.value == 'es' && word_trans.to.value == 'en') {
		popitup('http://www.wordreference.com/es/en/translation.asp?spen=' + worda)
	} else if (word_trans.to.value == 'en' && word_trans.from.value == 'es') {
		popitup('http://www.wordreference.com/es/translation.asp?tranword=' + worda)
	} else if (word_trans.to.value == 'en' && word_trans.from.value == 'it' ||
				word_trans.to.value == 'en' && word_trans.from.value == 'fr' ||
				word_trans.to.value == 'es' && word_trans.from.value == 'fr' ||
				word_trans.to.value == 'es' && word_trans.from.value == 'pt' ||
				word_trans.to.value == 'pt' && word_trans.from.value == 'es' ||
				word_trans.to.value == 'it' && word_trans.from.value == 'en' 
				) {
		popitup('http://www.wordreference.com/' + word_trans.from.value + word_trans.to.value + '/' + worda)
	} else {
		//usar google aunque es peor, ver si hay que escapar caracteres
		langpair = word_trans.from.value + '%7C' + word_trans.to.value;
		popitup('http://www.google.com/translate_t?hl=' + word_trans.from.value + '&langpair=' + langpair + '&ie=UTF8&text=' + worda);
	}
 }
function finishingLoad() {
var div = AJS.$('tit');
AJS.fx.highlight(div);
var div = AJS.$('tit2');
AJS.fx.highlight(div);
}
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()}
	
	//GB_showFullScreen("",url);

}
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);
	}
}