
function adapteImage(objetImage)
{try
{var photo=window.event?window.event.srcElement:objetImage;if(photo.yetAdapted==true)
{return;}
photo.yetAdapted=true;var photoOrigine=new Image();photoOrigine.src=photo.src;var photoHeight=null;var photoWidth=null;if(photo.currentStyle)
{if(null==photo.currentStyle.height||null==photo.currentStyle.width)
{return;}
photoHeight=parseInt(photo.currentStyle.height);photoWidth=parseInt(photo.currentStyle.width);}
else
{if(null==photo.height||null==photo.width)
{return;}
photoHeight=photo.height;photoWidth=photo.width;}
if(null==photoOrigine.width||null==photoOrigine.height||0==photoOrigine.width||0==photoOrigine.height||0==photoWidth||0==photoHeight)
{return;}
var coeff=Math.min((photoWidth/photoOrigine.width),(photoHeight/photoOrigine.height));var newPhotoWidth=Math.round(coeff*photoOrigine.width);var newPhotoHeight=Math.round(coeff*photoOrigine.height);var paddingWidth=(photoWidth-newPhotoWidth)/2;var paddingHeight=(photoHeight-newPhotoHeight)/2;photo.style.width=newPhotoWidth+"px";photo.style.height=newPhotoHeight+"px";photo.style.paddingLeft=(Math.floor(paddingWidth))+"px";photo.style.paddingRight=(Math.ceil(paddingWidth))+"px";photo.style.paddingTop=(Math.floor(paddingHeight))+"px";photo.style.paddingBottom=(Math.ceil(paddingHeight))+"px";}
catch(e)
{}}
function adapteImageWParent(objetImage){var _maxSizeImage=jQuery(objetImage).parent().width();var img=new Image();img.src=jQuery(objetImage).attr('src');if(img.height>_maxSizeImage){img.width=Math.round(_maxSizeImage/img.height*img.width);img.height=_maxSizeImage;}
if(img.width>_maxSizeImage){img.height=Math.round(_maxSizeImage/img.width*img.height);img.width=_maxSizeImage;}
jQuery(objetImage).attr('height',img.height+'px').attr('width',img.width+'px');jQuery(objetImage).height(img.height);jQuery(objetImage).width(img.width);}
