/* webdev: Pim Rijpsma - pim.rijpsma@gmail.com */

// browser sniffer
var Browser = function(){
  this.uA = navigator.userAgent.toLowerCase();
  this.aN = navigator.appName.toLowerCase();
  this.iE = this.aN.indexOf('microsoft') != -1 ? 1 : 0;
  this.mac =  this.uA.indexOf('mac') != -1 ? 1 : 0;
  this.win = this.uA.indexOf('windows') != -1 ? 1 : 0;
  this.safari =  this.uA.indexOf('webkit') != -1 ? 1 : 0;
  this.safariMobile =  this.uA.indexOf('mobile') != -1 ? 1 : 0;
  this.opera =  this.uA.indexOf('opera') != -1 ? 1 : 0;   
  this.operaMini =  this.uA.indexOf('mini') != -1 ? 1 : 0;  
  this.mozilla = this.aN.indexOf('netscape') != -1 && !this.safari ? 1 : 0;
  this.winMozilla = this.mozilla && this.win ? 1 : 0;
  this.winIE = this.iE && this.win && !this.opera ? 1 : 0;
  this.winIE6 = this.winIE && /msie|MSIE 6/.test(navigator.userAgent) == 1 ? 1 : 0;
	this.winIE7 = this.winIE && /msie|MSIE 7/.test(navigator.userAgent) == 1 ? 1 : 0;
	this.winIE8 = this.winIE && /msie|MSIE 8/.test(navigator.userAgent) == 1 ? 1 : 0;
  this.macIE = this.iE && this.mac ? 1 : 0;
};
var browser = new Browser();


//incl. .js
var jsPath = "/scripts/";
document.write('<scr'+'ipt type="text/javascript" src="' + jsPath + 'cufon-yui.js"><\/scr'+'ipt>');
document.write('<scr'+'ipt type="text/javascript" src="' + jsPath + 'TheSans_500.font.js"><\/scr'+'ipt>');
//document.write('<scr'+'ipt type="text/javascript" src="' + jsPath + 'thesans_light_500.font.js"><\/scr'+'ipt>');


//layout 
$.fn.layOut = function(){
	
	//cufon font embed
	//Cufon.replace('h1', { fontFamily: 'thesans bold' });
	//Cufon.replace('h2', { fontFamily: 'thesans light' });
	Cufon.replace('h2', { fontFamily: 'TheSans' });
	
	
	
	
	//Cufon.replace('ul.nav li a', { fontFamily: 'thesans bold', hover: true });
	Cufon.now();
	
	//load footer on DOM
	setFooter();
	
	//add ID
	if ($("body.homepage").length > 0) { $("html").attr("id", "homepage"); };
	if ($("body.page").length > 0) { $("html").attr("id", "page"); };
	
};

function setFooter() {
	if(!$('body.homepage') || $('body.homepage').height() < 680){
		var myHeight = ($(window).height() - 115+"px");
		if(browser.winIE6){$('#container').css({ height: myHeight });}else{$('#container').css({ minHeight: myHeight });};
		$('#footer').css({ height: "100px" });
	} else { 
		var myHeight = ($(window).height() - 215+"px");
		if(browser.winIE6){$('#container').css({ height: myHeight });}else{$('#container').css({ minHeight: myHeight });};
		$('#footer').css({ height: "200px" });
	}
};
var resizeTimer = null;
$(window).bind('resize', function() { 
    if (resizeTimer) clearTimeout(resizeTimer); 
    resizeTimer = setTimeout(setFooter, 100);
});
//safari onLoad after DOM src
if(browser.safari){
	var srcLoadTimer = null;
	$('img').ready(function() { 
	    if (srcLoadTimer) clearTimeout(srcLoadTimer); 
	    srcLoadTimer = setTimeout(setFooter, 100);
	});
};


//DOM loader (before css vs jQuery)
function init() {
	if (arguments.callee.done) return;
	arguments.callee.done = true;
	if (_timer) clearInterval(_timer);
		$('html').layOut();
		if(browser.winIE) {try {document.execCommand('BackgroundImageCache', false, true);} catch(e) {};}
	};
if (document.addEventListener) {	document.addEventListener("DOMContentLoaded", init, null);}
if (/WebKit/i.test(navigator.userAgent)) { var _timer = setInterval(function() { if (/loaded|complete/.test(document.readyState)) { clearInterval(_timer); init();}}, 10);};
/*@cc_on @*/
	/*@if (@_win32)document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");var script = document.getElementById("__ie_onload");script.onreadystatechange = function() {	if (this.readyState == "complete") { init(); }};
/*@end @*/
window.onload = init;

