﻿/* Javascript Library for Double PASS bvba v5
 * Date: 4 feb 2011
 * Author: Robbie De Sutter
 * E-mail: info@doublepass.com
 */
 
window.onload = function() {
	setCopyrightYear();
	displayBanner();
	window.onresize = mainContentHeight; // no () at the end!
	mainContentHeight();
}

function mainContentHeight() {
	// get height of browser windows
		var innerH = getWindowInnerH();
		if (innerH < 400) { innerH = 400; } // set minimum height
		
		// get content
		var container = document.getElementById('right_content');
		
		// get content required height

		// set the height		
		container.style.height = innerH-180 + "px";
		
		// My Happy Club banner only on the dutch site
		if (doDisplayBanner()) {
			container.style.height = innerH-280 + "px";
		}
	}
	
function doDisplayBanner() {
	// only dutch pages
	var language = window.navigator.userLanguage || window.navigator.language;
	if (language.indexOf('nl') == -1) return false;

	var container = document.getElementById('mhc_banner');
	if (container == null) return false; // banner does not exist

	// get the date
	now = new Date;
	theYear = now.getYear();
	if (theYear < 1900) theYear=theYear+1900;
	theMonth = now.getMonth() + 1;
	
	// display it?
	if ((theYear == 2011) && (theMonth < 5)) {
		return true;
	}
	return false;
}
	
function displayBanner() {
	var container = document.getElementById('mhc_banner');
	if (container == null) return;
	if (doDisplayBanner()) {
		container.display = 'block';
	}
	else {
		container.display = 'none';
	}	
}
	
function getWindowInnerH(){
	var innerH = null;
	if (typeof(window.innerHeight) == "number"){//MOZILLA, OPERA
	innerH = window.innerHeight;
	}else if (typeof(document.documentElement.clientHeight) == "number"){//IE 6+
	innerH = document.documentElement.clientHeight;
	}
	
	return innerH;
}
			
function setCopyrightYear() {
	now = new Date;
	theYear=now.getYear();
	if (theYear < 1900) theYear=theYear+1900;
	var container = document.getElementById('copyrightYear');
	container.innerHTML = theYear;
}

function detectLanguage() {
		var language = window.navigator.userLanguage || window.navigator.language;
		
		if (language.indexOf('en') > -1) document.location.href = 'EN/';
		else if (language.indexOf('de') > -1) document.location.href = 'DE/';
		else if (language.indexOf('fr') > -1) document.location.href = 'FR/';
		else if (language.indexOf('nl') > -1) document.location.href = 'NL/';
	}

