function setBGHeight() {
	// Check if we have a footer
	if($('div.wrapperFooter').length) {
		// Get top position of footer
		var posFooter = $('div.wrapperFooter').position();

		// Check if we have backgroundContentGeneral layer
		if($('div.backgroundContentGeneral').length) {
			// Reset height
			$('div.backgroundContentGeneral').height(posFooter.top);
		}

		// Check if we have backgroundContent layer
		if($('div.backgroundContent').length) {
			// Reset height
			$('div.backgroundContent').height(posFooter.top);
		}

		// Check if we have layerVruchtenhagelTwo layer
		if($('div.layerVruchtenhagelTwo').length) {
			// Reset height
			$('div.layerVruchtenhagelTwo').height(posFooter.top);
		}

		// Check if we have layerVruchtenhagelThree layer
		if($('div.layerVruchtenhagelThree').length) {
			// Reset height
			$('div.layerVruchtenhagelThree').height(posFooter.top);
		}
	}
}

function setEqualHeights(el1, el2) {
	// Check if we have both content blocks
	if($(el1).length && $(el2).length) {
		// Get both heights
		var heightBlockLeft = $(el1).height();
		var heightBlockRight = $(el2).height();

		if(heightBlockLeft > heightBlockRight) {
			// Reset right height if left is higher
			$(el2).height(heightBlockLeft);
		} else {
			// Reset left height if right is higher
			$(el1).height(heightBlockRight);
		}
	}
}

function setBGFAQPage() {
	if($('ul.FAQAccordion').length) {
		// Reset height content
		$('div.contentTermsLeft').height(($('ul.FAQAccordion').height()+103));
	}
}

function setBackgroundBelowContent() {
	if($('div.backgroundBelowContent').length) {
		// Get header height
		var headerHeight = $('div.holderHeader').height();
		// Padding height top
		var paddingHeight = ($('div.backgroundBelowContent').hasClass('landingPage')?45:68);
		// Get content height
		var contentHeight = ($('div.holderContent').height()-paddingHeight);
		// Get footer height
		var footerHeight = $('div.wrapperFooter').height();
		// Get page height
		var pageHeight = $(document).height();
		// Set background height
		$('div.backgroundBelowContent').css({
			'top': (headerHeight+contentHeight)+'px',
			'height': pageHeight-(headerHeight+contentHeight+footerHeight)+'px'
		});
	}	
}

function setScrollPane(type, el, scroll, dragMin, dragMax) {
	if(type=='vertical') {
		// Set scrollpane
		el.jScrollPane({
			scrollbarWidth: scroll,
			dragMinHeight: dragMin,
			dragMaxHeight: dragMax,
			maintainPosition: true
		});
	} else { // else horizontal
		el.jScrollHorizontalPane({
			scrollbarHeight: scroll,
			dragMinWidth: dragMin,
			dragMaxWidth: dragMax,
			leftCapHeight: 20,
			maintainPosition: true
		});
	}
}

function getProductMenuWidth() {
	var totalWidth = 0;

	$('div.menuSub ul li').each(function() {
		totalWidth += ($(this).width()+24);
	});

	return totalWidth;
}

function setButtonsHover() {
	// Check if we have a buttons to hover
	if($('img.hover').length) {
		// Get all menu items
		$('img.hover').each(function() {
			var currImage = $(this).attr('src');

			// Add mouseover event
			$(this).mouseover(function() {
				// Show mouse over image
				$(this).attr('src', currImage.replace(/([^.]*)\.(.*)/, "$1-over.$2")); 
			});
				
			// Add mouseout event
			$(this).mouseleave(function() {
				// Show normal image
				$(this).attr('src', currImage.replace('-over','')); 
			});
		});
	}
}

function setFAQHover() {
	// Check if we have a FAQ
	if($('ul.FAQAccordion').length) {
		// Get all menu items
		$('ul.FAQAccordion li a').each(function() {
			// If button exists
			if($(this).length) {
				// Add mouseover event
				$(this).mouseover(function() {
					// Show mouse over state
					if(!$(this).hasClass('active') && !$(this).hasClass('activeHover')) {
						$(this).removeClass().addClass('question normalHover');
					} else {
						$(this).removeClass().addClass('question activeHover');
					}
				});

				// Add mouseout event
				$(this).mouseout(function() {
					if(!$(this).hasClass('active') && !$(this).hasClass('activeHover')) {
						$(this).removeClass().addClass('question normal');
					} else {
						$(this).removeClass().addClass('question active');
					}
				});

				// Add click event
				$(this).click(function() {
					setActiveFAQ($(this));
				});
			}
		});
	}
}

function setActiveFAQ(el) {
	// Check if we have a FAQ
	if($('ul.FAQAccordion').length) {
		// Reset previous active item
		$('ul.FAQAccordion li').each(function() {
			$(this).find('a').removeClass().addClass('question normal'); 
		});

		if(el.length) {
			// Set normal class and add active class
			el.removeClass().addClass('question active');
		} else {
			// Remove normal class and add active class
			$('ul.FAQAccordion li:first a').removeClass().addClass('question active');
		}
	}
}

function setMainMenuHover() {
	// Check if we have a menu
	if($('ul.menuMain').length) {
		// Get all menu items
		$('ul.menuMain li.menuItem').each(function() {
			// Only when menuItem is not active
			if(!$(this).hasClass('active')) {
				// Add mouseover event
				$(this).mouseover(function() {
					// Show underline
					$('div.itemUnderline', this).show();
				});
				
				// Add mouseout event
				$(this).mouseleave(function() {
					// Hide underline
					$('div.itemUnderline', this).hide();
				});
			}
		});
	}
}
