﻿function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
  return myHeight;
}

function round(valore, posizioniDecimali)
{
    var ris = valore * Math.pow(10,posizioniDecimali);
    ris = Math.round(ris);
    return ris / Math.pow(10,posizioniDecimali);
}
	
$(document).ready(function() {
//var innercontent = $("#items").innerHeight();
//var abswidth = $("#floating").innerWidth();
//alert(innercontent, abswidth);
//window.resizeTo(screen.width, screen.heigth);
	$("#btnmail").click(function(){
		if ($("#mail").is(":hidden")){
			$("#mail").slideDown("fast");
		}else{
			$("#mail").slideUp("fast");
		}
		

});

function Vscroll(){
	var chk=false;
	if ($(document).height()> $(window).height()) { 
	    chk=true; 
	}
	return chk;
}


// Check if body width is higher than window width :) 
	/*
	if ($(document).width() > $(window).width()) { 
	    alert("Horizontal Scrollbar! D:<"); 
	}
	*/
var ratio = round((screen.width/screen.height),2)
var chk = false;
if (BrowserDetect.browser=="Explorer"){
	if((screen.width == 1366) && (screen.height == 768)){
		//alert("1366x768");		
		$("#items").css("height",320);
		$("#core1").css("height",320);
		$("#core2").css("height",320);
		$("#core3").css("height",320);
		$("#tabwrap_video").css("height",320);
		$("#tabwrap_clienti").css("height",320);
		$("#mediabox").css("height",320);

		if($("#container").innerHeight()>$(window).height()){
			$("#container").css("width",1345);
			$("#bb1").css("top", 124);
			$("#bb2").css("top", 97);
			$("#bb3").css("top", 133);
		}else{
			if($(document).height()==745){
				$("#container").css("width",1366);
				$("#bb3").css("top", 131);
			}else{
				$("#container").css("width",1362);
				$("#bb3").css("top", 132);
			}
			$("#bb1").css("top", 124);
			$("#bb2").css("top", 96);	
		}

		chk=true;
	}
	if((screen.width == 1280) && (screen.height == 768)){
		//alert("1280x768");
		$("#items").css("height",340);
		$("#core1").css("height",340);
		$("#core2").css("height",340);
		$("#core3").css("height",340);
		$("#tabwrap_video").css("height",340);
		$("#tabwrap_clienti").css("height",340);
		$("#mediabox").css("height",340);

		$("#bb1").css("top", 129);
		$("#bb2").css("top", 121);
		$("#bb3").css("top", 156);
		//$("#container").css("width",$("#floating").innerWidth());
		//alert($("#floating").innerWidth());
		if(Vscroll()){
			$("#container").css("width",1259);
			$("#bb1").css("top", 130);
			$("#bb2").css("top", 123);
			$("#bb3").css("top", 158);
		}else{
			$("#container").css("width",1280);
			$("#bb1").css("top", 129);
			$("#bb2").css("top", 121);
			$("#bb3").css("top", 157);
		}

		chk=true;
	}
	if((screen.width == 1280) && (screen.height == 720)){
		//alert("1280x720");
		$("#items").css("height",340);
		$("#core1").css("height",340);
		$("#core2").css("height",340);
		$("#core3").css("height",340);
		$("#tabwrap_video").css("height",340);
		$("#tabwrap_clienti").css("height",340);
		$("#mediabox").css("height",340);

		$("#bb1").css("top", 129);
		$("#bb2").css("top", 121);
		$("#bb3").css("top", 156);
		//$("#container").css("width",$("#floating").innerWidth());
		//alert($("#floating").innerWidth());
		if(Vscroll()){
			$("#container").css("width",1259);
			$("#bb1").css("top", 130);
			$("#bb2").css("top", 123);
			$("#bb3").css("top", 158);
		}else{
			$("#container").css("width",1280);
			$("#bb1").css("top", 129);
			$("#bb2").css("top", 121);
			$("#bb3").css("top", 157);
		}

		chk=true;

	}
	if((screen.width == 1024) && (screen.height == 768)){
		//alert("1024x768");
		$("#items").css("height",450);
		$("#core1").css("height",450);
		$("#core2").css("height",450);
		$("#core3").css("height",450);
		$("#tabwrap_video").css("height",450);
		$("#tabwrap_clienti").css("height",450);
		$("#mediabox").css("height",450);


		$("#bb1").css("top", 237);
		$("#bb2").css("top", 181);
		$("#bb3").css("top", 265);
		//$("#container").css("width",$("#floating").innerWidth());
		//alert($("#floating").innerWidth());
		if(Vscroll()){
			$("#container").css("width",1003);
			$("#bb1").css("top", 238);
			$("#bb2").css("top", 200);
			$("#bb3").css("top", 266);
		}else{
			$("#container").css("width",1024);
			$("#bb1").css("top", 237);
			$("#bb2").css("top", 181);
			$("#bb3").css("top", 267);
		}

		chk=true;
	}
	
	if((screen.width == 1024) && (screen.height == 600)){
		//alert("1024x600");
		$("#items").css("height",450);
		$("#core1").css("height",450);
		$("#core2").css("height",450);
		$("#core3").css("height",450);
		$("#tabwrap_video").css("height",450);
		$("#tabwrap_clienti").css("height",450);
		$("#mediabox").css("height",450);

		$("#bb1").css("top", 237);
		$("#bb2").css("top", 181);
		$("#bb3").css("top", 265);
		//$("#container").css("width",$("#floating").innerWidth());
		//alert($("#floating").innerWidth());
		if(Vscroll()){
			$("#container").css("width",1003);
			$("#bb1").css("top", 238);
			$("#bb2").css("top", 200);
			$("#bb3").css("top", 266);
		}else{
			$("#container").css("width",1024);
			$("#bb1").css("top", 237);
			$("#bb2").css("top", 181);
			$("#bb3").css("top", 265);
		}

		chk=true;
	}	
	if((screen.width == 800) && (screen.height == 600)){
		//alert("800x600");
		$("#items").css("height",560);
		$("#core1").css("height",560);
		$("#core2").css("height",560);
		$("#core3").css("height",560);
		$("#tabwrap_video").css("height",560);
		$("#tabwrap_clienti").css("height",560);
		$("#mediabox").css("height",560);

		$("#bb1").css("top", 325);
		$("#bb2").css("top", 287);
		$("#bb3").css("top", 370);
		//alert($("#floating").innerWidth());
		if(Vscroll){
		
			$("#bb1").css("top", 326);
			$("#bb2").css("top", 288);
			$("#bb3").css("top", 372);
			if(alertSize() == 577){
				$("#container").css("width",783);
				$("#bb3").css("top", 371);
			}else{
				$("#container").css("width",779);
			}
			
		}else{
			$("#container").css("width",800);
			$("#bb1").css("top", 325);
			$("#bb2").css("top", 287);
			$("#bb3").css("top", 370);
		}
		//$("#container").css("width",$("#floating").innerWidth());
		chk=true;
	}
}
if (BrowserDetect.browser=="Firefox"){	
	//$("#container").css("width",$("#floating").innerWidth());
	if((screen.width == 1366) && (screen.height == 768)){
		//alert("1366x768");
		$("#items").css("height",318);
		$("#core1").css("height",318);
		$("#core2").css("height",318);
		$("#core3").css("height",318);
		$("#tabwrap_video").css("height",318);
		$("#tabwrap_clienti").css("height",318);
		$("#mediabox").css("height",318);

		//alert($("#floating").innerWidth());
		//alert(Vscroll());
		if(Vscroll()){
			$("#container").css("width",1349);
			$("#bb1").css("top", 122);
			$("#bb2").css("top", 95);
			$("#bb3").css("top", 130);
		}else{
			$("#container").css("width",1366);
			$("#bb1").css("top", 122);
			$("#bb2").css("top", 94);
			$("#bb3").css("top", 129);
		}
		chk=true;
	}
	if((screen.width == 1280) && (screen.height == 768)){
		//alert("1280x768");
		$("#items").css("height",340);
		$("#core1").css("height",340);
		$("#core2").css("height",340);
		$("#core3").css("height",340);
		$("#tabwrap_video").css("height",340);
		$("#tabwrap_clienti").css("height",340);
		$("#mediabox").css("height",340);

		//alert($("#floating").innerWidth());
		//alert(Vscroll());
		if(Vscroll()){
			$("#container").css("width",1263);
			$("#bb1").css("top", 130);
			$("#bb2").css("top", 122);
			$("#bb3").css("top", 158);
		}else{
			$("#container").css("width",1280);
			$("#bb1").css("top", 129);
			$("#bb2").css("top", 121);
			$("#bb3").css("top", 157);
		}
		chk=true;
	}
	if((screen.width == 1280) && (screen.height == 720)){
		//alert("1280x720");
		$("#items").css("height",340);
		$("#core1").css("height",340);
		$("#core2").css("height",340);
		$("#core3").css("height",340);
		$("#tabwrap_video").css("height",340);
		$("#tabwrap_clienti").css("height",340);
		$("#mediabox").css("height",340);

		//alert($("#floating").innerWidth());
		//alert(Vscroll());
		if(Vscroll()){
			$("#container").css("width",1263);
			$("#bb1").css("top", 130);
			$("#bb2").css("top", 122);
			$("#bb3").css("top", 158);		
		}else{
			$("#container").css("width",1280);
			$("#bb1").css("top", 129);
			$("#bb2").css("top", 121);
			$("#bb3").css("top", 157);		
		}
		chk=true;
	}
	if((screen.width == 1024) && (screen.height == 768)){
		//alert("1024x768");
		$("#items").css("height",450);
		$("#core1").css("height",450);
		$("#core2").css("height",450);
		$("#core3").css("height",450);
		$("#tabwrap_video").css("height",450);
		$("#tabwrap_clienti").css("height",450);
		$("#mediabox").css("height",450);

		$("#bb1").css("top", 238);
		$("#bb2").css("top", 199);
		$("#bb3").css("top", 265);
		if(Vscroll()){
			$("#container").css("width",1007);
			$("#bb1").css("top", 238);
			$("#bb2").css("top", 199);
			$("#bb3").css("top", 265);
		}else{
			$("#container").css("width",1024);
			$("#bb1").css("top", 238);
			$("#bb2").css("top", 198);
			$("#bb3").css("top", 264);
		}

		chk=true;
	}
	if((screen.width == 1024) && (screen.height == 600)){
		//alert("1024x600");
		$("#items").css("height",450);
		$("#core1").css("height",450);
		$("#core2").css("height",450);
		$("#core3").css("height",450);
		$("#tabwrap_video").css("height",450);
		$("#tabwrap_clienti").css("height",450);
		$("#mediabox").css("height",450);

		//alert($("#floating").innerWidth());
		//alert(Vscroll());
		if(Vscroll()){
			$("#container").css("width",1007);
			$("#bb1").css("top", 238);
			$("#bb2").css("top", 199);
			$("#bb3").css("top", 265);
		}else{
			$("#container").css("width",1024);
			$("#bb1").css("top", 238);
			$("#bb2").css("top", 198);
			$("#bb3").css("top", 264);
		}
		chk=true;
	}
	if((screen.width == 800) && (screen.height == 600)){
		//alert("800x600");
		$("#items").css("height",560);
		$("#core1").css("height",560);
		$("#core2").css("height",560);
		$("#core3").css("height",560);
		$("#tabwrap_video").css("height",560);
		$("#tabwrap_clienti").css("height",560);
		$("#mediabox").css("height",560);

		$("#bb1").css("top", 326);
		$("#bb2").css("top", 288);
		$("#bb3").css("top", 371);
		//$("#container").css("width",$("#floating").innerWidth());
		//alert($("#floating").innerWidth());
		if(Vscroll){
			$("#container").css("width",783);
			//$(".box").css("width", 169);
		}else{
			$("#container").css("width",800);
		}

		chk=true;
	}
}
if(navigator.userAgent.toLowerCase().indexOf('chrome') > -1){
	//$("#container").css("width",$("#floating").innerWidth());
	if((screen.width == 1366) && (screen.height == 768)){
		//alert("1366x768");
		$("#items").css("height",310);
		$("#core1").css("height",310);
		$("#core2").css("height",310);
		$("#core3").css("height",310);
		$("#tabwrap_video").css("height",310);
		$("#tabwrap_clienti").css("height",310);
		$("#mediabox").css("height",310);

		$("#msg").css("width", 245);
		//alert($("#floating").innerWidth());
		//alert(Vscroll());
		if(Vscroll()){
			$("#container").css("width",1345);
			$("#bb1").css("top", 117);
			$("#bb2").css("top", 90);
			$("#bb3").css("top", 124);
		}else{
			//alert(alertSize());
			if(alertSize()==763){
				$("#container").css("width",1356);
			}else{
				$("#container").css("width",1366);
			}
			$("#bb1").css("top", 117);
			$("#bb2").css("top", 90);
			$("#bb3").css("top", 124);
		}
	chk=true;
	}
	if((screen.width == 1280) && (screen.height == 768)){
		//alert("1280x768");
		$("#items").css("height",340);
		$("#core1").css("height",340);
		$("#core2").css("height",340);
		$("#core3").css("height",340);
		$("#tabwrap_video").css("height",340);
		$("#tabwrap_clienti").css("height",340);
		$("#mediabox").css("height",340);

		$("#bb1").css("top", 133);
		$("#bb2").css("top", 126);
		$("#bb3").css("top", 160);
		//alert($("#floating").innerWidth());
		//alert(Vscroll());
		//alert(alertSize());
		if(Vscroll()){
			$("#container").css("width",1263);
			$("#bb1").css("top", 133);
			$("#bb2").css("top", 126);
			$("#bb3").css("top", 160);
		}else{
			if(alertSize()==763){
				$("#container").css("width",1270);
				}else{
				$("#container").css("width",1280);
				}
			$("#bb1").css("top", 133);
			$("#bb2").css("top", 126);
			$("#bb3").css("top", 160);
		}
		chk=true;
	}
	if((screen.width == 1280) && (screen.height == 720)){
		//alert("1280x720");
		$("#items").css("height",340);
		$("#core1").css("height",340);
		$("#core2").css("height",340);
		$("#core3").css("height",340);
		$("#tabwrap_video").css("height",340);
		$("#tabwrap_clienti").css("height",340);
		$("#mediabox").css("height",340);

		//alert($("#floating").innerWidth());
		//alert(Vscroll());
		if(Vscroll()){
			$("#container").css("width",1263);
			$("#bb1").css("top", 134);
			$("#bb2").css("top", 127);
			$("#bb3").css("top", 161);
		}else{
			$("#container").css("width",1270);
			$("#bb1").css("top", 134);
			$("#bb2").css("top", 127);
			$("#bb3").css("top", 161);
		}
		chk=true;
	}
	if((screen.width == 1024) && (screen.height == 768)){
		//alert("1024x768");
		$("#items").css("height",445);
		$("#core1").css("height",445);
		$("#core2").css("height",445);
		$("#core3").css("height",445);
		$("#tabwrap_video").css("height",445);
		$("#tabwrap_clienti").css("height",445);
		$("#mediabox").css("height",445);

		//alert($("#floating").innerWidth());
		//alert(Vscroll());
		if(Vscroll()){
			$("#container").css("width",1007);
			$("#bb1").css("top", 238);
			$("#bb2").css("top", 200);
			$("#bb3").css("top", 264);
			$("div.blackbox").css("left", -1);
		}else{
			$("#container").css("width",1014);
			$("#bb1").css("top", 237);
			$("#bb2").css("top", 200);
			$("#bb3").css("top", 264);
			$("div.blackbox").css("left", -1);
		}
		chk=true;
	}
	if((screen.width == 1024) && (screen.height == 600)){
		//alert("1024x600");
		$("#items").css("height",445);
		$("#core1").css("height",445);
		$("#core2").css("height",445);
		$("#core3").css("height",445);
		$("#tabwrap_video").css("height",445);
		$("#tabwrap_clienti").css("height",445);
		$("#mediabox").css("height",445);

		if(Vscroll()){
			if(alertSize()==595){
				$("#container").css("width",997);
				$("#bb1").css("top", 238);
				$("#bb2").css("top", 184);
				$("#bb3").css("top", 265);

			}else{
				$("#container").css("width",1007);
				$("#bb1").css("top", 238);
				$("#bb2").css("top", 200);
				$("#bb3").css("top", 264);
			}
			$("div.blackbox").css("left", -1);
		}else{
			$("#container").css("width",997);
			$("#bb1").css("top", 238);
			$("#bb2").css("top", 184);
			$("#bb3").css("top", 265);
			$("div.blackbox").css("left", -1);
		}
		chk=true;
	}
	if((screen.width == 800) && (screen.height == 600)){
		//alert("800x600");
		$("#items").css("height",560);
		$("#core1").css("height",560);
		$("#core2").css("height",560);
		$("#core3").css("height",560);
		$("#tabwrap_video").css("height",560);
		$("#tabwrap_clienti").css("height",560);
		$("#mediabox").css("height",560);

		if(Vscroll()){
			if(alertSize()==595){
				$("#container").css("width",773);
				$("#bb1").css("top", 333);
				$("#bb2").css("top", 295);
				$("#bb3").css("top", 376);
			}else{
				$("#container").css("width",783);
				$("#bb1").css("top", 332);
				$("#bb2").css("top", 295);
				$("#bb3").css("top", 376);
			}
			$("div.blackbox").css("left", -1);
		}else{
			$("#container").css("width",773);
			$("#bb1").css("top", 332);
			$("#bb2").css("top", 295);
			$("#bb3").css("top", 376);
			$("div.blackbox").css("left", -1);
		}
		chk=true;
	}
}

if (BrowserDetect.browser=="Opera"){

	if((screen.width == 1366) && (screen.height == 768)){
		$("#items").css("height",320);
		$("#core1").css("height",320);
		$("#core2").css("height",320);
		$("#core3").css("height",320);
		$("#tabwrap_video").css("height",320);
		$("#tabwrap_clienti").css("height",320);
		$("#mediabox").css("height",320);

		$("#bb1").css("top", 122);
		$("#bb2").css("top", 94);
		$("#bb3").css("top", 130);
		$("#msg").css("width", 245);
		$("#container").css("width",1366);
		$("div.column").css("width",1366);
		chk=true;
	}
	if((screen.width == 1280) && (screen.height == 768)){
		//alert("1280x768");
		$("#items").css("height",343);
		$("#core1").css("height",343);
		$("#core2").css("height",343);
		$("#core3").css("height",343);
		$("#tabwrap_video").css("height",343);
		$("#tabwrap_clienti").css("height",343);
		$("#mediabox").css("height",343);

		$("#bb1").css("top", 131);
		$("#bb2").css("top", 124);
		$("#bb3").css("top", 160);
		$("#container").css("width",1280);
		$("div.column").css("width",1280);
		chk=true;
	}
	if((screen.width == 1280) && (screen.height == 720)){
		//alert("1280x720");
		//alert($("div.column").innerHeight());
		$("#items").css("height",343);
		$("#core1").css("height",343);
		$("#core2").css("height",343);
		$("#core3").css("height",343);
		$("#tabwrap_video").css("height",343);
		$("#tabwrap_clienti").css("height",343);
		$("#mediabox").css("height",343);

		$("#bb1").css("top", 131);
		$("#bb2").css("top", 124);
		$("#bb3").css("top", 160);
		$("div.column").css("width", 1263);
		$("#container").css("width",1263);
		chk=true;
	}
	if((screen.width == 1024) && (screen.height == 768)){
		//alert("1024x768");
		$("#items").css("height",450);
		$("#core1").css("height",450);
		$("#core2").css("height",450);
		$("#core3").css("height",450);
		$("#tabwrap_video").css("height",450);
		$("#tabwrap_clienti").css("height",450);
		$("#mediabox").css("height",450);

		$("#bb1").css("top", 236);
		$("#bb2").css("top", 197);
		$("#bb3").css("top", 264);
		$("div.column").css("width", 1007);
		$("#container").css("width",1007);
		chk=true;
	}
	if((screen.width == 1024) && (screen.height == 600)){
		//alert("1024x600");
		$("#items").css("height",450);
		$("#core1").css("height",450);
		$("#core2").css("height",450);
		$("#core3").css("height",450);
		$("#tabwrap_video").css("height",450);
		$("#tabwrap_clienti").css("height",450);
		$("#mediabox").css("height",450);

		$("#bb1").css("top", 238);
		$("#bb2").css("top", 199);
		$("#bb3").css("top", 265);
		$("div.column").css("width", 1007);
		$("#container").css("width",1007);
		chk=true;
	}
	if((screen.width == 800) && (screen.height == 600)){
		//alert("800x600");
		$("#items").css("height",545);
		$("#core1").css("height",545);
		$("#core2").css("height",545);
		$("#core3").css("height",545);
		$("#tabwrap_video").css("height",545);
		$("#tabwrap_clienti").css("height",545);
		$("#mediabox").css("height",545);

		$("#bb1").css("top", 308);
		$("#bb2").css("top", 270);
		$("#bb3").css("top", 355);
		$("div.column").css("width", 783);
		$("#container").css("width",783);
		chk=true;
	}
}

if(!chk){
		//alert("1024x768 - browser non testato");
		$("#items").css("height",450);
		$("#core1").css("height",450);
		$("#core2").css("height",450);
		$("#core3").css("height",450);
		$("#tabwrap_video").css("height",450);
		$("#tabwrap_clienti").css("height",450);
		$("#mediabox").css("height",450);

		$("div.blackbox").css("margin-left", -1);
		if(Vscroll()){
			$("#container").css("width",1007);
			$("#container").css("border-width",5);
			$("#container").css("border-color", "#6e6e6e");
			$("#container").css("border-style", "solid");
			$("#bb1").css("top", 243);
			$("#bb2").css("top", 205);
			$("#bb3").css("top", 269);
		}else{
			$("#container").css("width",1024);
			$("#container").css("border-width",5);
			$("#container").css("border-color", "#6e6e6e");
			$("#container").css("border-style", "solid");
			$("#bb1").css("top", 243);
			$("#bb2").css("top", 205);
			$("#bb3").css("top", 269);
		}
		//$("#container").css("left", (screen.width/2));
		$("#container").css("margin-left", "auto");
		$("#container").css("margin-right", "auto");
}
/*$("#container").css("width",screen.width);
	$("#overwrap").css("width",((screen.width/4)*3)-2);
	$("#overwrap").css("left",(screen.width/4));
*/
//alertSize(innercontent);
$("#wrapper").scrollable({size: 1}).navigator({
			// select #flowtabs to be used as navigator
			navi: "#nav",
			// select A tags inside the navigator to work as items (not direct children)
			naviItem: 'a',
			// assign "current" class name for the active A tag inside navigator
			activeClass: 'current'
		});

$("#wrapperimg").scrollable({size: 1}).navigator({

			// select #flowtabs to be used as navigator
			navi: "#navimg",

			// select A tags inside the navigator to work as items (not direct children)
			naviItem: 'a',

			// assign "current" class name for the active A tag inside navigator
			activeClass: 'current'

});
});

