// JavaScript Document

document.observe("dom:loaded", function() {
	// Toggle blocks like in an product's spec sheet
	$$('.toggle-block-content').invoke('hide');
	$$('.toggle-block-btn').invoke('observe', 'click', function(ev) {
		this.toggleClassName('toggle-block-btn-active');
		this.next('.toggle-block-content').toggle();
		Event.stop(ev);
	});
	
	$$('#specificationSheetButtons a.linkToAnchor').invoke('observe', 'click', function(ev) {
		var anchorId = this.href.substring(this.href.lastIndexOf("#") + 1);
		$(anchorId).toggleClassName('toggle-block-btn-active');
		$(anchorId).next('.toggle-block-content').toggle();
	});
	
	jar = new CookieJar({
	expires:3600, // seconds
	path: '/'
	});
	
	h2oFlashAdvert = jar.get('h2oFlashAdvert');
	
	if (h2oFlashAdvert && h2oFlashAdvert.flyerResto == 1) {
		$('flashAdvert').hide();
		$('lightBox').hide();
	}
	else {
		$('lightBox').show();
		$('lightBox').setStyle({height : $('global').getHeight()+'px'});
	}
});

function showHideNextElement (buttonElement) {
	var el = $(buttonElement).next();
	el.style.display = ( el.style.display == 'none' ) ? 'block' : 'none';
}

function hideFlash () {
	$('flashAdvert').hide();
	$('lightBox').hide();
	
	flashAdvertData = {flyerResto: 1};
	 
	jar.put('h2oFlashAdvert', flashAdvertData);
}

