var mouse = {x: 0, y: 0};
document.onmousemove = function(e) {
      if(!e) e = window.event;
      mouse.x = e.clientX;
      mouse.y = e.clientY;
}
function cerrarImgZoom() {
	$("#fotoZoom").css({display: "none", width: "200px", height: "100px"});
	$('#barraFotoZoom').css('width', '100%');
	$("#capaImgZoom").css({width: "50px", height: "40px", display: "none", background: ""});
	$('#imgZoom').css('visibility', 'visible');
}
function cargaImgZoom(url, maxTam){
	var m = {x: mouse.x, y: mouse.y};
	var aux = new Image();
	obj = document.getElementById('imgZoom');
	$("#fotoZoom").css({top: m.y+$(window).scrollTop()-66+"px", left: m.x+$(window).scrollLeft()+"px", display: "block"});
	aux.onload = function() {
		var w = aux.width;
		var h = aux.height;
		$("#fotoZoom").css({top: m.y+$(window).scrollTop()-(h/2)-16+"px", left: m.x+$(window).scrollLeft()+"px", width: w+16+'px', height: h+34+"px"});
		$("#barraFotoZoom").width(w+16+'px');
		$("#capaImgZoom").css({width: w+"px", height: h+"px", background: "url("+aux.src+")"}).show();
		obj.style.visibility = 'hidden';
	}
	aux.src = url;
}
function abrirModalDialog(sUrl,sName,ancho,alto,scroll){
	var anW = (ancho == null) ? anW=300 : ancho;
	var alW = (alto == null) ? alW=400 : alto;
	var scrollbars = (scroll == 1) ? scrollbars='yes' : 'no';
	anE=screen.width;
	alE=screen.height;
	x=anE/2-anW/2;
	y=alE/2-alW/2;
	var popUp=null;
	popUp=open(sUrl,sName,'toolbar=no,location=no,directories=no,scrollbars='+scrollbars+',status=no,menubar=no,resizable=no,width='+anW+',height='+alW+',top='+y+',left='+x);
	popUp.focus();
}
$(document).ready(function () {
   $("#idLinkFotoAmpliar").click(function() {
   		cargaImgZoom(this.href,0);
   		return false;
   });
   $("#idLinkFotoMasImagenes").click(function() {
   		cargaImgZoom(this.href,0);
   		return false;
   });	   
   $("#zoom a").click(function() {
   		cargaImgZoom(this.href,0);
   		return false;
   });	   
 });