window.onload = function(){

    var stretchers = document.getElementsByClassName('stretcher'); //div that stretches
    var toggles = document.getElementsByClassName('display'); //h2s where I click on

    //accordion effect
    var myAccordion = new fx.Accordion(
    toggles, stretchers, {opacity: true, duration: 400}
    );

    //hash function

    function checkHash(){
        var found = false;
        toggles.each(function(h3, i){
            if (window.location.href.indexOf(h3.title) > 0) {
                myAccordion.showThisHideOpen(stretchers[i]);
                found = true;
            }
        });
        return found;
    }

    if (!checkHash()) myAccordion.showThisHideOpen(stretchers[0]);

    modifyFontSize('init');

    try{
        addReflections();
    }catch(e){}
}



function modifyFontSize(size)
{
    var font_size = parseInt(Cookie.get('font_size'));
    if(!font_size){
        font_size = 80;
    }
    if(size == 'original'){
        font_size=80;
    }else {
        if(size == 'bigger' && font_size < 180){
            font_size = font_size+20;
        }else if(font_size > 80 && size != 'init'){
            font_size = font_size-20;
        }
        if(font_size==180){
            Element.hide('increase_font_size');
        }else{
            Element.show('increase_font_size');
        }
    }
    if(font_size==80){
        Element.hide('decrease_font_size');
        Element.hide('original_font_size');
        Element.show('increase_font_size');
    }else{
        Element.show('decrease_font_size');
        Element.show('original_font_size');
    }
    if(font_size > 180){
        font_size = 180;
    }
    if(font_size < 80){
        font_size = 80;
    }
    document.body.style.fontSize = font_size+'%';
    Cookie.set('font_size',font_size,15);
}

function accesibleVersion()
{
    document.location = '/page/' + 
    "accesible"+'?url='+document.location;
}
function originalVersion()
{
    document.location = '/page/' + 
    "original"+'?url='+document.location;
}
