/* CREDITS
 * ----------------------------------------------------------
 * Title:		WEBSITE - Main Javascript file
 * Author:		Inventis <info@inventis.be>
 * Date:		00/00/0000
 * Last Edit:	00/00/0000 [Author]
 * ----------------------------------------------------------
 * Inventis - Web Architects - We design the Web!
 * www.inventis.be
 */
window.addEvent('domready', function(){

    if ($('legendSwitcher')) {
        var mySlide = new Fx.Slide('legendSwitcher').hide();
        $('legendSwitcher').setStyle('display', 'block');
        
        $('legendSwitch').addEvent('click', function(el){
            el.stop();
            mySlide.toggle();
        });
    }
    
    if (document.getElement('div.cartpopup')) {
    
        var div = $$('div.cartpopup');
        var divClone = $$('div.cartpopup').clone().setStyles({
            'display': 'none',
            'opacity': '0'
        });
        divClone.inject(document.body, 'bottom');
        div.destroy();
        
        divClone.setStyle('display', 'block');
        var overLay = new Element('div', {
            'class': 'cartOverlay'
        }).inject(document.body, 'bottom');
        
        overLay.setStyle('height', window.getScrollSize().y);
        divClone.set('opacity', 1);
    }
    
    $each($$('a.help'), function(e){
        e.getFirst('strong').setStyle('display', 'none');
        
        e.addEvent('mouseover', function(i){
            e.getFirst('strong').setStyle('display', 'block');
		});
		
		e.addEvent('mouseout', function(j){
			e.getFirst('strong').setStyle('display', 'none');
		});
    });
    
    var content = $('content');
    if (content){
        var links = content.getElementsByTagName('a');
        var link, href;
        for(i=0; i<links.length; i++)
        {
            link = links[i];
            href = link.getAttribute('href');
            
            if(href && href.substring(0,4) == 'http' && !href.match(/rlkm\.be/))
                link.setAttribute('target', '_blank');
        }
    }
    
    var invoice = $('chk_invoice');
    var vat = $('inp_vat');
    if(invoice){
        invoice.addEvent('change', function(){
            if(this.checked){
                vat.setStyle('display', 'block');
            } else {
                vat.setStyle('display', 'none');
            }
        });
    }
});

