function YHCarousel(mover,align,thumbs,content,height,leftButton,rightButton,width,pages,thumbSpeed,contentSpeed,asyncIDs,asyncSRCs){this.elements=content;this.height=height;this.position=0;this.width=width;this.pages=pages;this.align=align;this.thumbs=thumbs;this.thumbSpeed=thumbSpeed;this.contentSpeed=contentSpeed;this.asyncIDs=asyncIDs;this.asyncSRCs=asyncSRCs;this.loaded=0;this.carousel=new yhFx.Style($(mover),'marginLeft',{duration:this.thumbSpeed});this.rightHeight=$(rightButton).scrollHeight;$(rightButton).addEvent('mouseover',function(){$(rightButton+'_idle').style.display='none';$(rightButton+'_hover').style.display='block';$(rightButton+'_down').style.display='none';});$(rightButton).addEvent('mouseout',function(){$(rightButton+'_idle').style.display='block';$(rightButton+'_hover').style.display='none';$(rightButton+'_down').style.display='none';});$(rightButton).addEvent('mousedown',function(){$(rightButton+'_idle').style.display='none';$(rightButton+'_hover').style.display='none';$(rightButton+'_down').style.display='block';});$(rightButton).addEvent('mouseup',function(){this.moveRight();$(rightButton+'_idle').style.display='none';$(rightButton+'_down').style.display='none';$(rightButton+'_hover').style.display='block';}.bind(this));this.leftHeight=$(leftButton).scrollHeight;$(leftButton).addEvent('mouseover',function(){$(leftButton+'_idle').style.display='none';$(leftButton+'_hover').style.display='block';$(leftButton+'_down').style.display='none';});$(leftButton).addEvent('mouseout',function(){$(leftButton+'_idle').style.display='block';$(leftButton+'_hover').style.display='none';$(leftButton+'_down').style.display='none';});$(leftButton).addEvent('mousedown',function(){$(leftButton+'_idle').style.display='none';$(leftButton+'_hover').style.display='none';$(leftButton+'_down').style.display='block';});$(leftButton).addEvent('mouseup',function(){this.moveLeft();$(leftButton+'_idle').style.display='none';$(leftButton+'_down').style.display='none';$(leftButton+'_hover').style.display='block';}.bind(this));$(rightButton+'_idle').style.display='block';$(rightButton+'_hover').style.display='none';$(rightButton+'_down').style.display='none';$(leftButton+'_idle').style.display='block';$(leftButton+'_hover').style.display='none';$(leftButton+'_down').style.display='none';var hideH;this.elements.each(function(el,i){if(i){var hideO=new yhFx.Style($(el),'opacity',{duration:0});hideO.custom(0,0);$(el).style.display='none';}},this);var showH=new yhFx.Style($(align),'height',{duration:0});showH.custom(0,$(this.elements[0]).offsetHeight);i=0;thumbs.each(function(thumb,i){if(this.asyncSRCs[i]==''){$(thumb).addEvent('click',function(){this.showThisHideOpen(i)}.bind(this));}else{$(thumb).style.opacity=0.25;}},this);}
YHCarousel.prototype.loadLate=function(){if(this.loaded>this.asyncSRCs.length){return;}
	var w=Math.ceil(this.asyncSRCs.length/this.pages);var j=(this.position+1)*w;var newarray=this.asyncSRCs.slice(this.loaded,j+w);this.imageAsset=new Asset.images(newarray,{onProgress:function(){if($(this.asyncIDs[this.loaded])){$(this.asyncIDs[this.loaded]).src=this.asyncSRCs[this.loaded];}
																																									var fadeinO=new yhFx.Style($(this.thumbs[this.loaded]),'opacity',{duration:200});fadeinO.start(1.0);$(this.thumbs[this.loaded]).addEvent('click',function(index){this.showThisHideOpen(index)}.bind(this,this.loaded));this.loaded++;}.bind(this)});var i;var fadeinO=[];}
YHCarousel.prototype.moveLeft=function(){if(this.position==0){return;}
oldM=this.position*this.width*-1;this.position=this.position-1;newM=this.position*this.width*-1;this.carousel.custom(oldM,newM);}
YHCarousel.prototype.moveRight=function(){if(this.position>=this.pages-1){return;}
oldM=this.position*this.width*-1;this.position=this.position+1;newM=this.position*this.width*-1;this.carousel.custom(oldM,newM);this.loadLate();}
YHCarousel.prototype.showThisHideOpen=function(iToShow){if(iToShow!=this.previousClick){this.previousClick=iToShow;var objObjs={};var madeInactive=false;var elToShow='';var elToHide='';var showHeight=this.height;var ov;var newHeight;this.elements.each(function(el,i){if(i!=iToShow){if($(el).offsetHeight>0){elToHide=$(this.elements[i]);}}else{elToShow=$(this.elements[i]);}},this);if(elToHide==''){if(iToShow==0)
	return;else
		elToHide=$(this.elements[0]);}
var showO=new yhFx.Style(elToShow,'opacity',{duration:this.contentSpeed,onComplete:function(){}});var changeH=new yhFx.Style($(this.align),'height',{duration:this.contentSpeed,onComplete:function(){showO.custom(0,1);elToShow.style.overflow=ov;}});var hideO=new yhFx.Style(elToHide,'opacity',{duration:this.contentSpeed,onComplete:function(){ov=elToShow.getStyle('overflow');elToShow.style.overflow='hidden';elToShow.style.display='block';newHeight=(showHeight)?showHeight:elToShow.scrollHeight;elToShow.style.display='none';elToShow.style.overflow=ov;changeH.custom(elToHide.offsetHeight,newHeight);elToHide.style.display='none';elToShow.style.display='block';}});hideO.custom(1,0);}}
