objMuGallery=new Class({initialize:function(a,b,c,d,e){window.addEvent('domready',function(){this.start(a,b,c,d,e)}.bind(this))},start:function(a,b,c,d,e){this.error=false;this.errMsgs=new Array();this.fadeDuration=750;this.storyDelay=1000;this.storyDuration=10000;this.boolRandomOnStart=false;this.initialindex=0;this.galName='MU Gallery Rotator';this.errMsgHeaderText='Errors Encountered with the '+this.galName;this.errMsgIntroText='I apologize for the inconvenience, but the following errors were encountered while trying to create the '+this.galName;if($type(a)=='string'&&a!=''&&$chk($(a))){this.galleryID=a}else{this.error=true;this.errMsgs.include('I have to have the ID of the element that will contain the Gallery, and that element must exist.')}if(($type(b)=='object'||$type(b)=='array')&&b.length>0){this.datasource=b}else{this.error=true;this.errMsgs.include('I have to have a valid Data Source')}if($defined(c)){var f='I am unable to determine if you want a random story on start-up.  Please include a boolean true or false as your value.';switch($type(c)){case'string':switch(c){case'true':this.boolRandomOnStart=true;break;case'false':this.boolRandomOnStart=false;break;default:this.error=true;this.errMsgs.include(f);break}break;case'boolean':this.boolRandomOnStart=c;break;default:this.error=true;this.errMsgs.include(f);break}}if($defined(d)){this.SetFadeDuration(d)}if($defined(e)){this.SetStoryDuration(e)}if(!this.error){if(this.boolRandomOnStart){this.initialindex=$random(0,(this.datasource.length-1))}this.currentindex=this.initialindex;this.beginGallery()}else{this.buildErrors()}},SetFadeDuration:function(a){var b='I am unable to determine how long you want the Fade Duration to be. Please double-check the value you have provided.  Remember, Fade Duration is in milliseconds.';switch($type(a)){case'number':if(a>0){this.fadeDuration=a}break;case'string':if(a!=''){this.fadeDuration=a.toInt()}break;default:this.error=true;this.errMsgs.include(b);break}if($defined(this.fadeDuration)){this.storyDelay=(this.fadeDuration*1.333).toInt()}},SetStoryDuration:function(a){var b='I am unable to determine how long you want the Story Duration to be. Please double-check the value you have provided.  Remember, Story Duration is in milliseconds.';switch($type(a)){case'number':this.storyDuration=a;break;case'string':this.storyDuration=a.toInt();break;default:this.error=true;this.errMsgs.include(b);break}},buildGallery:function(){objCurrentStory=this.datasource[this.initialindex];var f=$(this.galleryID);f.empty();var g=new Element('div',{id:'gallery-img-contain'});f.appendChild(g);var h=new Element('img',{src:objCurrentStory.image,alt:objCurrentStory.headline,id:'gallery-main-img'});var i=new Element('a',{href:objCurrentStory.href,id:'gallery-main-img-link'});i.appendChild(h);g.appendChild(i);var j=new Element('div',{id:'gallery-controls'});f.appendChild(j);$each(this.datasource,function(a,b){var c=new Element('a',{'href':a.href,'id':'gallery-thumb-link-'+b});c.addEvent('click',function(e){new Event(e).stop();this.rotator=$clear(this.rotator);this.updateStory(b)}.bind(this));var d=new Element('img',{src:a.thumb,alt:a.headline,id:'gallery-thumb-'+b});if(b==this.initialindex){d.addClass('current')}else{d.setOpacity(0.5)}c.appendChild(d);j.appendChild(c)}.bind(this));var k=new Element('a',{href:objCurrentStory.href});k.setHTML(objCurrentStory.headline);var l=new Element('h2',{id:'gallery-headline'});l.appendChild(k);f.appendChild(l);var m=new Element('div',{id:'gallery-teaser'});m.setHTML(objCurrentStory.teaser);f.appendChild(m);var n=new Element('a',{id:'gallery-readmore-link',href:objCurrentStory.href});n.setHTML('Read more about '+objCurrentStory.headline);galReadMore=new Element('div',{id:'gallery-readmore','class':'read-more'});galReadMore.appendChild(n);f.appendChild(galReadMore)},updateStory:function(b){this.imgEffect=new Fx.Style('gallery-main-img','opacity',{duration:this.fadeDuration,transition:Fx.Transitions.Quart.easeInOut});this.imgEffect.start(1,0);var c=$('gallery-main-img-link');var d=$('gallery-main-img');var e=$('gallery-controls');var f=$('gallery-headline');var g=$('gallery-teaser');var h=$('gallery-readmore-link');var j=this.datasource[b];var k=this.datasource.length;(function(){d.src=j.image;d.alt=j.headline;c.href=j.href;if(f.hasChild()){var a=f.getChildren();a.href=j.href;a.setText(j.headline)}else{f.empty();var a=new Element('a',{href:j.href});a.setHTML(j.headline);f.appendChild(a)}g.setHTML(j.teaser);h.setHTML('Read more about '+j.headline);h.href=j.href;for(i=0;i<k;++i){imgThumb=$('gallery-thumb-'+i);if(imgThumb.hasClass('current')){imgThumb.removeClass('current')}if(i==b){imgThumb.setOpacity(1);imgThumb.addClass('current')}else{imgThumb.setOpacity(0.5)}}}).delay(this.storyDelay);this.imgEffect.start.pass([0,1],this.imgEffect).delay(this.storyDelay)},buildErrors:function(){var c=$E('body');c.empty();var d=new Element('h2',{id:'gallery-error-header'});d.setText(this.errMsgHeaderText);var e=new Element('p',{id:'gallery-error-intro'});e.setText(this.errMsgIntroText);c.appendChild(d);c.appendChild(e);var f=new Element('ul',{id:'gallery-error-list'});var g=1;this.errMsgs.each(function(a){var b=new Element('li',{id:'gallery-error-message-'+g});b.setHTML(a);f.appendChild(b);g++});c.appendChild(f)},beginGallery:function(){this.buildGallery();this.rotator=(function(){if(this.currentindex==(this.datasource.length-1)){this.currentindex=0}else{this.currentindex=this.currentindex+1}this.updateStory(this.currentindex)}.bind(this)).periodical(this.storyDuration)}});