function cliper(j,id) {
	var w = parseInt(S(j).width);
	var h = parseInt(S(j).height);
	var l = X(j);
	var t = Y(j);
	clipleft="0px";
	cliptop="0px";
	clipwidth=parseInt(document.getElementById(id).width);
	clipheight=parseInt(document.getElementById(id).height);
	var cp=0;
	if (
		( X(id) + clipwidth > 10 ) &&
		( X(id) < w - 10  ) &&
		( Y(id) + clipheight > 10 ) &&
		( Y(id) < h - 10  )
	) {
		if ( X(id) < 0 ) {clipleft=-X(id) +"px";cp=1;}
		if ( Y(id) < 0 ) {cliptop=-Y(id) +"px";cp=1;}
		if ( ( X(id) + clipwidth ) > w ){clipwidth=(w-X(id))+"px";cp=1;}
		if ( ( Y(id) + clipheight ) > h ) {clipheight=(h-Y(id))+"px";cp=1;}
		if (cp==1) {
			document.getElementById(id).style.clip="rect("+cliptop+" "+clipwidth+" "+clipheight+" "+clipleft+")";
		}
	}

}

function N(i) {return parseInt(i);}
function I() {var a=I.arguments;if (L(a)==2) {document.getElementById(a[0]).innerHTML=a[1];} else {var u=document.getElementById(a[0]).innerHTML;return (String(N(u))==u)?N(u):u;}}
function L(i) {return i.length;}
function S(id) {return document.getElementById(id).style;}
function X(id) {return parseInt(document.getElementById(id).style.left);}
function Y(id) {return parseInt(document.getElementById(id).style.top);}
function Z(id) {return document.getElementById(id).style.zIndex;}

function displayPic() {
	var img="";
	for (var i=0;i<arguments.length;i++) {
		var u = arguments[i].split("=");
		eval("var "+u[0]+"='"+u[1]+"'");
	}
	if (typeof(width)=="undefined") {width=100;}
	if (typeof(height)=="undefined") {height=100;}
	if (typeof(idom)=="undefined") {idom="";} else {idom="id='"+idom+"'";}
	img+="<div "+idom+" style='float:left;width:"+width+"px;height:"+height+"px;'>";
		img+="<div style='position:relative;top:0px;left:0px;'>";
		img+="<div style='position:absolute;top:0px;left:0px;'><img src='/img/pet_in_store/"+parseInt(id)+".jpg' width='"+width+"' height='"+height+"' border='0'></div>";
		if (typeof(agilite)!="undefined") {
			agilite=eval(agilite);
			beaute=eval(beaute);
			courage=eval(courage);
			physique=eval(physique);
			var pic="";var alt="";
			var statmin=Math.min(agilite,beaute);
			statmin=Math.min(statmin,courage);
			statmin=Math.min(statmin,physique);
			if ((statmin>=100)&&(statmin<1000)) {
				pic="bestargent.png";
				alt="Best Argent";
			} else if ((statmin>=1000)&&(statmin<10000)) {
				pic="bestor.png";
				alt="Best Or";
			} else if ((statmin>=10000)&&(statmin<100000)) {
				pic="kingargent.png";
				alt="King Argent";
			} else if ((statmin>=100000)&&(statmin<1000000)) {
				pic="kingor.png";
				alt="King Or";
			} else if ((statmin>=1000000)&&(statmin<10000000)) {
				pic="masterargent.png";
				alt="Master Argent";
			} else if (statmin>=10000000) {
				pic="masteror.png";
				alt="Master Or";
			}  
			if (pic!="") {
				img+="<div style='position:absolute;top:0px;left:0px;'><img "+idom+" src='/_img/pictos/"+pic+"' width='"+width+"' height='"+height+"' border='0' title='"+alt+"'></div>";
			}	
			if (typeof(idp)!="undefined") {
				var x=Math.ceil(width/2-23);
				var y=height-18;
				img+="<div style='position:absolute;top:"+y+"px;left:"+x+"px;'><a href='#' onClick='return ecrinOuvre("+idp+");' style='font-size:12px;'><img src='/_img/pictos/ecrin.png' border='0'></a></div>";
			}
		}
		img+="</div>";
	img+="</div>";
	if ((typeof(write)=="undefined") || (write == "")) {document.write(img);return true;}
	else {return img;}
}

function ecrinOuvre(id) {
	 document.getElementById("loadecrinurl").src="/_html/ecrinpop.php?pet="+id;
	 document.getElementById("loadecrinurl").style.display='block';
	 document.getElementById("loadecrin").style.display='block';
	 
	// window.open("/_html/ecrinpop.php?pet="+id,"ecrin"+id,"menubar=no,status=no,scrollbars=no,resize=no,menubar=no,resize=no,width=400,height=430");
	 return false;
}