window.addEvent('domready', function(){

//Header
var headerFx = new Fx.Style('header', 'top', {duration: 200, wait: false})
var headerTab1Fx = new Fx.Style('header_tab', 'opacity', {duration: 200, wait: false})
var headerTab2Fx = new Fx.Style('header_tab', 'top', {duration: 250, wait: false})

var login_checker;

$('header_anm').addEvent('click', function(){
headerFx.toggle(-12, 12),
headerTab1Fx.start(1, 0),
headerTab2Fx.start(0, -32);
login_checker = 1;
})



$('wrapper').addEvent('click', function(){
if (login_checker==1) {
headerFx.toggle(12, -12)
headerTab1Fx.start(0, 1),
headerTab2Fx.start(-32, 0);
login_checker = 0;
}
})

$('videolinks').addEvent('click', function(){
if (login_checker==1) {
headerFx.toggle(12, -12)
headerTab1Fx.start(0, 1),
headerTab2Fx.start(-32, 0);
login_checker = 0;
}
})


$$('#header_tab li').each(function(element) {
 	var fx = new Fx.Styles(element, {duration:200, wait:false});
 	element.addEvent('mouseenter', function(){
		fx.start({
			'padding-top': '5px',
			'color': '#CCCCCC'
		});
	});
 	element.addEvent('mouseleave', function(){
		fx.start({
			'padding-top': '0px',
			'color': '#666666'
		});
	});
 
});


// Archiv 07 Button

var arch07_toggle = 0;

$('arch07').addEvent('click', function(e) {
if (arch07_toggle==0) {
	e = new Event(e).stop();
	var arch07 = "http://tv.mxr.at/login/usercontent/arch07";
	new Ajax(arch07, {
		method: 'get',
		update: $('kwick'),
		evalScripts: true,
		onRequest: function() {
		$('loading_bgnd').setStyle('display', 'block');
		$('loading').setStyle('display', 'block');
		},
		onComplete: function() {
		$('loading_bgnd').setStyle('display', 'none');
		$('loading').setStyle('display', 'none');
		initTips();
		loadFile({file:'xml/quickzig.xml'})
		$('arch07').setHTML('Zur&uuml;ck');
		arch07_toggle = 1;
		}
	}).request();
	}
else {
	var log = "http://tv.mxr.at/login/usercontent/default";
	new Ajax(log, {
		method: 'get',
		update: $('kwick'),
		evalScripts: true,
		onRequest: function() {
		$('loading_bgnd').setStyle('display', 'block');
		$('loading').setStyle('display', 'block');
		},
		onComplete: function() {
		$('loading_bgnd').setStyle('display', 'none');
		$('loading').setStyle('display', 'none');
		initTips();
		loadFile({file:'xml/default.xml'})
		$('arch07').setHTML("Archiv '07");
		arch07_toggle = 0;
		}
	}).request();
}
});



//Tips

function initTips(){
var Tips3 = new Tips($$('.kwick'), {
	initialize:function(){
		this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 200, wait: false}).set(0),
		this.fx2 = new Fx.Style(this.toolTip, 'margin-top', {duration: 200, wait: false});
	},
	onShow: function(toolTip) {
		this.fx.start(1),
		this.fx2.start(50);
	},
	onHide: function(toolTip) {
		this.fx.start(0),
		this.fx2.start(30);
	},
	hideDelay: 200,
	fixed: true
});
}

initTips();

$('myForm').addEvent('submit', function(e) {
new Event(e).stop();
var log = $('kwick').empty();
	this.send({
		update: log,
		evalScripts: true,
		onRequest: function() {
		$('loading_bgnd').setStyle('display', 'block');
		$('loading').setStyle('display', 'block');
		

		},
		onComplete: function() {
		$('loading_bgnd').setStyle('display', 'none');
		$('loading').setStyle('display', 'none');
		initTips();
		headerFx.toggle(-12, 12);
		headerTab1Fx.start(0, 1),
		headerTab2Fx.start(-32, 0);
		login_checker = 0;
		}
	});
});

});