/* 
	Document Javascript 
	Popup
*/
var w_height 	 = "";
var w_width   	= "";
var popin 		= "";
var popinCont 	= "";
var popinHead 	= "";
var popinBody 	= "";
var popinFoot 	= "";
var popinColor = "";
var popinTextCont = "";

function launchPopin(p_Col) { 
	
	if (document.getElementById('pop_envoyer_ami') && checkIt('firefox/1')) {
		document.getElementById("clearFx15").style.height = "120px"
	}
	
	document.body.innerHTML += ''
	 +'<div id="js_popin">'
	 	+'<img src="img/popin/spacer.gif" width="100%" height="100%" alt="" id="opac_img" />'
		+'<div id="popin_cont">'
			+'<div id="popin_head"></div>'
			+'<div id="popin_inner"></div>'
			+'<div id="popin_body"></div>'
			+'<div id="popin_foot"></div>'
		+'</div>'
	+'</div>';

	w_height = document.body.clientHeight+50+"px";
	w_width	= document.body.clientWidth+"px";
	var w_half_height = document.body.clientHeight/8+"px";
	
	popin = document.getElementById("js_popin");
	popinCont = document.getElementById("popin_cont");
	popinHead = document.getElementById("popin_head");
	popinBody = document.getElementById("popin_body");
	popinFoot = document.getElementById("popin_foot");
	popinInner = document.getElementById("popin_inner");
	popinText = document.getElementById("popin_text");
	
	popinInner.className = p_Col;
	popin.style.height = w_height;
	popin.style.width = w_width;
	
	if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("MSIE 6.0") != -1) {
		popin.style.background 	= 'transparent';
		popin.style.opacity = "0.4";
		popin.style.filter 		= "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/popin/bg_px.png', sizingMethod='scale')";
		popinHead.style.filter 	= "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/popin/bg_"+p_Col+"_05.png', sizingMethod='crop')";
		popinBody.style.filter 	= "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/popin/bg_"+p_Col+"_07.png', sizingMethod='scale')";
		popinFoot.style.filter 	= "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/popin/bg_"+p_Col+"_09.png', sizingMethod='crop')";
		var selectEl = document.getElementsByTagName("select");
		var selectLength = selectEl.length
		for (var i=0; i < selectLength; i++) {
			if ((selectEl[i].id != "ep_valeur") || (selectEl[i].id != "pop_thematique")) {
				if (selectEl[i].id != "pop_thematique") selectEl[i].style.visibility = "hidden";
			}
		}
	}
	else {
		popinHead.style.background = 'url(img/popin/bg_'+p_Col+'_05.png) no-repeat';
		popinBody.style.background = 'url(img/popin/bg_'+p_Col+'_07.png) repeat-y';
		popinFoot.style.background = 'url(img/popin/bg_'+p_Col+'_09.png) no-repeat';
	}
	
	if (popinText.innerHTML == "") { 
		popinInner.innerHTML = popinTextCont;
		popinText.innerHTML = popinTextCont;
	}
	else { 
		popinTextCont = popinText.innerHTML;
		popinInner.innerHTML = popinTextCont;
	}
	
	popinCont.style.marginTop = w_half_height;
	popinText.style.display = "block";
	setTimeout(function() {
		popinBody.style.height = popinText.offsetHeight-132+"px";
		popinInner.style.height = popinText.offsetHeight+"px";
		popinText.style.display = "none";
		setTimeout(function() { popinText.innerHTML = ""; }, 1);
	}, 1);
	
}

function closePopin() {
	popin.style.display = "none"
	if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("MSIE 6.0") != -1) {
		var selectEl = document.getElementsByTagName("select");
		var selectLength = selectEl.length
		for (var i=0; i < selectLength; i++) { 
			selectEl[i].style.visibility = "visible";
		}
	}
	popinText.innerHTML = popinTextCont;
	try {
		document.body.removeChild(document.getElementById("js_popin"));
	} catch(o) { }
	finally { popin.style.display = "none" }
}


function openBar(statMsg) {
	document.getElementById("newsletter").innerHTML += '<div id="statMsg"><p>Lorem Ipsum<br /><br /><a href="javascript:;" onclick="closeBar()">Fermer</a></p></div>';
}
function closeBar() {
	removeElement("statMsg");
}
function removeElement(id)   {
   var Node = document.getElementById(id);
   Node.parentNode.removeChild(Node);
}
var detect = navigator.userAgent.toLowerCase();
function checkIt(string) {
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}
