$(document).ready(function() {
	
	$('.slideshow').cycle({
		fx: 'fade', 
		speed: '4000',
		cleartypeNoBg: true		});
	
	$(".inline1").fancybox({
		'width'			: 280,
		'height'		: 220,
		'padding'		: 0,
		'margin'		: 0,
		'titleShow'		: false,
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic'
	});
	
	$(".videolink").fancybox({
		'width'			: 496,
		'height'		: 290,
		'padding'		: '0',
		'margin'		: '0',
		'scrolling'		: 'no',
		'autoScale'		: false,
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'type'			: 'iframe'
	});

	$(".videolink960").fancybox({
		'width'			: 976,
		'height'		: 555,
		'padding'		: '0',
		'margin'		: '0',
		'scrolling'		: 'no',
		'autoScale'		: false,
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'type'			: 'iframe'
	});
  	
  	$('div#myRoundabout div').mouseover(function(e) {
  		pushItem('<span>' + $(this).html() + '</span>');
  	}).mouseout(function(e) {
  		$('#companytext').html('<span></span>');
  	});
  	
  	var intervall;
  	$('div#myRoundabout').roundabout({
  		childSelector: 'div.top-logo', 
  		duration: 700, 
  		startingChild: 0,
  		minOpacity: 1.0,
  		minScale: 0.70,
  		maxScale: 0.80,
  		btnNext: '#next',
			btnPrev: '#prev',
			reflect: true, 
			clickToFocus: false, 
			tilt: -5 
  	}).hover(
  		function(){clearInterval(interval);},
  		function(){interval = startAutoPlay();}
  	);
	$("#myRoundabout").show();
  	interval = startAutoPlay();
});
	
function pushItem(message) {
	var sname = $('a', message).attr('name');
	var sout = sname;
	if (sname == 'lf') {sout = '<a title="Ludwig Freytag" class="inline1" href="#data">Ludwig Freytag</a>' }
	if (sname == 'lfservice') {sout = '<a name="lfservice" title="LF Service" href="http://lfservice.de">LF Service</a>' }
	if (sname == 'pmb') {sout = '<a name="pmb" title="Freytag &amp; v.d. Linde" href="http://www.freytag-vdlinde.de">Freytag &amp; v.d. Linde</a>' }
	if (sname == 'bpn') {sout = '<a name="bpn" title="Bauplanung Nord-Oldenburg (BPN)" href="http://bauplanung-nord.de">Bauplanung Nord-Oldenburg (BPN)</a>' }
	if (sname == 'danzer') {sout = '<a name="danzer" title="Danzer Betonwerk" href="http://danzer-betonwerk.de">Danzer Betonwerk</a>' }
	if (sname == 'tagu') {sout = '<a name="tagu" title="Tiefbau GmbH Unterweser" href="http://tagu.de">Tiefbau GmbH Unterweser</a>' }
	if (sname == 'nostag') {sout = '<a name="nostag" title="Offshore" href="http://www.tagu-offshore.de">NOSTAG Offshore</a>' }
	if (sname == 'rakwserv') {sout = '<a name="rakwserv" title="RAKW Service" href="http://rakw-service.de">RAKW Service</a>' }
	if (sname == 'rakw') {sout = '<a title="Ludwig Freytag" class="inline1" href="#data">Rohrleitungs- u. Anlagenbau (RAKW)</a>' }
	if (sname == 'rmt') {sout = '<a name="rakw" title="Rohrleitungs- u. Anlagenbau (RAKW)" href="http://rakw.de">RMT Rohrleitungs- und Anlagenbau</a>' }
	if (sname == 'lmr') {sout = '<a name="lmr" title="LMR Drilling" href="http://lmr-drilling.de">LMR Drilling</a>' }	
	$('#companytext').html('<span>'+sout+'</span>');
}

function startAutoPlay(){
	return setInterval(function() {
		$('div#myRoundabout').roundabout_animateToNextChild();
	}, 3000);
}

function clickSelect(current) {
	if (current.options[current.selectedIndex].value != "noLink" && current.options[current.selectedIndex].value != "noLink2") {
		clearInterval(interval);
		var target;
		target = current.options[current.selectedIndex].value;
		current.selectedIndex=0;
		/* window.location.href=(target); */
		window.open(target, '_top');
	} else {
	    if (current.options[current.selectedIndex].value == "noLink2") { 
	      clearInterval(interval);
	      current.selectedIndex=0;
	      $.fancybox(
		$('#dataholder').html(),
		{
		'width'			: 280,
		'height'		: 220,
		'padding'		: 0,
		'margin'		: 0,
		'scrolling'		: 'no',
		'titleShow'		: false,
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic'
		}
	     );
	  }
	}
}
