/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
typo3 generated functions
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
var browserName=navigator.appName;var browserVer=parseInt(navigator.appVersion);var version="";var msie4=(browserName=="Microsoft Internet Explorer"&&browserVer>=4);if((browserName=="Netscape"&&browserVer>=3)||msie4||browserName=="Konqueror"||browserName=="Opera"){version="n3";}else{version="n2";}
function blurLink(theObject){theObject.blur();}
function decryptCharcode(n,start,end,offset){n=n+offset;if(offset>0&&n>end){n=start+(n-end-1);}else if(offset<0&&n<start){n=end-(start-n-1);} return String.fromCharCode(n);}
function decryptString(enc,offset){var dec="";var len=enc.length;for(var i=0;i<len;i++){var n=enc.charCodeAt(i);if(n>=0x2B&&n<=0x3A){dec+=decryptCharcode(n,0x2B,0x3A,offset);}else if(n>=0x40&&n<=0x5A){dec+=decryptCharcode(n,0x40,0x5A,offset);}else if(n>=0x61&&n<=0x7A){dec+=decryptCharcode(n,0x61,0x7A,offset);}else{dec+=enc.charAt(i);}} return dec;}
function linkTo_UnCryptMailto(s){location.href=decryptString(s,-2);}

/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
jQuery hackz 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
var $j = jQuery.noConflict();

$j(document).ready(function() {
	// resize function calls
	resize();
	$j(window).resize(function(){ resize(); });
	$j(window).load(function(){ resize(); });
	
	/* 
	// preload background-images
	$j.preload([ '01', '02', '03', '04' ], {
    base:'fileadmin/gfx/random/',
    ext:'.jpg',
    onFinish: function(){
			_closeMask();
		}
	});
	*/
	
	// mp3-player
	if($j('#player').length) writePlayer();

	// lightbox
	if($j('div.gallery').length) {
		var i = 0;
		$j('div.gallery').each(function() {
			$j(this).find('a').each(function() {
				tmp_link = $j(this).attr('href');
				parts = tmp_link.split('&');
				$j(this).attr('href', parts[1].substr(5).replace(/%2F/g, '/'));
				$j(this).attr('rel', 'set_'+i);
				$j(this).removeAttr('target');
				$j(this).focus(function() { this.blur(); } )
				tmp_img = $j(this).children();
				if(tmp_img[0].width > tmp_img[0].height)
					$j(tmp_img[0]).css('margin-top', '10px');
			})
			i++;
			$j(this).find('a').lightBox();
		})
		
	}
});

/* resize function */
function resize() {
	bg_width 		= 1280;
	bg_height 	= 852;
	margin_left	= 15;
	margin_top 	= 15;
	
	doc_height = $j(window).height();
	if(bg_height < doc_height) {
		margin_top += ((doc_height - bg_height)/2);
	}
	$j('#main').css('margin-top', margin_top+'px');
	
	doc_width = $j(window).width();
	if(bg_width < doc_width) {
		margin_left += ((doc_width - bg_width)/2);
	}
	$j('#main').css('margin-left', margin_left+'px');
}

/* mp3-player functions */
function writePlayer() {
/*
	var so = new SWFObject('fileadmin/scripts/player.swf','mpl','406','20','9');
	so.addParam('allowscriptaccess','always');
	so.addParam('flashvars','&backcolor=ffffff&autostart=false');
	so.write('player');
*/
	var so = new SWFObject('fileadmin/scripts/niftyplayer.swf','mpl','430','54','9');
	so.addParam('allowscriptaccess','always');
	//so.addParam('flashvars','&file=fileadmin/downloads/mp3/dummy.mp3&as=0');
	so.write('player');
}

function playTrack(track, elem) {
	//document.getElementById('mpl').sendEvent("LOAD", 'fileadmin/downloads/mp3/'+track);
	//document.getElementById('mpl').sendEvent("PLAY","true");
	niftyplayer('mpl').loadAndPlay('fileadmin/downloads/mp3/'+track)
	
//	$j('#'+elem).parent().attr('class', 'track_over');
	$j('#'+elem).removeAttr('onmouseout');
	
	$j('p > a').each(function() {
		id = $j(this).attr('id');
		if(id != elem) {
			noTrack(this);
			a = document.createAttribute('onmouseout');
			a.nodeValue = 'noTrack(this)';
			document.getElementById(id).setAttributeNode(a);
		}
	})
}

function roTrack(elem) {
	$j(elem).parent().attr('class', 'track_over');
}

function noTrack(elem) {
	$j(elem).parent().attr('class', 'track');
}

// mask content
function _openMask() {
	w = $j(document).width();
	h = $j(document).height();
	
	$j('body').append('<div id="mask"><img src="fileadmin/gfx/ajax-loader.gif" alt="Loading..." style="margin-left: '+(w/2-110)+'px; margin-top: '+(h/2-10)+'px" /></div>');
	$j('#mask').attr('style', 'width:'+w+'px; height:'+h+'px;').fadeTo('fast', 0.70);
}

// unmask content
function _closeMask() {
	$j('#mask').hide();
}

