/**
 * @author Hein Bekker
 * @copyright (c) 2010 Hein Bekker
 * @license New BSD License
 */

/**
 * Supplement jQuery.browser
 */
var ua = navigator.userAgent.toLowerCase();

$.browser.firefox = $.browser.mozilla && /firefox/.test(ua);
$.browser.chrome = /chrome/.test(ua);

if ($.browser.chrome){
	$.browser.safari = false;
}

$.browser.msie7 = ($.browser.msie && parseInt($.browser.version) === 7) ? true : false;
$.browser.msie8 = ($.browser.msie && parseInt($.browser.version) === 8) ? true : false;





/**
 * Set configuration.
 */
//$NETBEK.set({
//	flash_version: '9.0.115',
//	has_flash_version: swfobject.hasFlashPlayerVersion('9.0.115'),
//	has_flash: swfobject.hasFlashPlayerVersion('5.0.0')
//});





/**
 * Global variables.
 */
//var preloader = $NETBEK.Preloader(),
var opening_queue = [], // Functions that should be called from opening()
	closing_queue = []; // Functions that should be called from closing()

opening_queue.push(function(){
//	// Cufon.
//	Cufon.replace('.heading, .subheading, .contact', {
//		fontFamily: 'Plantin Std'
//	});



//	// Preload.
//	var tpl_url = $NETBEK.get('tpl_url');
//
//	preloader.load([
//		tpl_url + 'img/sprite.png',
//	]);
});





/**
 * Functions to call once document is ready.
 */
$(document).ready(function(){
	$NETBEK.setup();
	$NETBEK.draw();

	$(window).resize(function(){
		$NETBEK.draw();
	});
});





/**
 * Functions to call at top of page.
 *
 * @return void
 */
function opening(){
	if (opening_queue.length){
		$.each(opening_queue, function($k, $v){
			$v();
		});
	}
}





/**
 * Functions to call at bottom of page.
 *
 * @return void
 */
function closing(){
	// De-obfuscated email addresses.
	$('a.' + $NETBEK.get('mailto_class')).each(function(){
		var elm = $(this),
			href = $NETBEK.redirectMailto(elm.attr('href'), false),
			onclick;

		elm.attr('href', href);

		if ((onclick = elm.attr('onclick'))){
			elm.text(href.substr(7));
			elm.removeAttr('onclick');
		}
	});

//	// Cufon.
//	Cufon.now();

	if (closing_queue.length){
		$.each(closing_queue, function($k, $v){
			$v();
		});
	}
}
