function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
};
var navigateur = {
	ie : document.all && navigator.appVersion.match("MSIE 7.0") ? true : false ,
	ie6 : document.all && !navigator.appVersion.match("MSIE 7.0") && window.ActiveXObject ? true : false ,
	moz : !document.all && document.getElementById ? true : false,
	firefox : !document.all && document.getElementById && navigator.userAgent.toLowerCase().match("gecko") ? true : false,
	mozmac : document.getElementById && navigator.userAgent.toLowerCase().indexOf('mac') + 1 && !navigator.userAgent.toLowerCase().indexOf('safari') + 1 ? true : false
};
var getPosition = {
	findPosX : function(obj) {
		    var curleft = 0;
		    if(obj.offsetParent)
		      	  while(1) {
		          	curleft += obj.offsetLeft;
		        	  if(!obj.offsetParent)
		            		break;
		          	obj = obj.offsetParent;
		        	}
		    else if(obj.x)
		       		 curleft += obj.x;
		    return curleft;
	},
	findPosY: function(obj){
		var curtop = 0;
		if(obj.offsetParent){
			while(1){
				curtop += obj.offsetTop;
				if(!obj.offsetParent) break;	
				obj = obj.offsetParent;
			}
		}else if(obj.y) curtop += obj.y;	
		return curtop;
	}
};
function pop(chemin,nom,param){
	/* popupImage = window.open('',nom,param)
	html = '<HTML><HEAD><BODY LEFTMARGIN=0 MARGINWIDTH=0 TOPMARGIN=0 MARGINHEIGHT=0><IMG SRC="old/'+chemin+'" BORDER=0></BODY></HEAD></HTML>';
	popupImage.document.open();
	popupImage.document.write(html);
	popupImage.document.close(); */
	var paramArray = param.replace(/[^0-9,]/g,'').split(',');
	jsPopupImage.init('old/'+chemin,paramArray);
};

	var jsPopupImage = {
		init : function(file,paramArray,elem){
			this.paramArray = paramArray;
			this.file = file;
			this.elem = elem ? elem : null ;
			this.setSize();
			this.createContainer();
		
		},
		setSize : function(){
			var maxH = document.documentElement.clientHeight;
			this.w = this.paramArray[0];
			this.h = this.paramArray[1];
			if(this.paramArray[1]>maxH){
				var ratio = this.h/maxH;
				this.w = (this.w/ratio)-20;
				this.h = maxH-20;
			}
		},
		createContainer : function(){
			var 	_this = this,	
				clHeight = document.documentElement.clientHeight,
				scrlTop = document.documentElement.scrollTop || document.body.scrollTop,
				posTop = (clHeight/2)-(this.h/2)+scrlTop;
			if(this.outerContainer) document.body.removeChild(this.outerContainer);
			this.bg = document.createElement('div');
			this.outerContainer = document.createElement('div');
			this.innerContainer = document.createElement('div');
			this.img = document.createElement('img');
			this.legendContainer = document.createElement('div');
			this.legend = document.createElement('div');
			this.img.src = this.file;
			//this.img.title = 'click to close';
			
			this.innerContainer.appendChild(this.img);
			this.outerContainer.appendChild(this.innerContainer);
			this.outerContainer.appendChild(this.legendContainer);
			this.legendContainer.innerHTML = 'cliquer sur l\'image pour fermer';
			this.outerContainer.onclick = function(){ _this.removeContainer() };
			if(!document.all){
				this.bg.setAttribute(
					'style',
					'position:absolute;'+
					'top:0;'+
					'width:100%;'+
					'height:'+(document.body.offsetHeight+50)+'px;'+
					'opacity:.7;'+
					'background-color:#000;'+
					'z-index:190;');
				this.img.setAttribute(
					'style',
					'cursor:pointer;'+
					'width:'+this.w+'px;'+
					'height:'+this.h+'px;');
				this.outerContainer.setAttribute(
					'style',
					'position:absolute;'+
					'border: solid 4px #fff;'+
					'top:'+posTop+'px;'+
					'left:50%;'+
					'margin-left:-'+this.w/2+'px;'+
					'z-index:200;+');
				this.legendContainer.setAttribute(
					'style',
					'position:absolute;'+
					'bottom:0;'+
					'padding: 1px 5px;'+
					'background-color:#000;'+
					'color:#fff;'+
					'font:bold 10px arial;'+
					'opacity:.7;');
			}else{
				this.bg.style.setAttribute(
					'cssText',
					'position:absolute;'+
					'top:0;'+
					'width:100%;'+
					'height:'+(document.body.offsetHeight+50)+'px;'+
					'filter: alpha(opacity = 70);'+
					'background-color:#000;'+
					'z-index:190;');
				this.img.style.setAttribute(
					'cssText',
					'cursor:pointer;'+
					'width:'+this.w+'px;'+
					'height:'+this.h+'px;');
				this.outerContainer.style.setAttribute(
					'cssText',
					'position:absolute;'+
					'border: solid 4px #fff;'+
					'top:'+posTop+'px;'+
					'left:50%;'+
					'margin-left:-'+this.w/2+'px;'+
					'z-index:200;+');
				this.legendContainer.style.setAttribute(
					'cssText',
					'position:absolute;'+
					'bottom:0;'+
					'padding: 1px 5px;'+
					'background-color:#000;'+
					'color:#fff;'+
					'font:bold 10px arial;'+
					'filter: alpha(opacity = 70);');
			}
			document.body.appendChild(this.bg);
			document.body.appendChild(this.outerContainer);
		},
		removeContainer : function(){
			document.body.removeChild(this.outerContainer);
			document.body.removeChild(this.bg);
			this.outerContainer = null;
		}
	};

function print(bloc){
	var contenu = document.getElementById(bloc).innerHTML;
	popimprime = window.open('','','resizable=yes, location=no, width=500, height=500, menubar=no, status=no, scrollbars=yes');
	html = '<html><head><link rel="stylesheet" type="text/css" href="_css_/print.css"/></head><body><div id="printZone">'+contenu+'</div></body></html>';
	code = "<script type=\"text/javascript\">setTimeout(\"window.print()\",200)</script>";
	popimprime.document.open();
	popimprime.document.write(html+code);
	popimprime.document.close();
};

function increaseText(bloc){
	var bloc = document.getElementById(bloc);
	var perc = parseInt(bloc.style.fontSize.substr(0,bloc.style.fontSize.length-1));
	bloc.style.fontSize = perc+10+"%";
};

function decreaseText(bloc){
	var bloc = document.getElementById(bloc);
	var perc = parseInt(bloc.style.fontSize.substr(0,bloc.style.fontSize.length-1));
	bloc.style.fontSize = perc-10+"%";
};
