/*\
*** pelAccordion v1
***
*** A javascript Plugin
*** from Bird & Co Creative
***
*** 20100127
\*/

$(document).ready(function(){
	var heightArray = new Array();
	$("div#pelAcc").children().each(function(){

		tempHeight = $(this).find(".pelAccContent").height();
		tempClass = $(this).attr("class");
		heightArray.push(tempHeight);
		if(!tempClass.match("current")){
			$(this).find(".pelAccContent").hide();
			var prep = "<p class='paIndicator'>+</p>&nbsp;";
		}else{
			var prep = "<p class='paIndicator'>-</p>&nbsp;";
		}

		//Add +-
		/*$(this).prepend(prep + "<div>test");
		$(this).append("</div>");*/
		var tempHtml = $(this).html();
		$(this).html(prep + "<div class='accRight'>" + tempHtml + "</div>");
	});
	
    $('div#pelAcc a.pelAccTitle').click(function(){
        $(this).css('outline','none');
        if($(this).parent().parent().hasClass('current')){
        	$(this).parent().parent().find('.paIndicator').html('+');
        	$(this).siblings('div').slideUp('slow',function(){
            	$(this).parent().parent().removeClass('current');
            });
        }else{
            var ii = 0;
            $("div#pelAcc").children().removeClass("current");
            $(this).parent().parent().addClass("current");
            $("div#pelAcc").children().each(function(){
            	$(this).find('.paIndicator').html('+');
            	tempClass = $(this).attr("class");
            	if(tempClass.match("current")){
            		$(this).find('.paIndicator').html('-');
            		$(this).find(".pelAccContent").css("height","0px");
            		$(this).find(".pelAccContent").animate({
            	        height: heightArray[ii] + "px"
            		}, 500 );
        		}else{
        			$(this).find(".pelAccContent").slideUp('slow');
        		}
            	
            	ii++;
            });
        }  
        return false;  
    });  
});
