/*
 FILE JS PRINCIPALE PER IL SITO AMATORI
*/

var ua = navigator.userAgent.toLowerCase();
var isStrict = document.compatMode == 'CSS1Compat',
    isOpera = ua.indexOf("opera") > -1,
    isIE = ua.indexOf('msie') > -1,
    isIE7 = ua.indexOf('msie 7') > -1,
    isBorderBox = isIE && !isStrict,
    isSafari = (/webkit|khtml/).test(ua),
    isSafari3 = isSafari && !!(document.evaluate),
    isGecko = !isSafari && ua.indexOf('gecko') > -1,
    isWindows = (ua.indexOf('windows') != -1 || ua.indexOf('win32') != -1),
    isMac = (ua.indexOf('macintosh') != -1 || ua.indexOf('mac os x') != -1),
    isLinux = (ua.indexOf('linux') != -1);
    
var getViewportHeight = function(){
  var height = window.innerHeight; // Safari
  var mode = document.compatMode;
  if((mode || isIE) && !isOpera){
      height = isStrict ? document.documentElement.clientHeight : document.body.clientHeight;
  }
  return height;
};

var getViewportWidth = function(){
  var width = window.innerWidth; // Safari
  var mode = document.compatMode;
  if(mode || isIE){
      width = isStrict ? document.documentElement.clientWidth : document.body.clientWidth;
  }
  return width;
};

var getDocumentHeight = function(){
  var scrollHeight = isStrict ? document.documentElement.scrollHeight : document.body.scrollHeight;
  return Math.max(scrollHeight, getViewportHeight());
};
var getDocumentWidth = function(){
  var scrollWidth = isStrict ? document.documentElement.scrollWidth : document.body.scrollWidth;
  return Math.max(scrollWidth, getViewportWidth());
};

var InitPage = function(){
	var CreditsWidth = jQuery('#Credits').width();
	var CreditsHeight = jQuery('#Credits').height();
jQuery('#btnCredits').click(
		function(event) {
			event.preventDefault();
			var width = (getViewportWidth() - CreditsWidth)/2;//210
			var height = (getViewportHeight() - CreditsHeight)/2;
			jQuery('#Fondo').prepend("<div id='Overlay' style='opacity:0;display:block;position:absolute;top:0;left:0;width:"+getDocumentWidth()+"px;height:"+getDocumentHeight()+"px;background-color:#000;'></div>");
			jQuery('#Overlay').fadeTo(500,0.8);
			jQuery('#Credits').css('left',width+'px').css('top',height+'px').show("blind",{direction:"vertical"},500);
		});
jQuery('#Chiudi').click(
		function(event) { 
			event.preventDefault();
			jQuery('#Credits').hide("blind",{direction:"vertical"},500); 
			jQuery('#Overlay').fadeTo(500,0,function(){jQuery('#Overlay').remove()});	
		});
}