(function(A){A.fn.animatedinnerfade=function(C){var B;var D=false;this.each(function(){var G={animationtype:"fade",speed:"normal",timeout:15000,type:"sequence",containerheight:"300px",containerwidth:"600px",runningclass:"innerfade",animationSpeed:15000,bgFrame:"none",controlButtonsPath:"img",controlBox:"none",controlBoxClass:"none",displayTitle:"none",titleClass:"innerfade-title"};if(C){A.extend(G,C)}var H=A(this).children();if(G.displayTitle!="none"){A(this).append("<div class='"+G.titleClass+"'><h2>"+A(H[0]).find("a:first img").attr("title")+"</h2></div>")}if(G.bgFrame!="none"){A(this).append("<div class='bg-frame'><a href='"+A(H[0]).find("a:first").attr("href")+"'><img src='"+G.bgFrame+"' width='"+G.containerwidth+"' height='"+G.containerheight+"'/></a></div>");A(this).find(".bg-frame").css("position","absolute").css("top",0).css("left",0).css("z-index",300).css("height",G.containerheight).css("width",G.containerwidth)}if(G.controlBox!="none"){A(this).bind("mouseover",function(){A(this).find(".control-panel").show()});A(this).bind("mouseout",function(){A(this).find(".control-panel").hide()});A(this).append("<div class='"+G.controlBoxclass+" control-panel'><a class='back-button' href='#'><img src='"+G.controlButtonsPath+"/previous.gif' alt='previous' /></a> <a class='pause-button' href='#'><img src='"+G.controlButtonsPath+"/pause.gif' alt='pause' /></a> <a class='next-button' href='#'><img src='"+G.controlButtonsPath+"/next.gif' alt='next' /></a></div>");A(this).find(".control-panel").hide();A(this).find(".control-panel").css("z-index",350).css("position","absolute");if(G.controlBoxClass=="none"){A(".control-panel").css("right","10px").css("top","5px").css("textAlign","right").css("margin",0).css("paddingTop","0").css("marginRight","0").css("fontSize","20px").css("color","#88d300")}A(this).find(".control-panel a.next-button").bind("click",function(){D=false;clearTimeout(B);A(".control-panel a.pause-button").html("<img src='"+G.controlButtonsPath+"/pause.gif' alt='pause' />");A.animatedinnerfade.next(H,G,1,0,B,D);return false});A(this).find(".control-panel a.back-button").bind("click",function(){D=false;clearTimeout(B);A(".control-panel a.pause-button").html("<img src='"+G.controlButtonsPath+"/pause.gif' alt='pause' />");A.animatedinnerfade.next(H,G,H.length-1,0,B,D);return false});A(this).find(".control-panel a.pause-button").bind("click",function(){clearTimeout(B);if(!D){D=true;A(this).html("<img src='"+G.controlButtonsPath+"/play.gif' alt='play' />");A(H[0]).stop().stop()}else{D=false;A(this).html("<img src='"+G.controlButtonsPath+"/pause.gif' alt='pause' />");var J=-(parseInt(A(H[0]).find("img").attr("width"))-parseInt(G.containerwidth));if(J>0){J=0}var I=parseInt(G.timeout)-parseInt((parseInt(A(H[0]).css("left"))/parseInt(J))*parseInt(G.timeout));A(H[0]).animate({top:0,left:J},I);B=setTimeout(function(){A.animatedinnerfade.next(H,G,1,0,B,D)},I)}return false})}if(H.length>1){A(this).css("position","relative").css("overflow","hidden").css("height",G.containerheight).css("width",G.containerwidth);A(this).addClass(G.runningclass);for(var F=0;F<H.length;F++){A(H[F]).css("position","absolute").css("top",0).css("left",0).css("z-index",String(H.length-F));A(H[F]).hide()}A(H[0]).css("top",0);A(H[0]).css("left",0);A.animatedinnerfade.move_photo(H[0],G);if(G.type=="sequence"){B=setTimeout(function(){A.animatedinnerfade.next(H,G,1,0,B,D)},G.timeout)}else{var E;do{E=Math.floor(Math.random()*(H.length))}while(E==0);B=setTimeout((function(){A.animatedinnerfade.next(H,G,E,0,B,D)}),G.timeout)}A(H[0]).show()}})};A.animatedinnerfade=function(){};A.animatedinnerfade.next=function(B,E,J,K,F,C){clearTimeout(F);var I,D;if(J==(B.length-1)){I=0}else{I=J+1}if(J==0){D=B.length-1}else{D=J-1}for(var H=0;H<B.length;H++){if((H!=K)&&(H!=J)){A(B[H]).css("z-index","1");A(B[H]).hide()}}A(B[K]).css("z-index","190");A(B[J]).css("z-index","195");if(E.displayTitle!="none"){A("."+E.titleClass+" h2").html(A(B[J]).find("a:first img").attr("title"))}if(E.controlBox!="none"){A(this).find(".control-panel a.next-button").unbind("click");A(".control-panel a.next-button").bind("click",function(){C=false;clearTimeout(F);A(".control-panel a.pause-button").html("<img src='"+E.controlButtonsPath+"/pause.gif' alt='pause' />");A.animatedinnerfade.next(B,E,I,J,F,C);return false});A(this).find(".control-panel a.back-button").unbind("click");A(".control-panel a.back-button").bind("click",function(){C=false;clearTimeout(F);A(".control-panel a.pause-button").html("<img src='"+E.controlButtonsPath+"/pause.gif' alt='pause' />");A.animatedinnerfade.next(B,E,D,J,F,C);return false});A(this).find(".control-panel a.pause-button").unbind("click");A(".control-panel a.pause-button").bind("click",function(){clearTimeout(F);if(!C){C=true;A(this).html("<img src='"+E.controlButtonsPath+"/play.gif' alt='play' />");A(B[J]).stop().stop()}else{C=false;A(this).html("<img src='"+E.controlButtonsPath+"/pause.gif' alt='pause' />");var M=-(parseInt(A(B[J]).find("img").attr("width"))-parseInt(E.containerwidth));if(M>0){M=0}var L=parseInt(E.timeout)-parseInt((parseInt(A(B[J]).css("left"))/parseInt(M))*parseInt(E.timeout));A(B[J]).animate({top:0,left:M},L);F=setTimeout((function(){A.animatedinnerfade.next(B,E,I,J,F,C)}),L)}return false})}if(E.bgFrame!="none"){A(this).find(".bg-frame a").attr("href",A(B[J]).find("a:first").attr("href"))}A(B[J]).css("top",0).css("left",0);if(E.animationtype=="slide"){A(B[K]).slideUp(E.speed,A(B[J]).slideDown(E.speed))}else{if(E.animationtype=="fade"){A(B[K]).fadeOut(E.speed);A(B[J]).fadeIn(E.speed)}else{alert("animationtype must either be 'slide' or 'fade'")}}A.animatedinnerfade.move_photo(B[J],E);if(E.type=="sequence"){F=setTimeout((function(){A.animatedinnerfade.next(B,E,I,J,F,C)}),E.timeout)}else{var G;do{G=Math.floor(Math.random()*(B.length))}while(G==J);F=setTimeout((function(){A.animatedinnerfade.next(B,E,G,J,F,C)}),E.timeout)}};A.animatedinnerfade.move_photo=function(C,D){var B=-(parseInt(A(C).find("img").attr("height"))-parseInt(D.containerheight));var E=-(parseInt(A(C).find("img").attr("width"))-parseInt(D.containerwidth));if(B>0){B=0}if(E>0){E=0}A(C).animate({top:B,left:parseInt(E/2)},parseInt(D.animationSpeed/2)).animate({top:0,left:E},parseInt(D.animationSpeed/2))}})(jQuery)