var ddaccordion={ajaxloadingmsg:'<img src="./imgs_others/loading.gif" /><br />Loading Content...',headergroup:{},contentgroup:{},preloadimages:function(a){a.each(function(){(new Image).src=this.src})},expandone:function(a,b){this.toggleone(a,b,"expand")},collapseone:function(a,b){this.toggleone(a,b,"collapse")},expandall:function(a){var b=this.headergroup[a];this.contentgroup[a].filter(":hidden").each(function(){b.eq(parseInt($(this).attr("contentindex"))).trigger("evt_accordion")})},collapseall:function(a){var b= this.headergroup[a];this.contentgroup[a].filter(":visible").each(function(){b.eq(parseInt($(this).attr("contentindex"))).trigger("evt_accordion")})},toggleone:function(a,b,c){var e=this.headergroup[a].eq(b),a=this.contentgroup[a].eq(b);(typeof c=="undefined"||c=="expand"&&a.is(":hidden")||c=="collapse"&&a.is(":visible"))&&e.trigger("evt_accordion")},ajaxloadcontent:function(a,b,c,e){function g(a){if(a&&(f.cacheddata=a,f.status="cached",b.queue("fx").length==0))b.hide().html(a),f.status="complete", e();f.status!="complete"&&setTimeout(function(){g(f.cacheddata)},100)}var f=a.data("ajaxinfo");f.status=="none"?(b.html(this.ajaxloadingmsg),b.slideDown(c.animatespeed),f.status="loading",$.ajax({url:f.url,error:function(a){g("Error fetching content. Server Response: "+a.responseText)},success:function(a){g(a==""?" ":a)}})):f.status=="loading"&&g(f.cacheddata)},expandit:function(a,b,c,e,g,f){var d=a.data("ajaxinfo");if(d)if(d.status=="none"||d.status=="loading")this.ajaxloadcontent(a,b,c,function(){ddaccordion.expandit(a, b,c,e,g)});else if(d.status=="cached")b.html(d.cacheddata),d.cacheddata=null,d.status="complete";this.transformHeader(a,c,"expand");b.slideDown(f?0:c.animatespeed,function(){c.onopenclose(a.get(0),parseInt(a.attr("headerindex")),b.css("display"),e);if(c.postreveal=="gotourl"&&g){var d=a.is("a")?a.get(0):a.find("a:eq(0)").get(0);d&&setTimeout(function(){location=d.href},200)}})},collapseit:function(a,b,c,e){this.transformHeader(a,c,"collapse");b.slideUp(c.animatespeed,function(){c.onopenclose(a.get(0), parseInt(a.attr("headerindex")),b.css("display"),e)})},transformHeader:function(a,b,c){a.addClass(c=="expand"?b.cssclass.expand:b.cssclass.collapse).removeClass(c=="expand"?b.cssclass.collapse:b.cssclass.expand);b.htmlsetting.location=="src"?(a=a.is("img")?a:a.find("img").eq(0),a.attr("src",c=="expand"?b.htmlsetting.expand:b.htmlsetting.collapse)):b.htmlsetting.location=="prefix"?a.find(".accordprefix").html(c=="expand"?b.htmlsetting.expand:b.htmlsetting.collapse):b.htmlsetting.location=="suffix"&& a.find(".accordsuffix").html(c=="expand"?b.htmlsetting.expand:b.htmlsetting.collapse)},urlparamselect:function(a){a=window.location.search.match(RegExp(a+"=((\\d+)(,(\\d+))*)","i"));a!=null&&(a=RegExp.$1.split(","));return a},getCookie:function(a){a=RegExp(a+"=[^;]+","i");if(document.cookie.match(a))return document.cookie.match(a)[0].split("=")[1];return null},setCookie:function(a,b){document.cookie=a+"="+b+"; path=/"},init:function(a){document.write('<style type="text/css">\n');document.write("."+ a.contentclass+"{display: none}\n");document.write("a.hiddenajaxlink{display: none}\n");document.write("</style>");jQuery(document).ready(function(b){ddaccordion.urlparamselect(a.headerclass);var c=ddaccordion.getCookie(a.headerclass);ddaccordion.headergroup[a.headerclass]=b("."+a.headerclass);ddaccordion.contentgroup[a.headerclass]=b("."+a.contentclass);var e=ddaccordion.headergroup[a.headerclass],g=ddaccordion.contentgroup[a.headerclass];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";a.htmlsetting=typeof a.togglehtml=="undefined"?{location:"none"}:{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 f={},d=ddaccordion.urlparamselect(a.headerclass)||(a.persiststate&& c!=null?c:a.defaultexpanded);typeof d=="string"&&(d=d.replace(/c/ig,"").split(","));d.length==1&&d[0]=="-1"&&(d=[]);a.collapseprev&&d.length>1&&(d=[d.pop()]);a.onemustopen&&d.length==0&&(d=[0]);e.each(function(c){var e=b(this);/(prefix)|(suffix)/i.test(a.htmlsetting.location)&&e.html()!=""&&(b('<span class="accordprefix"></span>').prependTo(this),b('<span class="accordsuffix"></span>').appendTo(this));e.attr("headerindex",c+"h");g.eq(c).attr("contentindex",c+"c");var h=g.eq(c),i=h.find("a.hiddenajaxlink:eq(0)"); i.length==1&&e.data("ajaxinfo",{url:i.attr("href"),cacheddata:null,status:"none"});jQuery.inArray(typeof d[0]=="number"?c:c+"",d)!=-1?(ddaccordion.expandit(e,h,a,!1,!1,!a.animatedefault),f={$header:e,$content:h}):(h.hide(),a.onopenclose(e.get(0),parseInt(e.attr("headerindex")),h.css("display"),!1),ddaccordion.transformHeader(e,a,"collapse"))});e.bind("evt_accordion",function(c,e){var d=g.eq(parseInt(b(this).attr("headerindex")));d.css("display")=="none"?(ddaccordion.expandit(b(this),d,a,!0,e),a.collapseprev&& f.$header&&b(this).get(0)!=f.$header.get(0)&&ddaccordion.collapseit(f.$header,f.$content,a,!0),f={$header:b(this),$content:d}):(!a.onemustopen||a.onemustopen&&f.$header&&b(this).get(0)!=f.$header.get(0))&&ddaccordion.collapseit(b(this),d,a,!0)});e.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 return b(this).trigger("evt_accordion", [!0]),!1});e.bind("mouseleave",function(){clearTimeout(a.revealdelay)});a.oninit(e.get(),d);b(window).bind("unload",function(){e.unbind();var c=[];g.filter(":visible").each(function(){c.push(b(this).attr("contentindex"))});a.persiststate==!0&&e.length>0&&(c=c.length==0?"-1c":c,ddaccordion.setCookie(a.headerclass,c))})})}};ddaccordion.preloadimages(jQuery(ddaccordion.ajaxloadingmsg).filter("img"));
