///* 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 write_workframe()
{
	document.writeln('<input type="hidden" id="___srz_setia__stat_id">');
}

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

function forms_remake()
{
	for (i=0;i<document.forms.length;i++) {
		if (document.forms[i]['statid']) continue;
		var el=document.createElement('input');
		el.setAttribute('type','hidden');
		el.setAttribute('name','statid');
		el.setAttribute('value',document.getElementById('___srz_setia__stat_id').value);
		document.forms[i].appendChild(el);
	}

}

function set_html(a)
{
	window.location='http://'+window.location.host+'/'+a;
}

document.documentElement.className='jestjs';

function init_menu()
{
	
	function add_onclick(li)
	{
		var ul,a;
		for (ul=li.firstChild;ul;ul=ul.nextSibling) if (ul.nodeName.toLowerCase()=='ul') break;
		if (!ul) return;
		for (a=li.firstChild;a;a=a.nextSibling) if (a.nodeName.toLowerCase()=='a') break;
		if (!a) return;
		a.onclick=function()
		{
			if (!ul) return;
			if (li.className != 'open') {
				li.className='open';
				ul.className='visible';
			}
			else {
				li.className='closed';
				ul.className='';
			}
			return false;
		}
				
	}
	
	var ul=document.getElementById('menuul');
	if (!ul) return;
	var lista,i;
	lista=ul.getElementsByTagName('li');
	for (i=0;i<lista.length;i++) add_onclick(lista[i]);
	var s=document.cookie;
	var n=s.indexOf('lastob=');
	if (n>=0) {
		var obiekt=parseInt(s.substr(n+7));
		if (!isNaN(obiekt) && obiekt>0) {
			var el=document.getElementById('ob_'+obiekt);
			if (el) {
				for (;;) {
					el=el.parentNode;
					if (!el || el == ul) break;
					if (el.nodeName.toLowerCase() == 'li') el.className='open';
					else el.className='visible';
				}
			}
		}	
	}
}

var popupwin;
function openpopup(adr)
{
	if (popupwin) popupwin.close();
	popupwin=window.open(adr,"gallery_popup","width=800,height=600");
	return false;
}
