//# jQuery - Horizontal Accordion
//# Version 2.00.00 Alpha 1
//#
//# portalZINE(R) - New Media Network
//# http://www.portalzine.de
//#
//# Alexander Graef
//# portalzine@gmail.com
//#
//# Copyright 2007-2009

(function(a){a.hrzAccordion={setOnEvent:function(d,b,g,c){a("#"+b+"Handle"+d).bind(c.eventTrigger,function(){if(1==a("[rel="+b+"ContainerSelected]").data("status")&&!0===c.eventWaitForAnim)return!1;if(a("#"+b+"Handle"+d).attr("rel")!=b+"HandleSelected"){c.eventAction;a("[id*="+b+"Handle]").attr("rel","");a("[id*="+b+"Handle]").attr("class",c.handleClass);a("#"+b+"Handle"+d).addClass(c.handleClassSelected);a("."+c.contentWrapper).css({width:g+"px"});switch(c.closeOpenAnimation){case 1:a("[rel="+b+
"ContainerSelected]").get(0)?(a("[rel="+b+"ContainerSelected]").data("status",1),a("[rel="+b+"ContainerSelected]").animate({width:"0px",opacity:"0"},{queue:!0,duration:c.closeSpeed,easing:c.closeEaseAction,complete:function(){a("[rel="+b+"ContainerSelected]").data("status",0)},step:function(c){width=a(this).width();new_width=g-width;a("#"+b+"Content"+d).width(Math.ceil(new_width)).css("opacity","1")}})):(a("[rel="+b+"ContainerSelected]").data("status",1),a("#"+b+"Content"+d).animate({width:g,opacity:"1"},
{queue:!1,duration:c.closeSpeed,easing:c.closeEaseAction,complete:function(){a("[rel="+b+"ContainerSelected]").data("status",0)}}));break;case 2:a("[id*="+b+"Content]").css({width:"0px"}),a("#"+b+"Content"+d).animate({width:g+"px",opacity:"1"},{queue:!1,duration:c.openSpeed,easing:c.openEaseAction,complete:c.completeAction})}a("[id*="+b+"Content]").attr("rel","");a("#"+b+"Handle"+d).attr("rel",b+"HandleSelected");a("#"+b+"Content"+d).attr("rel",b+"ContainerSelected")}})}};a.fn.extend({hrzAccordionLoop:function(d){return this.each(function(b){var d=
a(this).attr("id")||a(this).attr("class"),c=a("#"+d+" > li, ."+d+" > li").size(),h=a(this).data("settings");variable_holder="interval"+d;var e=0,f="start";variable_holder=window.setInterval(function(){a("#"+d+"Handle"+e).trigger(h.eventTrigger);e="start"==f?e+1:e-1;e==c&&"start"==f&&(f="end",e=c-1);0==e&&"end"==f&&(f="start",e=0)},h.cycleInterval)})},hrzAccordion:function(d){this.settings={eventTrigger:"click",containerClass:"container",listItemClass:"listItem",contentContainerClass:"contentContainer",
contentWrapper:"contentWrapper",contentInnerWrapper:"contentInnerWrapper",handleClass:"handle",handleClassOver:"handleOver",handleClassSelected:"handleSelected",handlePosition:"right",handlePositionArray:"",closeEaseAction:"swing",closeSpeed:500,openEaseAction:"swing",openSpeed:500,openOnLoad:2,hashPrefix:"tab",eventAction:function(){},completeAction:function(){},closeOpenAnimation:1,cycle:!1,cycleInterval:1E4,fixedWidth:"",eventWaitForAnim:!0};d&&a.extend(this.settings,d);var b=this.settings;return this.each(function(d){var c=
a(this).attr("id")||a(this).attr("class");a(this).data("settings",b);a(this).wrap("<div class='"+b.containerClass+"'></div>");var h=a("#"+c+" > li, ."+c+" > li").size();d=a("."+b.containerClass).width();var e=a("."+b.handleClass).css("width"),e=e.replace(/px/,""),f,k;f=b.fixedWidth?b.fixedWidth:d-h*e-e;a("#"+c+" > li, ."+c+" > li").each(function(d){a(this).attr("id",c+"ListItem"+d);a(this).attr("class",b.listItemClass);a(this).html("<div class='"+b.contentContainerClass+"' id='"+c+"Content"+d+"'><div class=\""+
b.contentWrapper+'"><div class="'+b.contentInnerWrapper+'">'+a(this).html()+"</div></div></div>");if(a("div",this).hasClass(b.handleClass)){var e=a("div."+b.handleClass,this).attr("id",""+c+"Handle"+d+"").html();a("div."+b.handleClass,this).remove();k='<div class="'+b.handleClass+"\" id='"+c+"Handle"+d+"'>"+e+"</div>"}else k='<div class="'+b.handleClass+"\" id='"+c+"Handle"+d+"'></div>";b.handlePositionArray&&(splitthis=b.handlePositionArray.split(","),b.handlePosition=splitthis[d]);switch(b.handlePosition){case "left":a(this).prepend(k);
break;case "right":a(this).append(k);break;case "top":a("."+c+"Top").append(k);break;case "bottom":a("."+c+"Bottom").append(k)}a("#"+c+"Handle"+d).bind("mouseover",function(){a("#"+c+"Handle"+d).addClass(b.handleClassOver)});a("#"+c+"Handle"+d).bind("mouseout",function(){"selected"!=a("#"+c+"Handle"+d).attr("rel")&&a("#"+c+"Handle"+d).removeClass(b.handleClassOver)});a.hrzAccordion.setOnEvent(d,c,f,b);d==h-1&&a("#"+c+",."+c).show();if(!1!==b.openOnLoad&&d==h-1){e=location.hash;e=e.replace("#","");
if("-1"!=e.search(b.hashPrefix))var g=1,e=e.replace(b.hashPrefix,"");e&&1==g?(a("#"+c+"Handle"+e).attr("rel",c+"HandleSelected"),a("#"+c+"Content"+e).attr("rel",c+"ContainerSelected"),a("#"+c+"Handle"+(e-1)).trigger(b.eventTrigger)):(a("#"+c+"Handle"+b.openOnLoad).attr("rel",c+"HandleSelected"),a("#"+c+"Content"+b.openOnLoad).attr("rel",c+"ContainerSelected"),a("#"+c+"Handle"+(b.openOnLoad-1)).trigger(b.eventTrigger))}});!0===b.cycle&&a(this).hrzAccordionLoop()})}})})(jQuery);