var $=function(id){return document.getElementById(id);};if(typeof(Element)!=='undefined'){Element.prototype.hasClassName=function(cls){if(this.className){var classes=this.className.split(' ');for(var i=0;i<classes.length;i++){if(classes[i]==cls){return true;}}}
return false;}};var Utils={setCookie:function(name,value,days){days=days||365;var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();document.cookie=name+"="+value+expires+"; path=/";},getCookie:function(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' '){c=c.substring(1,c.length);}
if(c.indexOf(nameEQ)==0){return c.substring(nameEQ.length,c.length);}}
return null;},addEvent:function(obj,type,fn){if(obj.addEventListener){obj.addEventListener(type,fn,false);}else if(obj.attachEvent){obj["e"+type+fn]=fn;obj[type+fn]=function(){obj["e"+type+fn](window.event);}
obj.attachEvent("on"+type,obj[type+fn]);}},getRealMousePosition:function(e){var posx=0;var posy=0;if(!e){e=window.event;}
if(e.pageX||e.pageY){posx=e.pageX;posy=e.pageY;}else if(e.clientX||e.clientY){posx=e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;posy=e.clientY+document.body.scrollTop+document.documentElement.scrollTop;}
return[posx,posy];},Ajax:function(url,params,callbackFn,method){var thisRequestObject;thisRequestObject=initiateRequest();thisRequestObject.onreadystatechange=processRequest;function initiateRequest(){if(window.XMLHttpRequest){return new XMLHttpRequest();}else if(window.ActiveXObject){return new ActiveXObject("Microsoft.XMLHTTP");}}
function processRequest(){if(thisRequestObject.readyState==4){if(thisRequestObject.status==200){if(callbackFn){callbackFn(thisRequestObject,params);}}else{}}}
this.send=function(){method=method||'post';if(method.toLowerCase()=='get'){this.sendGetData();}else{this.sendPostData();}}
this.sendGetData=function(){if(url){thisRequestObject.open("GET",url,true);thisRequestObject.send(params);}}
this.sendPostData=function(){if(url){thisRequestObject.open("POST",url,true);thisRequestObject.setRequestHeader("Content-Type","application/x-www-form-urlencoded");thisRequestObject.send(params);}}}}
var CatalogTree={tree:null,active:[],zoomWrapper:null,zoomContainer:null,imageZoomed:false,scrollAllowed:true,init:function(){CatalogTree.tree=document.getElementById('catalog-tree');var lis=CatalogTree.tree.getElementsByTagName('li');for(var i=0;i<lis.length;i++){if(lis[i].className=='active'){CatalogTree.active.push(lis[i]);}}
CatalogTree.zoomContainer=document.createElement('div');CatalogTree.zoomContainer.id='zoomContainer';CatalogTree.zoomWrapper=document.createElement('div');CatalogTree.zoomWrapper.id='zoomWrapper';document.body.appendChild(CatalogTree.zoomContainer);document.body.appendChild(CatalogTree.zoomWrapper)
Utils.addEvent(document,'click',CatalogTree.onDocumentClick);if(window.addEventListener){window.addEventListener('DOMMouseScroll',CatalogTree.onMouseWheel,false);}
window.onmousewheel=document.onmousewheel=CatalogTree.onMouseWheel;},onMouseWheel:function(e){if(!CatalogTree.scrollAllowed){if(window.addEventListener){e.stopPropagation();e.preventDefault();}
return false;}
return true;},onDocumentClick:function(event){event=event||window.event;var target=event.target||event.srcElement;if(CatalogTree.imageZoomed){CatalogTree.zoomWrapper.style.display='none';CatalogTree.zoomContainer.style.display='none';CatalogTree.scrollAllowed=true;CatalogTree.imageZoomed=false;}},display:function(el){var uls=el.parentNode.getElementsByTagName('ul');if(uls.length>0){if(uls[0].style.display!='none'){uls[0].style.display='none';}else{uls[0].style.display='';}
return false;}
return true;},removeActive:function(){for(var i=0;i<CatalogTree.active.length;i++){CatalogTree.active[i].className='';}
CatalogTree.active=[];},setActive:function(el){var li=el.parentNode;while(li.tagName.toLowerCase()=='li'){li.className='active';CatalogTree.active.push(li);li=li.parentNode.parentNode;}},getData:function(el){document.getElementById('catalog-data').innerHTML='<p>'+el.innerHTML.replace(/^. /,'')+'</p>';}}
Utils.addEvent(window,'load',CatalogTree.init);
var thumbnailviewer={enableTitle:false,enableAnimation:true,definefooter:'<div class="footerbar">UŽDARYTI X</div>',defineLoading:'<img src="/media/images/loading.gif" /> Kraunamas paveiksliukas...',scrollbarwidth:16,opacitystring:'filter:progid:DXImageTransform.Microsoft.alpha(opacity=10); -moz-opacity: 0.1; opacity: 0.1',targetlinks:[],createthumbBox:function(){document.write('<div id="thumbBox" onClick="thumbnailviewer.closeit()"><div id="thumbImage"></div>'+this.definefooter+'</div>')
document.write('<div id="thumbLoading">'+this.defineLoading+'</div>')
this.thumbBox=document.getElementById("thumbBox")
this.thumbImage=document.getElementById("thumbImage")
this.thumbLoading=document.getElementById("thumbLoading")
this.standardbody=(document.compatMode=="CSS1Compat")?document.documentElement:document.body},centerDiv:function(divobj){var ie=document.all&&!window.opera
var dom=document.getElementById
var scroll_top=(ie)?this.standardbody.scrollTop:window.pageYOffset
var scroll_left=(ie)?this.standardbody.scrollLeft:window.pageXOffset
var docwidth=(ie)?this.standardbody.clientWidth:window.innerWidth-this.scrollbarwidth
var docheight=(ie)?this.standardbody.clientHeight:window.innerHeight
var docheightcomplete=(this.standardbody.offsetHeight>this.standardbody.scrollHeight)?this.standardbody.offsetHeight:this.standardbody.scrollHeight
var objwidth=divobj.offsetWidth
var objheight=divobj.offsetHeight
var topposition=(docheight>objheight)?scroll_top+docheight/2-objheight/2+"px":scroll_top+10+"px"
divobj.style.left=docwidth/2-objwidth/2+"px"
divobj.style.top=Math.floor(parseInt(topposition))+"px"
divobj.style.visibility="visible"},showthumbBox:function(){thumbnailviewer.thumbLoading.style.visibility="hidden"
this.centerDiv(this.thumbBox)
if(this.enableAnimation){this.currentopacity=0.1
this.opacitytimer=setInterval("thumbnailviewer.opacityanimation()",20)}},loadimage:function(link){if(this.lastSrc==link.getAttribute("href")){this.closeit();this.lastSrc=null;return false;}
var imageHTML='<img src="'+link.getAttribute("href")+'" style="'+this.opacitystring+'" />'
if(this.enableTitle&&link.getAttribute("title"))
imageHTML+='<br />'+link.getAttribute("title")
this.centerDiv(this.thumbLoading)
this.thumbImage.innerHTML=imageHTML
this.featureImage=this.thumbImage.getElementsByTagName("img")[0]
if(this.featureImage.complete)
thumbnailviewer.showthumbBox()
else{this.featureImage.onload=function(){thumbnailviewer.showthumbBox()}}
if(document.all&&!window.createPopup)
this.featureImage.src=link.getAttribute("href")
this.featureImage.onerror=function(){thumbnailviewer.thumbLoading.style.visibility="hidden"}
this.lastSrc=link.getAttribute("href");},setimgopacity:function(value){var targetobject=this.featureImage
if(targetobject.filters&&targetobject.filters[0]){if(typeof targetobject.filters[0].opacity=="number")
targetobject.filters[0].opacity=value*100
else
targetobject.style.filter="alpha(opacity="+value*100+")"}
else
if(typeof targetobject.style.MozOpacity!="undefined")
targetobject.style.MozOpacity=value
else
if(typeof targetobject.style.opacity!="undefined")
targetobject.style.opacity=value
else
this.stopanimation()},opacityanimation:function(){this.setimgopacity(this.currentopacity)
this.currentopacity+=0.1
if(this.currentopacity>1)
this.stopanimation()},stopanimation:function(){if(typeof this.opacitytimer!="undefined")
clearInterval(this.opacitytimer)},closeit:function(){this.stopanimation()
this.thumbBox.style.visibility="hidden"
this.thumbImage.innerHTML=""
this.thumbBox.style.left="-2000px"
this.thumbBox.style.top="-2000px"
this.lastSrc=null;},cleanup:function(){this.thumbLoading=null
if(this.featureImage)
this.featureImage.onload=null
this.featureImage=null
this.thumbImage=null
for(var i=0;i<this.targetlinks.length;i++)
this.targetlinks[i].onclick=null
this.thumbBox=null},dotask:function(target,functionref,tasktype){var tasktype=(window.addEventListener)?tasktype:"on"+tasktype
if(target.addEventListener)
target.addEventListener(tasktype,functionref,false)
else
if(target.attachEvent)
target.attachEvent(tasktype,functionref)},init:function(){if(!this.enableAnimation)
this.opacitystring=""
var pagelinks=document.getElementsByTagName("a")
for(var i=0;i<pagelinks.length;i++){if(pagelinks[i].getAttribute("rel")&&pagelinks[i].getAttribute("rel")=="thumbnail"){pagelinks[i].onclick=function(){thumbnailviewer.stopanimation()
thumbnailviewer.loadimage(this)
return false}
this.targetlinks[this.targetlinks.length]=pagelinks[i]}}
this.dotask(window,function(){if(thumbnailviewer.thumbBox.style.visibility=="visible")
thumbnailviewer.centerDiv(thumbnailviewer.thumbBox)},"resize")}}
thumbnailviewer.createthumbBox()
thumbnailviewer.dotask(window,function(){thumbnailviewer.init()},"load")
thumbnailviewer.dotask(window,function(){thumbnailviewer.cleanup()},"unload")
