// move footer

function getWindowHeight() {
    var windowHeight = 0;
    if (typeof (window.innerHeight) == 'number') {
        windowHeight = window.innerHeight;
    }
    else {
        if (document.documentElement && document.documentElement.clientHeight) {
            windowHeight = document.documentElement.clientHeight;
        }
        else {
            if (document.body && document.body.clientHeight) {
                windowHeight = document.body.clientHeight;
            }
        }
    }
    return windowHeight;
}
function setFooter() {
    if (document.getElementById) {
        var windowHeight = getWindowHeight();
        if (windowHeight > 0) {
            var contentHeight = document.getElementById('page').offsetHeight;
            var footerElement = document.getElementById('homeFooter');
            var footerHeight = footerElement.offsetHeight;
            if (windowHeight - (contentHeight + footerHeight) >= 0) {
                footerElement.style.position = 'static';
                footerElement.style.top = (windowHeight - footerHeight) + 'px';
            }
            else {
                footerElement.style.position = 'static';
            }
        }
    }
}

// on window resize position footer

window.onresize = function() {
    setFooter();
}

$(function(){
	
	setFooter();
	
	//FOUC 
	$('html').removeClass('js');
		
	// Font Replacement
	Cufon.replace('.intro h4', { fontWeight: 'bold'});
	Cufon.replace('.intro h3 a, .mintroduction h3, .facebook h3', { fontSize: '16px', fontWeight: 'normal', textShadow:'text-shadow:-1px -1px 1px #FFF'});
	Cufon.replace('.product h3', { fontSize: '16px', fontWeight: 'normal', textShadow:'text-shadow:-1px -1px 1px #FFF'});
	Cufon.replace('.panel h3, .product-modal h4, #exit h4, #exit2 h4', { fontSize: '16px', fontWeight: 'normal', textShadow:'text-shadow:-1px -1px 1px #FFF'}); /* Psycle 25/03/2010 */
	Cufon.replace('.product h4', { fontSize: '16px', fontWeight: 'bold', textTransform: 'uppercase'});
	Cufon.replace('.product h4 span', { fontSize: '14px', fontWeight: 'bold'});
	Cufon.replace('.product-modal h5', { fontSize: '25px', fontWeight: 'bold', textTransform: 'uppercase'});
	Cufon.replace('.product-modal h5 span', { fontSize: '22px', fontWeight: 'bold'});
	Cufon.replace('#exit h5, #exit2 h5', { fontSize: '16px', fontWeight: 'bold'});
	Cufon.replace('#exit li, #exit2 li', { fontSize: '18px', fontWeight: 'bold'});
	Cufon.replace('#blog-content h4.headingSmall', { fontWeight: 'bold', fontSize: '18px'});
	Cufon.replace('#blog-content h4.headingLarge', { fontWeight: 'bold', fontSize: '28px', textTransform: 'uppercase'}); /* Psycle 25/03/2010 */
	
	// Modals
	$('a.inline').fancybox({
			'autoDimensions': 'false',
			'transitionIn': 'fade',
			'transitionOut': 'fade',
			'width': '643',
			'height': '300'
	});
	$('a.external').fancybox({
			'autoDimensions': 'false',
			'transitionIn': 'fade',
			'transitionOut': 'fade',
			'width': '303',
			'height': '300',
			onComplete	:	function() {				
				//setTimeout("location.href = $('#exit .new-window').attr('href');",8000);				
			}
	});
	$('.return').click(function() {
	 	$.fancybox.close();
	});
	$('#exit li a, #exit2 li a').click(function() {
	 	$.fancybox.close();
		return false;
	});
	
	// Open new window
	$('a.new-window').click(function(){
		window.open(this.href);
		return false;
	});
	
	// Make home page panels clickable 
	$('.george').click(function() {
	  window.location='blog/george.html';
	});
	$('.lisa').click(function() {
	  window.location='blog/lisa.html';
	});
	$('.clinton').click(function() {
	  window.location='blog/clinton.html';
	});
	$('.barry').click(function() {
	  window.location='blog/barry.html';
	});
	$('.facebook').click(function() {
	  $(".facebook a").trigger("click");
	});
	
	// Make whole product panels clickable to open fancybox
	$(".products-1").click(function() {
	    $(".products-1 a").trigger("click");
	});
	$(".products-2").click(function() {
	    $(".products-2 a").trigger("click");
	});
	$(".products-3").click(function() {
	    $(".products-3 a").trigger("click");
	});
	
})
