﻿// JScript File
Event.observe(window, 'load', initiateExpandCollapse);
function initiateExpandCollapse(){
    var elmContent = document.getElementsByClassName("ExpandableContent");
    for(i=0; i<elmContent.length; i++)
    {
            if($(elmContent[i]).style.maxHeight != '')
            {
                var maxHeight = $(elmContent[i]).style.maxHeight.gsub('px','');
                $(elmContent[i]).style.maxHeight = (maxHeight + 1) + 'px';
                
                if($(elmContent[i]).getHeight() > maxHeight)
                    new Insertion.After($(elmContent[i]), "<div align=\"right\" class=\"ExpandCollapse\"><a href=\"#\" class=\"ExpandLink\" onclick=\"expandContent(this, " + $(elmContent[i]).getHeight() + ");return false;\">[+] show more</a></div>"); 
                
                $(elmContent[i]).style.maxHeight = maxHeight + 'px';
                
            }
    }
}

function expandContent(elmLink){
    var cont = $(elmLink).parentNode.previousSibling;
    var origHeight = $(cont).getHeight();
    cont.style.maxHeight="";
    $(elmLink.parentNode).remove();
    new Insertion.After($(cont), "<div align=\"right\" class=\"ExpandCollapse\"><a href=\"#\" class=\"CollapseLink\" onclick=\"collapseContent(this, " + origHeight + ");return false;\">[-] show less</a></div>"); 
}

function collapseContent(elmLink, origHeight){
    var cont = $(elmLink).parentNode.previousSibling;
    cont.style.maxHeight=origHeight+'px';
    $(elmLink.parentNode).remove();
    new Insertion.After($(cont), "<div align=\"right\" class=\"ExpandCollapse\"><a href=\"#\" class=\"ExpandLink\" onclick=\"expandContent(this);return false;\">[+] show more</a></div>"); 
}

function email(mailbox)
{
    var recipient = mailbox;
    var domain = "lakecitiesballet.org";
    document.write('<a href=\"mailto:' + recipient + '@' + domain + '\">');
    document.write(recipient + '@' + domain + '<' + '/a>');
}

