var W = W || {};

(function(){W.Dom={isSafari:/webkit/.test(navigator.userAgent),isIE:/msie/.test(navigator.userAgent)&&!/opera/.test(navigator.userAgent),isMozilla:/mozilla/.test(navigator.userAgent)&&!/(compatible|webkit)/.test(navigator.userAgent),isOpera:/opera/.test(navigator.userAgent),$:function(id){if(typeof id=='string'){id=document.getElementById(id);}
return id;},loaded:false,load_timer:null,load_funcs:null,load:function(func)
{if(this.loaded){return func();}
if(this.load_timer){this.load_funcs.push(func);}else{var obj=this;W.Event.add(window,'load',function(){obj.isLoaded();});this.load_funcs=[func];this.load_timer=setInterval(function(){obj.isLoaded();},13);}},isLoaded:function()
{if(this.loaded){return true;}
if(document&&document.getElementsByTagName&&document.getElementById&&document.body){clearInterval(this.load_timer);this.load_timer=null;for(var i=0,max=this.load_funcs.length;i<max;++i){this.load_funcs[i]();}
this.loaded=true;}},getStyle:function(element,property)
{element=this.$(element);if(element.style[property]){return element.style[property];}else if(element.currentStyle){return element.currentStyle[property];}else if(document.defaultView&&document.defaultView.getComputedStyle){var style=document.defaultView.getComputedStyle(element,null);if(!style){return null;}
return style[property];}else{return null;}},getElementsByClassName:function(className,node,tag){if(document.getElementsByClassName){node=this.$(node)||document.body;return node.getElementsByClassName(className);}else{var classElements=[];node=this.$(node)||document.body;tag=tag||'*';var els=node.getElementsByTagName(tag);var elsLen=els.length;var pattern=new RegExp('(^|\\s)'+className+'(\\s|$)');if(tag=='*'&&!elsLen&&document.all){els=document.all;elsLen=els.length;}
for(var i=0,j=0;i<elsLen;i++){if(pattern.test(els[i].className)){classElements[j]=els[i];j++;}}
return classElements;}},preload:function()
{for(var i=0,l=arguments.length;i<l;++i){new Image().src=arguments[i];}},getWindowSize:function()
{var size={x:0,y:0};if(document.documentElement&&document.documentElement.clientHeight){size.x=document.documentElement.clientWidth;size.y=document.documentElement.clientHeight;}else if(document.body){size.x=document.body.clientWidth;size.y=document.body.clientHeight;}
return size;},getOffsets:function(elem)
{var offsets={left:0,top:0};while(elem){offsets.left+=elem.offsetLeft;offsets.top+=elem.offsetTop;elem=elem.offsetParent;}
return offsets;},getScroll:function()
{var scroll={x:0,y:0};if(window.scrollY!==undefined){return function()
{scroll.y=window.scrollY;scroll.x=window.scrollX;return scroll;};}else if(document.documentElement&&document.compatMode){return function()
{scroll.y=document.documentElement.scrollTop;scroll.x=document.documentElement.scrollLeft;return scroll;};}else{return function()
{scroll.y=document.body.scrollTop;scroll.x=document.body.scrollLeft;return scroll;};}}(),getContentSize:function()
{var size={x:0,y:0};var size_ie={x:0,y:0};if(document.documentElement&&document.documentElement.scrollWidth){size.x=document.documentElement.scrollWidth;size.y=document.documentElement.scrollHeight;}
size_ie.x=document.body.scrollWidth;size_ie.y=document.body.scrollHeight;if(size_ie.x>size.x){size.x=size_ie.x;}
if(size_ie.y>size.y){size.y=size_ie.y;}
var win=this.getWindowSize();if(win.y>size.y){size.y=win.y;}
if(win.x>size.x){size.x=win.x;}
return size;},addClassName:function(node,className)
{node=this.$(node);if(node.className.indexOf(className)==-1){node.className=node.className+' '+className;}},removeClassName:function(node,className)
{node=this.$(node);var regex=new RegExp('\\b ?'+className+'\\b');node.className=node.className.replace(regex,'');},hasClassName:function(node,className)
{node=this.$(node);var regex=new RegExp('\\b ?'+className+'\\b');return(node.className.search(regex)!=-1);},changeClassName:function(node,className)
{if(!node){return;}
var elements=[];if(typeof node=='string'){node=this.$(node);elements.push(node);}else{elements=node;}
for(var obj in elements){elements[obj].className=className;}}};})();W.$=W.Dom.$;

(function(){W.Event={listeners:[],add:function(obj,type,fn)
{if(!type&&!fn){if(obj===undefined){return false;}
this.listeners.push(obj);return true;}
var result,r,old;if(obj.addEventListener){if(type=='mousewheel'){obj.addEventListener('DOMMouseScroll',fn,false);}
obj.addEventListener(type,fn,false);result=true;}
else if(obj.attachEvent){r=obj.attachEvent('on'+type,fn);result=r;}
else{old=obj['on'+type];if(typeof obj['on'+type]!='function'){obj['on'+type]=fn;}else{obj['on'+type]=function()
{old();fn();};}}
return result;},remove:function(obj,type,fn)
{if(!type&&!fn){if(obj===undefined){return false;}
for(var i=this.listeners.length;--i>=0;){if(this.listeners[i]==obj){this.listeners.splice(i,1);return true;}}
return false;}
if(obj.removeEventListener){obj.removeEventListener(type,fn,false);}else if(obj.detachEvent){obj.detachEvent('on'+type,fn);}else{obj['on'+type]=null;}},broadcast:function(fn)
{if(fn===undefined){return false;}
var args=Array.prototype.slice.call(arguments,1);for(var i=this.listeners.length;--i>=0;){if(this.listeners[i][fn]){this.listeners[i][fn].apply(this.listeners[i],args);}}},preventDefault:function(e)
{if(e.preventDefault){e.preventDefault();}else{e.returnValue=false;}},cancelBubble:function(e)
{if(e.stopPropagation){e.stopPropagation();}else{e.cancelBubble=true;}},stop:function(e)
{e=e||window.event;if(e){this.cancelBubble(e);this.preventDefault(e);}},source:function(e)
{return window.event?window.event.srcElement:e?e.currentTarget:null;},target:function(e,targetElement)
{return window.event?targetElement:e?e.currentTarget:null;},getTarget:function(e)
{var targetElement=null;targetElement=this.source(e);while(targetElement.nodeType==3&&targetElement.parentNode!==null){targetElement=targetElement.parentNode;}
return targetElement;},findTarget:function(e,target)
{target=target.toUpperCase();while(e.nodeName.toUpperCase()!=target&&e.nodeName.toUpperCase()!='HTML'){e=e.parentNode;}
return(e.nodeName.toUpperCase()=='HTML')?null:e;},Cache:function()
{var listEvents=[];return{listEvents:listEvents,add:function(node,sEventName,fHandler){listEvents.push(arguments);},flush:function(){var i,item;for(i=listEvents.length-1;i>=0;i=i-1){item=listEvents[i];if(item[0].removeEventListener){item[0].removeEventListener(item[1],item[2],item[3]);}
if(item[1].substring(0,2)!="on"){item[1]="on"+item[1];}
if(item[0].detachEvent){item[0].detachEvent(item[1],item[2]);}
item[0][item[1]]=null;}}};}()};})();Function.prototype.bind=function(object,args)
{var method=this;return function(event){return method.call(object,event||window.event,args);};};if(Array.prototype.push===null){Array.prototype.push=function(){for(var i=0;i<arguments.length;++i){this[this.length]=arguments[i];}
return this.length;};}
W.Event.add(window,'unload',W.Event.Cache.flush);

W.Tween=function(param)
{this.init(param);};W.Tween.prototype={interval:30,b:0,c:0,d:0,e:0,t:0,a:0,p:0,s:0,o:null,om:'',f:null,cb:null,args:null,timer:null,event:null,init:function(param)
{var obj=this;this.b=param.start;this.c=param.change;this.d=param.duration;this.e=param.end;this.a=param.amplitude;this.p=param.period;this.s=param.overshoot;this.o=param.obj;this.om=param.bind;this.f=param.method;this.cb=param.callback;this.args=param.args;if(this.c===undefined&&this.e!==undefined){this.c=this.e-this.b;}
this.timer=setInterval(function(){obj.tween();},this.interval);},tween:function()
{++this.t;if(this.t<=this.d){this.o[this.om](this[this.f](),this.args);}else{clearInterval(this.timer);if(this.cb){this.o[this.cb](this.args);}}},stop:function()
{clearInterval(this.timer);},pause:function()
{clearInterval(this.timer);},resume:function()
{var obj=this;this.timer=setInterval(function(){obj.tween();},this.interval);},linear:function()
{var t=this.t;var b=this.b;var c=this.c;var d=this.d;return c*t/d+b;},easeInOutQuad:function()
{var t=this.t;var b=this.b;var c=this.c;var d=this.d;if((t/=d/2)<1){return Math.floor((c/2*t*t+b));}
return Math.floor((-c/2*((--t)*(t-2)-1)+b));},easeOutQuart:function()
{var t=this.t;var b=this.b;var c=this.c;var d=this.d;return-c*((t=t/d-1)*t*t*t-1)+b;},easeInOutQuart:function()
{var t=this.t;var b=this.b;var c=this.c;var d=this.d;if((t/=d/2)<1){return Math.floor(c/2*t*t*t*t+b);}
return Math.floor((-c/2*((t-=2)*t*t*t-2)+b));},easeInOutSine:function()
{var t=this.t;var b=this.b;var c=this.c;var d=this.d;return Math.floor((-c/2*(Math.cos(Math.PI*t/d)-1)+b));}};

W.Request=function(method,url,post)
{this.init(method,url,post);};W.Request.prototype={request:null,callback:null,post:null,init:function(method,url,post)
{var obj=this;this.request=this.xmlhttp();if(!this.request){return false;}
this.post=post||this.post;this.request.open(method,url,true);if(method.toUpperCase()=='POST'){this.request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');}
this.request.setRequestHeader('If-Modified-Since','Sat, 1 Jan 2000 00:00:00 GMT');this.request.onreadystatechange=function(){obj.update(this.request);};},send:function()
{this.request.send(this.post);},xmlhttp:function()
{var xmlreq=false;if(window.XMLHttpRequest){xmlreq=new XMLHttpRequest();}else if(window.ActiveXObject){try{xmlreq=new ActiveXObject("Msxml2.XMLHTTP");}catch(e1){try{xmlreq=new ActiveXObject("Microsoft.XMLHTTP");}catch(e2){return false;}}}
return xmlreq;},update:function()
{if(this.request.readyState==4){if(this.callback){this.callback();}}},call:function(fn)
{var obj=this;this.callback=function(){fn(obj.request);};this.send();},load:function(id)
{var obj=this;this.callback=function(){W.$(id).innerHTML=obj.request.responseText;};this.send();}};

W.Fader=function(param)
{this.init(param);};W.Fader.prototype={photos:null,index:1,prev_index:1,tween:null,timer:null,duration:7,_pause:3000,loop:true,auto:true,nav:null,crossfade:false,caption:false,class_name:'photo',swap:false,init:function(param)
{if(param){if(param.duration!==undefined){this.duration=param.duration;}
if(param.pause!==undefined){this._pause=param.pause;}
if(param.loop!==undefined){this.loop=param.loop;}
if(param.auto!==undefined){this.auto=param.auto;}
if(param.nav!==undefined){this.nav=W.$(param.nav);}
if(param.caption!==undefined){this.caption=param.caption;}
if(param.swap!==undefined){this.swap=param.swap;}
if(param.crossfade!==undefined){this.crossfade=param.crossfade;}}
this.photos=[];this.tween={};var obj=this;W.Event.add(document,'keyup',function(e){obj.key_nav(e);});W.Event.add(this);},init_nav:function(class_name,node,tag)
{this.class_name=class_name;var photos=W.Dom.getElementsByClassName(class_name,node,tag);var img;this.add_jump('previous','previous');for(var i=0,max=photos.length;i<max;++i){this.add_jump(i+1);if(photos[i].tagName.toLowerCase()=='img'){img=photos[i];}else{img=photos[i].getElementsByTagName('img')[0];}
this.add(img,i+1);}
this.add_jump('next','next');return this;},add:function(img,index)
{var obj=this;if(!img.complete||(typeof img.naturalWidth!="undefined"&&img.naturalWidth===0)){W.Event.add(img,'load',function(e){obj.init_photo(W.Event.source(e),index);});}else{this.init_photo(img,index);}},init_photo:function(img,index)
{var obj=this;this.photos[index]=img;W.Event.add(img,'click',function(){obj.next();});if(this.caption){var p=document.createElement('p');p.id='caption_'+index;p.innerHTML=img.title;this.find_container(index).appendChild(p);}
this.activate_jump(index);if(index==1){this.fade_in();this.select();}},key_nav:function(e)
{var code=e.charCode||e.keyCode;if(!this.swap||'photo_'+this.swap.current.id==this.class_name){if(code==39){this.next();this.auto=false;}else if(code==37){this.previous();this.auto=false;}}},add_jump:function(index,class_name)
{var li=document.createElement('li');var a=document.createElement('a');if(class_name){a.className=class_name;}
a.onclick=this.jump.bind(this,index);a.innerHTML='<span>'+index+'</span>';li.appendChild(a);if(this.nav){this.nav.appendChild(li);}},jump:function(e,index)
{W.Event.stop(e);if(index==this.index){return;}
for(var tween in this.tween){this.tween[tween].stop();}
if(this.index!=this.prev_index){this.set_opacity_out(0);}
clearTimeout(this.timer);this.fade_out();if(index=='next'){this.next();}else if(index=='previous'){this.previous();}else{this.index=index;if(this.crossfade){this.fade_in();}}
this.select();this.activate_previous_next();this.auto=false;},activate_jump:function(index)
{if(!this.nav){return;}
var lis=this.nav.getElementsByTagName('li');var li=lis[index];if(li){W.Dom.addClassName(li,'ready');}
if(this.photos.length==(lis.length-1)){this.activate_next(true);if(this.loop){this.activate_previous(true);}}},activate_previous:function(state)
{if(!this.nav){return;}
var li=this.nav.getElementsByTagName('li')[0];if(li){state?W.Dom.addClassName(li,'ready'):W.Dom.removeClassName(li,'ready');}},activate_next:function(state)
{if(!this.nav){return;}
var lis=this.nav.getElementsByTagName('li');var li=lis[lis.length-1];if(li){state?W.Dom.addClassName(li,'ready'):W.Dom.removeClassName(li,'ready');}},activate_previous_next:function()
{if(this.loop||this.index>1){this.activate_previous(true);}else{this.activate_previous(false);}
if(this.loop||this.index<(this.photos.length-1)){this.activate_next(true);}else{this.activate_next(false);}},select:function()
{if(!this.nav){return;}
var lis=this.nav.getElementsByTagName('li');var index=this.index;for(var i=0,max=lis.length;i<max;++i){if(i==index){W.Dom.addClassName(lis[i],'selected');}else{W.Dom.removeClassName(lis[i],'selected');}}},fade_in:function()
{var start=0;var change=100;delete this.tween.fade_out;this.tween.fade_in=new W.Tween({start:start,change:change,duration:this.duration,obj:this,bind:'set_opacity_in',method:'linear',callback:'finish'});},fade_out:function()
{var start=100;var change=-100;this.prev_index=this.index;delete this.tween.fade_in;var cb='fade_in';if(this.crossfade){cb=false;}
this.tween.fade_out=new W.Tween({start:start,change:change,duration:this.duration,obj:this,bind:'set_opacity_out',method:'linear',callback:cb});},set_opacity_in:function(num)
{var div=this.find_container(this.index);div.style.display='block';this.set_opacity(div,num);},set_opacity_out:function(num)
{var div=this.find_container(this.prev_index);this.set_opacity(div,num);},find_container:function(index)
{var elem=this.photos[index];while(!W.Dom.hasClassName(elem,this.class_name)&&elem.tagName.toLowerCase()!='body'){elem=elem.parentNode;}
return elem;},set_opacity:function(elem,num)
{elem.style.opacity=num/100;elem.style.filter='alpha(opacity='+num+')';if(num<=0){elem.style.display='none';}},next:function()
{if(this.index<(this.photos.length-1)||this.loop){this.fade_out();}
++this.index;if(this.index==this.photos.length){if(!this.loop){this.prev_index=this.index-1;this.index=1;return;}
this.index=1;}
if(this.crossfade){this.fade_in();}
this.select();this.activate_previous_next();},previous:function()
{this.fade_out();--this.index;if(this.index===0){this.index=this.photos.length-1;}
if(this.crossfade){this.fade_in();}
this.select();this.activate_previous_next();},pause:function()
{for(var tween in this.tween){this.tween[tween].pause();}
clearTimeout(this.timer);},resume:function()
{var has_tweens=false;for(var tween in this.tween){has_tweens=true;this.tween[tween].resume();}
if(!has_tweens){this.finish();}},stop:function()
{for(var tween in this.tween){this.tween[tween].stop();if(tween=='fade_out'){this.set_opacity_out(0);}else if(tween=='fade_in'){this.set_opacity_in(100);}}
clearTimeout(this.timer);},finish:function()
{var obj=this;delete this.tween.fade_in;if(this.auto){if(!this.swap||'photo_'+this.swap.current.id==this.class_name){this.timer=setTimeout(function(){obj.next();},this._pause);}}},onSwapSelectStart:function(e)
{this.pause();},onSwapSelectStop:function(e)
{if('photo_'+e.id==this.class_name){this.resume();}}};