﻿
function init() {
	
	var stretchers = document.getElementsByClassName('stretcher'); //div that stretches
	var toggles = document.getElementsByClassName('display'); //h3s where I click on

	//accordion effect
	var myAccordion = new fx.Accordion(
		toggles, stretchers, {opacity: true, duration: 500}
	);

	//hash function
	function checkHash(){
		var found = false;
		toggles.each(function(div, i){
			if (window.location.href.indexOf(div.title) > 0) {
				myAccordion.showThisHideOpen(stretchers[i]);
				found = true;
			}
		});
		return found;
	}
	    if (!checkHash())  { myAccordion.showThisHideOpen(stretchers[0]); }
    }
    
//    var lastId = 0;
//    function bG(obj) {
//        if(obj.id != lastId && lastId != 0) { $(lastId).className = 'collapse_item'; $("b"+lastId).style.display = "none"; }
//	    lastId = obj.id;
//	    if($(obj.id).className == 'collapse_item') { $(obj.id).className = 'expand_item'; $('0').className = 'collapse_item'; $("b0").style.display = "block";  }
//	    if($(obj.id).className == 'collapse_item' && $('0').className != 'expand_item') { $(obj.id).className = 'expand_item'; $("b"+obj.id).style.display = "block"; }
// 
//    }
    var lastId = null;
    function bG(obj) {
        if(obj.id != lastId && lastId != null) { $(lastId).className = "collapse_item"; $("b"+lastId).style.display = "none"; }
        lastId = obj.id;
        if($(obj.id).className == "collapse_item") { $(obj.id).className="expand_item"; $("b"+obj.id).style.display = "block"; }
        else {$(obj.id).className = "collapse_item"; $("b"+obj.id).style.display = "none"; };
    }
    
    function findId() {
        if($('0')) {
            $('0').className = "expand_item";
        }
    }
