var iMinWidth = 950; //put here the minimal width
var iMinHeight = 770; // put here the minimal height
var iMaxHeight = 1000;
var iMaxWidth = 1600;
var widthEnCours = 0;
var heightEnCours = 0;
var currentDiv = "flashcontent";

window.onresize = onResizeScreen;
window.onunload = onClose;

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

function onLoad(){
	onResizeScreen();
	setTimeout(function(){
		onResizeScreen();
	}, 100);
}

function onResizeScreen(){
	if(document.documentElement.clientHeight != undefined){
		var height = document.documentElement.clientHeight;
	}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;
	
	height = height - 50;
	
	document.getElementById(currentDiv).style.width = width+"px";
	document.getElementById(currentDiv).style.height = height+"px";
	widthEnCours = width;
	heightEnCours = height;
}

function trackFlash(tag){
	pageTracker._trackPageview(lang+"/"+tag);
}

function onClose(){
	$.post("../scripts/cleanTemp.aspx", {sessionID:sessionID}, function(data){});
}
function popUp(url, name, width, height) {
	window.open(url, name, 'scrollbars=1, resizable=1, left=200, top=200, width=' + width + ', height=' + height);
}
function changeDiv(userID){
	if(userID==0 || userID==""){
		$("#flashcontent2").html("");
		$("#flashcontent").height(heightEnCours+"px");
		$("#flashcontent2").height("0px");
		$("#flashcontent2").width("0px");
		currentDiv = "flashcontent";
	}else{
		$("#flashcontent").height("0px");
		$("#flashcontent2").height(heightEnCours+"px");
		$("#flashcontent2").width(widthEnCours+"px");
		currentDiv = "flashcontent2";
		$.post('../scripts/giveUser.aspx', {userID:userID, lang:lang}, function(data){
			var listDatas = data.split("~");
			var so = new SWFObject('../swf/indexpublication.swf', 'website', '100%', '100%', '9', '#F5F1EF');
			so.useExpressInstall('../js/swfobject/expressinstall.swf');
			so.addParam('menu', 'false');
			so.addParam("allowfullscreen", "true");
			so.addParam("allowScriptAccess", "always");
			so.addParam("quality", "high");
			so.addVariable("userID",userID);
			so.addVariable("universe",listDatas[0]);
			so.addVariable("fond",listDatas[1]);
			so.addVariable("sound",listDatas[2]);
			so.addVariable("creationdate",listDatas[5]);
			so.addVariable("lang",lang);
			so.addVariable("sessionid",sessionID);
			so.addVariable("place","local");
			so.addVariable("nickname",listDatas[4].substr(0,1).toUpperCase()+listDatas[4].substr(1, (listDatas[4].length - 1)).toLowerCase());
			if($.browser.msie)
				so.addVariable("msie","True");
			else
				so.addVariable("msie","False");
			so.addVariable("URI",listDatas[3]+".aspx");
			so.addVariable("URIFB",listDatas[6]+".aspx");
			so.write('flashcontent2');
		});
	}
}

$(document).ready(function(){
	var so = new SWFObject('../swf/index.swf', 'website', '100%', '100%', '9', '#F5F1EF');
	so.useExpressInstall('../js/swfobject/expressinstall.swf');
	so.addParam('menu', 'false');
	so.addParam("allowfullscreen", "true");
	so.addParam("allowScriptAccess", "always");
	so.addParam("quality", "high");
	if(pseudo!="") so.addVariable("pseudo",pseudo);
	so.addVariable("lang",lang);
	so.addVariable("sessionid",sessionID);
	if($.browser.msie)
		so.addVariable("msie","True");
	else
		so.addVariable("msie","False");
	so.addVariable("locate",locate);
	so.write('flashcontent');
	
	try {
		var pageTracker = _gat._getTracker("UA-9989837-1");
		//pageTracker._trackPageview();
		pageTracker._trackPageview(lang+"/index.aspx");
	} catch(err) {}
});

