/***************************************************************
Created by R.Ordax - ramon.ordax@gmail.com
Function getPageSize() required

A div is created with the ID determinated by the 'div_id' variable
You can modify the ID name and create the div style

A close imagen button is created at the top right of the div ('img_close' variable)

The div content is parsed by the 'html' variable

The div is showing/hidding by using the 'visibility' property, so take care about it.

By default the div takes a fixed width, but can be modified to set it dinamic based on the div contents

////////////////
DIV default style:

#winDiv
{
// DON'T MODIFY THESE PROPERTIES //
	position: absolute;
	visibility:hidden;	
	width:auto;	
	height:auto;
	z-index: 200;

//	MODIFY FROM HERE	//
	border: 1px solid #080808;
	background-color:#e5e7d3;	
	font: normal 8pt 'Tahoma';
	color:#666;
	padding:10px;	
}

***************************************************************/

function winDiv(html) {
	
	var div_id = "ventana_foto_detalles";
	var img_close = "img/ico_cerrar.gif";
	var img_close_alt = "cerrar"; //alt attribute for the 'close' image
	var div_width = 450; //in pixels
	var div_height = 580;
	var posX = 0;		
	var posY = 0;		
	
	var win = document.getElementById(div_id);
	if(document.all) browser = "ie";
	if(document.getElementById && !document.all) browser = "ns6";

	if(!win) 
	{
		var objBody = document.getElementsByTagName("body").item(0);
		var objDiv = document.createElement("div");
		objDiv.setAttribute('id',div_id);
		objBody.appendChild(objDiv);
		win = document.getElementById(div_id);			
	}
		
	
	

	if(html != 'close')
	{					
		html = "<div onclick=\"winDiv('close')\" style='cursor:pointer';'  title='Click para cerrar'><div style='text-align:right'><a href='javascript:void(null)' onclick=\"winDiv('close')\"><img src='"+img_close+"' border=0 alt='"+img_close_alt+"'></a></div>" + html + "</div>";
		win.innerHTML = html;
		
		win.style.width = div_width+'px';
		win.style.height = div_height+'px';
		//fixed Width, can be modified by allowing the following line		
		//posX = browser=="ie"? ((document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body).scrollLeft : window.pageXOffset; 
				
		posY = browser=="ie"? ((document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body).scrollTop : window.pageYOffset; 		
		var divleft = ((getPageSize()[2] - win.offsetWidth) / 2) ;
		var divtop = ((getPageSize()[3] - win.offsetHeight) / 2) + posY;
		
		win.style.left = divleft +"px";
		win.style.top = divtop +"px";					
		win.style.visibility='visible';		
	}
	else 
	{
		win.innerHTML = '';		
		win.style.width = 'auto';
		win.style.height = 'auto';
		win.style.visibility='hidden';
	}
}