var changing = false;
var hermano;

function fieldBlur(campo,idfld) {
	if (campo.value!="") {
		elem = document.getElementById( idfld );
		remotos = new datosServidor;
		nt = remotos.enviar(urlBase + "?fieldname=" +escape(elem.id)+ "&content="+escape(campo.value)+"&"+formVars,"");
		elem.innerHTML = nt;
		changing = false;
		return false;
	}
}

function highLight(span){
            span.parentNode.style.border = "2px solid #D1FDCD";
            span.parentNode.style.padding = "0";
            span.style.border = "1px solid #54CE43";          
}

function noLight(span){
        span.parentNode.style.border = "0px";
        span.parentNode.style.padding = "2px";
        span.style.border = "0px";       

}

//get width of text element
function widthEl(span){

	if (document.layers){
	  w=document.layers[span].clip.width;
	} else if (document.all && !document.getElementById){
	  w=document.all[span].offsetWidth;
	} else if(document.getElementById){
	  w=document.getElementById(span).offsetWidth;
	}
return w;
}

//get height of text element
function heightEl(span){

	if (document.layers){
	  h=document.layers[span].clip.height;
	} else if (document.all && !document.getElementById){
	  h=document.all[span].offsetHeight;
	} else if(document.getElementById){
	  h=document.getElementById(span).offsetHeight;
	}
return h;
}

//edit field created
function cambia(actual) {

	if(!changing){
		width = widthEl(actual.id) + 20;
		height =heightEl(actual.id) + 2;
		if(width < 100)
			width = 150;
		if(height < 40)
		{
			hermano=actual.parentNode.firstChild;
			/*var myHiddenField = document.createElement("input");
			myHiddenField.style.width=width;
			myHiddenField.style.height=height;
			myHiddenField.value = hermano.value;
			myHiddenField.name = hermano.name;
			myHiddenField.id = hermano.id;
			myHiddenField.maxLength = 254;
			myHiddenField.text = 'text';
			myHiddenField.onblur = reCambia; 
			/* and so on
			
			hermano.parentNode.replaceChild(myHiddenField, hermano)
			hermano=actual.parentNode.firstChild;*/
			
			
			hermano.style.width=width;
			hermano.style.height=height;
			hermano.maxlength=254;
			hermano.value=actual.innerHTML;
			hermano.style.display='block';
			//hermano.type='text';
			//hermano.onfocus=highLight;
			hermano.onblur=reCambia;
			actual.style.display='none';
			//actual.onclick=cambia(actual);
			}
		else
		{
			hermano=actual.parentNode.firstChild;
			hermano.style.width=width;
			hermano.style.height=height;
			hermano.maxlength;
			hermano.type='text';
			hermano.value=actual.innerHTML;
			//hermano.onfocus='highLight(this);';
			//hermano.onblur='noLight(this); reCambia(this);';
			actual.style.display='none';
			//actual.onclick='cambia(this)';
		}	
		changing = true;
	}
		padre = document.getElementById('cualquiera');
		padre.firstChild.focus();
}

function reCambia() {
	//alert(actual.id);
	var hermana;
	
	hermana=hermano.parentNode.lastChild;
	hermana.innerHTML = hermano.value;
	hermano.style.display='none';
	hermana.style.display='block';
	hermano.value=hermana.innerHTML;
	changing = false;
	}
