// <![CDATA

	/**		
	 * Dynamix Portfolio, version 0.3 beta (Dynamix-0.3.0 b)
	 * (c) 2008 Amorphik / Marc Hottinger
	 *
	 * http://www.amorphik.com/
	 *
	 * This script may not be used, modified, copied, etc. without the
	 * autorisation of amorphik.
	 *
	 *
	 * This script is meant to be further used with a Content Management System (CMS) in the next release.
	 * 
	 */

	/*
	var global = this;
	var asdf;
	*/


	// --------------------------------------------
	// hiding the ajax div
	// --------------------------------------------
	function initProjectsLoader() {
		Element.hide('projectsLoader');
		Element.hide('content');
		var loaded = false;
	}

	// --------------------------------------------
	// hiding the ajax div
	// --------------------------------------------
	function hideProject() {
		Effect.Fade('projectsLoader',{ duration: 0.3 });
		Effect.Fade('content', { delay: 1, duration: 0.3, afterFinish: function() { $('content').update(''); loaded = false; } } );
		
	}

	// --------------------------------------------
	// managing the ajax div display
	// --------------------------------------------

	// projects loading
	function showProject(pNum,pYear) {
		debug('attempt to load ajax content :'+pNum+'_'+pYear+'.html');
		new Ajax.Updater({ success: 'content'}, 'media/ajax/'+pYear+'/p'+pNum+'_'+pYear+'.html', {
			evalScripts: true,
			onCreate: startLoading,
			onComplete: function() {
				debug('suceeded in loading ajax content');
				
				if (Engine.isMSIE && !Engine.isMSIE7) {
					IE7.CSS.init();
					IE7.HTML.init();
					IE7.HTML.apply();
					IE7.CSS.apply();
					IE7.recalc();
					debug('msie 6');
				}
				stopLoading();
			},
			onFailure: function() {
				failure();
			}
		});
	}

	// loading notification

	function startLoading() {
		debug("loading image init");
		loaded = false;
		window.setTimeout('showLoadingImage()', 7);
	}

	function showLoadingImage() {
		debug("loading image displayed");
		var el = $("loading");
		if (el && !loaded) {
			el.update('<img src="media/images/portfolio/layout/special/loading.gif" alt="loading...">');
			new Effect.Appear('loading', { duration: 0.3 } );
		}
	}

	function stopLoading() {
		debug("loading image hidden");
		new Effect.Fade('loading', { delay: 0.5, duration: 0.3, afterFinish: function() { displayContent(); loaded = true; $('loading').update(''); } } );
	}

	function failure() {
		debug('failed to load ajax content');
		$('error').update('<p style="color: white">this content is unavailable.</p>');
		new Effect.Appear('error', { duration: 0.3 });
		new Effect.Fade('error', { delay: 1.5, duration: 0.3 });
	}

	// projects display
	function displayContent() {
		var delay = 0.2;
		Element.hide('infos');
		Element.hide('permalink');
		Effect.Appear('projectsLoader', { delay: delay, duration: 0.3 });
		if(Engine.isGecko) {
			Effect.Appear('content', { delay: delay+1.3, duration: 0.8 });
		} else {
			Effect.Appear('content', { delay: delay+1.3, duration: 0.5 });
		}
	}

// ]]>
