function loadPage(url, params){	jQuery.ajax({		url: url,		type: 'GET',		dataType: "html",		data: params,		complete: function(res, status){			if ( status == "success" || status == "notmodified" )			{				var content, contentMenu;				dummy = jQuery('<div/>').append(res.responseText);				content = dummy.children("#content");				contentMenu = dummy.children("#contentMenu");				if( content.length )				{					jQuery('#content').html(content.html());					if( tb_init !== undefined )						tb_init('a.thickbox, area.thickbox, input.thickbox');				}				if( contentMenu.length )					jQuery('#contentMenu').html(contentMenu.html());				jQuery('#contentMenu .contentLink.loading').removeClass('loading').addClass('active');				if( newCatagory )					{ $('#container').attr('className', newCatagory); newCatagory = ''; }			}		}	});}var newCatagory = '';function menuLinkClick(e){	if( $(e.target).parents('a').size() && $(e.target).parents('#contentMenu').size() ) {		stopTraversion(e);		$('#content').html('<img src="assets/templates/hotbrownie/images/loading.gif" class="loading"/>');		$('#contentMenu .contentLink').removeClass('active');		$(e.target).parents('.contentLink').addClass('loading');		loadPage($(e.target).parents('a').attr('href'), {contentType: 'contentLink'});	}	if( $(e.target).is('a') && $(e.target).parents('#menu').size() ) { // nieuwe catagorie		stopTraversion(e);		newCatagory = $(e.target).parent().attr('className');		hbImgLoader.preloadImages(newCatagory);		$('#content').html('<img src="assets/templates/hotbrownie/images/loading.gif" class="loading"/>');		$('#contentMenu').html('<img src="assets/templates/hotbrownie/images/loading.gif" class="loading"/>');		loadPage($(e.target).attr('href'), {contentType: 'contentMenuLink'});	}}function stopTraversion(e){	if( e.stopPropagation )		e.stopPropagation();	if( e.preventDefault )		e.preventDefault();	if( e.cancelBubble )		e.cancelBubble = true;}$(document).ready(function() {	hbImgLoader.preloadImages($('#container').attr('className'));	$('body').click(function(e) {		menuLinkClick(e);	});});function hbImg(src){ this.src = src; this.img = new Image(); this.required = false; }function hbImageLoader(){	this.imgs =	{		base:			new Array(				new hbImg('assets/templates/hotbrownie/images/loading.gif'),				new hbImg('assets/templates/hotbrownie/images/HB_web_backgr_top.png'),				new hbImg('assets/templates/hotbrownie/images/HB_web_backgr_down.png')			),		news:			new Array(				new hbImg('assets/templates/hotbrownie/images/HB_web_backgr_up_News.png'),				new hbImg('assets/templates/hotbrownie/images/HB_web_Newsblok.png')			),		artists:			new Array(				new hbImg('assets/templates/hotbrownie/images/HB_web_backgr_up_Artists.png'),				new hbImg('assets/templates/hotbrownie/images/HB_web_Artistsblok.png')			),		releases:			new Array(				new hbImg('assets/templates/hotbrownie/images/HB_web_backgr_up_Releases.png'),				new hbImg('assets/templates/hotbrownie/images/HB_web_Releasesblok.png')			),		contact:			new Array(				new hbImg('assets/templates/hotbrownie/images/HB_web_backgr_up_Contact.png'),				new hbImg('assets/templates/hotbrownie/images/HB_web_Contactblok.png')			)	}	this.loadQueue = new Array();	this.currPos = 0;	this.timer = undefined;	this.preloadImages = function(category)	{	var loadingNeeded = false;	this.loadQueue = new Array();		for( prop in this.imgs )		{			if( prop == 'base' || prop == category )				for(var i = 0; i < this.imgs[prop].length; i++)				{					this.imgs[prop][i].required = true;					this.loadQueue.unshift(this.imgs[prop][i]);					if( !this.imgs[prop][i].img.src ) loadingNeeded = true;				}			else				for(var i = 0; i < this.imgs[prop].length; i++)				{					this.imgs[prop][i].required = false;					this.loadQueue.push(this.imgs[prop][i]);					if( !this.imgs[prop][i].img.src ) loadingNeeded = true;				}		}		if( loadingNeeded )		{			$('#loaderBg').fadeIn('normal');			$('#loader').css('width', '0px');			this.currPos = 0;			this.preloadNextImg();		}	}	this.preloadNextImg = function()	{		var currImg = this.loadQueue[this.currPos];		if( currImg && !currImg.loaded )		{				currImg.img.src = currImg.src;			if( currImg.required )				this.setText('Loading images');			else				this.setText('Pre loading images');			if( !currImg.img.complete )			{				$(currImg.img).bind('error.imgLoad load.imgLoad onreadystatechange.imgLoad', function(e){ hbImgLoader.onImgLoad(e);} );				this.timer = setTimeout(function(){ hbImgLoader.onImgLoad(); }, 2000);			}			else			{				this.onImgLoad();			}		}	}		this.onImgLoad = function(e)	{		if( this.timer )			{	clearTimeout(this.timer);  this.timer = undefined; }		if( e )			$(this.loadQueue[this.currPos].img).unbind();					this.currPos++;		var parentWidth = $('#loaderBg').width();		$('#loader').css('width', (parentWidth * this.currPos / this.loadQueue.length).toFixed(0)+'px');		if( this.loadQueue.length > this.currPos )		{			this.preloadNextImg();		}		else		{			$('#loaderBg').fadeOut('slow');		}	}		this.setText = function(txt){ $('#loaderBg #text').text(txt); }}var hbImgLoader = new hbImageLoader();
