var viewportwidth;
var viewportheight;
if (typeof window.innerWidth != 'undefined') {
    viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
}
else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0) {
    viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
}
else {
    viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
}



function SetElementsPos() {
    if ($('.BodyFooter').length) {
        var obj = document.getElementById('BodyFooter');
        var pos = obj.offsetTop;
        while (obj.offsetParent) {
            pos = pos + obj.offsetParent.offsetTop;
            if (obj == document.getElementsByTagName('body')[0]) { break }
            else { obj = obj.offsetParent; }
        }
        if (pos < ((viewportheight * 1) - 50)) {
            document.getElementById('MainContainer').style.backgroundPosition = 'center ' + ((viewportheight * 1) - 500) + 'px';
	     document.getElementById('MainContainer').style.height = ((viewportheight * 1) - 50) + 'px';
            document.getElementById('BodyFooter').style.position = 'absolute';
            document.getElementById('BodyFooter').style.top = ((viewportheight * 1) - 50) + 'px';
            document.getElementById('BodyFooter').style.margin = '0';
        }
        else {
            document.getElementById('MainContainer').style.backgroundPosition = 'center ' + ((pos * 1) - 450) + 'px';
		
        }
    }
}

$(function () {
    $(window).load(function () {
        SetElementsPos();
        if ($('#googlemap').length) $('#googlemap').html("<iframe width='425' height='250' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='http://maps.google.nl/maps?f=d&amp;source=s_d&amp;saddr=51.445636,5.460227&amp;daddr=&amp;hl=nl&amp;geocode=&amp;mra=dme&amp;mrcr=0&amp;mrsp=0&amp;sz=16&amp;sll=51.445716,5.459518&amp;sspn=0.008024,0.022724&amp;ie=UTF8&amp;t=h&amp;ll=51.445716,5.459518&amp;spn=0.013374,0.036478&amp;z=14&amp;output=embed'></iframe><br /><small><a href='http://maps.google.nl/maps?f=d&amp;source=embed&amp;saddr=51.445636,5.460227&amp;daddr=&amp;hl=nl&amp;geocode=&amp;mra=dme&amp;mrcr=0&amp;mrsp=0&amp;sz=16&amp;sll=51.445716,5.459518&amp;sspn=0.008024,0.022724&amp;ie=UTF8&amp;t=h&amp;ll=51.445716,5.459518&amp;spn=0.013374,0.036478&amp;z=14' style='text-align:left'>Grotere kaart weergeven</a></small>");
    }
    );

    $('#IntroPromoA')
    .hover(function () {
        $(this).addClass("IntroPromoHover");
    },
    function () {
        $(this).removeClass("IntroPromoHover");
    })
    .click(function () {
        window.location.href = '/' + IntroPromoAurl + '/';
    })
    ;
    $('#IntroPromoB')
    .hover(function () {
        $(this).addClass("IntroPromoHover");
    },
    function () {
        $(this).removeClass("IntroPromoHover");
    })
    .click(function () {
        window.location.href = '/' + IntroPromoBurl + '/';
    })
    ;
    $('#IntroPromoC')
    .hover(function () {
        $(this).addClass("IntroPromoHover");
    },
    function () {
        $(this).removeClass("IntroPromoHover");
    })
    .click(function () {
        window.location.href = '/' + IntroPromoCurl + '/';
    })
    ;

});
