(function($){var isRunning=false,isIE6=$.browser.msie&&($.browser.version==4||$.browser.version==5||$.browser.version==6),divPosition=isIE6?"absolute":"fixed",loaderUrl="plugins/MantaIOFX/loading.gif",imgErrorUrl="plugins/MantaIOFX/imgError.jpg",msgBoxSize={width:300,height:80},_ERR_INVALID_PARAM=0,_ERR_BLOCKING_SCRIPT=1,_ERR_UNKNOWN_ERROR=99;$.fn.MantaIOFX=function(options){var imgInfo={height:0,width:0},imgFileNotFound=false,opts=$.extend({},$.fn.MantaIOFX.defaults,options),isImage=/([^\/\\]+)\.(png|gif|jpeg|jpg|bmp)$/i.test(options.imgUrl),isLoading=false;if(!isImage||isRunning){return this}isRunning=true;if(opts.showToolbar&&(!opts.showFilename&&!opts.showFileInfo&&(!opts.showFileLegend||(opts.showFileLegend&&opts.imgLegend!="")))){opts.showToolbar=false}if(opts.showStatusbar&&!opts.clickBgToClose&&!opts.clickImgToClose&&!opts.hitEscToClose){$.fn.MantaIOFX.reportError(_ERR_BLOCKING_SCRIPT);return this}if((opts.bgOpacity>1)||(opts.bgOpacity<0)||(opts.imgBorderWidth<0)){$.fn.MantaIOFX.reportError(_ERR_INVALID_PARAM);return this}createLayers();startLoading();if(opts.showStatusbar){buildStatusbar()}loadImage();function buildStatusbar(){var codeHtml="",idHtml=0;codeHtml='<table width="100%" cellspacing="1" cellpadding="2" class="MantaIOFX_statusbar"><tr><td class="MantaIOFX_statusbar">';if(opts.hitEscToClose){idHtml+=1}if(opts.clickImgToClose){idHtml+=2}if(opts.clickBgToClose){idHtml+=4}switch(idHtml){case 1:codeHtml+=$.fn.MantaIOFX.lang._MSG_STATUSBAR_ESCAPE;break;case 2:codeHtml+=$.fn.MantaIOFX.lang._MSG_STATUSBAR_IMAGE;break;case 3:codeHtml+=$.fn.MantaIOFX.lang._MSG_STATUSBAR_IMAGE_OR_ESCAPE;break;case 4:codeHtml+=$.fn.MantaIOFX.lang._MSG_STATUSBAR_BACKGROUND;break;case 5:codeHtml+=$.fn.MantaIOFX.lang._MSG_STATUSBAR_BACKGROUND_OR_ESCAPE;break;case 6:codeHtml+=$.fn.MantaIOFX.lang._MSG_STATUSBAR_IMAGE_OR_BACKGROUND;break;case 7:codeHtml+=$.fn.MantaIOFX.lang._MSG_STATUSBAR_IMAGE_OR_BACKGROUND_OR_ESCAPE;break}codeHtml+="</td></tr></table>";$("#MantaIOFX_StatusbarContainer").html(codeHtml);$("#MantaIOFX_StatusbarContainer").css({top:parseInt((isIE6?$(window).scrollTop():0)+$(window).height()-$("#MantaIOFX_StatusbarContainer").height())+"px"}).show()}function buildToolbar(){var codeHtml="";if(opts.showFilename){codeHtml+=$.fn.MantaIOFX.formatFilename(opts.imgUrl)}if(opts.showFileInfo){if(codeHtml!=""){codeHtml+="<br />"}codeHtml+=$.fn.MantaIOFX.formatFileInfo(imgInfo.width,imgInfo.height)}if(opts.showFileLegend&&opts.imgLegend!=""){if(codeHtml!=""){codeHtml+="<br />"}codeHtml+=$.fn.MantaIOFX.formatFileLegend(opts.imgLegend)}codeHtml='<table width="100%" cellspacing="1" cellpadding="0" class="MantaIOFX_toolbar"><tr><td class="MantaIOFX_toolbarHeader">'+opts.websiteUrl+'</td></tr><tr><td class="MantaIOFX_toolbar">'+codeHtml+"</td></tr></table>";$("#MantaIOFX_ToolbarContainer").html(codeHtml).show()}function scaleIt(freeSpace){var scale=opts.allowZoom?Math.min((freeSpace.height-2*opts.imgBorderWidth-2*opts.margin)/imgInfo.height,(freeSpace.width-2*opts.imgBorderWidth-2*opts.margin)/imgInfo.width):Math.min((freeSpace.height-2*opts.imgBorderWidth-2*opts.margin)/imgInfo.height,(freeSpace.width-2*opts.imgBorderWidth-2*opts.margin)/imgInfo.width,1);return{width:Math.floor(imgInfo.width*scale),height:Math.floor(imgInfo.height*scale)}}function getFreeSpace(){return{width:$(window).width(),height:$(window).height()-(opts.showToolbar?$("#MantaIOFX_ToolbarContainer").height():0)-(opts.showStatusbar?$("#MantaIOFX_StatusbarContainer").height():0)}}function resizeNshow(){var freeSpace=getFreeSpace();var scaledImg=scaleIt(freeSpace);$("#MantaIOFX_ImageContainer").css({left:parseInt((isIE6?$(window).scrollLeft():0)+Math.floor((freeSpace.width-scaledImg.width)/2)-opts.imgBorderWidth)+"px",top:parseInt((isIE6?$(window).scrollTop():0)+Math.floor((freeSpace.height-scaledImg.height)/2)-opts.imgBorderWidth+(opts.showToolbar?$("#MantaIOFX_ToolbarContainer").height():0))+"px"});$("#MantaIOFX_ImageContainer").html('<img id="MantaIOFX_Image" alt="" />');if(!isIE6){$("#MantaIOFX_Image").load(stopLoading)}$("#MantaIOFX_Image").css({border:opts.imgBorderWidth+"px "+opts.imgBorderStyle+" "+opts.imgBorderColor}).attr({width:scaledImg.width,height:scaledImg.height,src:(imgFileNotFound?imgErrorUrl:opts.imgUrl)}).fadeIn("slow");if(isIE6){stopLoading()}}function imageErrorModeText(){if(opts.showToolbar){buildToolbar()}var freeSpace=getFreeSpace();$("#MantaIOFX_ImageContainer").css({left:parseInt((isIE6?$(window).scrollLeft():0)+Math.floor((freeSpace.width-msgBoxSize.width)/2))+"px",top:parseInt((isIE6?$(window).scrollTop():0)+Math.floor((freeSpace.height-msgBoxSize.height)/2)+(opts.showToolbar?$("#MantaIOFX_ToolbarContainer").height():0))+"px"}).html('<table cellspacing="0" cellpadding="0" width="'+msgBoxSize.width+'" height="'+msgBoxSize.height+'"><tr><td class="MantaIOFX_imageTxtError">'+$.fn.MantaIOFX.lang._MSG_URL_NOT_FOUND+"</td></tr></table>");stopLoading()}function loadImage(){var objImg=null,step=0;objImg=new Image();objImg.onload=function(){imgInfo.width=objImg.width;imgInfo.height=objImg.height;if(opts.showToolbar){buildToolbar()}resizeNshow()};objImg.onerror=function(){opts.allowZoom=false;opts.showFileInfo=false;opts.imgBorderWidth=0;if(opts.showToolbar&&(!opts.showFilename&&!opts.showFileInfo&&(!opts.showFileLegend||(opts.showFileLegend&&opts.imgLegend!="")))){opts.showToolbar=false}switch(step){case 0:step++;imgFileNotFound=true;if(imgErrorUrl!=""){this.src=imgErrorUrl}else{imageErrorModeText()}break;case 1:imgErrorUrl="";imageErrorModeText();break}};objImg.src=opts.imgUrl}function createLayers(){$("embed, object, select").css({visibility:"hidden"});$("body").prepend('<div id="MantaIOFX_Background" />');$("#MantaIOFX_Background").hide().css({display:"block",backgroundColor:opts.bgColor,position:divPosition,display:"block",top:"0px",left:"0px",filter:"alpha(opacity="+(opts.bgOpacity*100)+")",opacity:opts.bgOpacity,zIndex:opts.zIndex,width:isIE6?Math.max($(window).width(),$(document).width())+"px":"100%",height:isIE6?Math.max($(window).height(),$(document).height())+"px":"100%"}).show();$("body").prepend('<div id="MantaIOFX_ImageContainer" />');$("#MantaIOFX_ImageContainer").css({top:isIE6?$(window).scrollTop():"0px",left:isIE6?$(window).scrollLeft():"0px",position:divPosition,display:"block",zIndex:opts.zIndex+2,display:"block"});$("body").prepend('<div id="MantaIOFX_LoaderContainer" />');$("#MantaIOFX_LoaderContainer").css({top:"0px",left:"0px",position:divPosition,display:"block",zIndex:opts.zIndex+10,display:"block"});if(opts.showToolbar){$("body").prepend('<div id="MantaIOFX_ToolbarContainer" />');$("#MantaIOFX_ToolbarContainer").css({top:isIE6?$(window).scrollTop():"0px",left:isIE6?$(window).scrollLeft():"0px",position:divPosition,display:"block",zIndex:opts.zIndex+3,width:isIE6?$(window).width()+"px":"100%",display:"block",overflow:"hidden"})}if(opts.showStatusbar){$("body").prepend('<div id="MantaIOFX_StatusbarContainer" />');$("#MantaIOFX_StatusbarContainer").css({top:isIE6?$(window).scrollTop()+$(window).height()-20:eval($(window).height()-20)+"px",left:isIE6?$(window).scrollLeft():"0px",position:divPosition,display:"block",zIndex:opts.zIndex+4,width:isIE6?$(window).width()+"px":"100%",display:"block",overflow:"hidden"})}addEvents()}function stopLoading(){$("#MantaIOFX_LoaderContainer").hide();isLoading=false}function startLoadingModeText(){$("#MantaIOFX_LoaderContainer").css({left:parseInt((isIE6?$(window).scrollLeft():0)+Math.floor(($(window).width()-msgBoxSize.width)/2))+"px",top:parseInt((isIE6?$(window).scrollTop():0)+Math.floor(($(window).height()-msgBoxSize.height)/2))+"px"}).html('<table width="'+msgBoxSize.width+'" height="'+msgBoxSize.height+'" cellspacing="0" cellpadding="0"><tr><td class="MantaIOFX_loaderTxt">'+$.fn.MantaIOFX.lang._MSG_LOADING+"</td></tr></table>")}function startLoading(){isLoading=true;if(loaderUrl==""){startLoadingModeText()}else{var objImgLoader=new Image();objImgLoader.onerror=function(){loaderUrl="";startLoadingModeText()};objImgLoader.onload=function(){$("#MantaIOFX_LoaderContainer").css({left:parseInt((isIE6?$(window).scrollLeft():0)+Math.floor(($(window).width()-objImgLoader.width)/2))+"px",top:parseInt((isIE6?$(window).scrollTop():0)+Math.floor(($(window).height()-objImgLoader.height)/2))+"px"}).html('<img src="'+loaderUrl+'" width="'+objImgLoader.width+'" height="'+objImgLoader.height+'" borer="0" alt="" />')};objImgLoader.src=loaderUrl}}function killMeSoftly(){removeEvents();$("#MantaIOFX_Image").attr("src","");if(opts.showToolbar){$("#MantaIOFX_ToolbarContainer").empty().remove()}if(opts.showStatusbar){$("#MantaIOFX_StatusbarContainer").empty().remove()}$("#MantaIOFX_LoaderContainer, #MantaIOFX_ImageContainer, #MantaIOFX_Background").empty().remove();$("embed, object, select").css({visibility:"visible"});isRunning=false}function removeEvents(){if(isIE6){$(window).unbind("resize",IE6_resizeScene);$(window).unbind("scroll",IE6_scrollScene)}else{$(window).unbind("resize",resizeScene)}if(opts.hitEscToClose==true){$(document).unbind("keyup",checkKeyToClose)}if(opts.clickImgToClose==true){$("#MantaIOFX_ImageContainer").unbind()}if(opts.clickBgToClose==true){$("#MantaIOFX_Background").unbind()}}function checkKeyToClose(e){if(e.keyCode==27){killMeSoftly()}}function addEvents(){if(isIE6){$(window).scroll(IE6_scrollScene);$(window).resize(IE6_resizeScene)}else{$(window).resize(resizeScene)}if(opts.hitEscToClose==true){$(document).bind("keyup",checkKeyToClose)}if(opts.clickImgToClose==true){$("#MantaIOFX_ImageContainer").click(killMeSoftly)}if(opts.clickBgToClose==true){$("#MantaIOFX_Background").click(killMeSoftly)}}function animResizingImg(){var freeSpace=getFreeSpace(),posX=isIE6?$(window).scrollLeft():0,posY=isIE6?$(window).scrollTop():0;if(!imgFileNotFound||(imgFileNotFound&&(imgErrorUrl!=""))){var scaledImg=scaleIt(freeSpace);posX+=Math.floor((freeSpace.width-scaledImg.width)/2)-opts.imgBorderWidth;posY+=Math.floor((freeSpace.height-scaledImg.height)/2)-opts.imgBorderWidth+(opts.showToolbar?$("#MantaIOFX_ToolbarContainer").height():0);$("#MantaIOFX_ImageContainer").animate({left:posX,top:posY},"fast","linear",function(){$("#MantaIOFX_Image").animate({width:scaledImg.width,height:scaledImg.height},"slow","linear")})}else{posX+=Math.floor((freeSpace.width-msgBoxSize.width)/2);posY+=Math.floor((freeSpace.height-msgBoxSize.height)/2)+(opts.showToolbar?$("#MantaIOFX_ToolbarContainer").height():0);$("#MantaIOFX_ImageContainer").animate({left:posX,top:posY},"fast","linear")}}function resizeScene(){if(!isRunning){return}if(opts.showStatusbar){$("#MantaIOFX_StatusbarContainer").css({top:parseInt($(window).height()-$("#MantaIOFX_StatusbarContainer").height())+"px"})}if(isLoading){$("#MantaIOFX_LoaderContainer").css({left:parseInt(Math.floor(($(window).width()-$("#MantaIOFX_LoaderContainer").width())/2))+"px",top:parseInt(Math.floor(($(window).height()-$("#MantaIOFX_LoaderContainer").height())/2))+"px"})}else{animResizingImg()}}function IE6_resizeScene(){if(!isRunning){return}$("#MantaIOFX_Background").hide().css({top:$(window).scrollTop(),left:$(window).scrollLeft(),width:$(window).width()+"px",height:$(window).height()+"px"}).show();if(opts.showToolbar){$("#MantaIOFX_ToolbarContainer").css({top:$(window).scrollTop(),left:$(window).scrollLeft(),width:$(window).width()+"px"}).show()}if(opts.showStatusbar){$("#MantaIOFX_StatusbarContainer").css({left:$(window).scrollLeft(),width:$(window).width()+"px"});$("#MantaIOFX_StatusbarContainer").css({top:$(window).scrollTop()+$(window).height()-$("#MantaIOFX_StatusbarContainer").height()})}if(isLoading){$("#MantaIOFX_LoaderContainer").css({left:parseInt($(window).scrollLeft()+Math.floor(($(window).width()-$("#MantaIOFX_LoaderContainer").width())/2))+"px",top:parseInt($(window).scrollTop()+Math.floor(($(window).height()-$("#MantaIOFX_LoaderContainer").height())/2))+"px"})}else{animResizingImg()}}function IE6_scrollScene(){if(opts.showToolbar){$("#MantaIOFX_ToolbarContainer").css({top:$(window).scrollTop(),left:$(window).scrollLeft()})}if(opts.showStatusbar){$("#MantaIOFX_StatusbarContainer").css({top:$(window).scrollTop()+$(window).height()-$("#MantaIOFX_StatusbarContainer").height(),left:$(window).scrollLeft()})}if(isLoading){$("#MantaIOFX_LoaderContainer").css({left:parseInt($(window).scrollLeft()+Math.floor(($(window).width()-$("#MantaIOFX_LoaderContainer").width())/2))+"px",top:parseInt($(window).scrollTop()+Math.floor(($(window).height()-$("#MantaIOFX_LoaderContainer").height())/2))+"px"})}else{var freeSpace=getFreeSpace();$("#MantaIOFX_ImageContainer").css({left:eval($(window).scrollLeft()+Math.floor((freeSpace.width-$("#MantaIOFX_ImageContainer").width())/2))+"px",top:eval($(window).scrollTop()+Math.floor((freeSpace.height-$("#MantaIOFX_ImageContainer").height())/2)+(opts.showToolbar?$("#MantaIOFX_ToolbarContainer").height():0))+"px"})}}return this};$.fn.MantaIOFX.formatFilename=function(fname){var s=new String(fname);var pos=s.lastIndexOf("/");if(pos!=-1){s=s.substr(++pos)}return'<span class="MantaIOFX_Filename">'+s+"</span>"};$.fn.MantaIOFX.formatFileInfo=function(width,height){return'<span class="MantaIOFX_FileInfo">[ '+width+"*"+height+" pixels ]</span>"};$.fn.MantaIOFX.formatFileLegend=function(legend){return'<span class="MantaIOFX_FileLegend">'+legend+"</span>"};$.fn.MantaIOFX.reportError=function(errorCode){switch(errorCode){case _ERR_INVALID_PARAM:alert($.fn.MantaIOFX.lang._MSG_ERR_INVALID_PARAM);break;case _ERR_BLOCKING_SCRIPT:alert($.fn.MantaIOFX.lang._MSG_ERR_BLOCKING_SCRIPT);break;case _ERR_UNKNOWN_ERROR:alert($.fn.MantaIOFX.lang._MSG_ERR_UNKNOWN_ERROR);break}};$.fn.MantaIOFX.lang={_MSG_ERR_INVALID_PARAM:"Op?ration annul?e: param?tres invalides!",_MSG_ERR_BLOCKING_SCRIPT:"Op?ration annul?e: script bloquant!",_MSG_ERR_UNKNOWN_ERROR:"Op?ration annul?e: erreur inconnue!",_MSG_LOADING:"Chargement en cours ...",_MSG_URL_NOT_FOUND:"Erreur de fichier<br /><br />URL non r?solue!",_MSG_STATUSBAR_ESCAPE:"Appuyez sur la touche [Echap] pour fermer.",_MSG_STATUSBAR_IMAGE:"Cliquez sur l'image pour fermer.",_MSG_STATUSBAR_BACKGROUND:"Cliquez sur le fond de page pour fermer.",_MSG_STATUSBAR_IMAGE_OR_BACKGROUND:"Cliquez sur l'image ou le fond de page pour fermer.",_MSG_STATUSBAR_IMAGE_OR_ESCAPE:"Cliquez sur l'image ou appuyez sur la touche [Echap] pour fermer.",_MSG_STATUSBAR_BACKGROUND_OR_ESCAPE:"Cliquez sur le fond de page, ou appuyez sur la touche [Echap] pour fermer.",_MSG_STATUSBAR_IMAGE_OR_BACKGROUND_OR_ESCAPE:"Cliquez sur l'image ou le fond de page, ou appuyez sur la touche [Echap] pour fermer."};$.fn.MantaIOFX.defaults={allowZoom:false,imgUrl:"",imgLegend:"",imgBorderWidth:0,imgBorderColor:"#ddd",imgBorderStyle:"solid",bgColor:"#3f3f3f",bgOpacity:0.95,zIndex:666,clickImgToClose:true,clickBgToClose:true,hitEscToClose:true,showToolbar:true,showFilename:true,showFileInfo:true,showFileLegend:true,showStatusbar:true,margin:5,websiteUrl:"www.mysite.com"}})(jQuery);

