/* popin
------------------------------------------------------------------------------*/
var displayPopin = true;

function masquer_popin()
{
	displayPopin = false;
	//window.clearInterval(boucle);
	$("select").show();
	$("#popin,#ecran").hide();
	$("#attente").css('visibility','hidden');
/*
	if(document.all) {document.body.style.overflow = 'auto';}
	else {document.body.style.overflow = 'visible';}

	document.getElementsByTagName('html')[0].style.height = "auto";
	document.getElementsByTagName('body')[0].style.height = "auto";
	document.getElementsByTagName('html')[0].style.overflow = "auto";
	document.getElementsByTagName('body')[0].style.overflow = "auto";
	if(typeof document.body.style.maxHeight != "undefined") {
		document.getElementsByTagName('html')[0].style.overflow = "scroll";
		document.getElementsByTagName('body')[0].style.overflow = "visible";
	}
*/	
	if( jQuery.browser.msie ) {
		$("html").css('overflow','auto');
		$("html").css('height','auto');
	}
	else {
		$("html").css('overflow','auto');
	}
	//$("#ecran").css('height','auto');
	
	var POPIN_COOKIE_NAME = 'warmj_recherche';
	var POPIN_COOKIE_OPTIONS = { path: '/', expires: 10 };
	
	$.cookie(POPIN_COOKIE_NAME, '1', POPIN_COOKIE_OPTIONS);
	
}
function afficher_popin()
{
	$("select").hide();
	/*
	$("#popin").load(page,function(){
	});
	*/
	$("#popin .bhaut a").click(function(){
		masquer_popin();
		return false;
	});	
	$("#popin .aLater a").click(function(){
		masquer_popin();
		return false;
	});	
	$("#popin .aClose a").click(function(){
		masquer_popin();
		return false;
	});	
	$("#popin .aWindow a").click(function(){
		masquer_popin();
	});
	$("#ecran,#popin").show();
	window.setInterval(initPopin, 100);
}
var popupBarometre = null;
function openBarometre(url,largeur,hauteur)
{
	var dessus=(screen.height/2)-(hauteur/2);
	var gauche=(screen.width/2)-(largeur/2);
	var features='';
	features+='  height='+hauteur+''
	features+=', width='+largeur+''
	features+=', top='+dessus+''
	features+=', left='+gauche+''
	features+=', scrollbars=yes';
	if(popupBarometre) popupBarometre.close();
	popupBarometre  = window.open(url,'barometre',features);
	if(popupBarometre) masquer_popin();
}
/************************** Traitement de la PopIn */
function initPopin()
{
	if($("#popin").length && $("#ecran").length )
	{
		if($("#popin").css('display') == 'block')
			$("#ecran").show();
		
		if($("#ecran").css('display') == 'block')
			$("#popin").show();
		
		if($("#popin").css('display') == 'block')
		{
			// Traitement de la largeur
			docWidth = document.all?document.body.offsetWidth:window.innerWidth;
			$("#popin").css('left',returnResize(docWidth,700,45,2000));
			// Traitement de la hauteur
			docHeight = document.all?document.body.offsetHeight:window.innerHeight;
			$("#popin").css('top',returnResize(docHeight,400,100,100));
			// Efface le scroll
		//	document.getElementsByTagName('html')[0].style.overflow = "hidden";
		//	document.getElementsByTagName('body')[0].style.overflow = "hidden";
			//changeAttribut(document.body,'style','overflow:hidden;');
		}
	}
}
// boucle2 = window.setInterval(initPopin, 100);
document.onmouseover = initPopin

function returnResize(docl,l,min,max)
{
	if(docl < min) docl = min;
	if(docl > max) docl = max;
	returnL = (docl - l)/2;
	if(returnL < min) returnL = min;
	return returnL + 'px';
}
/*
------------------------------------------------------------------------------*/