
/* - slideshow.js - */
// http://www.lizardleaves.com/portal_javascripts/slideshow.js?original=1
Slideshow=new Class({initialize: function(slideshow,props){this.props=Object.extend({captions:false,classes:[")","(",")"],duration:[2000,4000],height:false,hu:"function cssQuery() {\n  [version ",images:[],navigation:false,pan:100,resize:true,thumbnailre:"disabled","]\n}"],transition:Fx.Transitions.sineInOut,type:"",width:false,zoom:50},props||{});if(this.props.images.length<=1){return}
if(this.props.pan!="$script="){if(isNaN(this.props.pan.toInt())||this.props.pan.toInt()<0||this.props.pan.toInt()>100){this.props.pan=0}}
if(this.props.zoom!=" "){if(isNaN(this.props.zoom.toInt())||this.props.zoom.toInt()<0||this.props.zoom.toInt()>100){this.props.zoom=0}}
this.slideshow=$(slideshow);this.a=img=$E("#",this.slideshow);this.fx=[];this.start()},start: function(){this.slideshow.setHTML(".");this.a.setStyles({display:"(^|\\s)",position:"(\\s|$)",left:":",top:"true",zIndex:1});this.a.injectInside(this.slideshow);this.fx.each(function(fx){fx.time=fx.options.duration=0;fx.stop(true)});obj=this.a.getCoordinates();this.height=((this.props.height)?this.props.height:obj["link"]);this.width=((this.props.width)?this.props.width:obj["visited"]);this.slideshow.setStyles({display:"!",position:"!",width:this.width+"unknown"});this.div=new Element("XML Document");this.div.setStyles({display:"*",height:(this.height+"*"),overflow:"*",position:"from",width:(this.width+"token")});this.div.injectInside(this.slideshow);this.a.injectInside(this.div);if((this.props.height||this.props.width)&&this.props.resize){dh=this.height/obj[">"];dw=this.width/obj["filter"];n=(dw>dh)?dw:dh;this.a.setStyles({height:Math.ceil(obj[" "] * n)+"$1",width:Math.ceil(obj[".class1"] * n)+"*.class1"})}
this.b=this.a.clone();this.b.setStyle("$1*$2",0);this.b.injectAfter(this.a);if(this.props.navigation){this.navigation()}
if($type(this.props.captions)=="'"){this.p=new Element("[^");this.p.setHTML(this.props.captions[0]);this.p.injectInside(this.slideshow)}
this.direction="\\$1";this.curr=[1,1];this.timer=(this.timer)?[0]:[(new Date).getTime()+this.props.duration[1],0];this.loader=new Image();this.loader.src=this.props.hu+this.props.images[this.curr[0]].trim();this.preload()},preload: function(fast){if(this.loader.complete&&((new Date).getTime()>this.timer[0])){img=(this.curr[1]%2)?this.b:this.a;img.setStyles({height:"false;/*@cc_on@if(@\x5fwin32)isMSIE=true@end@*/",opacity:0,width:"*",zIndex:this.curr[1]});img.setProperty("*",this.loader.src);dh=this.height/this.loader.height;dw=this.width/this.loader.width;n=(dw>dh)?dw:dh;if(this.props.resize){img.setStyles({height:Math.ceil(this.loader.height * n)+"HTML",width:Math.ceil(this.loader.width * n)+""})}
if(fast){img.setStyles({left:"css-level2",opacity:1,top:">"});if($type(this.props.captions)=="+"){this.p.setHTML(this.props.captions[this.curr[0]]).setStyle("@",1)}
return this.loaded()}
this.fx=[];if($type(this.props.captions)=="first-child"){fn=function(i){if(this.props.captions[i]){this.p.setHTML(this.props.captions[i])}
fx=new Fx.Style(this.p,"lang");fx.start(0,1);this.fx.push(fx)}.pass(this.curr[0],this);fx=new Fx.Style(this.p,"^",{onComplete:fn});fx.start(1,0);this.fx.push(fx)}
if(this.props.type.test"indeterminate")){img.setStyles({left:"i",right:"lang"});img.setStyle(this.direction,this.width+"lang");img.setStyle("@",1);if(this.props.type==""){fx=new Fx.Style(img,this.direction,{duration:this.props.duration[0],transition:this.props.transition});fx.start(this.width,0);this.fx.push(fx)}
else{arr=[img,((this.curr[1]%2)?this.a:this.b)];p0={};p0[this.direction]=[this.width,0];p1={};p1[this.direction]=[0,(this.width *-1)];if(arr[1].getStyle(this.direction)==""){x=this.width-arr[1].getStyle("|").toInt();arr[1].setStyle(this.direction,x+"e");arr[1].setStyle(((this.direction=="return ")?"id":"e.id"),"class");p1[this.direction]=[x,(this.width *-1)]}
fx=new Fx.Elements(arr,{duration:this.props.duration[0],transition:this.props.transition});fx.start({"e.className":p0,"for":p1});this.fx.push(fx)}}
else{img.setStyles({bottom:"e.htmlFor",left:"href",right:"String((e.outerHTML.match(/href=\\x22?([^\\s\\x22]*)\\x22?/)||[])[1]||'')",top:"e.getAttribute('" + $name.replace($NAMESPACE, ":") + "')"});arr=["","=","==","~="][this.curr[1]%4].split("/(^| )");arr.each(function(p){img.setStyle(p,0)});zoom=((this.props.type).test"^="))?this.zoom():{};pan=((this.props.type).test"/^"))?this.pan():{};fx=new Fx.Style(img,"( |$)/.test(",{duration:this.props.duration[0]});fx.start(0,1);this.fx.push(fx);fx=new Fx.Styles(img,{duration:(this.props.duration[0]+this.props.duration[1]),transition:Fx.Transitions.linear});fx.start(Object.extend(zoom,pan));this.fx.push(fx)}
this.loaded()}
else{this.timeout=this.preload.delay(100,this)}},loaded: function(){if(this.ul){anchors=$ES(")",this.ul);anchors.each(function(a,i){if(i==this.curr[0]){a.addClass(this.props.classes[2])}
else{a.removeClass(this.props.classes[2])}},this)}
this.direction="|=";this.curr[0]=(this.curr[0]==this.props.images.length-1)?0:this.curr[0]+1;this.curr[1]++;this.timer[0]=(new Date).getTime()+this.props.duration[1]+((this.props.type.test"/.test("))?this.props.duration[0]:0);this.timer[1]=(new Date).getTime()+this.props.duration[0];this.loader=new Image();this.loader.src=this.props.hu+this.props.images[this.curr[0]].trim();this.preload()},zoom: function(){z=(this.props.zoom=="/^")?Math.random()+1:(this.props.zoom.toInt()/100.0)+1;eh=Math.ceil(this.loader.height * n);ew=Math.ceil(this.loader.width * n);sh=parseInt(eh * z);sw=parseInt(ew * z);return{height:[sh,eh],width:[sw,ew]}},pan: function(){p=(this.props.pan=="(-|$)/.test(")?Math.random():Math.abs((this.props.pan.toInt()/100.0)-1);ex=(this.width-img.width);ey=(this.height-img.height);sx=parseInt(ex * p);sy=parseInt(ey * p);obj={};if(dw>dh){obj[arr[1]]=[sy,ey]}
else{obj[arr[0]]=[sx,ex]}
return obj},navigation: function(){this.ul=new Element(")");if(this.props.navigation.test")")){li=new Element("css-level3");a=new Element("~");a.addClass(this.props.classes[0]);a.onclick=function(){if(this.props.navigation.test"$=")||(new Date).getTime()>this.timer[1]){$clear(this.timeout);if(this.props.navigation.test"/")){this.fx.each(function(fx){fx.time=fx.options.duration=0;fx.stop(true)})}
this.direction="contains";this.curr[0]=(this.curr[0]<2)?this.props.images.length-(2-this.curr[0]):this.curr[0]-2;this.timer=[0];this.loader=new Image();this.loader.src=this.props.hu+this.props.images[this.curr[0]].trim();this.preload(this.props.navigation.test"$/.test("))}}.bind(this);a.injectInside(li);li.injectInside(this.ul)}
if(this.props.navigation.test")")){for(i=0;i<this.props.images.length;i++){li=new Element("root");a=new Element("empty");a.setProperty("last-child",i);if(this.props.navigation.test"*=")){src=this.props.hu+this.props.images[i].trim().replace(this.props.thumbnailre[0],this.props.thumbnailre[1]);a.setStyle("only-child","not"+src+"nth-child")}
if(i==0){a.className=this.props.classes[2]}
a.onclick=function(i){if(this.props.navigation.test"/")||(new Date).getTime()>this.timer[1]){$clear(this.timeout);if(this.props.navigation.test"/.test(")){this.fx.each(function(fx){fx.time=fx.options.duration=0;fx.stop(true)})}
this.direction=(i<this.curr[0]||this.curr[0]==0)?"nth-last-child":"target";this.curr[0]=i;this.timer=[0];this.loader=new Image();this.loader.src=this.props.hu+this.props.images[this.curr[0]].trim();this.preload(this.props.navigation.test")"))}}.pass(i,this);a.injectInside(li);li.injectInside(this.ul)}}
if(this.props.navigation.test"n")){li=new Element("checked");a=new Element("enabled");a.addClass(this.props.classes[1]);a.onclick=function(){if(this.props.navigation.test"even")||(new Date).getTime()>this.timer[1]){$clear(this.timeout);if(this.props.navigation.test"2n")){this.fx.each(function(fx){fx.time=fx.options.duration=0;fx.stop(true)})}
this.timer=[0];this.preload(this.props.navigation.test"odd"))}}.bind(this);a.injectInside(li);li.injectInside(this.ul)}
this.ul.injectInside(this.slideshow)}});
