// <![CDATA[

/** AdvancedBox JS - Start
* This work is open source
* AdvancedBox for resized images based on "Reimg Image Resizer (+ lightbox)" from http://www.taletn.com/ - http://www.phpbb.com/community/viewtopic.php?f=70&t=907805
* Paked with : A JavaScript Compressor.  version 3.0 - http://dean.edwards.name/packer/
*
* eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('t 2A=1d y(){t j=22;t k,J,X,17,F,H,v,8,x,K=1s;t l,U=0;t m,18=0;t n=10;t o=0;t p,1e=C=1s;t q,19,1a,D,1t=1s;t r=1d 1u();t s=1d 1u();23=y(){t a=I.1F.1G.1H(/(^|\\W)(24)\\s+(\\d+)(\\.\\d+)?/);9(!a){a=I.1F.1G.1H(/(^|\\W)(25|26|27)\\/(\\d+)(\\.\\d+)?/);9(!a){a=I.1F.1G.1H(/(^|\\W)(28)\\/[\\d.]+\\s+\\(.*?2B:(\\d+)(\\.\\d+)?.*?\\)/)}}9(!a||a.1n<5){V}t b=2C(a[3]+a[4]);a=a[2];9(a=="24"){C=b}E 9(a=="25"){t c=b}E 9(a=="26"){t d=b}E 9(a=="27"){t e=b}E 9(a=="28"){t f=b}p=(C&&C<=7.0)?29:13;1e=(C>=7.0||c>3.0)?29:13},1f=y(a,b,c,d){9(!J){2a()}J.6.B="";X.6.B="";a=1v(a);K=1d 2D();K.L(\'14\',a);b=K.z;c=K.A;1w=I.1I("1J();",1);V 13},1v=y(a){a=2E(a.2F().1o(/\\s/g,\' \'));9(a.1p(\'2G\')!=-1){t b=a.1K(0,a.1p(\'?\'));t c=a.1K(a.1p(\'O\'));t d=c.1K(c.1p(\'O\'),c.1p(\'&\'));a=b+\'?\'+(d?d:c)}V a},1J=y(){o++;9(o==2H){1x(1w);1g()}9(!K.2I=="2b"||!K.2b){9(K.z>1y){1q(K.14,K.z,K.A,n)}E{1w=I.1I("1J();",2J)}}E{1x(1w);1q(K.14,K.z,K.A,n)}},2a=y(){t a=1L();t b=1M();1z=u.2c("G").2K(0);J=u.P("2d");J.1A="2L";J.6.B="Y";J.6.2M=\'2N(2e:\'+j+\')\';J.6.2O=J.6.2P=J.6.2e=(j/1y);J.6.z="1y%";J.6.A=b[2]+"w";X=u.P("a");X.L(\'O\',\'2Q\');X.15=X.16=2f;X.Q=1g;v=u.P("1N");v.6.B="Y";v.6.2g=(p?\'2h\':\'2R\');H=u.P("1N");H.L(\'O\',\'2S\');H.6.2g=(1e?\'2T\':\'2h\');17=u.P("a");17.L(\'O\',\'2U\');17.15=17.16=2f;17.Q=1g;F=u.P("a");F.L(\'O\',\'2V\');F.Q=1O;D=u.P("a");D.L(\'O\',\'1P\');D.15=D.16=2i;D.Q=y(){1h(\'1B\');V 13};q=u.P("a");q.L(\'O\',\'2W\');19=u.P("1N");19.L(\'O\',\'2X\');1a=u.P("a");1a.L(\'O\',\'2Y\');8=u.P("2d");x=u.P("2Z");x.1A=8.1A=v.1A="31";x.32=x.33=2j;x.Q=1g;1z.T(J);1z.T(X);H.T(17);H.T(F);H.T(q);H.T(1a);H.T(19);H.T(D);v.T(H);8.T(x);v.T(8);1z.T(v)},2k=y(){t a=1L();t b=1M();l=b[3]-20;l=(1e)?(l+20):l;l=(C&&C<7.0)?l+10:l;U=b[4]+20;U=(1e)?(U-22):U;U=(C&&C<7.0)?U-30:U;v.6.Z=(!p?0:a[1])+"w";v.6.M=(!p?0:a[2])+"w"},1q=y(a,b,c,d){I.2l=2m;2k();1Q(\'2n\');2o.34();8.6.2p="";x.L(\'14\',a);x.6.z=8.6.z=(m=b)+"w";x.6.A=8.6.A=(18=c)+"w";v.6.B="";v.6.z=v.6.A=8.6.Z=8.6.M="";t e=0;9(v.N>l&&b){e=b;b-=v.N-l+1;c=1b.1R(c*b/e);x.6.z=8.6.z=b+"w";x.6.A=8.6.A=c+"w"}9(v.1i>U&&c){e=c;c-=v.1i-U;b=1b.1R(b*c/e);x.6.z=8.6.z=b+"w";x.6.A=8.6.A=c+"w";9(v.N>l&&b){e=b;b-=v.N-l;c=1b.1R(c*b/e);x.6.z=8.6.z=b+"w";x.6.A=8.6.A=c+"w"}}9(e){F.15=F.16=35.1o(/%1\\$s/,m).1o(/%2\\$s/,18);F.Q=1O;F.6.B=""}E{F.15=F.16=2q;F.Q=1S;F.6.B="Y"}v.6.z=l+"w";v.6.A=U+"w";8.6.Z=1b.1C((v.N-8.N)/2-8.1j)+"w";8.6.M=1b.1C((v.1i-8.1i)/2-8.36)+"w";8.6.M=(C&&C<7.0)?(11(8.6.M)+20)+"w":8.6.M;H.6.Z=(11(8.1j))+"w";H.6.M=(11(8.6.M)+(C&&C<7.0?-20:10))+"w";1h();n=d;9(n>=1y){1T()}},1h=y(a,b){q.6.B="Y";19.6.B="Y";1a.6.B="Y";D.6.B="Y";t c=x.14;t d=37(c,r);t e=d[0];t f=d[1];t g=r.1n;9(e){t h=r[f-1];t i=r[f+1];9(f-1>=0){q.6.B="";q.Q=y(){1f(h);V 13}}19.6.B="";19.38=39.1o(/%1\\$s/,f+1).1o(/%2\\$s/,g);9(f+1<g){1a.6.B="";1a.Q=y(){1f(i);V 13}}9(g>1){D.6.B=""}9(a&&2r(a)!="3a"){9(!b&&f+1==g){b=1;1U=r[0]}E{b=f+1;1U=i}9(a==\'1B\'&&b<g){D.L(\'O\',\'3b\');D.15=D.16=3c;D.Q=y(){1h(\'3d\');V 13};1f(1U);1t=I.1I("1h(\'1B\', \'"+b+"\');",(3e))}E{D.L(\'O\',\'1P\');D.15=D.16=2i;D.Q=y(){1h(\'1B\');V 13};1x(1t)}}}},2j=y(e){X.6.B="Y"},1g=y(e){1Q(\'2s\');2o.3f();I.2l=1s;1x(1t);D.L(\'O\',\'1P\');x.L(\'14\',3g);J.6.B=v.6.B=X.6.B="Y"},2m=y(e){t a=x.14;1g();1q(a,m,18,n)},1S=y(e){1q(x.14,m,18,10)},1O=y(e){1T()},1T=y(){9(11(x.6.z)>=m&&11(x.6.A)>=18){V}x.6.z=m+"w";x.6.A=18+"w";8.6.2p="2t";9(!p){8.6.M=8.6.Z=v.6.A=0;8.6.z="2t"}E{t a=8.N-8.1r;8.6.M=8.6.Z=v.6.A=0;8.6.z=(l-2*8.1j-a)+"w";9(v.N>l){8.6.z=(l-(v.N-l))+"w"}}8.6.Z=1b.1C((v.N-8.N)/2-8.1j)+"w";8.6.M=11(8.6.M)+((C&&C<7.0)?30:0)+"w";9(8.1r>m){8.6.z=m+"w";8.6.z=(m+(m-8.1r))+"w";8.6.Z=1b.1C((v.N-8.N)/2-8.1j)+"w"}8.6.A=11(8.6.A)+(1e?+3h:0)+"w";9(8.1k){8.1k=0}9(8.1l){8.1l=0}F.15=F.16=2q;F.Q=1S;H.6.Z=(11(8.1j))+"w";H.6.M=(11(8.6.M)+(C&&C<7.0?-20:10))+"w"},1M=y(){t a,1m;9(I.1D&&I.2u){a=u.G.2v;1m=I.1D+I.2u}E 9(u.G.2w>u.G.1i){a=u.G.2v;1m=u.G.2w}E{a=u.G.N;1m=u.G.1i}t b,1c;9(1V.1D){b=1V.3i;1c=1V.1D}E 9(u.12&&u.12.1W){b=u.12.1r;1c=u.12.1W}E 9(u.G){b=u.G.1r;1c=u.G.1W}9(1m<1c){1X=1c}E{1X=1m}9(a<b){1Y=b}E{1Y=a}V 1d 1u(\'\',1Y,1X,b,1c)},1L=y(){t a=0;t b=0;9(2r(I.2x)==\'3j\'){b=I.2x;a=I.3k}E 9(u.G&&(u.G.1k||u.G.1l)){b=u.G.1l;a=u.G.1k}E 9(u.12&&(u.12.1k||u.12.1l)){b=u.12.1l;a=u.12.1k}V 1d 1u(\'\',a,b)},1Q=y(a){9(C){9(a!=\'2s\'){a=\'2n\'}1Z(t S=0;S<u.1E.1n;S++){1Z(t R=0;R<u.1E[S].1n;R++){9(u.1E[S].2y[R].3l){u.1E[S].2y[R].6.2z=a}}}}t b=u.2c("3m");1Z(t i=0;i<b.1n;i++){b[i].6.2z=a}};23();21.3n=r;21.1f=1f;21.1v=1v};',62,210,'||||||style||objImageContainer|if||||||||||||||||||||var|document|objContainer|px|objImage|function|width|height|display|msie|objPlay|else|objZoom|body|objToolbar|window|objOverlay|newObjImage|setAttribute|top|offsetWidth|id|createElement|onclick|||appendChild|MaxHeight|return||objLoading|none|left||parseInt|documentElement|false|src|alt|title|objCloser|RealImgHeight|objText|objNext|Math|windowHeight|new|NewStyle|Show|Close|Slide_Show|offsetHeight|offsetLeft|scrollLeft|scrollTop|yScroll|length|replace|indexOf|ShowImage|clientWidth|null|SlideWait|Array|Clear_url|imgWait|clearTimeout|100|objBigBody|className|play|floor|innerHeight|forms|navigator|userAgent|match|setTimeout|waitFor|substring|getScrollXY|getPageSize|span|ZoomInClick|PlayLink|ToggleVisibility|round|ZoomOutClick|ZoomIt|PlayNext|self|clientHeight|pageHeight|pageWidth|for||this|60|DetectBrowser|MSIE|Firefox|Opera|Safari|Mozilla|true|Initialize|complete|getElementsByTagName|div|opacity|ImageResizerCloseAlt|position|absolute|ImageResizerPlayAlt|loading_hide|Calculate|onresize|Resize|hidden|ScrollFreeze|overflow|ImageResizerZoomOutAlt|typeof|visible|auto|scrollMaxY|scrollWidth|scrollHeight|pageYOffset|elements|visibility|AdvancedBox|rv|parseFloat|Image|decodeURIComponent|toString|download|250|readyState|500|item|AdvancedBoxBackGround|filter|alpha|KHTMLOpacity|MozOpacity|LoadingLink|fixed|hoverNav|relative|CloserLink|ZoomLink|PrevLink|nOnText|NextLink|img||AdvancedBoxImage|onload|onerror|on|ImageResizerZoomInAlt|offsetTop|contains|innerHTML|ImageResizerNumberOf|undefined|PauseLink|ImageResizerPauseAlt|pause|5000|off|ImageResizerBlankImage|55|innerWidth|number|pageXOffset|options|object|SlideShows'.split('|'),0,{}))
**/

var AdvancedBox = new function()
{
	/** Set opacity on background element **/
	var ojbOpacity = 60;
	/** Global Variables **/
	var objBody, objOverlay, objLoading, objCloser, objZoom, objToolbar, objContainer, objImageContainer, objImage, newObjImage = null;
	/** Dimensions of the box **/
	var MaxWidth, MaxHeight = 0;
	/** Dimensions of the current displayed image **/
	var RealImgWidth, RealImgHeight	= 0;
	/** Zoom level **/
	var zoomLevel = 10;
	/** Loading **/
	var Wait_pass = 0;
	/** The browser **/
	var OldStyle, NewStyle = msie = null;
	/** SlideShow **/
	var objPrev, objText, objNext, objPlay, SlideWait = null;
	var SlideShows = new Array();
	var objSlide = new Array();

	/**
	* This browser detection is based on code from Martinic <http://www.martinic.com/>
	**/
	DetectBrowser = function()
	{
		var browser = window.navigator.userAgent.match(/(^|\W)(MSIE)\s+(\d+)(\.\d+)?/);

		if (!browser)
		{
			browser = window.navigator.userAgent.match(/(^|\W)(Firefox|Opera|Safari)\/(\d+)(\.\d+)?/);
			if (!browser)
			{
				browser = window.navigator.userAgent.match(/(^|\W)(Mozilla)\/[\d.]+\s+\(.*?rv:(\d+)(\.\d+)?.*?\)/);
			}
		}
		if (!browser || browser.length < 5)
		{
			return;
		}
		var version = parseFloat(browser[3]+browser[4]);
		browser = browser[2];

		if (browser == "MSIE")
		{
			msie = version;
		}
		else if (browser == "Firefox")
		{
			var firefox = version;
		}
		else if (browser == "Opera")
		{
			var opera = version;
		}
		else if (browser == "Safari")
		{
			var safari = version;
		}
		else if (browser == "Mozilla")
		{
			var mozilla = version;
		}

		/** IE6=T : IE7=T : FF2=F : FF3=F : O=F **/
		OldStyle = ( msie && msie <= 7.0 ) ? true : false;
		/** IE6=F : IE7=T : FF2=F : FF3=F : O=F **/
		NewStyle = ( msie >= 7.0 || firefox > 3.0) ? true : false;

	},

	Show = function(url, width, height, zoomlvl)
	{
		if ( !objOverlay )
		{
			Initialize();
		}
		/** Show the background overlay **/
		objOverlay.style.display = "";

		/** Show the loading image **/
		objLoading.style.display = "";

		/** Clear the image url **/
		url = Clear_url( url );

		/** Try to get the real image dimensions **/
		newObjImage	= new Image();
		newObjImage.setAttribute('src', url);
		width		= newObjImage.width;
		height		= newObjImage.height;

		/** Let's do some extra checks **/
		imgWait = window.setTimeout( "waitFor();", 1 );

		return false;
	},

	/** Clear the image url **/
	Clear_url = function( url )
	{
		url = decodeURIComponent( url.toString().replace(/\s/g, ' ') );

		/** If this an attached image ? if yes, need more work to clear the image url **/
		if ( url.indexOf('download') != -1 )
		{
			/** Will get the real url to the download script, ex : http://www.mssti.com/phpbb3/download/file.php **/
			var valor   = url.substring( 0, url.indexOf('?') );
			/** Will get an string starting from the id, ex : id=65&mode=view or only id=65 **/
			var valorId1= url.substring( url.indexOf('id') );
			/** Will get only the id value, ex : id=65 or null if have no extra params **/
			var valorId2 = valorId1.substring( valorId1.indexOf('id'), valorId1.indexOf('&') );
			/** Recreate the image url, ex : http://www.mssti.com/phpbb3/download/file.php?id=65 **/
			url = valor + '?' + ( valorId2 ? valorId2 : valorId1 );
		}
		return url;
	},

	waitFor = function( )
	{
		/** Safety end the process if can't load the image afer 250 intents ( 2.0833333333333335 Minutes ) **/
		Wait_pass++;
		if ( Wait_pass == 250 )
		{
			clearTimeout(imgWait);
			Close();
		}

		if ( !newObjImage.readyState == "complete" || !newObjImage.complete )
		{
			/** Seems that IE when create an image gives a default width to 28 **/
			if ( newObjImage.width > 100)
			{
				ShowImage( newObjImage.src, newObjImage.width, newObjImage.height, zoomLevel );
			}
			else
			{
				imgWait = window.setTimeout( "waitFor();", 500 );
			}
		}
		else
		{
			clearTimeout(imgWait);
			ShowImage( newObjImage.src, newObjImage.width, newObjImage.height, zoomLevel );
		}
	},

	/** Create the background, image and close button elements. **/
	Initialize = function()
	{
		/** Determine the current scroll position within the document **/
		var arrayScroll = getScrollXY();

		/** Determine the dimensions of the entire document **/
		var arraySize = getPageSize();

		objBigBody = document.getElementsByTagName("body").item(0);

		/** Create the background element (div) **/
		objOverlay = document.createElement("div");
		objOverlay.className = "AdvancedBoxBackGround";
		objOverlay.style.display = "none";
		objOverlay.style.filter = 'alpha(opacity:'+ojbOpacity+')';
		objOverlay.style.KHTMLOpacity = objOverlay.style.MozOpacity = objOverlay.style.opacity = (ojbOpacity/100);
		/** The background gets the document's dimensions, so a shadow can be cast over the entire document **/
		objOverlay.style.width	= "100%";
		objOverlay.style.height	= arraySize[2]+"px";

		/** Create the Loading button **/
		objLoading = document.createElement("a");
		objLoading.setAttribute('id','LoadingLink');
		objLoading.alt = objLoading.title = ImageResizerCloseAlt;
		objLoading.onclick = Close;

		/** Create the big image container **/
		objContainer = document.createElement("span");
		objContainer.style.display = "none";
		/** Use old style CSS positioning (absolute instead of fixed) for IE <7 **/
		objContainer.style.position = ( OldStyle ? 'absolute' : 'fixed' );
//		objContainer.onclick = Close;

		/** Create the toolbar **/
		objToolbar = document.createElement("span");
		objToolbar.setAttribute('id','hoverNav');
		/** Use old style CSS positioning (absolute instead of relative) for IE <7 **/
		objToolbar.style.position = ( NewStyle ? 'relative' : 'absolute' );

		/** Create the Close button **/
		objCloser = document.createElement("a");
		objCloser.setAttribute('id','CloserLink');
		objCloser.alt = objCloser.title = ImageResizerCloseAlt;
		objCloser.onclick = Close;

		/** Create the Zoom button **/
		objZoom = document.createElement("a");
		objZoom.setAttribute('id','ZoomLink');
		objZoom.onclick = ZoomInClick;

		/** Create the Play button **/
		objPlay = document.createElement("a");
		objPlay.setAttribute('id','PlayLink');
		objPlay.alt = objPlay.title = ImageResizerPlayAlt;
		objPlay.onclick = function() { Slide_Show( 'play' ); return false; };

		/** Create the Prev button **/
		objPrev = document.createElement("a");
		objPrev.setAttribute('id','PrevLink');

		/** Create the text n of n picture **/
		objText = document.createElement( "span" );
		objText.setAttribute('id','nOnText');

		/** Create the Next button **/
		objNext = document.createElement("a");
		objNext.setAttribute('id','NextLink');

		/** Create the image container **/
		objImageContainer = document.createElement("div");

		/** Create the image here **/
		objImage = document.createElement("img");
		objImage.className = objImageContainer.className = objContainer.className = "AdvancedBoxImage";
		/** Hide the loading image **/
		objImage.onload = objImage.onerror = loading_hide;
		objImage.onclick = Close;

		/** Place the background in the document **/
		objBigBody.appendChild(objOverlay);
		/** Place the Loading button in the background **/
		objBigBody.appendChild(objLoading);
		/** Place the Close button in the toolbar **/
		objToolbar.appendChild(objCloser);
		/** Place the Zoom button in the toolbar **/
		objToolbar.appendChild(objZoom);
		/** Place the PrevLink button in the toolbar **/
		objToolbar.appendChild(objPrev);
		/** Place the Next button in the toolbar **/
		objToolbar.appendChild(objNext);
		/** Place the text n of n in the toolbar **/
		objToolbar.appendChild(objText);
		/** Place the PlayLink button in the toolbar **/
		objToolbar.appendChild(objPlay);
		/** Place the toolbar in the big container **/
		objContainer.appendChild(objToolbar);
		/** Place the image in the image container **/
		objImageContainer.appendChild(objImage);
		/** Place the image container in the big container **/
		objContainer.appendChild(objImageContainer);
		/** Place the the big container in the document element **/
		objBigBody.appendChild(objContainer);
	},

	Calculate = function ()
	{
		/** Determine the current scroll position within the document **/
		var arrayScroll = getScrollXY();

		/** Determine the dimensions of the entire document **/
		var arraySize = getPageSize();

		/** Determine the visible dimensions of the browser window (the "viewport") **/
		MaxWidth	= arraySize[3]-20;
		/** Adjust the max width for old browsers **/
		MaxWidth	= (NewStyle) ? (MaxWidth+20) : MaxWidth ;
		MaxWidth	= ( msie && msie < 7.0 ) ? MaxWidth+10 : MaxWidth ;

		MaxHeight	= arraySize[4]+20;/** Adjust the max height - toolbar bar height **/
		/** Adjust the max height for old browsers **/
		MaxHeight	= (NewStyle) ? (MaxHeight-60) : MaxHeight ;
		MaxHeight	= ( msie && msie < 7.0 ) ? MaxHeight-30 : MaxHeight ;

		/** The image span will get (but not just now) the dimensions of the visible window, so it will exactly fit in the viewport **/

		/** Position the image span at the current scroll position **/
		objContainer.style.left	= (!OldStyle ? 0 : arrayScroll[1] )+"px";
		objContainer.style.top	= (!OldStyle ? 0 : arrayScroll[2] )+"px";
	},

	/** Show an image using a pseudo light box effect **/
	ShowImage = function(url, width, height, zoomlvl)
	{
		/** Resize event handlers **/
		window.onresize = Resize;

		Calculate();

		/** hide some tags **/
		ToggleVisibility( 'hidden' );
		
		/** Stop the body scroll function **/
		ScrollFreeze.on();

		objImageContainer.style.overflow = "";
		objImage.setAttribute('src', url);

		objImage.style.width = objImageContainer.style.width = (RealImgWidth = width)+"px";
		objImage.style.height = objImageContainer.style.height = (RealImgHeight = height)+"px";

		/** Show the image, zoom and close buttons included **/
		objContainer.style.display = "";

		/** Optionally resize the image **/
		objContainer.style.width = objContainer.style.height = objImageContainer.style.left = objImageContainer.style.top = "";
		var org = 0;
		if (objContainer.offsetWidth > MaxWidth && width)
		{
			org = width;
			/** Opera fix: "+1" or image appears left instead of centered **/
			width -= objContainer.offsetWidth-MaxWidth+1;
			height = Math.round(height*width/org);
			objImage.style.width = objImageContainer.style.width = width+"px";
			objImage.style.height = objImageContainer.style.height = height+"px";
		}

		if (objContainer.offsetHeight > MaxHeight && height)
		{
			org = height;
			height -= objContainer.offsetHeight-MaxHeight;
			width = Math.round(width*height/org);
			objImage.style.width = objImageContainer.style.width = width+"px";
			objImage.style.height = objImageContainer.style.height = height+"px";
			if (objContainer.offsetWidth > MaxWidth && width)
			{
				org = width;
				width -= objContainer.offsetWidth-MaxWidth;
				height = Math.round(height*width/org);
				objImage.style.width = objImageContainer.style.width = width+"px";
				objImage.style.height = objImageContainer.style.height = height+"px";
			}
		}

		/** Swap Zoom In for Zoom Out **/
		if (org)
		{
			objZoom.alt = objZoom.title = ImageResizerZoomInAlt.replace(/%1\$s/, RealImgWidth).replace(/%2\$s/, RealImgHeight);
			objZoom.onclick = ZoomInClick;
			objZoom.style.display = "";
		}
		else
		{
			objZoom.alt = objZoom.title = ImageResizerZoomOutAlt;
			objZoom.onclick = ZoomOutClick;
			objZoom.style.display = "none";
		}

		/** As promised in Calculate(): The image span gets the dimensions of the visible window, so it will exactly fit in the viewport **/
		objContainer.style.width = MaxWidth+"px";
		objContainer.style.height = MaxHeight+"px";

		/** Center the box **/
		objImageContainer.style.left = Math.floor((objContainer.offsetWidth-objImageContainer.offsetWidth)/2-objImageContainer.offsetLeft)+"px";
		objImageContainer.style.top = Math.floor((objContainer.offsetHeight-objImageContainer.offsetHeight)/2-objImageContainer.offsetTop)+"px";
		objImageContainer.style.top = ( msie && msie < 7.0 ) ? (parseInt(objImageContainer.style.top )+20)+"px" : objImageContainer.style.top ;

		/** Position the Zoom bar **/
		objToolbar.style.left	= (parseInt(objImageContainer.offsetLeft)   )+"px";
		objToolbar.style.top	= (parseInt(objImageContainer.style.top ) + ( msie && msie < 7.0 ? -20 : 10) )+"px";

		/** Update SlideShow **/
		Slide_Show( );

		/** Optionally zoom in 1:1 **/
		zoomLevel = zoomlvl;
		if (zoomLevel >= 100)
		{
			ZoomIt();
		}
	},

	Slide_Show = function( PlayOnOff, PlayNumber )
	{
		/** Reset to default values **/
		objPrev.style.display = "none";
		objText.style.display = "none";
		objNext.style.display = "none";
		objPlay.style.display = "none";

		/** Get the actual picture **/
		var curr	= objImage.src;

		/** Get current pos in the array **/
		var search	= contains(curr, SlideShows);
		var found	= search[0];
		var pos		= search[1];
		var last	= SlideShows.length;

		if ( found )
		{
			var prev = SlideShows[pos-1];
			var next = SlideShows[pos+1];

			if ( pos-1 >= 0 )
			{
				objPrev.style.display = "";
				objPrev.onclick = function() { Show( prev ); return false; };
			}

			objText.style.display = "";
			objText.innerHTML = ImageResizerNumberOf.replace(/%1\$s/, pos+1 ).replace(/%2\$s/, last);

			if ( pos+1 < last )
			{
				objNext.style.display = "";
				objNext.onclick = function() { Show( next ); return false; };
			}

			/** Run the SlideShow **/
			if ( last > 1 )
			{
				objPlay.style.display = "";				
			}

			if (PlayOnOff && typeof(PlayOnOff) != "undefined")
			{

				/** Calling from last pict, so start from first : else : start from next pict :) **/
				if ( !PlayNumber && pos+1 == last )
				{
					PlayNumber	= 1;
					PlayNext	= SlideShows[0];
				}
				else
				{
					PlayNumber	= pos+1;
					PlayNext	= next;
				}
				
				if ( PlayOnOff == 'play' && PlayNumber < last )
				{
					objPlay.setAttribute('id','PauseLink');
					objPlay.alt = objPlay.title = ImageResizerPauseAlt;
					objPlay.onclick = function() { Slide_Show( 'pause' ); return false; };				
					Show( PlayNext );
					SlideWait = window.setTimeout( "Slide_Show('play', '"+PlayNumber+"');", (5000) );
				}
				else
				{
					objPlay.setAttribute('id','PlayLink');
					objPlay.alt = objPlay.title = ImageResizerPlayAlt;		
					objPlay.onclick = function() { Slide_Show( 'play' ); return false; };
					clearTimeout(SlideWait);
				}
			}
		}

	},

	// Hide the loading when it has fully loaded.
	loading_hide = function(e)
	{
		/** Hide the loading image **/
		objLoading.style.display = "none";
	},

	/** Reset to default values **/
	Close = function(e)
	{
		/** Show some tags **/
		ToggleVisibility( 'visible' );

		/** Return the body scroll function **/
		ScrollFreeze.off();

		/** Canel Resize event handlers **/
		window.onresize=null;

		/** Cancel Slideshow **/
		clearTimeout(SlideWait);
		objPlay.setAttribute('id','PlayLink');

		/** Hide the image, background and buttons **/
		objImage.setAttribute('src', ImageResizerBlankImage);
		objOverlay.style.display = objContainer.style.display = objLoading.style.display = "none";
	},

	/** If the browser window is resized, recalculate dimensions and positions **/
	Resize = function(e)
	{
		var CurrImageSrc = objImage.src;
		Close();
		ShowImage( CurrImageSrc, RealImgWidth, RealImgHeight, zoomLevel );
	},

	ZoomOutClick = function(e)
	{
		ShowImage( objImage.src, RealImgWidth, RealImgHeight, 10 );
/*
		if (e && typeof(e.stopPropagation) != "undefined")
		{
			e.stopPropagation();
		}
		else if (window.event)
		{
			window.event.cancelBubble = true;
		}
*/	},

	ZoomInClick = function(e)
	{
		ZoomIt();
/*
		if (e && typeof(e.stopPropagation) != "undefined")
		{
			e.stopPropagation();
		}
		else if (window.event)
		{
			window.event.cancelBubble = true;
		}
*/	},

	/** Zoom in to real dimensions, adding scroll bars if necessary **/
	ZoomIt = function()
	{
		/** Zoom in 1:1 **/
		if (parseInt(objImage.style.width) >= RealImgWidth && parseInt(objImage.style.height) >= RealImgHeight)
		{
			return;
		}

		objImage.style.width = RealImgWidth+"px";
		objImage.style.height = RealImgHeight+"px";

		objImageContainer.style.overflow = "auto";

		/** Maximize the image container **/
		if (!OldStyle)
		{
			 objImageContainer.style.top = objImageContainer.style.left= objContainer.style.height = 0;
			objImageContainer.style.width = "auto";
		}
		else
		{
			var border = objImageContainer.offsetWidth-objImageContainer.clientWidth;

			 objImageContainer.style.top = objImageContainer.style.left = objContainer.style.height = 0;
			objImageContainer.style.width = (MaxWidth-2*objImageContainer.offsetLeft-border)+"px";
			if (objContainer.offsetWidth > MaxWidth)
			{
				objImageContainer.style.width = (MaxWidth-(objContainer.offsetWidth-MaxWidth))+"px";
			}
		}

		/** Center the box **/
		objImageContainer.style.left = Math.floor((objContainer.offsetWidth-objImageContainer.offsetWidth)/2-objImageContainer.offsetLeft)+"px";
		objImageContainer.style.top = parseInt(objImageContainer.style.top )+(( msie && msie < 7.0 ) ? 30 : 0)+"px";

		/** If the image is smaller than the maximized image container, then shrink the width of the image container **/
		if (objImageContainer.clientWidth > RealImgWidth)
		{
			objImageContainer.style.width = RealImgWidth+"px";
			objImageContainer.style.width = (RealImgWidth+(RealImgWidth-objImageContainer.clientWidth))+"px";
			objImageContainer.style.left = Math.floor((objContainer.offsetWidth-objImageContainer.offsetWidth)/2-objImageContainer.offsetLeft)+"px";
		}
		objImageContainer.style.height = parseInt( objImageContainer.style.height )+( NewStyle ? +55 : 0 )+"px";

		/** Reset the scroll position **/
		if (objImageContainer.scrollLeft)
		{
			objImageContainer.scrollLeft = 0;
		}
		if (objImageContainer.scrollTop)
		{
			objImageContainer.scrollTop = 0;
		}

		/** Swap Zoom In for Zoom Out **/
		objZoom.alt = objZoom.title = ImageResizerZoomOutAlt;
		objZoom.onclick = ZoomOutClick;

		/** Position the toolbar **/
		objToolbar.style.left = (parseInt(objImageContainer.offsetLeft))+"px";
		objToolbar.style.top  = (parseInt(objImageContainer.style.top ) + ( msie && msie < 7.0 ? -20 : 10) )+"px";
	},

	/**
	* Returns array with page width, height and window width, height
	* Code from - quirksmode.org
	**/
	getPageSize = function()
	{
		var xScroll, yScroll;

		if (window.innerHeight && window.scrollMaxY)
		{
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		}
		else if (document.body.scrollHeight > document.body.offsetHeight)
		{	/** all but Explorer Mac **/
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		}
		else
		{	/** Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari **/
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}

		var windowWidth, windowHeight;

		if (self.innerHeight)
		{	/** all except Explorer **/
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
		{	/** Explorer 6 Strict Mode **/
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		}
		else if (document.body)
		{	/** other Explorers **/
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}

		/** for small pages with total height less then height of the viewport **/
		if(yScroll < windowHeight)
		{
			pageHeight = windowHeight;
		}
		else
		{
			pageHeight = yScroll;
		}

		/** for small pages with total width less then width of the viewport **/
		if(xScroll < windowWidth)
		{
			pageWidth = windowWidth;
		}
		else
		{
			pageWidth = xScroll;
		}
		return new Array('',pageWidth,pageHeight,windowWidth,windowHeight);
	},

	/**
	* Returns array with x,y page scroll values.
	* Code from - http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
	**/
	getScrollXY = function()
	{
		var xScroll = 0;
		var yScroll = 0;

		if( typeof( window.pageYOffset ) == 'number' )
		{	/** Netscape compliant **/
			yScroll = window.pageYOffset;
			xScroll = window.pageXOffset;
		}
		else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) )
		{	/** DOM compliant **/
			yScroll = document.body.scrollTop;
			xScroll = document.body.scrollLeft;
		}
		else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) )
		{	/** IE6 standards compliant mode **/
			yScroll = document.documentElement.scrollTop;
			xScroll = document.documentElement.scrollLeft;
		}
		return new Array('',xScroll, yScroll);
	},

	/** Hide selects/object on page
	* documentation for this script at http://www.shawnolson.net/a/1198/hide-select-menus-javascript.html
	* possible values for action are 'hidden' and 'visible'
	**/
	ToggleVisibility = function (action)
	{
		if (msie)
		{
			if (action!='visible'){action='hidden';}
			
			for (var S = 0; S < document.forms.length; S++)
			{
				for (var R = 0; R < document.forms[S].length; R++)
				{
					if (document.forms[S].elements[R].options)
					{
						document.forms[S].elements[R].style.visibility = action;
					}
				}
			}
		}
			
		var theObjects = document.getElementsByTagName("object");
		for (var i = 0; i < theObjects.length; i++)
		{
			theObjects[i].style.visibility = action;
		}
	};

	DetectBrowser();
	this.SlideShows = SlideShows;
	this.Show = Show;
	this.Clear_url = Clear_url;
};

/**
* If you don't find a better way, this may have to be a job for ScrollFreeze.
* Code from - http://bytes.com/forum/thread498334.html
**/
ScrollFreeze = /*2843293230303620532E4368616C6D657273*/
{
	propFlag : true,
	Ydisp : 0,
	Xdisp : 0,

	on : function()
	{
		if(this.getProp())
		{
			window.onscroll=function(){ ScrollFreeze.setXY(); }
		}
	},

	off : function(){window.onscroll=null;},

	getProp : function()
	{
		if( typeof window.pageYOffset != 'undefined' )
		{
			this.Ydisp=window.pageYOffset;
			this.Xdisp=window.pageXOffset;
		}
		else if(document.documentElement)
		{
			this.Ydisp=document.documentElement.scrollTop;
			this.Xdisp=document.documentElement.scrollLeft;
		}
		else if(document.body && typeof document.body.scrollTop != 'undefined')
		{
			this.Ydisp=document.body.scrollTop;
			this.Xdisp=document.body.scrollLeft;
		}
		else
		{
			this.propFlag=false;
		}
		return this.propFlag;
	},

	setXY : function()
	{
		window.scrollTo( this.Xdisp, this.Ydisp );
	}
}

/**
* Add a new value to an Array if isn't repeat
**/
function ArrayPush( arr, val )
{
	val = AdvancedBox.Clear_url( val )
	/** have this array this value ? **/
	var found = contains( val, arr );

	if( !found[0] )
	{
		arr[arr.length] = val;
	}
}

/**
* Search in array
* Returns (true and number ) if 'v' is contained in the array 'a'
**/
function contains( v, a )
{
	for( var j=0; j<a.length; j++ )
	{
		if( a[j] == v )
		{
			return new Array( true, j );
		}
	}
	return new Array( false, 0 );
}
/** AdvancedBox JS - End **/

/**
* Image Resizer JS - START
* Code from : http://www.silkroadforums.com/viewtopic.php?f=9&t=81182&view=previous
* eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('6.r=\'1e\';6.C=\'1f\';d 6(a,b){5.i=a;5.7=b;5.e=0;5.f=0;5.g=u;5.j=u;b.i=6.r+a};6.U=d(){D a=1;1g(c.L(6.r+a)!=u){a++}v a};6.1h=d(a){6.V=1i;6.W=1j;6.l=1k;6.m=1l;6.X=1m;6.Y=1n;6.Z=1o;6.10=1p;D b=M;h(a.i&&a.i.1q(6.r)==0&&c.L(6.C+a.i.11(6.r.N))!=u){w=a.i.11(6.r.N);9=12 6(w,a);b=O;9.13()}P{w=6.U();9=12 6(w,a)}h(9.e==0)9.e=a.8;h(9.f==0)9.f=a.n;h((6.l>0&&9.e>6.l)||(6.m>0&&9.f>6.m)){h(b){9.14(5.g)}P{9.15()}9.E()}};6.x.13=d(){D a=c.o(\'17\');a.p=5.7.p;5.7.8=a.8;5.7.n=a.n};6.x.14=d(){D a=c.L(6.C+w);5.g=a;5.j=a.Q.Q.1r[1].Q;5.g.F=5;5.E()};6.x.15=d(){k=c.o(\'1s\');R=c.o(\'1t\');G=c.o(\'1u\');y=c.o(\'18\');z=c.o(\'18\');q=c.o(\'17\');H=c.1v(\'\');q.p=6.W;q.8=16;q.n=16;q.1w=\'\';q.1x=0;y.8=1y;y.I=\'1z\';z.1A=\'1B\';z.I=\'1C\';k.I=\'1D\';k.1E=H;k.F=5;k.i=6.C+5.i;y.t(q);z.t(H);G.t(y);G.t(z);R.t(G);k.t(R);5.7.1F.1G(k,5.7);5.g=k;5.j=H;1H(S.1I,5.7.p)};6.x.E=d(){h(6.l>0&&5.e>6.l){19=O;5.7.8=6.l;5.7.n=(6.l/5.e)*5.f}h(6.m>0&&5.f>6.m){19=O;5.7.n=6.m;5.7.8=(6.m/5.f)*5.e}5.g.8=5.7.8;5.g.1a=d(){v 5.F.1b()};h(5.7.T&&5.7.T>0){5.j.A=6.Z.B(\'%1$s\',5.e).B(\'%2$s\',5.f).B(\'%3$s\',1J.1K(5.7.T/1L))}P{5.j.A=6.10.B(\'%1$s\',5.e).B(\'%2$s\',5.f)}h((5.j.A.N)*4.4>5.7.8){5.j.A=6.X}v M};6.x.1b=d(){1M(6.V){J\'S\':S.1N(5.7.p);K;1O:J\'1P\':1c.1d(5.7.p,\'1Q\');K;J\'1R\':1c.1d(5.7.p,\'1S\');K;J\'1T\':5.7.8=5.e;5.7.n=5.f;5.7.I=\'1U\';h(5.g!=u){5.j.A=6.Y;5.g.8=5.7.8;5.g.1a=d(){v 5.F.E()}}K}v M};',62,119,'|||||this|NcodeImageResizer|img|width|resizer|||document|function|originalWidth|originalHeight|warning|if|id|warningTextNode|mtable|MaxWidth|MaxHeight|height|createElement|src|mimg|IMAGE_ID_BASE||appendChild|null|return|newid|prototype|mtd1|mtd2|data|replace|WARNING_ID_BASE|var|scale|resize|mtr|mtext|className|case|break|getElementById|false|length|true|else|firstChild|mtbody|AdvancedBox|fileSize|getNextId|mode|WarningImage|warning_small|warning_fullsize|warning_filesize|warning_no_filesize|substr|new|restoreImage|reclaimWarning|createWarning||IMG|TD|resized|onclick|unScale|window|open|ncode_imageresizer_container_|ncode_imageresizer_warning_|while|createOn|ImageResizerMode|ImageResizerWarningImage|ImageResizerMaxWidth|ImageResizerMaxHeight|ImageResizerWarningSmall|ImageResizerWarningFullsize|ImageResizerWarningFilesize|ImageResizerWarningNoFilesize|indexOf|childNodes|TABLE|TBODY|TR|createTextNode|alt|border|20|td1|unselectable|on|td2|ncode_imageresizer_warning|textNode|parentNode|insertBefore|ArrayPush|SlideShows|Math|round|1024|switch|Show|default|newwindow|_blank|samewindow|_self|enlarge|ncode_imageresizer_original'.split('|'),0,{}))
**/
NcodeImageResizer.IMAGE_ID_BASE = 'ncode_imageresizer_container_';
NcodeImageResizer.WARNING_ID_BASE = 'ncode_imageresizer_warning_';

function NcodeImageResizer(id, img)
{
	this.id = id;
	this.img = img;
	this.originalWidth = 0;
	this.originalHeight = 0;
	this.warning = null;
	this.warningTextNode = null;

	img.id = NcodeImageResizer.IMAGE_ID_BASE + id;
};

NcodeImageResizer.getNextId = function()
{
	var id = 1;
	while (document.getElementById(NcodeImageResizer.IMAGE_ID_BASE + id) != null)
	{
		id++;
	}
	return id;
};

NcodeImageResizer.createOn = function(img)
{
	NcodeImageResizer.mode					= ImageResizerMode;
	NcodeImageResizer.WarningImage			= ImageResizerWarningImage;
	NcodeImageResizer.MaxWidth				= ImageResizerMaxWidth;
	NcodeImageResizer.MaxHeight				= ImageResizerMaxHeight;
	NcodeImageResizer.warning_small			= ImageResizerWarningSmall;
	NcodeImageResizer.warning_fullsize		= ImageResizerWarningFullsize;
	NcodeImageResizer.warning_filesize		= ImageResizerWarningFilesize;
	NcodeImageResizer.warning_no_filesize	= ImageResizerWarningNoFilesize;

	var isRecovery = false;
	/** if this is a recovery from QuickEdit, which only restores the HTML, not the OO structure **/
	if (img.id && img.id.indexOf(NcodeImageResizer.IMAGE_ID_BASE) == 0 && document.getElementById(NcodeImageResizer.WARNING_ID_BASE + img.id.substr(NcodeImageResizer.IMAGE_ID_BASE.length)) != null)
	{
		newid = img.id.substr(NcodeImageResizer.IMAGE_ID_BASE.length);
		resizer = new NcodeImageResizer(newid, img);
		isRecovery = true;
		resizer.restoreImage();
	}
	else
	{
		newid = NcodeImageResizer.getNextId();
		resizer = new NcodeImageResizer(newid, img);
	}

	if (resizer.originalWidth == 0) resizer.originalWidth = img.width;
	if (resizer.originalHeight == 0) resizer.originalHeight = img.height;

	if ((NcodeImageResizer.MaxWidth > 0 && resizer.originalWidth > NcodeImageResizer.MaxWidth) || (NcodeImageResizer.MaxHeight > 0 && resizer.originalHeight > NcodeImageResizer.MaxHeight))
	{
		if (isRecovery)
		{
			resizer.reclaimWarning(this.warning);
		}
		else
		{
			resizer.createWarning();
		}
		resizer.scale();
	}
};

NcodeImageResizer.prototype.restoreImage = function()
{
	var newimg = document.createElement('IMG');
	newimg.src = this.img.src;
	this.img.width = newimg.width;
	this.img.height = newimg.height;
};

NcodeImageResizer.prototype.reclaimWarning = function()
{
	var warning = document.getElementById(NcodeImageResizer.WARNING_ID_BASE + newid);

	this.warning = warning;
	this.warningTextNode = warning.firstChild.firstChild.childNodes[1].firstChild;
	this.warning.resize = this;
	this.scale();
};

NcodeImageResizer.prototype.createWarning = function()
{
	mtable = document.createElement('TABLE');
	mtbody = document.createElement('TBODY');
	mtr = document.createElement('TR');
	mtd1 = document.createElement('TD');
	mtd2 = document.createElement('TD');
	mimg = document.createElement('IMG');
	mtext = document.createTextNode('');

	mimg.src = NcodeImageResizer.WarningImage;
	mimg.width = 16;
	mimg.height = 16;
	mimg.alt = '';
	mimg.border = 0;

	mtd1.width = 20;
	mtd1.className = 'td1';

	mtd2.unselectable = 'on';
	mtd2.className = 'td2';

	mtable.className = 'ncode_imageresizer_warning';
	mtable.textNode = mtext;
	mtable.resize = this;
	mtable.id = NcodeImageResizer.WARNING_ID_BASE + this.id;

	mtd1.appendChild(mimg);
	mtd2.appendChild(mtext);		
	mtr.appendChild(mtd1);
	mtr.appendChild(mtd2);
	mtbody.appendChild(mtr);
	mtable.appendChild(mtbody);

	this.img.parentNode.insertBefore(mtable, this.img);

	this.warning = mtable;
	this.warningTextNode = mtext;
	
	ArrayPush(AdvancedBox.SlideShows , this.img.src);

};

NcodeImageResizer.prototype.scale = function()
{
	if (NcodeImageResizer.MaxHeight > 0 && this.originalHeight > NcodeImageResizer.MaxHeight)
	{
		resized = true;
		this.img.height = NcodeImageResizer.MaxHeight;
		this.img.width = (NcodeImageResizer.MaxHeight / this.originalHeight) * this.originalWidth;
	}
	if (NcodeImageResizer.MaxWidth > 0 && this.originalWidth > NcodeImageResizer.MaxWidth)
	{
		resized = true;
		this.img.width = NcodeImageResizer.MaxWidth;
		this.img.height = (NcodeImageResizer.MaxWidth / this.originalWidth) * this.originalHeight;
	}

	this.warning.width = this.img.width;
	this.warning.onclick = function()
	{
		return this.resize.unScale();
	};

	if (this.img.fileSize && this.img.fileSize > 0)
	{
		this.warningTextNode.data = NcodeImageResizer.warning_filesize.replace('%1$s', this.originalWidth).replace('%2$s', this.originalHeight).replace('%3$s', Math.round(this.img.fileSize / 1024));
	}
	else
	{
		this.warningTextNode.data = NcodeImageResizer.warning_no_filesize.replace('%1$s', this.originalWidth).replace('%2$s', this.originalHeight);
	}

	if ( (this.warningTextNode.data.length)*4.4 > this.img.width  )
	{
		this.warningTextNode.data = NcodeImageResizer.warning_small;
	}

	return false;
};

NcodeImageResizer.prototype.unScale = function()
{
	switch (NcodeImageResizer.mode)
	{
		case 'AdvancedBox' :
			AdvancedBox.Show(this.img.src);
			break;
		default:
		case 'newwindow':
			window.open(this.img.src, '_blank');
			break;
		case 'samewindow':
			window.open(this.img.src, '_self');
			break;
		case 'enlarge':
			this.img.width = this.originalWidth;
			this.img.height = this.originalHeight;
			this.img.className = 'ncode_imageresizer_original';
			if (this.warning != null)
			{
				this.warningTextNode.data = NcodeImageResizer.warning_fullsize;
				this.warning.width = this.img.width;
				this.warning.onclick = function()
				{
					return this.resize.scale();
				};
			}
			break;
	}
	return false;
};
/** Image Resizer JS - END **/

/**
*
**/
function ImgOnLoad()
{
	/** Get all images inside posts **/
	var posted_images_ary = new Array();

	/** Subsilver2 styles **/
	if ( document.getElementById("pagecontent") )
	{
		posted_images_ary = document.getElementById("pagecontent").getElementsByTagName("img");
	}
	/** ProSilver styles **/
	if ( document.getElementById("page-body") )
	{
		posted_images_ary = document.getElementById("page-body").getElementsByTagName("img");
	}

	for (var pia = 0; pia < posted_images_ary.length; pia++)
	{
		var GetParent = false;
		var img = posted_images_ary[pia];

		if ( img.className.match(/(^|\s)hoverbox(\s|$)/) /** ABBC3 thumbnail **/
//		  || img.parentNode.className.match(/(^|\s)attach-image(\s|$)/) /** prosilver style attach - image **/
		  || img.parentNode.parentNode.parentNode.className.match(/(^|\s)thumbnail(\s|$)/) /** prosilver attach - thumbnail **/
//		  || img.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.className.match(/(^|\s)attachtitle(\s|$)/) /** subsilver2 attach - image **/
		  || img.parentNode.parentNode.className.match(/(^|\s)attachcontent(\s|$)/) /** subsilver2 attach - thumbnail **/
		  || ( img.parentNode.parentNode.className.match(/(^|\s)row[\d](\s|$)/) && img.parentNode.parentNode.parentNode.parentNode.parentNode.className.match(/(^|\s)tablebg(\s|$)/) ) /** subsilver2 in-line attach **/
		)
		{
			if ( img.parentNode.parentNode.parentNode.className.match(/(^|\s)thumbnail(\s|$)/)
			||   img.parentNode.parentNode.className.match(/(^|\s)attachcontent(\s|$)/)
			|| ( img.parentNode.parentNode.className.match(/(^|\s)row[\d](\s|$)/) && img.parentNode.parentNode.parentNode.parentNode.parentNode.className.match(/(^|\s)tablebg(\s|$)/) )
			)
			{
				GetParent = true;
			}

			switch (ImageResizerMode)
			{
				case 'AdvancedBox' :
					if ( !GetParent )
					{
						ArrayPush(AdvancedBox.SlideShows , img.src);
						img.onclick = function() {AdvancedBox.Show(this.src); return false;}
					}
					else
					{
						ArrayPush(AdvancedBox.SlideShows , img.parentNode.href);
						img.onclick = function() {AdvancedBox.Show(this.parentNode.href); return false;}
					}
					break;
				default:
				case 'newwindow':
					img.onclick = function() {window.open(this.src, '_blank'); return false;}
					break;
				case 'samewindow':
					img.onclick = function() {window.open(this.src, '_self'); return false;}
					break;
				case 'enlarge':
					img.onclick = function() {ImgOnLoad_unScale(this); return false;}
					break;
			}
		}
		else
		{
			if ( (ImageResizerMaxWidth > 0 || ImageResizerMaxHeight > 0) && (img.width > ImageResizerMaxWidth || img.height > ImageResizerMaxHeight) )
			{
				NcodeImageResizer.createOn(img);
			}
		}
	}
}

function ImgOnLoad_unScale(img)
{
	var new_img = new Image();
	new_img.setAttribute('src', img.src); // new_img.src = img.src;
	img.setAttribute('width', new_img.width);
	img.onclick = function() { ImgOnLoad_scale(img); return false;}
}

function ImgOnLoad_scale(img)
{
	img.setAttribute('width', (img.className.match(/(^|\s)hoverbox(\s|$)/) ? ImageResizerThumbnails : ImageResizerThumbnailsPhpbb) );
	img.onclick = function() { ImgOnLoad_unScale(img); return false;}
}

/**
* Install the safety net to catch any images that were somehow not resized - START
**/
if (window.onload_functions) // prosilver
{
	onload_functions[onload_functions.length] = "ImgOnLoad();";
}
else if (typeof(window.addEventListener) != "undefined") // DOM
{
	window.addEventListener("load", ImgOnLoad, false);
}
else if (typeof(window.attachEvent) != "undefined") // MSIE
{
	window.attachEvent("onload", ImgOnLoad);
}
/** Install the safety net to catch any images that were somehow not resized - END **/

// ]]>
