//                _                 __       _     _____                      
//   __  ______  (_)___ ___  ____ _/ /______(_)  _/__  /  _  _____  _________ 
//  / / / / __ \/ / __ \__ \/ __ \/ __/ ___/ / |/_/ / /  | |/_/ _ \/ ___/ __ \
// / /_/ / / / / / / / / / / /_/ / /_/ /  / />  <  / /___>  </  __/ /  / /_/ /
// \__,_/_/ /_/_/_/ /_/ /_/\__,_/\__/_/  /_/_/|_| /____/_/|_|\___/_/   \____/ 
//                                                                           
// This Javascript file was created for Nadja Verena Marcin by Sam Figueroa
// 2008-03-02

new Event.observe(window, 'load', function(el){
    $$('.abridge').each(function(el){
        // exit if the text is very short anyway
        if(el.innerHTML.length < 50) return false
        
        // size down the containers
        el.setStyle({overflow: 'hidden',
                     height: '1.5em'})
        
        // create an element to be clicked on to reveal the whole text again
        moreObj = document.createElement('span')
        moreObj.innerHTML = "..."
        moreObj.onclick = function(){
            // reset the height to the automatic setting i.e. should expand to full height of text agein
            this.setStyle({height: ''})
            
            // transition in the container with all text a bit
            new Effect.Appear(this);
            new Effect.Highlight(this, {startcolor: '#EFEFEF', endcolor: '#ffffff'});
            
            // get rid of the expand 'button' since it is of no use anymore since the container is fully expanded now
            Element.remove(this.parentNode.lastChild)
        }.bind(el)
        
        // add the element 
        el.parentNode.appendChild(moreObj)
    })
})
