<!--

 /****************************************************************************\
 * loader.js                                                                  *
 ******************************************************************************
 * (c) 2006-2008 Mike Lohmann - mike@werk01.de						          *
 *               for Mukutu GmbH	                                          *
 ******************************************************************************
 * in this file all other used javascript files are loaded 					  *
 * some simple debug methods and      										  *
 * helper functions are provided.                                             *
 \****************************************************************************/

var M_DEBUG = false;
var M_LOG = false;


// simple logging to javascript console. works in mozillas and safari.
/**
 * this method is actually not used as long as there is firebug.js included
 * in the page which implements console.log() among others.
 */

var startPoint=new Date().getTime(); 
var initCalled = false;
function log(text)
{
	if(!M_LOG) return false;
	var timestamp=new Date().getTime();
	var secondsPassed=(timestamp-startPoint);
	text=secondsPassed+": "+text;
	
	if(window.console)
	{
		window.console.log(text);
	}
	else
	{
		alert(text);
		/*if(!this.logwin)
		{
			this.logwin = window.open('about:blank', '_new', 'width=460, height=580, dependent=yes, menubar=yes, resizable=yes, scrollbars=yes, status=no, toolbar=no');
			this.alter = 0;
		}

		if(this.logwin)
		{
			//this.logwin.document.writeln('<p style="background:#'+((this.alter%2)?'DDD':'EEE')+';padding:2px 5px;margin:0;">'+text+'</p>');
			//this.logwin.scrollBy(0, 50);
		}
		this.alter++;*/
	}
}

function group(text)
{
	if(!M_LOG) return false;
	if(window.console)
	{
		window.console.group(text);
		window.console.time(text);
	}
}

function groupEnd(text)
{
	if(!M_LOG) return false;
	if(window.console)
	{
		window.console.timeEnd(text);
		window.console.groupEnd(text);		
	}
}


/* End of thanks */
window.onunload = function()
{
	log('BYE BYE!');
	if(this.logwin)	this.logwin.close();
}

function info(text){if(M_LOG && window.console)window.console.info(text);}
function warn(text){if(M_LOG && window.console)window.console.warn(text);}
function error(text){if(M_LOG && window.console)window.console.error(text);}
// reload current url decidedly loosing any hash.
function reload(){location.href = location.pathname+location.search;}
function redirect(text){location.href = text;}
String.prototype.trim = function() {return this.replace(/^\s+|\s+$/g,"");}

/**
  * parsing querystring
  * to activate logging or debug functionality inactive by default.
  */
var pars = location.search.substr(1).split("&");
for(var i=0; i < pars.length; i++)
{
	var p = pars[i].split("=");
	if(p[0] == 'jsdebug')	M_DEBUG	= p[1] == 'true' ? true : false;
	if(p[0] == 'jslog')		M_LOG		= p[1] == 'true' ? true : false;
}

/* -------------------------------------------------------------------------- */


/**
  * loading more javascripts
  * have to use document.write here since safari apparently does not process or
  * fully load scripts added using dom functions.
  */

var scripts = new Array();

scripts = scripts.concat(['lightbox.js',
						  'slide.js',
						  'float.js',
						  'tooltip.js'
						]);


	
for(var i=0; i<scripts.length; i++){
	var s=scripts[i];
	log('loading '+s+'..');
  document.write('\n\t<sc'+'ript type="text/javascript" src="'+TEMPLATEPATH+'/javascript/'+s+'"><!--[CDATA[/*nothing*]]//--></sc'+'ript>');
};

/**
  * all javascript onload events are triggered here.
  * make sure that calls to functions that access elements of the page are not
  * executed before the window.onload event, since the page elements will not be
  * available before that.
  */

// Dean Edwards/Matthias Miller/John Resig

function init() 
{
	log('init called');
	if(initCalled){
		return true;
	}
	
	initCalled = true;
	//banner position start
	var hX = 970;
	var vY = 0;
	var dD = document;
	log('element: float = '+dD.getElementById('float'));
	float(hX, vY, 'float', dD).Fm();

	//init the slide for the detail view
	initShowHideSlides();
	
	//init the tooltips
	initNewTooltip();
	
};