﻿var ddaccordion={contentclassname:{},expandone:function(a,b){this.toggleone(a,b,"expand")},collapseone:function(a,b){this.toggleone(a,b,"collapse")},expandall:function(b){var a=jQuery,c=a("."+b);a("."+this.contentclassname[b]+":hidden").each(function(){c.eq(parseInt(a(this).attr("contentindex"))).trigger("evt_accordion")})},collapseall:function(b){var a=jQuery,c=a("."+b);a("."+this.contentclassname[b]+":visible").each(function(){c.eq(parseInt(a(this).attr("contentindex"))).trigger("evt_accordion")})},toggleone:function(c,d,a){var e=jQuery,f=e("."+c).eq(d),b=e("."+this.contentclassname[c]).eq(d);if(typeof a=="undefined"||a=="expand"&&b.is(":hidden")||a=="collapse"&&b.is(":visible"))f.trigger("evt_accordion")},expandit:function(a,c,b,d,e){this.transformHeader(a,b,"expand");c.slideDown(b.animatespeed,function(){b.onopenclose(a.get(0),parseInt(a.attr("headerindex")),c.css("display"),d);if(b.postreveal=="gotourl"&&e){var f=a.is("a")?a.get(0):a.find("a:eq(0)").get(0);if(f)setTimeout(function(){location=f.href},200)}})},collapseit:function(a,c,b,d){this.transformHeader(a,b,"collapse");c.slideUp(b.animatespeed,function(){b.onopenclose(a.get(0),parseInt(a.attr("headerindex")),c.css("display"),d)})},transformHeader:function(b,a,c){b.addClass(c=="expand"?a.cssclass.expand:a.cssclass.collapse).removeClass(c=="expand"?a.cssclass.collapse:a.cssclass.expand);if(a.htmlsetting.location=="src"){b=b.is("img")?b:b.find("img").eq(0);b.attr("src",c=="expand"?a.htmlsetting.expand:a.htmlsetting.collapse)}else if(a.htmlsetting.location=="prefix")b.find(".accordprefix").html(c=="expand"?a.htmlsetting.expand:a.htmlsetting.collapse);else if(a.htmlsetting.location=="suffix")b.find(".accordsuffix").html(c=="expand"?a.htmlsetting.expand:a.htmlsetting.collapse)},urlparamselect:function(b){var a=window.location.search.match(new RegExp(b+"=((\\d+)(,(\\d+))*)","i"));if(a!=null)a=RegExp.$1.split(",");return a},getCookie:function(b){var a=new RegExp(b+"=[^;]+","i");if(document.cookie.match(a))return document.cookie.match(a)[0].split("=")[1];return null},setCookie:function(b,a){document.cookie=b+"="+a+"; path=/"},init:function(a){document.write('<style type="text/css">\n');document.write("."+a.contentclass+"{display: none}\n");document.write("</style>");jQuery(document).ready(function(b){ddaccordion.urlparamselect(a.headerclass);var f=ddaccordion.getCookie(a.headerclass);ddaccordion.contentclassname[a.headerclass]=a.contentclass;a.cssclass={collapse:a.toggleclass[0],expand:a.toggleclass[1]};a.revealtype=a.revealtype||"click";a.revealtype=a.revealtype.replace(/mouseover/i,"mouseenter");if(a.revealtype=="clickgo"){a.postreveal="gotourl";a.revealtype="click"}if(typeof a.togglehtml=="undefined")a.htmlsetting={location:"none"};else a.htmlsetting={location:a.togglehtml[0],collapse:a.togglehtml[1],expand:a.togglehtml[2]};a.oninit=typeof a.oninit=="undefined"?function(){}:a.oninit;a.onopenclose=typeof a.onopenclose=="undefined"?function(){}:a.onopenclose;var d={},c=ddaccordion.urlparamselect(a.headerclass)||(a.persiststate&&f!=null?f:a.defaultexpanded);if(typeof c=="string")c=c.replace(/c/ig,"").split(",");var e=b("."+a["contentclass"]);if(c.length==1&&c[0]=="-1")c=[];if(a["collapseprev"]&&c.length>1)c=[c.pop()];if(a["onemustopen"]&&c.length==0)c=[0];b("."+a["headerclass"]).each(function(f){if(/(prefix)|(suffix)/i.test(a.htmlsetting.location)&&b(this).html()!=""){b('<span class="accordprefix"></span>').prependTo(this);b('<span class="accordsuffix"></span>').appendTo(this)}b(this).attr("headerindex",f+"h");e.eq(f).attr("contentindex",f+"c");var g=e.eq(f),h=typeof c[0]=="number"?f:f+"";if(jQuery.inArray(h,c)!=-1){if(a.animatedefault==false)g.show();ddaccordion.expandit(b(this),g,a,false);d={$header:b(this),$content:g}}else{g.hide();a.onopenclose(b(this).get(0),parseInt(b(this).attr("headerindex")),g.css("display"),false);ddaccordion.transformHeader(b(this),a,"collapse")}});b("."+a["headerclass"]).bind("evt_accordion",function(g,f){var c=e.eq(parseInt(b(this).attr("headerindex")));if(c.css("display")=="none"){ddaccordion.expandit(b(this),c,a,true,f);if(a["collapseprev"]&&d.$header&&b(this).get(0)!=d.$header.get(0))ddaccordion.collapseit(d.$header,d.$content,a,true);d={$header:b(this),$content:c}}else if(!a["onemustopen"]||a["onemustopen"]&&d.$header&&b(this).get(0)!=d.$header.get(0))ddaccordion.collapseit(b(this),c,a,true)});b("."+a["headerclass"]).bind(a.revealtype,function(){if(a.revealtype=="mouseenter"){clearTimeout(a.revealdelay);var c=parseInt(b(this).attr("headerindex"));a.revealdelay=setTimeout(function(){ddaccordion.expandone(a["headerclass"],c)},a.mouseoverdelay||0)}else{b(this).trigger("evt_accordion",[true]);return false}});b("."+a["headerclass"]).bind("mouseleave",function(){clearTimeout(a.revealdelay)});a.oninit(b("."+a["headerclass"]).get(),c);b(window).bind("unload",function(){b("."+a["headerclass"]).unbind();var c=[];b("."+a["contentclass"]+":visible").each(function(){c.push(b(this).attr("contentindex"))});if(a.persiststate==true&&b("."+a["headerclass"]).length>0){c=c.length==0?"-1c":c;ddaccordion.setCookie(a.headerclass,c)}})})}}
