$.fn.image = function(src, f){ 
    return this.each(function(){ 
     var i = new Image(); 
     i.src = src; 
     i.onload = f; 
     $(i).hide();
     this.appendChild(i);
     
   }); 
} 
function onloadResult(static_code){
	$(".absControl").each(function(){
			$(this).parents("div.risultato").find("div.absClose").hide();
			$(this).toggle(function(){$(this).parents("div.risultato").find("div.absClose").slideDown('slow');$(this).text('chiudi -')},
					function(){$(this).parents("div.risultato").find("div.absClose").slideUp();$(this).text('leggi tutto +')}
					)
		});
		$(".absControlPDF").each(function(){
			$(this).parents("div.risultato").find("div.absClosePDF").hide();
			$(this).toggle(function(){$(this).parents("div.risultato").find("div.absClosePDF").slideDown('slow');$(this).text('chiudi -')},
					function(){$(this).parents("div.risultato").find("div.absClosePDF").slideUp();$(this).text('allegati +')}
				)
		});	
		
		$(".slide > a").each(function(){
			var title = $(this).attr("href");
			title = title.substring(0,title.indexOf("/low"))+"/thumb"+title.substring(title.indexOf("/low")+4);
			var titleAttr = $(this).attr("title");
			
			if(!jQuery.browser.safari || jQuery.browser.version > 400){
				$(this).image(title,function(){
					$(this).prev("img").remove();
					$(this).attr("alt",titleAttr);
					$(this).fadeIn();
				});
			}else{
				$(this).find("img").attr("src",title);
				$(this).find("img").attr("alt",titleAttr);
			}
			 
			// $(this).find("img").attr("src", "http://media.regesta.com/dm_0/IBC/IBCAS00132/thumb/"+title + ".jpg")
	});
};
function onloadResultFoto(static_code){
 	$(".centraFoto > a").each(function(){
		var title = $(this).attr("rel");
			if(!jQuery.browser.safari || jQuery.browser.version > 400){
				$(this).image(title,function(){
				var classAttr = $(this).prev("img").attr("class");
				$(this).attr("class",classAttr);
				$(this).prev("img").remove();
				$(this).fadeIn();
				});
			}else{ 
				$(this).find("img").attr("src",title); 
			}
			
		
		$(this).attr("rel","");
	});	
}
function onloadNewPage(){
	$("a[@rel='newpage']").each(function(){
		$(this).attr("target","_new");
		$(this).attr("rel","");
	})
}

