// JavaScript Document

//jQuery('a[rel*=facebox]').facebox();
/*$(document).ready(function(e) {
	$('a[rel*=facebox]').facebox();
});*/
jQuery(document).ready(function() {
	jQuery('a[rel*=facebox]').facebox() 
})

function openwindow(url, x, y) {
   if (!x)  x = 550;
   if (!y)  y = 200;
   if (document.all || document.getElementById)
	   options = "scrollbars=no, resizable=no, width="+x+", height="+y+", left=10, top=50";
   if (document.layers)
	   options = 'scrollbars=no,resizable=yes,outerWidth='+x+',outerHeight='+y+',screenX=10,screenY=50';
   window.open(url, 'MaFenetre', options);
}


var objVideo;

function gerePerso(objid)//,booplay,nomvideo
{
	objVideo = document.getElementById(objid);
	
	/*if(booplay && nomvideo!='')
	{
		var t = setTimeout("videoFadeIn('"+nomvideo+"')",1000);
	}*/
}

function videoFadeIn(nomvideo)
{
	objVideo.playVideo(nomvideo);
	return true;
}
function videoFadeOut()
{
	objVideo.stopVideo();
	return true;
}
function videoEnd()
{
	objVideo.showReplay();
	return true;
}

function printAdvice(section, page)
{
	var pageprint = window.open('../impressionconseil/imprimer-conseil.jsp?s='+section+'&p='+page, 'conseilprint', 'width=900,height=650,scrollbars=yes,status=no,addressbar=no,noresize');
}
function printPicto(nompage)
{
	var pageprint = window.open('../imprimer-picto.jsp?n='+nompage, 'pictoprint', 'width=900,height=650,scrollbars=yes,status=no,addressbar=no,noresize');
}

function showDiv(divname)
{
	var thediv = document.getElementById(divname);
	thediv.style.display = 'inline';
	thediv.style.zIndex = '100';
	centerDiv(thediv);
}

function hideDiv(divname)
{
	var thediv = document.getElementById(divname);
	thediv.style.display = 'none';
}


function centerDiv(divobj)
{
	var result=returnSize();
	var myWidth=result[0];
	var myHeight=result[1];
	var elementWidth=divobj.offsetWidth;
	var elementHeight=divobj.offsetHeight;
	var myScrollLeft, myScrollTop;
	//alert(elementWidth+";"+elementHeight);
	
	if(navigator.appName.indexOf('Microsoft')<0){
		myScrollLeft = window.pageXOffset;
		myScrollTop = window.pageYOffset;
	}
	else
	{
		myScrollLeft = document.documentElement.scrollLeft;
		myScrollTop = document.documentElement.scrollTop;
	}
	//alert(myScrollLeft+";"+myScrollTop);
	var posX=myScrollLeft+myWidth-myWidth/2-elementWidth/2
	var posY=myScrollTop+myHeight-myHeight/2-elementHeight/2;
	divobj.style.left=(posX+50)+"px";
	divobj.style.top=(posY+50)+"px";

}
function returnSize() {
	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;
	}
	var result = new Array(myWidth,myHeight);
	return result;
}

function baxterExit(externalLink)
{
	openwindow('../sortie-baxter.jsp?link='+externalLink,550,100);
	return false;
}

function nothing()
{
	return false;
}

function disableRightClick() // /!\ NE FONCTIONNE PAS SOUS OPERA
{
	document.oncontextmenu = document.body.oncontextmenu = nothing;
}