function init_carousel()
{
	// Let's define some variables first
	var wrapper = $('wrap'); // The outer wrapper
	var carousel = $('carousel'); // The inner wrapper
	var items = $$('#carousel li'); // The different elements, this is an array
	var item_width = 590; // The full width of a single item (incl. borders, padding, etc ... if there is any)
	var max_margin = items.length * item_width - item_width;
	
	// Set up the animation
	var animation = new Fx.Tween(carousel, {duration: 500});
	
	// The function to browse forward
	function next_item(pos){
		if(pos == -max_margin){
			animation.start('left', 0);
		} else { 
			var newposition = pos - item_width;
			animation.start('left', newposition);
		}
		
		var item = -pos/item_width + 2;
		var prev = item - 1;
		if (item == 7) item = 1;
		$('cp_'+prev).removeClass('carousel_page_selected');
		$('cp_'+item).addClass('carousel_page_selected');
	}
	
	// The function to browse backward
	function previous_item(pos){
		if(pos == 0){
			animation.start('left', -max_margin);
		} else { 
			var newposition = pos + item_width;
			animation.start('left', newposition);
		}		
		var item = -pos/item_width;
		var prev = item + 1;
		if (item == 0) item = 6;
		$('cp_'+prev).removeClass('carousel_page_selected');
		$('cp_'+item).addClass('carousel_page_selected');
	}
	
	// Set up the 'next' and 'previous' buttons
	$('next').addEvent('click', function(){
		var position = parseInt(carousel.getStyle('left'));
		next_item(position);
	});
	
	$('previous').addEvent('click', function(){
		var position = parseInt(carousel.getStyle('left'));
		previous_item(position);
	});
}

var tabs = ['languages_div','disciplines_div','regions_div'];
var heads = ['languages_head','disciplines_head','regions_head'];
var current_section = 1;




function show_tab(id)
{
	
	var li = document.getElementById(id+'_li');
	for(var i=0;i<tabs.length;i++)	
	{
		var el = document.getElementById(tabs[i] + '_li');
		var sp = document.getElementById(tabs[i] + '_span');
		var div = document.getElementById(tabs[i]);		
		if (tabs[i] != id)	div.style.display = 'none';
		else div.style.display = '';
		
		if (el.className == 'on') 
		{
			el.className = 'noclass';
		}
	}
	li.className = 'on';	
	
	if (id == 'languages_div')
	{
		document.getElementById('disciplines_div_span').style.display = '';
	}
	if (id == 'disciplines_div')
	{
		document.getElementById('languages_div_span').style.display = 'none';
	}
	if (id == 'regions_div')
	{
		document.getElementById('disciplines_div_span').style.display = 'none';
		document.getElementById('languages_div_span').style.display = '';
	}
}

function mark_head(id)
{
	var elem = document.getElementById(id);
	if (elem.style.fontWeight == 'bold') return;
	for(var i=0;i<heads.length;i++)
	{
		if (heads[i] != id)	
		{
			document.getElementById(heads[i]).style.fontWeight = 'normal';
		}
	}
	elem.style.fontWeight = 'bold';
}

function load_section(num)
{
	//make cycle
	if (current_section == 7) current_section = 1;
	current_section++;
	//load text for section via ajax
	/*
	Lightbox.get_html('ajax_load_section',{'id':current_section});
	current_section++;
	Lightbox.get_html_callback = function()
	{
		//replace current text with new loaded
		var elem = document.getElementById('ldr_right_part_text');
		elem.innerHTML = Lightbox.req.responseJS.html;
		t=setTimeout("load_section("+current_section+")",5000);
	}
	*/
	//body_blocker.create_block();
	var params = {'id':current_section};
	var send_url = ajax_prefix+'index.php?rm=ajax_load_section';
    var req = new JsHttpRequest();
    req.onreadystatechange = function()
    {
	    if (req.readyState == 4)
        {
    	  	var html = req.responseJS.html;
    	  	var elem = document.getElementById('ldr_right_part_text');
			elem.innerHTML = html;
			//body_blocker.remove_block();
			t=setTimeout("load_section("+current_section+")",15000);
		}
    }
    req.caching = false;
    req.open('GET', send_url, true);
    req.send({ q: params});
	
}


/***********************************************
* Cross browser Marquee II- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

var delayb4scroll=2000 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var marqueespeed=1 //Specify marquee scroll speed (larger is faster 1-10)
var pauseit=1 //Pause marquee onMousever (0=no. 1=yes)?

////NO NEED TO EDIT BELOW THIS LINE////////////

var copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
var actualheight=''

function scrollmarquee()
{
	if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8))
	cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px"
	else
	cross_marquee.style.top=parseInt(marqueeheight)+8+"px"		
}

function initializemarquee()
{
	cross_marquee=document.getElementById("news_feed")
	cross_marquee.style.top=0	
	marqueeheight=document.getElementById("marqueecontainer").offsetHeight
	actualheight=cross_marquee.offsetHeight	
	if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1)
	{ //if Opera or Netscape 7x, add scrollbars to scroll and exit
		cross_marquee.style.height=marqueeheight+"px"
		cross_marquee.style.overflow="scroll"	
		return
	}
	setTimeout('lefttime=setInterval("scrollmarquee()",30)', delayb4scroll)
}

if (window.addEventListener)
window.addEventListener("load", initializemarquee, false)
else if (window.attachEvent)
window.attachEvent("onload", initializemarquee)
else if (document.getElementById)
window.onload=initializemarquee
