function abreVentana(){
	var pX,pY;
	var longX=500;
	var longY=400;
	pX = (screen.width-longX)/2;
	pY = (screen.height-longY)/2;
	window.open('about:blank','popup','scrollbars=yes,resizable=no,toolbar=no,width='+longX+',height='+longY+',left='+pX+',top='+pY);
}

function cargarPadre(valor,idvalor) {
 
 	try {
		//Se envian datos al padre
		switch (document.forms[0].tipoListado.value) {
	   	case 'prc':
			window.opener.document.getElementById('idProcedente').value = valor;					
			window.opener.document.getElementById('procedente').value = idvalor;
			window.opener.document.getElementById('cuadroProcedente').value = idvalor;
			window.opener.document.getElementById('hProcedente').value = idvalor;
			window.opener.refrescar(); //para cargar el campo seccion en formulario de nuevo/edicion edictos
			break;
			
		case 'esp':
			window.opener.document.getElementById('idEspecie').value = valor;
			window.opener.document.getElementById('especie').value = idvalor;
			window.opener.document.getElementById('cuadroEspecie').value = idvalor;
			window.opener.document.getElementById('hEspecie').value = idvalor;
			window.opener.refrescar(); //para cargar el campo seccion en formulario de nuevo/edicion edictos			
			break;			
			
		case 'por':
			window.opener.document.getElementById('idPortador').value = valor;
			window.opener.document.getElementById('portador').value = idvalor;
			window.opener.document.getElementById('hPortador').value = idvalor;
			break;
			
		case 'pag':
			window.opener.document.getElementById('idPagadora').value = valor;
			window.opener.document.getElementById('pagadora').value = idvalor;
			window.opener.document.getElementById('hPagadora').value = idvalor;		
			break;
		}
		
				
	} catch (e) {}
 
	window.close();
	
	return false;
 }
 
// Función que resetea el formulario
function limpiar(objeto) {
	
	for (var i=0, j=objeto.elements.length; i<j; i++) {
		nombre= objeto.elements[i].type;
		
		if (nombre.indexOf('checkbox') > -1 || nombre.indexOf('radio') > -1) {
			objeto.elements[i].checked = "";
		}
        
        if (nombre.indexOf('hidden') > -1 || nombre.indexOf('password') > -1 || nombre.indexOf('text') > -1) {
            objeto.elements[i].value = "";
       	}
       
        if (nombre.indexOf('select') > -1) {
            for (var k=0, l=objeto.elements[i].options.length; k<l; k++) {
                selElementoCombo(objeto.elements[i],"");
      		}
        }
    }
}

// Selecciona un valor de un combo
function selElementoCombo(combo,valor) {
	var i;

	for(i=0;i<combo.options.length;i++) {
		if(combo.options[i].value == valor) {
			combo.selectedIndex = i;
		}
	}
}

// Valida XHTML 1.1
function externalLinks() {
 	if (!document.getElementsByTagName) return;
 		var anchors = document.getElementsByTagName("a");
 	
 	for (var i=0; i<anchors.length; i++) {
   		var anchor = anchors[i];
   		
   		if (anchor.getAttribute("href") &&
       		anchor.getAttribute("rel") == "external")
     	anchor.target = "_blank";
 	}
}

Behaviour.addLoadEvent(function(){
			externalLinks();
		});
