var div=document.createElement('div');
div.setAttribute('id','foto'); 
div.style.position='absolute';
div.style.display='none';
div.style.padding='0px 0px 0px 0px';
div.style.zIndex=10;

var ombra=document.createElement('div');
ombra.setAttribute('id','ombra'); 
ombra.style.position='absolute';
ombra.style.display='none';
ombra.style.padding='0px 0px 0px 0px';
ombra.style.zIndex=9;

//attributi foto
var w,h;

// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

//controlla se si muove il mouse
document.onmousemove = getMouseXY;

function hidePop(){
	//alert(id);
	//document.getElementById('foto').style.display='none';
	var div=document.getElementById('foto');
	if(div!=null){
		div.style.display='none';
	}
	
	var ombra=document.getElementById('ombra');
	if(ombra!=null){
		ombra.style.display='none';
	}
}

function showPop(wtemp,htemp,file,nome){
	w = wtemp;
	h = htemp;
	
	var div=document.getElementById('foto');
	if(div!=null){
		div.style.display='block';
		div.style.width= w + 'px';
	}
	
	var ombra=document.getElementById('ombra');
	if(ombra!=null){
		ombra.style.display='block';
		ombra.style.width= w + 'px';
	}
	
	var text = "";
	//alert(text);
	if(nome!=null){
		h = h + 20;
		text = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td align=\"center\"><img src=\"" +  file + "\" border=\"0\"/></td></tr><tr><td align=\"center\">" + nome + "</td></tr></table>";
	}
	else{
		text = "<img src=\"" +  file + "\" border=\"0\"/>";
	}
	
	if(div!=null){
		div.style.height= h + 'px';
		div.innerHTML=text;
		
		//ombra.innerHTML="&nbsp";
		ombra.style.height= h + 'px';
	}
	
}

function getMouseXY(e) {
	if (IE) { // grab the x-y pos.s if browser is IE
   		tempX = event.clientX + document.body.scrollLeft;
    	tempY = event.clientY + document.body.scrollTop;
    	windowWidth = document.body.offsetWidth;
 	}
 	else {  // grab the x-y pos.s if browser is NS
    	tempX = e.pageX;
    	tempY = e.pageY;
    	windowWidth = window.innerWidth;
  	}
  	var div=document.getElementById('foto');
  	var ombra=document.getElementById('ombra');
  	
  	var tempXombra, tempYombra;
  	
  	//document.Show.MouseY.value = divs[i];
  	//tempX = tempX - 5;
  	if(h==null)h=0;
  	if(tempY - h - 5 < 0){
  		tempY = tempY + 5;
  	}
  	else{
  		tempY = tempY - h - 5;
  	}
  	if(windowWidth < tempX + w){
  		tempX = tempX - w - 5;
  	}
  	
  	
  	if (tempX < 0 || tempX==null){tempX = 0;}
 	if (tempY < 0 || tempY==null){tempY = 0;}
 	//document.Show.MouseX.value = tempX;
  	//document.Show.MouseY.value = h;
  	//div.style.position='absolute';
  	//div.style.zIndex=10;
    if(div!=null){
    	div.style.left=tempX+'px';
		div.style.top=tempY+'px';
		
		tempXombra = tempX + 3;
		tempYombra = tempY + 3;
		
		ombra.style.left=tempXombra+'px';
		ombra.style.top=tempYombra+'px';
	}
}

function popUp(){
	document.body.appendChild(div);
	document.body.appendChild(ombra);
}
