var timeOuts= new Array();
$(document).ready(function () {
	$('#gtp_content_home').children().children().children().children('p').hide();
	$('#gtp_highlights').hide();
	$('#gtp_highlights').fadeIn('slow');
	//$('#news01').slideDown('slow');
	$("#highlight01").hide();
	$("#hl01").hide();
	$("#hl02").hide();
	$("#hl03").hide();
});

// 
var $scroll = $('#slider .scroll');

$scroll
  .before('<img class="scrollButtons left" src="../images/aktuelles/previous.gif" />')
  .after('<img class="scrollButtons right" src="../images/aktuelles/next.gif" />');
// bind the navigation clicks to update the selected nav:
$('#slider .navigation').find('a').click(selectNav);

// handle nav selection - lots of nice chaining :-)
function selectNav() {
  $(this)
    .parents('ul:first') // find the first UL parent
      .find('a') // find all the A elements
        .removeClass('selected') // remove from all
      .end() // go back to all A elements
    .end() // go back to 'this' element
    .addClass('selected');
}

function trigger(data) {
  // within the .navigation element, find the A element
  // whose href ends with ID ($= is ends with)
  var el = $('#slider .navigation').find('a[href$="' + data.id + '"]').get(0);

  // we're passing the actual element, and not the jQuery instance.
  selectNav.call(el);
}

var hNr = 1;
timeOuts['showcase'] = setTimeout('showHighlight(\''+hNr+'\',1)',1000);

function showNavi(id) {
	clearTimeout(timeOuts['\''+id+'\'']);
	$('#'+id).slideDown('slow');
	timeOuts['\''+id+'\''] = setTimeout('hideNavi(\''+id+'\')',3000);
};

function hideNavi(id) {           	
	$('#'+id).slideUp('slow');
};

function toggleNews(id) {
	$(document).find("p.newsteaser").slideUp("slow");
    if ($("#"+id).is(":hidden")) {
		$("#"+id).slideDown("slow");
	} else {
		$("#"+id).slideUp("slow");
	}
};

function startGallery(id) {
	$('#'+id).fadeIn('fast');
	$.scrollTo('#breadcrumbs',1000);
};

function closeGallery() {
	$('div.gallery_layer').fadeOut('fast');
};

function showHighlight(nr,loop) {
	if (nr!==1 && $("#highlight01").not(":hidden")) {
		$("#highlight01").fadeOut(1000);
		$("#hl01").fadeOut();
	}
	if (nr!==2 && $("#highlight02").not(":hidden")) {
		$("#highlight02").fadeOut(1000);
		$("#hl02").fadeOut();
	}
	if (nr!==3 && $("#highlight03").not(":hidden")) {
		$("#highlight03").fadeOut(1000);
		$("#hl03").fadeOut();
	}
	$("#hl0"+nr).fadeIn();
	$("#highlight0"+nr).fadeIn(1000);
	if(loop==1){
		hNr++;
		if(hNr==4)hNr=1;
		timeOuts['showcase'] = setTimeout('showHighlight(\''+hNr+'\',1)',8000);
	} else {
		clearTimeout(timeOuts['showcase']);
	}
};

function clearAllTimeouts(){
  for(key in timeOuts){
    clearTimeout(timeOuts[key]);
  }
}

function playYoutube(ytID){
	document.getElementById('youtube_container').style.display='block';
	document.getElementById('youtube_video').innerHTML='<div id="flash"><iframe title="YouTube video player" width="640" height="389" src="http://www.youtube.com/embed/'+ytID+'?autoplay=1" frameborder="0" border="0" allowfullscreen="true"></iframe></div>';
}

function hideYoutube(){
	document.getElementById('youtube_container').style.display='none';
	document.getElementById('youtube_video').innerHTML='';
}



