function agregarPalabras() 
{
	new Ajax.Updater('respuestaServer', 'agregarPalabra.php', {method: 'post', 
			parameters : { 
				p0:document.getElementById("p0").value
			}
	});
	document.getElementById("p0").value = "";
}

var lastIds = new Array();
lastIds[0] = "agregarPalabras";
lastIds[1] = "intro";
function toggleVisibility(id, idx) { 
  if (id == lastIds[idx]) return;
  if (lastIds[idx] != null && id == lastIds[idx]) lastIds[idx] = null;
  else {
	  if (lastIds[idx] != null) Effect.toggle(lastIds[idx], 'appear');
	  //if (lastIds[idx] != null) document.getElementById(lastIds[idx]).style.display="none";
	  document.getElementById(lastIds[idx]+"btn").style.borderBottomStyle="none";
	  document.getElementById(id+"btn").style.borderBottomStyle="solid";
	  lastIds[idx] = id;
  }
  Effect.toggle(id, 'appear'); 
  //document.getElementById(lastId).style.display="inline";
}

function changeIdioma(lang) {
	document.location = changeWindowLanguaje(document.location.href, lang);
}

function changeWindowLanguaje(url, idioma) {
	str = url;
	
	re = /\?idioma=(CA|ES|EN)\&/g; 
	str = str.replace(re,"?");

	re = /(\?i|\&i)dioma=(CA|ES|EN)/g;
	str = str.replace(re, "");

	if (str.indexOf('?')>0) 
		str = str + "&idioma=" + idioma;
	else
		str = str + "?idioma=" + idioma;
	return str;
}

function loadWords()
{
	new Ajax.Updater('wordStat', 'statPalabras.php', {method: 'post'});
	setTimeout ( loadWords, 5000 ); 
}

