// JavaScript Document
// ricava le dimensioni della finestra
function getWindowDimension(){
 if (window.innerHeight) return [window.innerWidth-10,window.innerHeight-10,window.pageXOffset,window.pageYOffset];
 else if (document.documentElement.clientHeight) return [document.documentElement.clientWidth-10,document.documentElement.clientHeight-10,document.documentElement.scrollLeft,document.documentElement.scrollTop];
 return [document.body.clientWidth,document.body.clientHeight,document.body.scrollLeft,document.body.scrollTop];
}

function blankoutsize(){ 
	var winDimen = getWindowDimension();
    document.getElementById('alert_overlay').style.width = winDimen[0];   //applica la larghezza al div
	document.getElementById('alert_overlay').style.height = winDimen[1];  //applica l'altezza al al div
}

	/* al ridimensionamento  della pagina */
	if(document.attachEvent){
		window.attachEvent('onresize',function(e){blankoutsize();});
	}else if(document.addEventListener){
		window.addEventListener('resize',function(e){blankoutsize();},false);
	}else{
		window.onresize = function(e){bankoutsize();};
	}
	
	/* this makes the resize script fire on page-scrolling */
	if(document.attachEvent){
		window.attachEvent('onscroll',function(e){blankoutsize();});
	}else if(document.addEventListener){
		window.addEventListener('scroll',function(e){blankoutsize();},false);
	}else{
		window.onscroll = function(e){bankoutsize();};
	}

function playSound(soundfile) {
 document.getElementById("soundsfx").innerHTML=
 "<embed src=\""+soundfile+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" />";
}
	
function open_alert(text)
{  
	document.getElementById('alert_box').style.display='block';
	document.getElementById('alert_overlay').style.display='block';
	document.getElementById('response-text').innerHTML = text;
	playSound('http://www.aroundsalerno.it/lib/js/alertbox_web/sound01.mp3')
	// applica opacita
	//	da problemi con ie e tmtvaliadtor
	/*opacity('alert_box', 0, 100, 300)
	opacity('alert_overlay', 0, 60, 300)*/	
}

function close_alert(button)
{
  // button.parentNode.parentNode.parentNode.style.display = 'none';
  document.getElementById('response-text').innerHTML = '';
 /* //	da problemi con ie e tmtvaliadtor 
 	opacity('alert_box', 100, 0, 300)
  opacity('alert_overlay', 100, 0, 300)*/
  	document.getElementById('alert_box').style.display='none';
	document.getElementById('alert_overlay').style.display='none';  
}
/*
function opacity(id, opacStart, opacEnd, millisec) {
		//speed for each frame
		var speed = Math.round(millisec / 100);
		var timer = 0;		
		
		//determine the direction for the blending, if start and end are the same nothing happens
		if(opacStart > opacEnd) {	
		
		
		// alert_overlay-OUT ---------------------------------------------
		for(i = opacStart; i >= opacEnd; i--){
		setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
		timer++;
		}
		setTimeout("hideElement('"+id+"')",(timer * speed));	
		
		
		} else if(opacStart < opacEnd) {
		
		// alert_overlay-IN ------------------------------------------------
		document.getElementById(id).style.visibility = 'visible';
		for(i = opacStart; i <= opacEnd; i++){
		setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
		timer++;
		}
		}
	}//function
	
	//change the opacity for different browsers
	
	function changeOpac(opacity, id) {
		var object = document.getElementById(id).style;
		object.opacity = (opacity / 100);
		object.MozOpacity = (opacity / 100);
		object.KhtmlOpacity = (opacity / 100);
		object.filter = "alpha(opacity=" + opacity + ")";
	}
	
	
	function hideElement(id) {
		document.getElementById(id).style.visibility = 'hidden';
		return;
	}
*/
