// JavaScript Document

<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


//alert("What's up!")


function open_win(file,w,h,type,dir) 
{ 
    switch(type)
	{
		
	    case 'img':
		   window.open("../open_win.php?file="+file,"","width="+w+",height="+h+",scrollbars=no") 
		   break;
		   
		case 'thb':
		   window.open("../../thumb_enlarge.php?file="+file+"&dir="+dir,"","width="+w+",height="+h+",scrollbars=no") 
		   break;   
		   
		case 'imgBig':
		   window.open("../open_win.php?file=company/"+file,"","width="+w+",height="+h+",scrollbars=no") 
		   break;   
		   
		case 'mov':
		   window.open("../virtual_movies/"+file,"","width="+w+",height="+h+",scrollbars=no") 
		   break;   
		   
	 	
	}
	
	
}





function centradiv(idDiv, width, height, top, url) { //Centra un div nella pagina

	var windowWidth;
	var windowHeight;
	
	if(typeof(window.innerWidth) == 'number') 
	{
		//Non-IE
		windowWidth = window.innerWidth;
		windowHeight = window.innerHeight;
  	} 
	else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight )) 
	{
		//IE 6+ in 'standards compliant mode'
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}
	
	var scrollOffsetY = 0;
	
	if(typeof(window.pageYOffset) == 'number') 
	{
    	//Netscape compliant
    	scrollOffsetY = window.pageYOffset;
	} 
	else if(document.body && document.body.scrollTop)
	{
    	//DOM compliant
    	scrollOffsetY = document.body.scrollTop;
	} 
	else if(document.documentElement && document.documentElement.scrollTop)
	{
    	//IE6 standards compliant mode
    	scrollOffsetY = document.documentElement.scrollTop;
  	}
	
	var divLeft = Math.round(windowWidth / 2) - Math.round(width / 2);
	var divTop = Math.round(windowHeight / 2) - Math.round(height / 2) + scrollOffsetY;
	
	
	var opacity = 60;
	var opaque = (opacity / 100);
	
	if (!window.document.getElementById("darkLayer")) {
		alert("aaaaaaa");
		var darkLayer = document.createElement("div");
		darkLayer.setAttribute("id", "darkLayer");
		darkLayer.style.position = "absolute";
		darkLayer.style.left = "0px";
		darkLayer.style.top = "0px";
		darkLayer.style.zIndex = "50";
		darkLayer.style.width = "100%";
		darkLayer.style.height = "100%"; //"" + ( scrollOffsetY + ((document.height !== undefined) ? document.height : document.body.offsetHeight) )+ "px";	//"100%";
//		darkLayer.style.backgroundColor = "#FFFFFF";
//		darkLayer.style.opacity = opaque;                      
//		darkLayer.style.MozOpacity = opaque;
//		darkLayer.style.filter = 'alpha(opacity=' + opacity + ')';
		window.document.body.appendChild(darkLayer);
	}
	
	//var messagePopUp = document.createElement("div");
	//messagePopUp.setAttribute("id", ""+idDiv+"");
	var messagePopUp = document.getElementById(""+idDiv+"");
	messagePopUp.style.position = "absolute";
	//messagePopUp.style.position = "relative";	
	messagePopUp.style.left = divLeft + "px"; 
	messagePopUp.style.top = divTop + "px";	
	messagePopUp.style.zIndex = "1000";
	messagePopUp.style.width = width + "px"; 
	messagePopUp.style.height = height + "px";
	//messagePopUp.className = 'messaggioPopup';
	messagePopUp.innerHTML = "<div style=\"text-align: right; padding: 5px\"><a href=\"javascript:void(0);\" onclick=\"closeMessagePopup('"+idDiv+"'); return false\"><strong>X</strong></a></div><div style=\"text-align: center; padding: 5px\">" + "</div>";
	sendAction(url,idDiv);
	//window.document.body.appendChild(messagePopUp);
	messagePopUp.style.display = "block";

	
} // end func centradiv

function closeMessagePopup(idDiv)
{
	if (window.document.getElementById("darkLayer")) {
		divElement = window.document.getElementById("darkLayer");
		parentElement = divElement.parentNode;
		parentElement.removeChild(divElement);
	}
	
	/*divElement = window.document.getElementById(""+idDiv+"");
	parentElement = divElement.parentNode;
	parentElement.removeChild(divElement);*/
	if (document.getElementById(""+idDiv+"")) document.getElementById(""+idDiv+"").style.display='none';
	
} // end func closeMessagePopup


function sendAction(url,idDiv) {
	
	new Ajax.Request(url, {
		method: 'get',
		timeout: 0,
		asynchronous: false,  //false=chiamata bloccante; true=asincrona (non bloccante)
		onSuccess: function(transport) {
			//alert(transport.responseText);
			$(idDiv).innerHTML += transport.responseText;
			
		}
	});

} // end func sendAction





















//-->