var cur_twit = 1;
var twit_arr = new Array();
var cur_twit2 = 1;
var twit_arr2 = new Array();


function activate_multibox() {
	//call multiBox
	if($$('.mb').length > 0)//only triggered if 'mb' class found on page
	{
		initMultiBox_1 = new multiBox('mb', {
			descClassName: 'multiBoxDesc',//the class name of the description divs
			path: '',//path to mp3 and flv players
			useOverlay: true,//use a semi-transparent background. default: false;
			maxWidth: false,//max width (set to false to disable)
			maxHeight: false,//max height (set to false to disable)
			addDownload: false,//do you want the files to be downloadable?
			pathToDownloadScript: '',//if above is true, specify download script
			addRollover: true,//add rollover fade to each multibox link
			addOverlayIcon: false,//adds overlay icons to images within multibox links
			addChain: false,//cycle through all images fading them out then in
			recalcTop: true//subtract the height of controls panel from top position
		});
	};
}

window.addEvent('domready', function() {
		var subnavi = $$('#navlist a');
		subnavi.each(function(element) {
 			
 			var subfx = new Fx.Morph(element, {duration:400, wait:false});
 			
 			subfx.start({
				'opacity': 1
			});
 			
			element.addEvent('mouseenter', function(){
				subfx.start({
					'opacity': 0.01
				});
			});
 	
			element.addEvent('mouseleave', function(){
				subfx.start({
					'opacity': 1
				});
			});
 		});	
		
		activate_multibox();


	if($$('.ideelink').length > 0) {
		$$('.ideelink').each( function (el) {
 			var ideefx = new Fx.Morph(el, {duration:400, wait:false});	
			el.addEvent('mouseenter', function(){
				ideefx.start({
					'color': "#1da4af"
				});
			});
			el.addEvent('mouseleave', function(){
				ideefx.start({
					'color': "#7a8d8d"
				});
			});

		});
		
		var spalt1fx = new Fx.Morph($('spal1'), {duration:700, wait:false});
		var spalt2fx = new Fx.Morph($('spal3'), {duration:700, wait:false});
		spalt1fx.start({
				'opacity': 0.3
		});
		spalt2fx.start({
				'opacity': 0.3
		});

		$('spal1').addEvent('mouseenter', function(){
			spalt1fx.start({
					'opacity': 1
			});
		});
		$('spal1').addEvent('mouseleave', function(){
			spalt1fx.start({
					'opacity': 0.3
			});
		});
		$('spal3').addEvent('mouseenter', function(){
			spalt2fx.start({
					'opacity': 1
			});
		});
		$('spal3').addEvent('mouseleave', function(){
			spalt2fx.start({
					'opacity': 0.3
			});
		});

	}
	
	// TWITTER
	if (document.getElementById('tbutton_b_link2')) {
		$('tbutton_b_link2').addEvent('click', function () {
			prev_twit2();
			return false;
		});
	}
	if (document.getElementById('tbutton_n_link2')) {
		$('tbutton_n_link2').addEvent('click', function () {
			next_twit2();
			return false;
		});
	}
	if (document.getElementById('tbutton_b_link2')) {
		load_twitter2();
		start_twitter_clicker2();
	}
});

function setidee(lang, url_title) {
	if (lang == 'de') {
		var base_url = "/main/zeile_3_2/";
	} else {
		var base_url = "/main_sl/zeile_3_2/";	
	}
	$('idee').set('html', "<img src='/images/ajax-loader.gif' alt='Loading' style='margin:20px 0 0 60px; padding:0;' />");
	var the_url = base_url + url_title + "/"
	var ajload_idee = new Request({
		url: the_url,
		onSuccess: function(text, rxml) {
				$('idee').set('html', text);
				// Make the idea fash
				var ideefx2 = new Fx.Morph($('idee'), {duration:200, wait:false, transition: Fx.Transitions.Quad.easeInOut});
				var ideefx3 = new Fx.Morph($('idee'), {duration:800, wait:false, transition: Fx.Transitions.Sine.easeInOut});
				ideefx2.start({'color': '#fff'}).chain(function () {
					ideefx3.start({'color': '#7a8d8d'});
				});
			}
		});
	ajload_idee.send();	
	return true;
}

function load_twitter2() {
	var ajload_tw = new Request.JSON({
		url: "/main/get_twitter2/",
		onSuccess: function(rs) {
			var i = 1;
			while ((c_twit = eval('rs.twita_' + i))) {
				twit_arr2[i] = c_twit;
				i++;
			}
			$('twit_content2').set('html', twit_arr2[cur_twit]);
		}
		});
	ajload_tw.send();	
}
function prev_twit2() {
		if (cur_twit2 > 1) {
			cur_twit2--;
			if (twit_arr2[cur_twit2]) {
				$('twit_content2').set('html', twit_arr2[cur_twit2]);
			} else {cur_twit2++;}
		}
		if (timerRunning2) {stop_twitter_clicker2();}
		return false;
}

function next_twit2() {
		if (cur_twit2 < 20) {
			cur_twit2++;
			if (twit_arr2[cur_twit2]) {
				$('twit_content2').set('html', twit_arr2[cur_twit2]);
			} else {cur_twit2--;}		
		}
		if (timerRunning2) {stop_twitter_clicker2();}
		return false;
}

/* Timer für Twitter Klicks */
var secs;
var delay = 8000;

var timerID2 = null; 
var timerRunning2 = false;

function stop_twitter_clicker2() { 
	if(timerRunning2) {
		clearTimeout(timerID2);
		timerRunning2 = false;
		timerID2 = null;
	}
}
function start_twitter_clicker2() {
        timerRunning2 = true;
        timerID2 = self.setTimeout("click_twitter2()", delay);
}
function click_twitter2() {
	if (cur_twit2 < 6) {
		next_twit2();
		start_twitter_clicker2();
	} else {
		cur_twit2 = 1;
		if (twit_arr2[cur_twit2]) {
			$('twit_content2').set('html', twit_arr2[cur_twit2]);
			stop_twitter_clicker2()
			start_twitter_clicker2();
		}
	}
}

/* Kommentare */

function comment_post() {
	if (document.kommform.pime.value=="") {
		alert("Bitte Deinen Namen eingeben");
		return false;
	}
	if (document.kommform.pstatus.value=="") {
		alert("Bitte Deinen Kommentar eingeben");
		return false;
	}
	if (document.kommform.security_code.value == "") {
		alert("Bitte den Sicherheitscode eingeben!");
		return false;
	}
	
	var daten = "pime=" + document.kommform.pime.value +"&pstatus="+document.kommform.pstatus.value+"&security_code="+document.kommform.security_code.value;
	
	var send_komm = new Request.HTML({
		url: "/home/write_comment/",
		method: 'post',
		data : daten,
		onSuccess: function(tre, so, html) {
			$('kom_form').set('html', html);
		}
	});
	send_komm.send();
	return false;
}

function comment_post_sl() {
	if (document.kommform.pime.value=="") {
		alert("Prosim vnesi tvoj ime");
		return false;
	}
	if (document.kommform.pstatus.value=="") {
		alert("Prosim vnesi tvoj komantar");
		return false;
	}
	if (document.kommform.security_code.value == "") {
		alert("Nisi vnesel/a varnostne kode!");
		return false;
	}
	
	var daten = "pime=" + document.kommform.pime.value +"&pstatus="+document.kommform.pstatus.value+"&security_code="+document.kommform.security_code.value;
	
	var send_kommsl = new Request.HTML({
		url: "/home_sl/write_comment/",
		method: 'post',
		data : daten,
		onSuccess: function(tre, so, html) {
			$('kom_form').set('html', html);
		}
	});
	send_kommsl.send();
	return false;
}
