// Last updated - 2011-08-30
function insertFolderImages(r,B,a){function da(){window.jQuery&&jQuery.noConflict();for(var U=["/Common/ThirdParty/prototype.js","/Common/ThirdParty/lightbox/js/effects.js","/Common/ThirdParty/lightbox/js/lightbox.js"],c=document.getElementsByTagName("head")[0],a=0;a<U.length;++a)script=document.createElement("script"),script.type="text/javascript",script.src=U[a],setTimeout(function(a){return function(){c.appendChild(a)}}(script),a*50)}function J(a){try{h=new XMLHttpRequest,h.overrideMimeType("text/xml")}catch(c){try{h= new ActiveXObject("Msxml2.XMLHTTP")}catch(g){try{h=new ActiveXObject("Microsoft.XMLHTTP")}catch(d){return!0}}}if(F)h.onreadystatechange=C;h.open("GET",a,F);h.send(null)}function V(a,c,g){window.addEventListener?a.addEventListener(c,g,!1):a.attachEvent("on"+c,g)}function g(a){return!parseInt(a,10)?0:parseInt(a,10)}function ea(a,c){for(var w,d=[],b=0,e=[];b<a.length;b++)e.push(b);if(l){l=l.split(",");for(var e=e.length,f=w=0,h=",",b=[];f<l.length;++f)l[f]=l[f].replace(/^\s+|\s+$/g,""),l[f]=g(l[f]), h.indexOf(","+l[f]+",")==-1&&(b[w++]=l[f]),h+=l[f]+",";w=","+b.join(",")+",";if(c){for(f=[];b.length>0;)f.push(b.splice(Math.floor(Math.random()*b.length),1)[0]);b=f}for(f=0;f<e;++f)(h=a[f].getAttribute("title").replace(/^\s+|\s+$/g,"").match(/(^\d+)[\.\s]?\s*.*/))&&h[1].length&&w.indexOf(","+g(h[1])+",")>-1&&(d[g(h[1])]=f);f=0;for(w=[];f<b.length;++f)d[b[f]]!=void 0&&!(x&&d[b[f]]>e-2)&&(w.push(d[b[f]]),x&&w.push(d[b[f]]+1));e=w}else if(c){d=[];if(x)for(;Math.floor(e.length/2)*2>0;)b=Math.floor(Math.random()* Math.floor(e.length/2)),d.push(e.splice(b*2,1)[0]),d.push(e.splice(b*2,1)[0]);else for(;e.length>0;)d.push(e.splice(Math.floor(Math.random()*e.length),1)[0]);e=d}t<e.length&&(e=e.splice(0,t*(x?2:1)));return e}function W(a){var c,h=a.offsetWidth,d=a.parentNode;if(d.nodeName!="DIV")d=d.parentNode;a=[];(c=d.getElementsByTagName("strong")).length&&a.push(c[0]);(c=d.getElementsByTagName("span")).length&&a.push(c[0]);for(c=0;c<a.length;++c){if(s)h-=g(a[c].currentStyle.marginLeft)+g(a[c].currentStyle.marginRight); else if(d=window.getComputedStyle(a[c],null))h-=g(d.paddingLeft)+g(d.paddingRight)+g(d.borderLeftWidth)+g(d.borderRightWidth)+g(d.marginLeft)+g(d.marginRight);a[c].style.width=h+"px";a[c].style.display="block";a[c].style.overflow="hidden";a[c].style.clear="both"}}function C(){if((!F||h.readyState==4)&&h.responseXML){var a=h.responseXML.getElementsByTagName("album");if(!a.length)return!1;var c,l=(a[0].getAttribute("lgPath")||"").replace(/http:\/\/[^\/]*/,"");if(fa){c=[];for(var d=0;d<a.length;++d){var b= a[d].getElementsByTagName("img");for(ims=0,imsLength=b.length;ims<imsLength;++ims)c.push(b[ims])}}else c=a[0].getElementsByTagName("img");if(c.length){y.innerHTML="";var a=ea(c,ga),e=[],f=x?-2:-1,r=!1,d=RegExp("^(http://)?((www.)?"+location.hostname.replace(/^www\./,"")+"|shop.churchinsight.com|(www.)?endisinspire.com)","i");if(u){u=u.toString().replace(/^\s+|\s+$/g,"").replace(/\s+/g," ");b=u.split(" ");if(b.length>3&&(b[1]=="*"||b[3]=="*"))b[1]="*",b[3]="*";if(u=="*"||b.length>1&&b[1]=="*")r=!0; u=b.join(" ").replace(/\*/g,"0")}for(var G=b=0,B=a.length,t=x?2:1,A=B-t;b<B;b+=t,G++){var m=a[b],n=l+c[m+(x?1:0)].getAttribute("src"),k,C,j,q=X;j=M;k=x?l+c[m].getAttribute("src")+"?ent="+H:(C=g(N))>0?"/Publisher/GetResizedImage.aspx?w="+C+"&h="+C+"&url="+encodeURIComponent(n)+"&ent="+H:n+"?ent="+H;N=="system"&&(k=k.replace(/(\/)([^\/]*)$/i,"/Thumbnail/$2"));if(k!=void 0){var i=document.createElement("img");i.setAttribute("src",k);if(s)var J=i.width,L=i.height;var o=c[m].getAttribute("title").replace(/^\s+|\s+$/g, "").replace(/^\d+[\.\s]?\s*(.*)/,"$1");o&&ha&&i.setAttribute("alt",o);if(k=c[m].getAttribute("caption")){k=k.replace(/^\s+|\s+$/g,"").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"');var p=k.match(/^title\->.*$|^caption\->.*$|^tooltip\->.*$/gmi);if(p)for(var O=0;O<p.length;++O){var v=p[O].split("->");v[0].toLowerCase()=="caption"&&(v.shift(),k=v[0]);v[0].toLowerCase()=="title"&&(v.shift(),o=v[0]);v[0].toLowerCase()=="tooltip"&&(v.shift(),j=v[0])}}p=c[m].getAttribute("link");typeof p== "string"&&(p=p.replace(d,""));if(n=Y||D?n:p){var z=document.createElement("a"),E=c[m].getAttribute("target");E&&!D&&!Y&&z.setAttribute("target",E);if(D||P)z.setAttribute("rel",D||P);z.setAttribute("href",n);z.appendChild(i);z.style[s?"styleFloat":"cssFloat"]="left";m=z;k&&(k.match(/<a/i)&&(q=!1),k=k.replace(/(<a[^>]*)(href=["']["'])([^<]*<\/a>)/gi,'$1href="'+n+'"$3'))}else m=i;typeof j=="string"?(n&&z.setAttribute("title",j),i.setAttribute("title",j)):j&&(n&&z.setAttribute("title",o),i.setAttribute("title", o));j=document.createElement("div");j.appendChild(m);j.style[s?"styleFloat":"cssFloat"]="left";if(Q&&o){m=document.createElement("strong");if(R)m.style.display="none";p&&Z?(n=document.createElement("a"),n.setAttribute("href",p),E&&n.setAttribute("target",E),n.innerHTML=o,m.appendChild(n)):m.innerHTML=o;j.appendChild(m)}if(S&&k){o=document.createElement("span");if(R)o.style.display="none";q&&p?(q=document.createElement("a"),q.setAttribute("href",p),E&&q.setAttribute("target",E),q.innerHTML=k,o.appendChild(q)): o.innerHTML=k;j.appendChild(o)}if(T)j.setAttribute("id",T.toString()+G),j.id=T.toString()+G;if($&&b==A)j.className=$;y.appendChild(j);var I=function(){if(r&&e.length){var a=y,c=e.length,b,d=0;s?(b=a.offsetWidth-(g(a.currentStyle.paddingLeft)+g(a.currentStyle.paddingRight)),b-=g(a.currentStyle.borderLeftWidth)+g(a.currentStyle.borderRightWidth)):(b=window.getComputedStyle(a,null),b=g(b.width));for(a=0;a<c;a++)d+=e[a].offsetWidth;if(c==1)e[0].style.marginLeft=b/2-d/2+"px",e[0].style.visibility="visible"; else{d=(b-d)/(c-1);for(a=0;a<c;a++)e[a].style.marginRight=a<c-1?Math.floor(d*(a+1))-Math.floor(d*a)+"px":"0",e[a].style.marginLeft="0",e[a].style.visibility="visible",a==c-1&&(e[a].style[s?"styleFloat":"cssFloat"]="right")}}aa&&da();typeof ba=="function"&&ba()};if(r)j.style.visibility="hidden",e.push(j);if(u)j.style.margin=u;if(R&&(S||Q))i.readyState!="complete"&&!i.complete?V(i,"load",function(a){return function(){W(a)}}(i)):W(i);i.readyState!="complete"&&!i.complete?V(i,"load",function(a,b){return function(){K(b, a);(f+=t)==A&&I()}}(i,G)):(K(G,i),(f+=t)==A&&I());if(s&&r&&(q=g(i.currentStyle.width)||i.offsetWidth-(g(i.currentStyle.borderLeftWidth)+g(i.currentStyle.borderRightWidth)),q=Math.floor(q/J*L)))i.height=q}}typeof ca=="function"&&ca()}}}if(!r||!B)return!1;a||(a={});typeof a=="string"&&(a={margin:a});var u=a.margin||"",t=a.limit,N=a.thumbnails,D=a.addRel,P=a.addRelExternal,aa=a.lightbox,S=a.addCaption,X=a.addCaptionLink,Q=a.addTitle,Z=a.addTitleLink,M=a.addTitleAttr==void 0?!1:a.addTitleAttr,ha=a.addAlt== void 0?!0:a.addAlt,ga=a.shuffle,A=g(a.cacheTime!=void 0?a.cacheTime:180),R=a.autoTextWidth,ba=a.oncomplete,K=a.onimageload,ca=a.onlayout,T=a.id,$=a.addLastClass,l=a.filter,fa=a.subfolders,Y=a.linkToImage;t||(t=999999999);A<0&&(A=0);X&&(S=!0);Z&&(Q=!0);if((D||P)&&!M)M=!0;typeof K!="function"&&(K=function(){});var x=N=="custom",s=window.ActiveXObject&&parseInt(navigator.userAgent.toLowerCase().split("msie")[1],10)||!1,h,F=s&&s<7?!1:!0,H=A?Math.floor((new Date).getTime()/(A*1E3)):"0";r+=(r.indexOf("?")!= -1?"&":"?")+"rdm="+H;aa&&!D&&(D="lightbox["+H+"]");var y=typeof B.nodeName=="string"?B:document.getElementById(B);if(s&&u.indexOf("*")!=-1)var L=0,I=setInterval(function(){if(++L==45)y.style.width="auto";L==55&&clearInterval(I);if(y.offsetWidth>0){if(y.currentStyle.width=="auto")y.style.width=y.offsetWidth+"px";clearInterval(I);J(r);!F&&h&&C()}},100);else J(r),!F&&h&&C()};
