/* WEBDESIGN & CODE BY STEFAN ZACHLEDER, ZACHLEDER DESIGN & ARCHITEKTUR, WWW.ZACHLEDER.CH *//* DESIGN & CODE IS COPYRIGHT PROTECTED, ANY USE BY THIRD PARTIES IS PROHIBITED */window.addEvent("domready",function(){G=new gallery();G.init_settings();if(/MSIE (\d+\.\d+);/.test(navigator.userAgent)){var A=new Number(RegExp.$1);
if(A<6){alert("Internet Explorer 6+ needed!")}}if(navigator.appName=="Microsoft Internet Explorer"){G.fade_in_on_load=false
}window.addEvent("mousedown",function(C){C.stop()});$("gallery").fade("hide");$("loader").fade("hide");
G.init_base_layout();G.init_button_layout();if(G.info_system){G.init_infosystem()
}this.actual_image_set=false;G.switch_to_image_set(0);G.inject_images(G.actual_image_set);
if(G.autoplay){G.init_autoplay()}var B=setInterval(function(){if(!G.image_set[G.actual_image_set].initialized){return 
}clearInterval(B);if(G.fade_in_on_load){$("gallery").fade("in")}else{$("gallery").fade("show")
}},10)});function fisherYates(C){var B=C.length;if(B==0){return false}while(--B){var A=Math.floor(Math.random()*(B+1));
var E=C[B];var D=C[A];C[B]=D;C[A]=E}}function gallery(){this.actual_image_set=0;this.autoplay=true;
this.autoplay_img_time=5;this.autoplay_timer=10;this.images_opacity=0.75;this.opacity_background="#222";
this.fade_in_on_load=true;this.gallery_fade_duration=1500;this.scroll_duration=600;
this.image_fade_duration=500;this.imageset_fadein_duration=300;this.imageset_fadeout_duration=150;
this.info_system=true;this.info_fadeout_timer=20;this.info_fade_duration=800;this.infobutton_yoffset=50;
this.infobutton_height=24;this.infobutton_width=24;this.image_path="_images/";this.no_image="_components/noimage.gif";
this.mask_width=500;this.image_height=250;this.image_gap=2;this.button_gap=2;this.button_width=25;
this.button_arrow_off=7;this.button_hover=0.5;this.button_opacity=0.2;this.loader_width=48;
this.loader_height=48;this.last_click=$time();$("gallery").set("tween",{duration:this.gallery_fade_duration,transition:Fx.Transitions.Sine.easeOut});
$("loader").set("tween",{duration:this.imageset_fadein_duration*0.75,transition:Fx.Transitions.Sine.easeOut});
$("imagemask").set("tween",{transition:Fx.Transitions.Sine.easeOut});this.image_scroll=new Fx.Scroll($("imagemask"),{duration:this.scroll_duration,transition:Fx.Transitions.Cubic.easeOut})
}gallery.prototype.init_base_layout=function(){var A=this;$$("#gallery").setStyles({width:(A.mask_width+2*(A.button_gap+A.button_width))+"px",left:((A.mask_width+2*(A.button_gap+A.button_width))/-2)+"px",top:(A.image_height/2*-1.1)+"px"});
$$("#images").setStyles({height:A.image_height+"px"});$$("#imagemask").setStyles({width:A.mask_width+"px",height:A.image_height+"px",left:(A.button_width+A.button_gap)+"px"});
$$("#loader").setStyles({width:A.loader_width+"px",height:A.loader_height+"px",left:(A.button_width+(A.mask_width+2*A.button_gap)/2-A.loader_width/2)+"px",top:(A.image_height/2-A.loader_height/2)+"px"})
};gallery.prototype.init_button_layout=function(){var A=this;$("imageright_overlay").addEvent("click",function(B){B.stop();
A.last_click=$time();A.images_right()});$("imageleft_overlay").addEvent("click",function(B){B.stop();
A.last_click=$time();A.images_left()});$$("#imageleft_overlay").setStyles({background:"url(_components/transparent.gif)",height:A.image_height+"px",width:(A.mask_width/2+A.button_gap+A.button_width)+"px",left:(A.button_width+A.button_gap)+"px"});
$$("#imageright_overlay").setStyles({background:"url(_components/transparent.gif)",height:A.image_height+"px",width:(A.mask_width/2+A.button_gap)+"px",left:(A.button_width+A.button_gap+A.mask_width/2)+"px"});
new Element("img",{src:"_components/mask10_formlab.png",styles:{width:(A.image_height+1)+"px",height:(A.image_height+1)+"px",position:"absolute",top:"0px",left:(A.button_width+A.button_gap)+"px","z-index":2000}}).inject($("images"));
new Element("img",{src:"_components/mask10_address.png",styles:{width:(A.image_height+1)+"px",height:(A.image_height+1)+"px",position:"absolute",top:"0px",left:(A.button_width+A.button_gap+A.mask_width-A.image_height)+"px","z-index":2000}}).inject($("images"))
};gallery.prototype.init_infosystem=function(){var B=this;B.actual_infotext=1;B.info_shown=false;
B.info_margin=B.button_width+B.button_gap;B.info_margin=0;$$("#info").set({opacity:0});
$$("#infobutton").set({opacity:B.button_opacity});$$("#infobutton").setStyles({width:B.infobutton_width+"px",height:B.infobutton_height+"px",left:(B.button_width+B.button_gap+B.mask_width/2-B.infobutton_width/2)+"px",top:(B.image_height+B.infobutton_yoffset)+"px"});
$$("#info").setStyles({height:B.image_height+"px","margin-right":B.info_margin+"px","margin-left":B.info_margin+"px",padding:B.info_padding+"px 0 0 0"});
$$("#info").set("html",B.infotext);$$("#infobutton").addEvent("mouseenter",function(C){this.set({opacity:B.button_hover})
});$$("#infobutton").addEvent("mouseleave",function(C){this.set({opacity:B.button_opacity})
});$$("#infobutton").addEvent("click",function(C){B.last_click=$time();B.toggle_infotext()
});var A=setInterval(function(){if(B.info_shown&&($time()-B.last_click)>(B.info_fadeout_timer*1000)){B.toggle_infotext()
}},1000)};gallery.prototype.toggle_infotext=function(){var B=this;if(B.info_fade_event){return 
}B.info_fade_event=true;var A="#infotext"+B.actual_infotext;if(B.info_shown){$$("#info").morph({opacity:0});
$$("#images").morph({opacity:1});$$("#infobutton").setStyles({"background-position":"top"});
B.info_shown=false}else{$$("#info").set("morph",{duration:B.info_fade_duration});
$$("#info").morph({opacity:1});$$("#images").set("morph",{duration:B.info_fade_duration});
$$("#images").morph({opacity:0});$$("#infobutton").setStyles({"background-position":"bottom"});
B.info_shown=true}B.info_fade_event=false};gallery.prototype.init_autoplay=function(){var B=this;
var A=setInterval(function(){if(($time()-B.last_click)<(B.autoplay_timer*1000)){return 
}B.images_right()},B.autoplay_img_time*1000)};gallery.prototype.images_right=function(H){var K=this;
if(K.image_scroll_event){return }K.image_scroll_event=true;var J=K.actual_image_set;
var C=K.image_set[J].image_pos;var A=K.image_set[J].image_maxpos();var I=K.image_set[J].pos;
var B=K.image_set[J].pos_offset;C++;if(C>A){C=0;I=B-K.mask_width/2-(K.image_set[J].image[0].width()+K.image_gap)/2;
K.image_scroll.set(Math.round(I));var F=K.image_set[J].image[A].element;F.set({opacity:K.images_opacity});
var F=K.image_set[J].image[0].element.getParent().getPrevious().getFirst();F.set({opacity:1})
}else{var F=K.image_set[J].image[C-1].element}var D=K.image_set[J].image[C].element;
var I=B-K.mask_width/2;var E;for(E=0;E<C;E++){I+=K.image_set[J].image[E].width()+K.image_gap
}I+=(K.image_set[J].image[C].width()+K.image_gap)/2;K.image_scroll.start(Math.round(I)).chain(function(){K.image_scroll_event=false
});K.image_set[J].image_pos=C;K.image_set[J].pos=I;F.set("morph",{duration:K.image_fade_duration});
F.morph({opacity:K.images_opacity});D.set("morph",{duration:K.image_fade_duration});
D.morph({opacity:1})};gallery.prototype.images_left=function(H){var K=this;if(K.image_scroll_event){return 
}K.image_scroll_event=true;var J=K.actual_image_set;var C=K.image_set[J].image_pos;
var I=K.image_set[J].pos;var A=K.image_set[J].image_maxpos();var B=K.image_set[J].pos_offset;
C--;if(C<0){C=A;I=B-K.mask_width/2+K.image_set[J].width(K.image_gap)+(K.image_set[J].image[0].width()+K.image_gap)/2;
K.image_scroll.set(Math.round(I));var F=K.image_set[J].image[0].element;F.set({opacity:K.images_opacity});
var F=K.image_set[J].image[A].element.getParent().getNext().getFirst();F.set({opacity:1})
}else{var F=K.image_set[J].image[C+1].element}var D=K.image_set[J].image[C].element;
var I=B-K.mask_width/2;var E;for(E=0;E<C;E++){I+=K.image_set[J].image[E].width()+K.image_gap
}if(C>A){C=0}I+=(K.image_set[J].image[C].width()+K.image_gap)/2;K.image_scroll.start(Math.round(I)).chain(function(){K.image_scroll_event=false
});K.image_set[J].image_pos=C;K.image_set[J].pos=I;F.set("morph",{duration:K.image_fade_duration});
F.morph({opacity:K.images_opacity});D.set("morph",{duration:K.image_fade_duration});
D.morph({opacity:1})};gallery.prototype.inject_images=function(A){var D=this;var C=D.actual_image_set;
if(!D.image_set[A].initialized){D.image_set[A].image_path=D.image_path;D.image_set[A].load_images({height:D.image_height+"px"})
}var B=setInterval(function(){if(!D.image_set[A].loaded()){return }clearInterval(B);
var F=$("imagemask");F.getFirst().destroy();var K=new Element("ul").inject(F);D.image_set[A].image.each(function(P,O){var N=new Element("li").inject(K);
N.setStyles({"margin-right":D.image_gap+"px",background:D.opacity_background});P.element.setStyles({opacity:D.images_opacity});
P.element.inject(N)});var M,E,L,J,I=D.mask_width/2;D.image_set[A].post_clones=0;while(I>=0){for(J=0;
J<=D.image_set[A].image.length-1;J++){E=new Element("li").inject(K);E.setStyles({"margin-right":D.image_gap+"px",background:D.opacity_background});
M=D.image_set[A].image[J].element.clone();M.inject(E);D.image_set[A].post_clones++;
I-=D.image_set[A].image[J].width()+D.image_gap;if(I<0){break}}}var M,E,L,J,I=D.mask_width/2;
D.image_set[A].pre_clones=0;while(I>=0){for(J=D.image_set[A].image.length-1;J>=0;
J--){E=new Element("li").inject(K,"top");E.setStyles({"margin-right":D.image_gap+"px",background:D.opacity_background});
M=D.image_set[A].image[J].element.clone();M.inject(E);D.image_set[A].pre_clones++;
I-=D.image_set[A].image[J].width()+D.image_gap;if(I<0){break}}}if(!D.image_set[A].initialized){D.image_set[A].pos_offset=D.mask_width/2+I*-1-D.image_gap;
D.image_set[A].pos=D.image_set[A].pos_offset-D.mask_width/2+(D.image_set[A].image[0].width()+D.image_gap)/2
}var H=D.image_set[A].image_pos;D.image_set[A].image[H].element.set({opacity:1});
D.image_scroll.set(Math.round(D.image_set[A].pos));D.image_set[A].initialized=true;
D.actual_image_set=A},10)};gallery.prototype.switch_to_image_set=function(B){var A=this;
if(A.actual_image_set==B||A.switch_set_event){return }A.switch_set_event=true;$("loader").fade("in");
$("imagemask").set("tween",{duration:A.imageset_fadeout_duration});$("imagemask").fade("out").get("tween").chain(function(){A.inject_images(B);
var C=setInterval(function(){if(!A.image_set[B].initialized){return }clearInterval(C);
$("loader").fade("out");A.switch_infotext(B);$("imagemask").set("tween",{duration:A.imageset_fadein_duration});
$("imagemask").fade("in").get("tween").chain(function(){A.switch_set_event=false})
},10)})};function image(A){this.name=A;this.element;this.loaded=false;this.clone=new Array()
}image.prototype.width=function(){return this.element.getCoordinates().width};function image_set(B,D,C){this.image=new Array();
this.info_title=D;this.info_text=C;this.image_pos=0;this.pos=0;this.initialized=false;
this.pre_clones=0;this.post_clones=0;var A=this;B.each(function(E,F){A.image[F]=new image(E)
})}image_set.prototype.image_maxpos=function(){return this.image.length-1};image_set.prototype.width=function(A){var B=0;
this.image.each(function(C){B+=C.width()+A});return B-A};image_set.prototype.load_images=function(B){var A=this;
A.image.each(function(C){C.element=new Element("img",{src:A.image_path+C.name,styles:B});
C.element.addEvent("error",function(){this.src=G.no_image})})};image_set.prototype.loaded=function(){var A;
for(A=0;A<this.image.length;A++){if(!this.image[A].element.complete){return false
}}return true};
