rules_recargar_fotoAmpliada={
	ampliacion:function(){
	$("a.ampliarFoto").bind("click",rules_ampliar_foto.ejecutar);
	}
}
rules_ampliar_foto={
	evento:function(){
		$("a.ampliarFoto").bind("click",rules_ampliar_foto.ejecutar);
	},
	before:function(){
		if(p['ctn']=="")
			$("#modal").popUp();
		$().pre_loading("#modal",img_cargando,0.1,"modal");	
	},
	ejecutar:function(){
		p=parametros(this.href);
		var params=p["aP"].split("modulo=NEWSImageStaticOU&")[1];
		var foto=unescape(params);
    	foto=foto.split("foto=")[1];
    	
    	fin_foto=function(html){
			if(validarErr(html)){
				foto=$.fn.foto;
				alto=$.fn.alto;
				ancho=$.fn.ancho;
				var anchoConf=600;
				var altoConf=500;
				if(ancho>=alto){
						ratio=(ancho/anchoConf); 
						nuevaanchura=anchoConf;
						nuevaaltura=Math.round(alto/ratio); 
				}
				else{
						ratio=(alto/altoConf); 
						nuevaanchura=Math.round(ancho/ratio); 
						nuevaaltura=altoConf;
				}
				$("#modal").animate({opacity:"toggle"},"fast",function(){
						$("div#modal").html(html).popUp();
						$("#img_cargando").attr("src",foto);
						$().post_loading("#modal",1);
						$("div#modal").popUp();
						$("div#modal").each(rules_recargar_fotoAmpliada.ampliacion);
				});
			}
		}
    	fin=function(html){
			if(validarErr(html)){
				$("#modal").animate({opacity:"toggle"},"fast",function(){
						$("div#modal").html(html).popUp();
						$().post_loading("#modal",1);
						$("div#modal").popUp();
						$("div#modal").each(rules_recargar_fotoAmpliada.ampliacion);
				});
			}
		}
		if(foto!=undefined&&foto!=""){
				var preloader=new Image();
				preloader.onload=function(){
         
						var ancho=preloader.width;
						var alto=preloader.height;
						$.fn.ancho=ancho;
						$.fn.alto=alto;
						$.fn.foto=foto;
						preloader.onload=function(){};
						$.ajax({url:"/modulo/index.aspx",dataType:"html",data:p['aP'],beforeSend:rules_ampliar_foto.before,success:fin_foto});
				}
				preloader.src=foto;
		}
		else
				$.ajax({url:"/modulo/index.aspx",dataType:"html",data:p['aP'],beforeSend:rules_ampliar_foto.before,success:fin});
		return false;
	}
}
$(document).ready(rules_ampliar_foto.evento);
