function toggleJ(id)
{
	if (document.getElementById)
	{
		var div = document.getElementById(id).style;
		div.display = (div.display == "block")? "none":"block";
	}
}

function escapa(text)
{
	// text = text.replace(/,/g,".");
	text = text.replace(/'/g,"`");
	return text;
}

function posafocus(id)
{
	if (document.getElementById)
	{
		var div = document.getElementById(id);
		div.focus();
		div.select();
	}
}
function apareixer__(id)
{
	Effect.BlindDown(id);
}

function desapareixer__(id)
{
	Effect.BlindUp(id);
}

function apareixer_(id)
{
	if (document.getElementById)
	{
		var div = document.getElementById(id).style.display = "block";
	}
}

function desapareixer_(id)
{
	if (document.getElementById)
	{
		var div = document.getElementById(id).style.display = "none";
	}
}


function amaga_tots()
{
	if (document.getElementById)
	{
		var div = document.getElementById("administrar").style;
		div.display = "none";
	}
}

function nuevoAjax(){
	var xmlhttp=false;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}


function cridaAjax(campContenidor,campSelect,t2,t3,t4,accio,calSelect){
	var t1,contenedor,llista,ll;
	contenedor = document.getElementById(campContenidor);
	
	
	if (calSelect)
	{
		llista = document.getElementById(campSelect);
		t1 = llista.options[llista.selectedIndex].value;
	}
	else
		t1 = document.getElementById(campSelect).value;

	contenedor.innerHTML = "";


	ajax=nuevoAjax();
	ajax.open("GET", "/lib/ajax.php?op="+accio+"&data="+escapa(t1)+";;"+t2+";;"+t3+";;"+t4,true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			contenedor.innerHTML = ajax.responseText
		}
	}
	ajax.send(null)

}


function popitup(url)
{
	newwindow=window.open(url,'pimporreta','height=600,width=400');
	if (window.focus) {newwindow.focus()}
	return false;
}

function pajax(url,idcamp)
{
	new Ajax.Request(url,
	  {
	    method:'get',
		encoding:'iso-8859-1',
	    onSuccess: function(transport){
	      var response = transport.responseText || "no response text";
		var cont = document.getElementById(idcamp);
		cont.innerHTML = transport.responseText || "error";
	    },
	    onFailure: function(){ alert('Something went wrong...') }
	  });
}


function editarPost(idPost)
{
	desapareixer_('post-'+idPost);
	apareixer_('editapost-'+idPost);
}

function deseditarPost(idPost)
{
	apareixer_('post-'+idPost);
	desapareixer_('editapost-'+idPost);
}

var isNav, isIE

if (parseInt(navigator.appVersion) >= 4) {
  if (navigator.appName == "Netscape")
    isNav = true
  else
    isIE = true
}

function showKeyValue(evt) {
  var keyValue

  if (isNav) 
    keyValue = evt.which
  else
    keyValue = window.event.keyCode

  /*status = keyValue*/
        
  if (keyValue == 13) {
    /*alert(keyValue)*/
    javascript:document.xat.submit();
  }
  return false
}