﻿//GLOBAL REDIRECT LINK
var redirectURL = "";
var lan = "NL";

function printYear()
{
	now = new Date;
	theYear=now.getYear();
	if (theYear < 1900)
		theYear=theYear+1900;
	document.write(theYear)
}

function redirectPage() {
	$('.jqmWindow').jqmHide();	
	window.open(redirectURL);
}

function closeModal() {
	$('#popupOverlayInner').html('');
	$('.jqmWindow').jqmHide();	
}

function playVideo(video) {
	if ($.jqm) {			
		$('#popupOverlayInner').html('');
		$('#popupOverlayInner').load(video);
		$('#popupOverlay').jqm().fadeIn("slow"); 
		$('#popupOverlay').jqmShow();			
		return false;
	}
}

function loadLanguageText(lan) 
{
	var textToGet = "interstitialText" + lan; 
	$.get("/xml/redirectLanguages.xml", function(data)
	{              
		$("#interstitialContent").html($(data).find(textToGet).text());            
    });
}

var resizeTimer = null;

function fixHeight(){
	

	var viewportHeight = window.innerHeight ? window.innerHeight : $(window).height();
	var wrapperHeight = $('#outerWrapper').height();

	if(wrapperHeight < viewportHeight)
	{
		var offset = viewportHeight - wrapperHeight;
		var contentHeight = $('#content').height();
		$('#outerWrapper').height(viewportHeight);
		$('#content').height(contentHeight + offset);
	}
}


$(document).ready(function () {
	if ($.jqm) {
		$('a.leavingLink').live("click", function(){
			redirectURL = $(this).attr('href');
			$('#popupOverlayInner').html('');
			$('#popupOverlayInner').load('/content/leaving.htm');
			$('#popupOverlay').jqm().fadeIn("slow"); 
			$('#popupOverlay').jqmShow();
			findTop();
			return false;
		});
		
		window.onscroll = function () {
		    findTop();
		}
			
		function findTop() {
			var docTop = $(window).scrollTop();
		    var newTop = docTop + 120;
		    var strTop = newTop + 'px';
		 	$('.jqmWindow').css({top: strTop});
		 	$('.jqmOverlay').css({top: docTop});
		}
	}
	fixHeight();
		
		$(window).bind('resize', function() {
		if (resizeTimer) clearTimeout(resizeTimer);
		resizeTimer = setTimeout(fixHeight, 100);
	});

});
