function ocultar_capa_busqueda(id_j_frame) {
	$('contenedor_'+id_j_frame).setHTML('');
	$(id_j_frame).setStyle('visibility','hidden');
}

function iniciar_capa_busqueda(id_j_frame, servicio, otros_parametros, run_js, codificacion) {
	
	ir_a('contenedor_'+ id_j_frame, servicio, otros_parametros, run_js, codificacion);
	
	( function(){
		
			if( ( $('contenedor_'+id_j_frame).getTop() + $(id_j_frame).getSize()['size']['y'] ) > screen.availHeight ){
				var height_overflow = screen.availHeight - $('contenedor_'+id_j_frame).getTop();
				var top_init = $(id_j_frame).getStyle('top');
				var resto = top_init.toInt() - $(id_j_frame).getSize()['size']['y'] + ( height_overflow / 2 );
				$(id_j_frame).setStyle('top', resto );
			}
			$(id_j_frame).setStyle('visibility','visible');
			
	}.delay(10) );
	
	
	$(id_j_frame).makeDraggable(
		{ 
			handle: $('cabecera_'+id_j_frame),
			onStart: function(){
				$(id_j_frame).setOpacity(0.9);
			}.bind(this),
			 
			onComplete: function(){
				$(id_j_frame).setOpacity(1);
				prepara_scroll(id_j_frame);
			},
			
			x:0,
			y:0,
			limit: {
				x: [
					( window.getScrollLeft() - $('referencia_'+id_j_frame).getLeft() - 200 ), 
					function() { return ( 200 + document.body.offsetWidth - $('referencia_'+id_j_frame).getLeft() - $(id_j_frame).getSize()['size']['x'] );	}
				], 
				y: [
					( window.getScrollTop() - $('referencia_'+id_j_frame).getTop() ),
					function() { return ( 200 + window.screen.availHeight - $('referencia_'+id_j_frame).getTop() - $(id_j_frame).getSize()['size']['y'] );	}
				]
			}
		} );
}

function asignar_resultado_busqueda(variables, valores, delimitador) {
	if( ! delimitador ) delimitador = '|';
	arr_variables = variables.split(delimitador);
	arr_valores   = valores.split(delimitador);
	for(i=0 ; i<arr_variables.length ; ++i) {
		if($(arr_variables[i])) {
			$(arr_variables[i]).setProperty( 'value', arr_valores[i] );
			dispara_evento(arr_variables[i], 'sentencia_ejecutar');
		}
	}
}

function asignar_resultado_busqueda_en_opener(variables, valores, delimitador) {
	if(window.opener) {
		if( ! delimitador ) delimitador = '|';
		arr_variables = variables.split(delimitador);
		arr_valores   = valores.split(delimitador);
		var sentencias = "";
		for(i=0 ; i<arr_variables.length ; ++i) {
				sentencias += "$('"+arr_variables[i]+"').setProperty( 'value', '"+arr_valores[i]+"' );";
				sentencias += "dispara_evento('"+arr_variables[i]+"', 'sentencia_ejecutar');";
		}
		window.opener.setTimeout(sentencias,1);
	}
}

