/*************CONSTANTES************/
widthImg="";
heightImg="";
rel="imgbig";
/***********************************/


var strChUserAgent = navigator.userAgent;
var intSplitStart = strChUserAgent.indexOf("(",0);
var intSplitEnd = strChUserAgent.indexOf(")",0); 

var y=0;

function resetbigimg(){
	document.body.style.cursor="default";
	document.body.onclick=function(){ }
}

function disapear(){
	document.body.style.cursor="pointer";
	document.body.onclick=function(){
		document.getElementById('div-imgbig').style.display='none';
		setTimeout(resetbigimg,1);
	}
}


function verifChargementImg(img){
	if(!img.complete) setTimeout("verifChargementImg(img)",200);
	else {
		marginleft=parseInt(img.width/2);
		if(strChUserAgent.substring(intSplitStart,intSplitEnd).indexOf("MSIE 6")!=-1) margintop=parseInt(y/2)-parseInt(img.height/1.4);
		else margintop=-1*parseInt(img.height/2);
		newHeight=img.height+6;
		newWidth=img.width+6;
		document.getElementById('div-imgbig').style.width=newWidth+"px";
		document.getElementById('div-imgbig').style.height=newHeight+"px";
		document.getElementById('div-imgbig').style.marginLeft="-"+marginleft+"px";
		document.getElementById('div-imgbig').style.marginTop=margintop+"px";
		document.getElementById('div-imgbig').style.display="block";
	}
	
}


IE = document.all ? 1 : 0 ;

liens=document.getElementsByTagName('a');


for(var i=0;i<liens.length;i++){
	if(liens[i].rel==rel) {
		liens[i].onclick=function(){ 
			if(strChUserAgent.substring(intSplitStart,intSplitEnd).indexOf("MSIE 6")!=-1){
				y=window.event.clientY+document.documentElement.scrollTop;
			}
			img=new Image();
			img.src=this.href;
			
			if(!img.complete) verifChargementImg(img);
			else {
				marginleft=parseInt(img.width/2);
				if(strChUserAgent.substring(intSplitStart,intSplitEnd).indexOf("MSIE 6")!=-1) margintop=parseInt(y/2)-parseInt(img.height/2);
				else margintop=-1*parseInt(img.height/2);
				newHeight=img.height+6;
				newWidth=img.width+6;
				document.getElementById('div-imgbig').style.width=newWidth+"px";
				document.getElementById('div-imgbig').style.height=newHeight+"px";
				document.getElementById('div-imgbig').style.marginLeft="-"+marginleft+"px";
				document.getElementById('div-imgbig').style.marginTop=margintop+"px";
				document.getElementById('div-imgbig').style.display="block";
			}
			
			document.getElementById('div-imgbig').innerHTML="<img src=\""+img.src+"\" class=\"imgbig\"/>";
			setTimeout(disapear,1);
			return false;
		}
	}
}


