// JavaScript Document

// Function relativa al archivo lista_FT.asp
function buscar(){
	valor = document.getElementById("buscar").value;
	location.href="lista_FT.asp?buscar="+valor;
	}


// Funcion relativa al archivo FT.asp
var indiceFilaFormulario=1;	

function nuevoCampo(){
	myNewRow = document.getElementById("tablaFormulario").insertRow(-1);
	myNewRow.id=indiceFilaFormulario;
	myNewCell=myNewRow.insertCell(-1);
		myNewCell.innerHTML="<div align='center'><input name='nombreCampo["+indiceFilaFormulario+"]' type='text' class='nombreCampo' /></div>";
	//myNewCell.innerHTML="<div align='center'><input name='nombreCampo[]' type='text' class='nombreCampo' /></div>";
	myNewCell.valign='top';
	myNewCell=myNewRow.insertCell(-1);
	myNewCell.innerHTML="<div align='center'><input name='valorCampo["+indiceFilaFormulario+"]' type='text' class='valorCampo' id='Titulo' /></div>";
	//myNewCell.innerHTML="<div align='center'><textarea name='valorCampo[]' rows='3' class='valorCampo' id='Titulo'></textarea></div>";
	myNewCell=myNewRow.insertCell(-1);
	myNewCell.innerHTML="<div align='center'><input type='button' value='Eliminar' onclick='eliminarCampo(this)'></div>";
	indiceFilaFormulario++;
}

function eliminarCampo(obj){
	var oTr = obj;
	while(oTr.nodeName.toLowerCase()!='tr'){
		oTr=oTr.parentNode;
	}
	var root = oTr.parentNode;
	root.removeChild(oTr);
}

function pop_up_foto(e, objID , serverPage, img, carpeta, dim_max){
	// Dimensiones de la foto
	imgWidth = anchoIMG(img, carpeta);
	imgHeight = altoIMG(img, carpeta);
	
	// Calcula la dimension de la foto
	if(imgWidth > dim_max || imgHeight > dim_max){
		if(imgWidth > imgHeight){
			imgHeight = Math.floor(dim_max*imgHeight/imgWidth);
			imgWidth = dim_max;		
		} 
		else
		{
			imgWidth = Math.floor(dim_max*imgWidth/imgHeight);
			imgHeight = dim_max;	
		}
	}
	
	pop_up (e, objID , serverPage+"&w="+imgWidth+"&h="+imgHeight, imgHeight, imgWidth)
}

function sobreponer(obj1, obj2){
	
	document.getElementById(obj1).style.zIndex = document.getElementById(obj2).style.zIndex+1 
}