// JavaScript Document
var ubibar = 41; //$('#barre_ubi').height();
var currentHeight = 0;
var iMinWidth = 950; //put here the minimal width
var iMinHeight = 700; // put here the minimal height
var iMaxHeight = 850;
var iMaxWidth = 1920;
window.onresize = onResizeScreen;

function onLoad(){
	onResizeScreen();
	setTimeout(function(){
		onResizeScreen();
	}, 100);
}

function onResizeScreen(){
	if(document.documentElement.clientHeight != undefined){
		var height = document.documentElement.clientHeight - 205;
		
	}else if(window.innerHeight != undefined){
		var height = window.innerHeight;
	}else{
		var height = document.body.clientHeight;
	}
	
	if(document.documentElement.clientWidth != undefined){
		var width = document.documentElement.clientWidth;
	}else if(window.innerWidth != undefined){
		var width = window.innerWidth;
	}else{
		var width = document.body.clientWidth;
	}
	
	resize(width, height);			
}

function resize(width, height){
	width = (width > iMaxWidth) ? iMaxWidth : width;
	height = (height > iMaxHeight) ? iMaxHeight : height;
	
	width = (width < iMinWidth) ? iMinWidth : width;
	height = (height < iMinHeight) ? iMinHeight : height;
	
	if(document.getElementById("flashcontent")) document.getElementById("flashcontent").style.width = width+"px";
	currentHeight = height;
	if($("#flashcontent").height() > 10 ){
		//document.getElementById("flashcontent").style.height = height+"px";
		$("#flashcontent").height(currentHeight);
		$('#website').height(currentHeight);
	}else{
		document.getElementById("fond_sondage").style.height = (height-100)+"px";
	}
	/*document.getElementById("fond_image").style.height = height+"px";
	document.getElementById("fond_image").style.width = width+"px";*/
}

$(window).resize(function(){
	$("#fond_sondage").height($(document).height()-ubibar);
	if($.browser.msie && $.browser.version == "6.0") {
		$("#fond_sondage").width($(window).innerWidth());
		/*$("#sondage").height($(window).innerHeight());
		$("#sondage").width($(window).innerWidth());*/
	}else{
		$("#fond_sondage").width($(window).width());
		/*$("#sondage").height($(window).height());
		$("#sondage").width($(window).width());*/
	}
})

//gestion des zoom sur les screenshots
function displayFond(){
	//trace($(document).height()+" "+$(window).innerWidth());
	
	
	/*if($.browser.msie && $.browser.version == "6.0") {
		$("#fond_sondage").height($(document).height()-ubibar);
		$("#fond_sondage").width($(window).innerWidth());
	}else{
		$("#fond_sondage").height($(document).height()-ubibar);
		$("#fond_sondage").width($(document).width());
	}*/
	//$("#fond_sondage").css("margin-top", ubibar});
	
	currentHeight = $('#website').height();
	$('#website').height(0);
	$("#flashcontent").height(0);
	
	/*$("#fond_sondage").css("top",ubibar);*/
	$("#fond_sondage").css("display","block");
	$("#fond_sondage").height(currentHeight - 100);
	$("#fond_sondage").width($('#website').width());
	//$("#fond_sondage").fadeTo(1,.8);
	/*$("#sondage").css("display","block");*/
	/*if($.browser.msie && $.browser.version == "6.0") {
		$("#sondage").height($(window).innerHeight());
		$("#sondage").width($(window).innerWidth());
	}*/
	
	$.post("pages/poll.php", {}, function(data){
		$("#sondage").html(data);
		$("#sondage").css("width",$("#sondage").width()+"px");
	});
	
	//$("#fond_sondage").click(function(){ closePool(); });
	//setTimeout(function(){ closePool(); }, 2000);
	//$("#sondage").click(function(){ closePool()});
}

//gestion des zoom sur les screenshots
function displayFondFin(){
	$.post("pages/poll.php", $("#form").serialize(), function(data){
		$("#sondage").html(data);
	});
}

//fermeture des zooms
function closePool(){
	/*$("#sondage").css("display","none");*/
	$("#fond_sondage").css("display","none");
	$("#flashcontent").height(currentHeight);
	$('#website').height(currentHeight);
}

/*var hauteurUbiBar = 0;
$(document).ready(function(){
 hauteurUbiBar = $("#barre_ubi").height();
 $("ul.ubisoft-toolbar-dropdown li").mouseover(function(){
   var tab = $.makeArray($('li',this));
   var hauteurFinale = hauteurUbiBar;
   for(i=0;i<tab.length;i++){
		hauteurFinale+=$(tab[i]).height();
   }
   if(hauteurFinale != hauteurUbiBar) hauteurFinale += 5 ;
   $("#barre_ubi").stop();
   $("#barre_ubi").animate({height:hauteurFinale+"px"},500);
 });
 $("ul.ubisoft-toolbar-dropdown").mouseout(function(){
   $("#barre_ubi").stop();
   $("#barre_ubi").animate({height:hauteurUbiBar+"px"},500);
 });

});*/