function UnCryptMailto( s )
    {
        var n = 0;
        var r = "";
        for( var i = 0; i < s.length; i++)
        {
            n = s.charCodeAt( i );
            if( n >= 8364 )
            {
                n = 128;
            }
            r += String.fromCharCode( n - 1 );
        }
        return r;
    }

function fxFadeIn() {

	/*$('bg_fx').set('tween', {duration: 2500});
	$('bg_fx').tween('opacity', '1');
	timer = (function() {
		fxFadeOut();
	}).delay(2500); */
}

function fxFadeOut() {
	$('bg_fx').set('tween', {duration: 2500});
	$('bg_fx').tween('opacity', '0');
}
Element.Events.konami = {
	base: 'keyup',
	condition: function(e){
		$clear(this.retrieve('konami_timeout'));
		var input = this.retrieve('konami_input',[]);
		input.push(e.key);
		if (input.join(',') == "up,up,down,down,left,right,left,right,b,a,enter"){
			this.removeEvents('konami');
			return true;
		}
		this.store('konami_input',input).store('konami_timeout',(function(){this.eliminate('konami_input');}).delay(2000,this));
	}
};

window.addEvent("konami",function(event){
	event.stop();
	var s= document.createElement('script');s.type='text/javascript';document.body.appendChild(s);s.src='http://www.up2games.at/js/asteroids_min.js';void(0);
});


window.addEvent('domready', function() {
	$$('.email').each(function(el) {
	  var text = el.get('text');
	  var host = "@up2games.at";
          if (text == '2')
		el.set('text', "rankweil" + host);
          if (text == '3')
		el.set('text', "dornbirn" + host);
          if (text == '4')
		el.set('text', "bregenz" + host);
          el.setStyle("display", "block");	
        });
	if ($('nav_left')) {
		$('nav_left').pin();
		if ($('nav_list')) {
			$$('#nav_list img').each(function(el) {
				if (el.id != "active") {
					el.addEvents({
						'mouseover': function() {
							el.src = el.src.replace('inact', 'act');
						},
						'mouseout': function() {
							el.src = el.src.replace('act', 'inact');
						}
					});
				}
			});
		}
	}

	if ($$('.mo_button')) {
		$$('.mo_button').each(function(item) {
			item.addEvents({
				'mouseover': function(e) {
					this.src = this.src.replace('inact', 'act');
				},
				'mouseout': function(e) {
					this.src = this.src.replace('act', 'inact');
				}
			});
		});
	}

	if ($$('.mo_button_close')) {
		$$('.mo_button_close').each(function(item) {
			item.addEvents({
				'click': function(e) {
					e.stop();
					parent.Mediabox.close();
				},
				'mouseover': function(e) {
					this.src = this.src.replace('inact', 'act');
				},
				'mouseout': function(e) {
					this.src = this.src.replace('act', 'inact');
				}
			});
		});
	}

	if($('bg_fx')) {
		var pulse = new Fx.Tween($('bg_fx'), {duration: 2500, link: 'chain'});
		var blink = function() {
			pulse.start('opacity', 1).start('opacity', 0);
		}
		pulse.start('opacity', 1).start('opacity', 0);
		blink.periodical(5000);
	}

	if ($('email_bz')) {
		$('email_bz').setAttribute('href', 'mailto:bludenz@up2games.at');
		$('email_bz').set('html', 'bludenz@up2games.at');
	}
	if ($('email_rankweil')) {
		$('email_rankweil').setAttribute('href', 'mailto:rankweil@up2games.at');
		$('email_rankweil').set('html', 'rankweil@up2games.at');
	}
	if ($('email_dornbirn')) {
		$('email_dornbirn').setAttribute('href', 'mailto:dornbirn@up2games.at');
		$('email_dornbirn').set('html', 'dornbirn@up2games.at');
	}
	if ($('email_bregenz')) {
		$('email_bregenz').setAttribute('href', 'mailto:bregenz@up2games.at');
		$('email_bregenz').set('html', 'bregenz@up2games.at');
	}
	
	if (Browser.Plugins.Flash.version != 0 && Browser.Plugins.Flash.build != 0) {
		if($('flash')) {
			var flashvars = {};
			var params = {
				wmode: "transparent"
			};
			var attributes = {};

			swfobject.embedSWF("flash/up2_mw3_bg_anim.swf", "flash", "991", "568", "9.0.0","expressInstall.swf", flashvars, params, attributes);
			$('page_wrap').setStyle('background', 'none');

		}
	}

});

var timer;
window.addEvent('resize', function() {
	timer = (function() {
		if ($('nav_left')) {
			$('nav_left').unpin();
			$('nav_left').setStyles({
				position: 'absolute',
				top: '50px',
				left: 0
			});
			$('nav_left').pin();
		}
	}).delay(300);
});

