var config={debug:false};function log(A){if(config.debug){(typeof console!="undefined"&&typeof console.log!="undefined")?console.log(A):alert(A)}}function ImagePreloader(A,C){this.call_back=C;this.nLoaded=0;this.nProcessed=0;this.aImages=new Array;this.nImages=A.length;for(var B=0;B<A.length;B++){this.preload(A[B])}}ImagePreloader.prototype.preload=function(B){var A=new Image;this.aImages.push(A);A.onload=ImagePreloader.prototype.onload;A.onerror=ImagePreloader.prototype.onerror;A.onabort=ImagePreloader.prototype.onabort;A.oImagePreloader=this;A.bLoaded=false;A.src=B;log(B)};ImagePreloader.prototype.onComplete=function(){this.nProcessed++;if(this.nProcessed==this.nImages){this.call_back(this.aImages,this.nLoaded)}};ImagePreloader.prototype.onload=function(){this.bLoaded=true;this.oImagePreloader.nLoaded++;this.oImagePreloader.onComplete()};ImagePreloader.prototype.onerror=function(){this.bError=true;this.oImagePreloader.onComplete()};ImagePreloader.prototype.onabort=function(){this.bAbort=true;this.oImagePreloader.onComplete()};if(!Array.prototype.indexOf){Array.prototype.indexOf=function(B){var A=this.length,C=Number(arguments[1])||0;C=(C<0)?Math.ceil(C):Math.floor(C);if(C<0){C+=A}for(;C<A;C++){if(C in this&&this[C]===B){return C}}return -1}}var $extend=function(){var A=arguments,B;if(!A[1]){A=[this,A[0]]}for(B in A[1]){A[0][B]=A[1][B]}return A[0]};function $(A){return document.getElementById(A)}function $$(A){return document.getElementsByTagName(A)}function $$$(B,H){var D=new Array(),A=$$(B),F,G,C,E;for(F=0;F<A.length;F++){G=A[F];E=G.className.split(" ");for(C=0;C<E.length;C++){if(E[C]==H){D.push(G)}}}return D}function defined(A){return(A!=undefined)}function show(A){A.style.display=""}function hide(A){A.style.display="none"}function size(A){return{width:A.clientWidth,height:A.clientHeight}}function hasClass(C,B){var A;if(C.className!=undefined){A=C.className.indexOf(B)!=-1}else{A=false}return A}function addClass(B,A){if(!hasClass(B,A)){if(B.className!=undefined){B.className=(B.className+" "+A).replace(/\s+/," ")}else{B.className=A}}}function removeClass(B,A){B.className=B.className.replace(new RegExp("(^|\\s)"+A+"(?:\\s|$)"),"$1")}function addEvent(C,D,B,A){A=(A)?A:false;if(C.addEventListener){C.addEventListener(D,B,A)}else{if(C.attachEvent){C.attachEvent("on"+D,B)}else{C["on"+D]=B}}}function removeEvent(C,D,B,A){A=(A)?A:false;if(C.removeEventListener){C.removeEventListener(D,B,A)}else{if(C.attachEvent){C.detachEvent("on"+D,B)}else{C["on"+D]=null}}}function addOnLoadEvent(A){if(window.addEventListener||window.attachEvent){addEvent(window,"load",A,false)}else{var B=(window.onload)?window.onload:function(){};window.onload=function(){B();A()}}}function pos(A){var B=curtop=0;if(A.offsetParent){B=A.offsetLeft;curtop=A.offsetTop;while(A=A.offsetParent){B+=A.offsetLeft;curtop+=A.offsetTop}}return{left:B,top:curtop}}function Tabs(A,D,H,I){var F=document.getElementById(A).getElementsByTagName("a"),B=[],G,C=[],E;for(G=0;G<F.length;G++){B.push(F[G])}for(G=0;G<B.length;G++){C.push(document.getElementById(B[G].href.split("#")[1]))}E=function(){var J=B.indexOf(this),L=C[J],K;for(K=0;K<C.length;K++){C[K].style.display="none";element=B[K];while(element.nodeName.toLowerCase()!="li"){element=element.parentNode}klasa=element.className;if(klasa.indexOf("active")!=-1){if(klasa!=""){element.className=klasa.split("active")[0]+" "+klasa.split("active")[1]}else{element.className=""}}}L.style.display="block";element=this;while(element.nodeName.toLowerCase()!="li"){element=element.parentNode}element.className+=" active";if(H&&J==D){H()}if(I&&J!=D){I()}};for(G=0;G<B.length;G++){B[G].onclick=E;B[G].href="javascript:void(0)"}B[D].onclick();return{togglers:B,tabs:C}}function hash_merge(B,A){for(p in A){(typeof A[p]=="object"&&B[p])?hash_merge(B[p],A[p]):B[p]=A[p]}}Array.prototype.each=function(B){var A;for(A=0;A<this.length;A++){log("taking care of element: "+this[A]);B(this[A],A)}};Array.prototype.collect=function(B){var A;for(A=0;A<this.length;A++){this[A]=B(this[A])}};Array.prototype.include=function(B){var A;for(A=0;A<this.length;A++){if(this[A]==B){return true}}return false};if(!Array.indexOf){Array.prototype.indexOf=function(B){var A;for(A=0;A<this.length;A++){if(this[A]==B){return A}}return -1}}function getElements(C){var B,A=[];for(B=0;B<C.length;B++){A.push(C[B])}return A}function serialize(B){var E="",D,C,A;switch(typeof B){case"number":case"boolean":case"function":return B;break;case"string":return"'"+B+"'";break;case"object":if(B.constructor===Array||typeof B.callee!=="undefined"||B.constructor.toString().indexOf("Array")!=-1){E="[";A=B.length;for(C=0;C<A-1;C++){E+=serialize(B[C])+","}E+=serialize(B[C])+"]"}else{E="{";for(D in B){E+=D+":"+serialize(B[D])+","}E=E.replace(/\,$/,"")+"}"}return E;break;default:return"unknown";break}}function watchProperty(prop,func){var old_value=eval(prop),new_value;setInterval(function(){new_value=eval(prop);if(new_value!=old_value){func(old_value,new_value);old_value=new_value}},50)}function getCSSRule(D,F){D=D.toLowerCase();if(document.styleSheets){for(var B=0;B<document.styleSheets.length;B++){var E=document.styleSheets[B];var C=0;var A=false;do{if(E.cssRules){A=E.cssRules[C]}else{A=E.rules[C]}if(A){if(A.selectorText.toLowerCase()==D){if(F=="delete"){if(E.cssRules){E.deleteRule(C)}else{E.removeRule(C)}return true}else{return A}}}C++}while(A)}}return false}function killCSSRule(A){return getCSSRule(A,"delete")}function addCSSRule(A){if(document.styleSheets){if(!getCSSRule(A)){if(document.styleSheets[((arguments[1]&&arguments[1]<document.styleSheets.length)?arguments[1]:document.styleSheets.length-1)].addRule){document.styleSheets[((arguments[1]&&arguments[1]<document.styleSheets.length)?arguments[1]:document.styleSheets.length-1)].addRule(A,null,0)}else{document.styleSheets[((arguments[1]&&arguments[1]<document.styleSheets.length)?arguments[1]:document.styleSheets.length-1)].insertRule(A+" { }",0)}}}return getCSSRule(A)}function resizePhoto(C,D,A,B){if(typeof B=="undefined"){B={}}if(typeof B.shrink=="undefined"){B.shrink=true}if(typeof B.enlarge=="undefined"){B.enlarge=false}if((B.shrink&&(C.width>D||C.height>A))||(B.enlarge&&(C.width<D||C.height<A))){if(C.height!=0&&A!=0&&((C.width/C.height)>(D/A))){C.removeAttribute("height");C.width=D}else{C.removeAttribute("width");C.height=A}}}function Gallery(){var gallery=this,html;this.config={target_div:"gallery",images_path:"images",type:"small",active:0,gallery:{small:{image_size:{width:400,height:300},size:{width:420,height:0},cache:"all"},large:{image_size:{width:1024,height:768},size:{width:0,height:0},photo:{enlarge:false,shrink:true,center:false,click_closes:true},cache:1,same_window:false,overlay:true}}};if(typeof arguments[0]=="object"){hash_merge(gallery.config,arguments[0])}this.images_count=gallery.config.pictures.small.length;this.target=$(gallery.config.target_div);this.cache={};for(size in gallery.config.pictures){gallery.cache[size]=[]}["small","large"].each(function(x){if(typeof gallery.config.gallery[x]["cache"]!="number"||gallery.config.gallery[x]["cache"]>gallery.images_count){gallery.config.gallery[x]["cache"]=gallery.images_count}});css={small:[{selector:"#gallery-thumbs li",rules:{cssFloat:"left",styleFloat:"left",margin:"2px",padding:"0",fontSize:"0px"}},{selector:"#gallery-thumbs li a",rules:{margin:"0",display:"block",padding:"2px",outline:"none",background:"#fff url("+gallery.config.images_path+"/thumb-bg.gif) no-repeat 0 0"}},{selector:"#gallery-thumbs li a:hover",rules:{backgroundColor:"#999"}},{selector:"#gallery-thumbs li.active a",rules:{backgroundColor:"#000"}}]};html={small:'\n<div id="gallery" style="width: '+gallery.config.gallery.small.size.width+'px;margin: 20px auto;padding:20px 0 20px 0;position: relative; background: #fff;border: 1px #ccc solid">\n  <div id="gallery-container" style="text-align: center;padding: 0; margin: 0; height: 310px">\n    <img id="gallery-photo" style="margin: 0 auto; cursor: pointer"/>\n  </div>\n  <div id="gallery-thumbs-container" style="height: 100px;padding: 0;margin: 0">\n    <ul id="gallery-thumbs" style="list-style: none;padding: 0;margin: 20px 0 0 0; float: left; display: inline; margin-left:32px"><THUMBS></ul>\n  </div>\n	<div style="clear:both"></div>\n</div>\n',large:'\n<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\n  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n<html>\n<head>\n<script src="/js/all-ui-min.js" type="text/javascript" charset="utf-8"><\/script>\n<style type="text/css" media="screen">\n	body {background: #111; margin: 0; padding: 0; height: 100%}\n	#gallery {text-align: center}\n	#gallery-photo-container {text-align: center; margin-top: 10px}\n	#gallery-photo {border: 10px #fff solid}\n	#gallery-overlay {position:absolute;visibility:hidden;background:#000;width:100%;height:100%;opacity: 0.4;filter: alpha(opacity = 40);z-index:1001}\n	#gallery-thumbs {float:left; margin:0; padding:0 0 0 10px; list-style:none;height: 70px}\n	#gallery-thumbs li {float: left;}\n	#gallery-thumbs li a {margin: 0 2px; display: block; padding: 2px; outline: none; background: #fff url('+gallery.config.images_path+'/thumb-bg.gif) no-repeat 0 0}\n	#gallery-thumbs li a img { display:block }\n	#gallery-thumbs li a:hover {background-color: #999}\n	#gallery-thumbs li.active a {background-color: #000}\n	#gallery-thumbs.spinner {}\n</style>\n</head>\n<body onload="var gallery = new Gallery(<GALLERY-CONFIG>)">\n	<div id="gallery-overlay"></div>\n	<div id="gallery">\n		<div id="gallery-navbar" style="overflow: hidden; background: #fff;padding: 4px 0 4px 5px;border-bottom: 2px #333 solid;margin:0;height: 70px">\n			<img style="float:left" src="'+gallery.config.logo+'" />\n			<ul id="gallery-thumbs" class="spinner"></ul>\n		</div>\n		<div style="clear:both"></div>\n		<div id="gallery-photo-container">\n			<img id="gallery-photo" style="cursor:pointer" />\n		</div>\n	</div>\n</body>\n</html>\n'};this.popupLargeGallery=function(){var g,window_name,width,height,tmp={};gallery.config.gallery.large.size.width==0?width=window.screen.availWidth:width=gallery.config.gallery.large.size.width;gallery.config.gallery.large.size.height==0?height=window.screen.availHeight:height=gallery.config.gallery.large.size.height;gallery.config.gallery.large.same_window?window_name="GalleryWindow":window_name=Math.random().toString().replace(".","");g=window.open("",window_name,"width="+width+",height="+height+",left=0,top=0,resizable=yes");hash_merge(tmp,gallery.config);hash_merge(tmp,{type:"large"});g.document.write(html.large.replace("<GALLERY-CONFIG>",serialize(tmp)));g.document.title="Allegro - Galeria";g.document.close()};this.initGallery=function(){var lis,thumbs="";new ImagePreloader(gallery.config.pictures.small,function(){gallery.config.pictures.small.each(function(x,i){gallery.cache.small[i]=true})});if(gallery.images_count>1){gallery.config.pictures.small.each(function(pic){thumbs+='<li><a href="#"><img style="width:80px;height:60px;border:none" src="'+pic+'" /></a></li>\n'})}if(gallery.config.type=="small"){$(gallery.config.target_div).innerHTML=html.small.replace("<THUMBS>",thumbs);if(gallery.images_count<2){$("gallery-thumbs-container").style.height=0}$("gallery-photo").onclick=function(){gallery.popupLargeGallery()}}else{$("gallery-thumbs").innerHTML=thumbs;$("gallery-photo").onclick=function(){window.close()}}getElements($("gallery-thumbs").getElementsByTagName("li")).each(function(li,i){if(i==gallery.config.active){addClass(li,"active")}li.onclick=function(){gallery.showPhoto(i);return false}});this.watchOutFor("gallery.config.active",function(){var lis=$("gallery-thumbs").getElementsByTagName("li");removeClass(lis[arguments[0]],"active");addClass(lis[arguments[1]],"active")});gallery.showPhoto(gallery.config.active)};this.showPhoto=function(id){if(gallery.config.pictures.medium&&gallery.config.pictures.medium.length>0&&gallery.config.type=="small"){gallery.showImage("medium",id,$("gallery-photo"),function(){resizePhoto($("gallery-photo"),gallery.config.gallery.small.image_size.width,gallery.config.gallery.small.image_size.height)})}else{gallery.showImage("large",id,$("gallery-photo"))}gallery.config.active=id};this.showImage=function(size,img_no,el){var funkcja;(arguments.length==4&&typeof (arguments[3])=="function")?funkcja=arguments[3]:funkcja=false;if(gallery.cache[size][img_no]){if(el){el.src=gallery.config.pictures[size][img_no]}if(funkcja){funkcja()}}else{if(gallery.config.type=="large"){if(gallery.config.gallery.large.overlay){$("gallery-overlay").style.visibility="visible"}addClass($("gallery-thumbs"),"spinner")}new ImagePreloader([gallery.config.pictures[size][img_no]],function(){var i;gallery.cache[size][img_no]=true;if(el){el.src=gallery.config.pictures[size][img_no]}if(funkcja){funkcja()}if(gallery.config.type=="large"){if(gallery.config.gallery.large.overlay){$("gallery-overlay").style.visibility="hidden"}removeClass($("gallery-thumbs"),"spinner")}})}};this.watchOutFor=function(prop,func){var old_value=eval(prop),new_value;setInterval(function(){new_value=eval(prop);if(new_value!=old_value){func(old_value,new_value);old_value=new_value}},50)};gallery.initGallery()};
