function slideShow(){var cOpacity=1,nOpacity=0,current=0,nIndex=1,imgs=[];this.options={step:3000,duration:700,align:['center','middle']};this.ajax=function(xml){var ajax=new ajaxRequest(xml);ajax.callBack(function(data,fnc){var photos=[],tagPhoto=data.responseXML.getElementsByTagName('photo');for(var i=0,l=tagPhoto.length;i<l;i++){photos.push(tagPhoto[i].firstChild.nodeValue);};fnc.setImages(photos);},this)
ajax.get();};this.initialize=function(el,options){this.box=$(el);for(var property in options)this.options[property]=options[property];this.box.position='relative';imgs[0]=$el(this.box,'img')[0];setStyles(imgs[0],{position:'absolute'});};this.setImages=function(photos){for(var i=0,l=photos.length;i<l;i++){imgs[i+1]=addElement('img',{src:photos[i],styles:{display:'none',position:'absolute',opacity:0}});if(this.options.align[0]=='right')imgs[i+1].style.right=0;else imgs[i+1].style.left=0;if(this.options.align[1]=='bottom')imgs[i+1].style.bottom=0;else imgs[i+1].style.top=0;this.box.appendChild(imgs[i+1]);}
this.nextImage(1);};this.nextImage=function(numIm){nIndex=imgs[current+1]?current+1:0;var nextImage=new Image();addEvent(nextImage,'load',function(event,fnc){fnc.play(numIm);},this);nextImage.src=imgs[numIm].src;};this.play=function(numIm){imgs[numIm].style.display='block';if(this.options.align[0]=='center')imgs[numIm].style.left=((this.box.offsetWidth-imgs[numIm].offsetWidth)/2)+'px';else if(this.options.align[0]=='right')imgs[numIm].style.right=0;if(this.options.align[1]=='middle')imgs[numIm].style.top=((this.box.offsetHeight-imgs[numIm].offsetHeight)/2)+'px';else if(this.options.align[1]=='bottom')imgs[numIm].style.bottom=0;var fx=new Fx;fx.initialize([imgs[current],imgs[nIndex]],{duration:this.options.duration,curve:['cos']});setTimeout(function(fnc){return function(){fx.start({0:{'opacity':[1,0]},1:{'opacity':[0,1]}},function(){imgs[current].style.display='none';current=nIndex;nextLoad=imgs[nIndex+1]?nIndex+1:0;fnc.nextImage(nextLoad);});}}(this),this.options.step);};}
var LightBoxText=function(){this.options={loadingSrc:'images/light_loading.gif',lightBackOpacity:'0.65'};this.initialize=function(options){for(var property in options)this.options[property]=options[property];};};var Lp=LightBoxText.prototype={setLightBack:function(){if($('light_back')){var lightBack=$('light_back');lightBack.style.display='block';}else{var lightBack=addElement('div',{'id':'light_back',styles:{position:'absolute',top:0,left:0,background:'#000',zIndex:10,width:'100%'},opacity:this.options.lightBackOpacity});$css("body")[0].insertBefore(lightBack,$css("body")[0].firstChild);}
lightBack.style.height=Window.scrollHeight()+'px';},setLightBox:function(widthBox,heightBox){var lightBox=addElement('div',{id:'light_box',styles:{visibility:'hidden'}});$css("body")[0].insertBefore(lightBox,$css("body")[0].firstChild);setStyles(lightBox,{position:'absolute',zIndex:100,width:(widthBox)+'px',height:(heightBox+20)+'px'});this.centerObj(lightBox);var lightTop=addElement('div',{id:'light_top'});lightBox.appendChild(lightTop);addEvent(lightBox,'click',function(){$css("body")[0].removeChild(this);$('light_back').style.display='none';});return lightBox;},centerObj:function(obj){var winX=Window.width(),winY=Window.height();var topPos=((winY-obj.offsetHeight)>0)?(winY-obj.offsetHeight):10;var leftPos=((winX-obj.offsetWidth)>0)?(winX-obj.offsetWidth):10;obj.style.top=(topPos/2)+Window.scrollTop()+'px';obj.style.left=(leftPos/2)+Window.scrollLeft()+'px';obj.style.visibility='visible';},showText:function(title,text){var objContent=addElement('div',{'id':'light_content','styles':{width:'550px',height:'520px'}});$('light_loading').style.display='none';Lp.setLightBox(550,520);$('light_box').appendChild(objContent);$('light_top').innerHTML=title;objContent.innerHTML=text;},showLoading:function(){objloading=addElement('img',{id:'light_loading',src:this.options.loadingSrc});$css("body")[0].insertBefore(objloading,$css("body")[0].firstChild);setStyles(objloading,{'visibility':'hidden','position':'absolute','zIndex':'100'});objloading.src=this.options.loadingSrc;var imagesLoading=new Image();imagesLoading.onload=function(){setTimeout(function(){Lp.centerObj(objloading);},100);};imagesLoading.src=this.options.loadingSrc;}};function lightBoxHtml(title,htmlSrc){var lightAjax=new LightBoxText();lightAjax.initialize({lightBackOpacity:'0.5'});lightAjax.setLightBack();lightAjax.showLoading();var ajax=new ajaxRequest(htmlSrc);ajax.callBack(function(data){lightAjax.showText(title,data.responseText);});ajax.get();}
function gallery(data){var photo=$('gallery_image');var photoBox=$('gallery_box');var photoDescription=$('gallery_description');var loadingImg=$('loading');var preLoader=[];var galleryMenu=$el($('gallery_menu'),'a');addEvents(galleryMenu,'click',function(event,fnc){galleryMenu.forEach(function(img,i){preLoader[i].src='';});fnc.displayImage(this.id.replace('diapo_',''));stopEvent(event);},this);this.loader=function(){galleryMenu.forEach(function(item,index){preLoader[index]=new Image();preLoader[index].src=data.getElementsByTagName('photo_'+item.id.replace('diapo_',''))[0].getElementsByTagName('src')[0].firstChild.nodeValue;});},this.displayImage=function(numIm){photo.style.display='none';loadingImg.style.display='inline';var xmlPhoto=Xml(data).tag('photo_'+numIm).first;var srcPhoto=Xml(xmlPhoto).tag('src').value;var descPhoto=Xml(xmlPhoto).tag('description').value;var widthPhoto=Xml(xmlPhoto).tag('width').value;var heightPhoto=Xml(xmlPhoto).tag('height').value;var imagesLoader=new Image();addEvent(imagesLoader,'load',function(event,fnc){setTimeout(function(){var fx=new Fx;fx.initialize(photo,{duration:800,curve:['cos']});loadingImg.style.display='none';photoDescription.innerHTML=(descPhoto)?descPhoto:'';setStyles(photo,{'width':widthPhoto+'px','height':heightPhoto+'px','display':'inline','opacity':0})
photo.id='gallery_image';photo.src=srcPhoto;fx.start({'opacity':[0,1]});fnc.loader();},100);},this);imagesLoader.src=srcPhoto;}}
function slideDiapo(){var galleryMenu=$('gallery_slide');var topArrow=$('top_arrow');var bottomArrow=$('bottom_arrow');var topPosition=findPos(galleryMenu).top;var active=$el(galleryMenu,'a.item_on')[0];if(active){var activeHeight=findPos(active).top;var menuPosition=(activeHeight-topPosition);setStyles(galleryMenu,{'overflow':'hidden'});galleryMenu.scrollTop=(menuPosition>0)?menuPosition:0;}else{setStyles(galleryMenu,{'overflow':'hidden'});}
var scrollFx=new scrollBox();this.set=function(){topArrow.style.display=(galleryMenu.scrollHeight>galleryMenu.offsetHeight)?'block':'none';bottomArrow.style.display=(galleryMenu.scrollHeight>galleryMenu.offsetHeight)?'block':'none';scrollFx.set(galleryMenu);}
this.set();addEvent(galleryMenu,'mousemove',function(event){cursorRatio=(Cursor(event).page.y-(topPosition+(galleryMenu.offsetHeight/2)))/80;scrollFx.init({'Top':cursorRatio});});addEvent(topArrow,'mouseover',function(event){scrollFx.init({'Top':-5})});addEvent(topArrow,'mouseout',function(event){scrollFx.stop()});addEvent(bottomArrow,'mouseover',function(event){scrollFx.init({'Top':5})});addEvent(bottomArrow,'mouseout',function(event){scrollFx.stop()});addEvent(galleryMenu,'mouseleave',function(event){scrollFx.stop()});}
function scrollBox(){this.set=function(el){this.el=el;this.timer=false;this.limit={'Top':(el.scrollHeight)-(el.offsetHeight),'Left':(el.scrollWidth)-(el.offsetWidth)}};this.init=function(move){this.slide=[];this.increase=[];for(var pos in move){this.increase[pos]=move[pos];this.slide[pos]=this.el["scroll"+pos];}
if(!this.timer){this.timer=setInterval(function(fnc){return function(){for(var pos in move)fnc.move(pos);}}(this),20);}};this.move=function(pos){if(this.slide[pos]+this.increase[pos]<0){this.stop();this.el['scroll'+pos]=0;this.slide[pos]=0;}else if(this.slide[pos]+this.increase[pos]>this.limit[pos]){this.stop();this.slide[pos]=this.limit[pos];this.el['scroll'+pos]=this.limit[pos];}else{this.slide[pos]+=this.increase[pos];this.el['scroll'+pos]=this.slide[pos];}}
this.stop=function(){clearInterval(this.timer);this.timer=false;}}