function preload(aa){
    heavyImage = new Image();
    heavyImage.src = aa;
}
preload('/img/button_red_h.png');
preload('/img/log_in_on.png');
preload('/img/caddy_on.png');
preload('/img/log_out_on.png');

preload('/img/login_off.png');
preload('/img/caddy_off.png');
preload('/img/log_out_off.png');

preload('/img/mail2_icon.png');
preload('/img/pomp2_icon.png');
preload('/img/warm2_icon.png');

var helps = 'http://vikersonn.pl/help';
document.observe("dom:loaded", function() {

    $$('#footer a').each(function(e){
        if(e.href.startsWith(helps)){
            e.writeAttribute("rel", "help" );
        }
    });
    var windowObjectReference = null;
    $$('[rel="help"]').invoke('observe','click', function (e) {

        if(windowObjectReference == null || windowObjectReference.closed)
        {
            windowObjectReference = window.open(e.target.href,'Pomoc','width=400,height=400,menubar=no,status=no,dependent=yes,location=no,toolbar=no,scrollbars=yes');
            Event.stop(e);
        }
        else
        {
            windowObjectReference.focus();
            Event.stop(e);
        }
    });

        /* for links managment */
    $$('.selectonclick').each(function(s) {
        s.observe('click', function(event){
            Event.element(event).select();
        });
    });
    /*
    $$('.slider').each(function(item){
        Event.mouseEnter(item, function() {
            new Effect.Morph(item, {
                style: 'background-position:0px',
                duration: 0.3
            });

        })
    });

    $$('.slider').each(function(item) {
        Event.mouseLeave(item, function() {
            new Effect.Morph(item, {
                style: 'background-position:-325px',
                duration: 0.3
            });

        })
    })

*/
$('nav1').childElements().last().setStyle({
                background: 'none'
            });
    $$('#nav1 a').each(function(e){
        var hash = e.href+''+document.location.hash;
        if(document.location.href==e.href || hash==document.location.href){
            e.addClassName('active');
            e.up().addClassName('active');
            e.up(2).childElements('a').first().addClassName('active');
            e.up(2).addClassName('active');
            e.up(1).setStyle({
                display: 'block',
                visibility:'visible'
            });

        }
    });
    $$('#nav2 a,#nav3 a,#nav6 a,,#nav7 a,.box_blueish a').each(function(e){
        var hash = e.href+''+document.location.hash;
        if(document.location.href==e.href || hash==document.location.href){
            e.addClassName('active');
        }
    });
    $('himage').fade({
        duration: 5.0,
        from: 0,
        to: 1
    });
});
///alert(document.location.hash);
/*
    $('heat_price').observe('click' ,likealink('/kalkulator'));
     function likealink(where) {
        document.location.href=where;
    }
*/
