/*!
*
* general JS-functions for deam.org
* you are free to copy them :)
*
*/
function deamJump(url, timer)
{
	window.setTimeout('document.location.href="'+url+'"', timer);
}

function showhide(id, txt_none, txt_block)
{
	var displayMode = 'table-row-group';
	var nAgt = navigator.userAgent;
	if((verOffset=nAgt.indexOf("MSIE"))!=-1)
	{
		if(parseInt(parseFloat(nAgt.substring(verOffset+5))) <= 6)
		{
			displayMode = 'block';
		}
	}

	var e = document.getElementById(id);
	var visi = (e.style.display == displayMode) ? 'none' : displayMode;
	e.style.display = visi;

	if(document.getElementById(id+'_handle'))
	{
		if(visi == displayMode) { document.getElementById(id+'_handle').innerHTML = txt_block; }
		else { document.getElementById(id+'_handle').innerHTML = txt_none; }
	}
}

function showhide_block(id, txt_none, txt_block)
{
	var e = document.getElementById(id);
	var visi = (e.style.display == 'block') ? 'none' : 'block';
	e.style.display = visi;

	if(document.getElementById(id+'_handle'))
	{
		if(visi == 'block') { document.getElementById(id+'_handle').innerHTML = txt_block; }
		else { document.getElementById(id+'_handle').innerHTML = txt_none; }
	}
}

function decrementTimer(minutes, seconds)
{
	var min = new Number(minutes);
	var sec = new Number(seconds);
	if(min>-1)
	{
		document.getElementById('sessiontime').innerHTML = (min>9?min.toString():'0'+min.toString()) + ':' + (sec>9?sec.toString():'0'+sec.toString());
		if(sec>0)
		{
			sec--;
		}
		else
		{
			min--;
			sec = 59;
		}
		window.setTimeout('decrementTimer(' + min + ',' + sec + ');',1000) ;
	}
	else
	{
		document.getElementById('sessiontime').innerHTML = "(abgelaufen)";
	}
}

function ajax_generic(ref, param)
{
	new $.post('/ajax/', param,
		function(data){
			$('#'+ref).html(data);
		}
	);
}

function mycarousel_initCallback(carousel)
{
	// Disable autoscrolling if the user clicks the prev or next button.
	carousel.buttonNext.bind('click', function() {
		carousel.startAuto(0);
	});

	carousel.buttonPrev.bind('click', function() {
		carousel.startAuto(0);
	});

	// Pause autoscrolling if the user moves with the cursor over the clip.
	carousel.clip.hover(function() {
		carousel.stopAuto();
	}, function() {
		carousel.startAuto();
	});
};

$(document).ready(function() {
	$('#deamBlogNewsList').jcarousel({
		buttonNextHTML: '',
		buttonPrevHTML: '',
		start: 1,
		offset: 0,
		vertical:true,
		scroll: 1,
		auto:3,
		wrap: 'last',
		initCallback: mycarousel_initCallback
	});
});
$(document).ready(function() {
	$('.deamMoodblender').moodblender({
		blendOut:false,
		dwellTime:4000
	});
});
$(document).ready(function(){
	$('.deamAccordion').accordion({
		autoHeight:false,
		collapsible:false,
		active:1
	});
});

$(document).ready(function() {
	$('.deamBilder').imageZoom({
		speed: 200,			// Animation-speed of zoom
		dontFadeIn: 1,		// 1 = Do not fade in, 0 = Do fade in
		hideClicked: 0,		// Whether to hide the image that was clicked to bring up the imgzoom
		imageMargin: 30,	// Margin from image-edge to window-edge if image is larger than screen
		className: 'deamImageZoom',
		loading: 'Lade Bild...'
	});
});

