///* auto image sizer */

function ELIB_init_images()
{
	var ELIB_request;
	var ELIB_image_sizes;
	var ELIB_popup_window;
	
	function xmlh()
	{
		var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
		if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
			xmlhttp = new XMLHttpRequest();
		}
		return xmlhttp;
	}


	
	function ELIB_remake_images()
	{
		try {
			if (ELIB_request.readyState != 4) return;
			eval(ELIB_request.responseText);
			var lista=document.body.getElementsByTagName('a');
			for (i=0;i<lista.length;i++) {
				if (!lista[i].onclick && lista[i].href.match(/\.(jpe?g|png|gif)$/i)) {
					if (ELIB_image_sizes[lista[i].href]) lista[i].onclick=ELIB_click;
				}
			}
			lista=document.body.getElementsByTagName('area');
			for (i=0;i<lista.length;i++) {
				if (!lista[i].onclick && lista[i].href.match(/\.(jpe?g|png|gif)$/i)) {
					if (ELIB_image_sizes[lista[i].href]) lista[i].onclick=ELIB_click;
				}
			}
		}
		catch(e) { 
		}
	}
	
	function ELIB_click()
	{
		try {
			var w=0,h=0;
			var s=ELIB_image_sizes[this.href];
			if (s) {
				w=s.w+30;
				h=s.h+30;
			}
			if (ELIB_popup_window && ELIB_popup_window.close && !ELIB_popup_window.closed) {
				ELIB_popup_window.close();
			}
			
			var misio=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
	misio=true;
@end @*/
			var str="dependent=yes,toolbar=no,resizable=yes";
			if (w && h) {
				var sb=0;
				if (w>screen.availWidth) {w=screen.availWidth;sb=1;}
				if (h>screen.availHeight) {h=screen.availHeight;sb=1;}
				str+=",width="+w+",height="+h;
				if (sb) str+=",scrollbars=yes";
				var x,y;
				x=Math.floor((screen.availWidth-w)/2);
				y=Math.floor((screen.availHeight-h)/2);
				if (x>20) {
					str+=(misio?',left=':',screenX=')+x;
				}
				if (y>20) {
					str+=(misio?',top=':',screenY=')+y;
				}
			}
			ELIB_popup_window=window.open(this.href,"_blank",str);
			if (!ELIB_popup_window) return true;
			var doc=ELIB_popup_window.document;
			doc.open();
			var alt="",title="";
			if (this.alt) alt=this.alt;
			if (this.title) alt=this.title;
			doc.write(
	  			'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">' +
				'<html id="popup">' +
				'<head><head><title>' + title + '</title>' +
				'<meta http-equiv="Content-Type" content="text/html; charset=utf-8">' +
				'<style type="text/css">' +
				'body,html {margin:0px;padding:0px}\n'+
				'p {text-align:center;margin:0px;padding:15px 0 0 0}\n'+
				'img {display:inline}\n'+
				'</style>'+
				'</head><body><p><img src="'+this.href+'" alt="'+alt+'"></p>' +
				'<script type="text/javascript"> document.body.onmouseup = function(e) {var ev = e||event; if ((ev.button||ev.which) < 2) self.close();} ' +
				'</script></body></html>'
				);
			doc.close();
			if (misio) event.returnValue=false;
			return false;
		}
		catch(e) {
			return true;
		}
	}
	try {
		var arr=new Array();
		var i,j,str;
		if (!document.body.getElementsByTagName) return;
		var lista=document.body.getElementsByTagName('a');
		for (i=0;i<lista.length;i++) {
			if (!lista[i].onclick && lista[i].href.match(/\.(jpe?g|png|gif)/i)) {
				for (j=0;j<arr.length;j++) if (arr[j]==lista[i].href) break;
				if (j>=arr.length) arr[j]=lista[i].href;
			}
		}
		lista=document.body.getElementsByTagName('area');
		for (i=0;i<lista.length;i++) {
			if (!lista[i].onclick && lista[i].href.match(/\.(jpe?g|png|gif)/i)) {
				for (j=0;j<arr.length;j++) if (arr[j]==lista[i].href) break;
				if (j>=arr.length) arr[j]=lista[i].href;
			}
		}
		if (!arr.length) return;
		if (!(ELIB_request=xmlh())) return;
		for (i=0;i<arr.length;i++) {
			if (i) str+='&url=';else str='url=';
			try {
				str+=encodeURIComponent(arr[i]);
			}
			catch(e) {
				str+=escape(arr[i]);
			}
		}
		ELIB_request.open("POST","/imgsizer");
		ELIB_request.onreadystatechange=ELIB_remake_images;
		ELIB_request.send(str);
	}
	catch(e) {
	}
}


		
function pager_remake()
{
	ELIB_init_images();
}

function init()
{
    
    if (!document.getElementById) return;
      pager_remake();
      return;
}

(function()
{
	var wonlo=window.onload;
	window.onload=function() {
		init();
		if (wonlo) wonlo();
	}
})();


