/**
	Thanx to http://www.howtocreate.co.uk/tutorials/javascript/browserwindow for resolved compliances!
*/


var maxWidth = window.innerWidth;
var maxHeight = window.innerHeight;

// popup size
var popupWidth = 800;
var popupHeight = 500;

// popup displacement
var popupLeft = 0;
var popupTop = 20;


function alertSize() {
  
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
   	maxWidth = window.innerWidth;
    maxHeight = 1000;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    maxWidth = document.documentElement.clientWidth
    maxHeight = 1000;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    maxWidth = document.body.clientWidth;
    maxHeight = 1000;
  }
 
}


function openPopupReg(){
	alertSize();
	$('.overlayTrasp')[0].style.width = maxWidth+"px";
	$('.overlayTrasp')[0].style.height = 1100+"px";
	$('.overlayTrasp').show();

	
	popupLeft = Math.round((maxWidth-popupWidth)/2);
	
	
	$('.popupMsg')[0].style.top = popupTop+"px";
	$('.popupMsg')[0].style.left = popupLeft+"px";
	
	$('.popupMsg').show();
	

		
	
}



function openPopupReg_prog(){
	alertSize();

	
	$('.overlayTrasp_prog')[0].style.width = maxWidth+"px";
	$('.overlayTrasp_prog')[0].style.height = 900+"px";
	$('.overlayTrasp_prog').show();
	
	popupLeft = Math.round((maxWidth-popupWidth)/2);
	
	
	
	$('.popupMsg_prog')[0].style.top = 110+"px";
	$('.popupMsg_prog')[0].style.left = popupLeft+"px";
	
	$('.popupMsg_prog').show();
		
	
}




function resizeAll(){
	alertSize();
	
	
	$('.overlayTrasp')[0].style.width = maxWidth+"px";
	$('.overlayTrasp')[0].style.height = maxHeight+"px";
	
	$('.overlayTrasp_prog')[0].style.width = maxWidth+"px";
	$('.overlayTrasp_prog')[0].style.height = maxHeight+"px";

	
	popupLeft = Math.round((maxWidth-popupWidth)/2);


	$('.popupMsg')[0].style.top = popupTop+"px";
	$('.popupMsg')[0].style.left = popupLeft+"px";
	
	$('.popupMsg_prog')[0].style.top = 110+"px";
	$('.popupMsg_prog')[0].style.left = popupLeft+"px";

}



$(document).ready(function(){
	
	// setup components
	$('.overlayTrasp').hide();
	$('.popupMsg').hide();
	
	$('.overlayTrasp_prog').hide();
	$('.popupMsg_prog').hide();

	$('.ticket_link').click(function() {
		openPopupReg();
	})
	
	$('.ticket_link_prog').click(function() {
		openPopupReg_prog();
	})
	
	$('.link_chiusura').click(function() {
		$('.overlayTrasp').hide();
		$('.popupMsg').hide();
	})
	
	$('.link_chiusura_prog').click(function() {
		$('.overlayTrasp_prog').hide();
		$('.popupMsg_prog').hide();
	})
		
		
		
});
