/**
 * Maestra JS directorio v2
 * Autor : Juan Pablo Aqueveque
 * Version: 2007-11-07 16:25:47 
 */

$(document).ready(function(){
	$('#n').focus();
	$('#form').submit(
		function(){
			$('#resultado').remove();
			$('.detalles').remove();
			$('.mensaje').remove();
			$.get('/procesar.php', {n: $('#n').val(), bx: $('input[name=bx]:checked').val(), enviar:true, ajax:true},
			function(data) {
				$('#r').html(data)
				
					$("#r").find("a").click(function(){
						$(this).css({fontWeight:'bold'});
						var url = $(this).attr("href");
						url = url.replace(/http:\/\//,"");
						arrUrl = url.split("\/");
						var op = arrUrl[1];
						var bd = arrUrl[2];
						var id = arrUrl[3];
						$.get('/procesar.php',{op:op,bd:bd,id:id,ajax:true},function(data){ 
							$('#r').html(data) 
						
							$('#r').find("a.permalink").hover(
							      function () {
								$("#resultado > ul").append($("<span class=\"tip\"> Enlace permanente a esta información</span>"));
							      }, 
							      function () {
								$("#resultado > ul").find("span:last").remove();
							      }
							 );
						});

						return false;
					});
			});
			$("#estado").ajaxStart(function(){
				$(this).show();
			});

			$("#estado").ajaxStop(function(){
				$(this).hide();
			});
			return false;
		}
	); // submit

})

function addEngine(name,ext,cat)
{
	if ((typeof window.sidebar == "object") && (typeof
	window.sidebar.addSearchEngine == "function"))
	{
		window.sidebar.addSearchEngine(
			"http://directorio.uct.cl/plugin/"+name+".src",
			"http://directorio.uct.cl/plugin/"+name+"."+ext,
			name,cat);
		alert('Descarga Completa');
	}
	else
	{
		errorMsg(name,ext,cat);
	}
}

