﻿	window.onload = function() {
		if(document.getElementById('alert_fullscreen')){
			document.getElementById('alert_fullscreen').style.width = document.body.scrollWidth;
			document.getElementById('alert_fullscreen').style.height = document.body.scrollHeight;
		}
	}

	function newwin(source, w, h) {
		window.open(source,'_blank','scrollbars=yes,resizable=no,width=' + w + ',height=' + h + ',status=yes,location=no,toolbar=no,menubar=yes');
	}

	function popAff(ifrmSrc, divWidth, divHeight) {
		if(ifrmSrc=='')return;
		document.getElementById('alert_iframe').src = ifrmSrc;
		if(isNaN(divWidth)) divWidth=400;
		if(isNaN(divHeight)) divHeight=300;
		if(divWidth>window.document.body.clientWidth-10) divWidth=window.document.body.clientWidth-10;
		if(divWidth>980) divWidth=980;
		if(divHeight>window.document.body.clientHeight-60) divHeight=window.document.body.clientHeight-60;
		document.getElementById('alert_div').style.height = divHeight +'px';
		document.getElementById('alert_div').style.marginTop = (divHeight/-2)-2 +'px';
		document.getElementById('alert_div').style.width = divWidth +'px';
		document.getElementById('alert_div').style.marginLeft = divWidth/-2 +'px';
		SHL('alert_fullscreen','show'); SHL('alert_div','show');
		document.getElementById('alert_div').style.top = document.body.scrollTop+(window.document.body.clientHeight/2) +'px';
		document.getElementById('alert_div').style.left = document.body.scrollLeft+(window.document.body.clientWidth/2) +'px';
	}
	function SHL(nomdiv, etat) {
	    with (document) if (getElementById && ((obj=getElementById(nomdiv))!=null)) { v=etat;
	    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
	    obj.visibility=v;
		}
	}

	function escapeHTML(str)
	{
	   var div = document.createElement('div');
	   var text = document.createTextNode(str);
	   div.appendChild(text);
	   return div.innerHTML;
	};

	function redAccord(url, msg) {
		var agree = confirm(msg);
		if (agree) window.open(url, target="_self");
	}

	function classDisplay(dispCls, dispAct) {
		allel = (document.getElementsByTagName)?document.getElementsByTagName("*"):document.all;
		for(var a = 0; a<allel.length; a++) {
			arrayClassName = allel[a].className.split(' ')
			for(var ii = 0; ii<arrayClassName.length; ii++) {
				if(arrayClassName[ii] == dispCls) elementDisplay(allel[a], dispAct);
			}
		}
	}

	function elementDisplay(dispId, dispAct) {
		if(!document.getElementById(dispId))return false;
		if (dispAct==1)
		{
		document.getElementById(dispId).style.display = '';
		}
		else if (dispAct==-1)
		{
		document.getElementById(dispId).style.display = 'none';
		}
		else
		{
		if (document.getElementById(dispId).style.display=='')
			elementDisplay(dispId, -1);
		else
			elementDisplay(dispId, 1);
		}
	}

	function emailCliquable(email) {
	  var exp=new RegExp("([a-zA-Z0-9\.\-_]+@[a-zA-Z0-9\-_]+\.[a-zA-Z0-9]{2,})","g");
	  return email.replace(exp,"<a href='mailto:$1'>$1</a>");
	}

	function Replace(all,exV,nwV) {
	   var regEx = new RegExp(exV,"g")
	   return all.replace(regEx,nwV)
	}

	function redirect(thisUrl){
		window.open(thisUrl, target="_self")
	}

	function htmlencode(ch) {
	   ch = ch.replace(/&/g,"&amp;")
	   ch = ch.replace(/\"/g,"&quot;")
	   ch = ch.replace(/\'/g,"&#039;")
	   ch = ch.replace(/</g,"&lt;")
	   ch = ch.replace(/>/g,"&gt;")
	   return ch
	}

	function htmldecode(ch) {
	   ch = ch.replace(/&quot;/g,"\"")
	   ch = ch.replace(/&#039;/g,"'")
	   ch = ch.replace(/&lt;/g,"<")
	   ch = ch.replace(/&gt;/g,">")
	   ch = ch.replace(/&amp;/g,"&")
	   return ch
	}

	function getPositionLeft(gpID,XY){
		var el = document.getElementById(gpID);
		var pL = 0;
		if (XY == 'X')
		{
			while(el){pL+=el.offsetLeft;el=el.offsetParent;}
		}
		else
		{
			while(el){pL+=el.offsetTop;el=el.offsetParent;}
		}
		return pL
	}

