// JQUERY
$(document).ready(function(){
  //Shadowbox
  Shadowbox.init({
    language: 'en', 
    adapter:'jquery', 
    players: ['img','swf','flv']
  });

  // rollover related items
  $(".related").hover(
	function() {
		//alert('hover');
		$(this).addClass('relactive');
	}, function() {
		//alert('out');
		$(this).removeClass('relactive');
	});

  // events aus- einklappen
	$(".lr_right").find(".openlink").click(
    function() {
      $(this).parent().next().show();
      $(this).parent().hide();
      //$(this).parents(".related").find(".eventdetail").slideDown(600);
      $(this).parents(".related").find(".eventdetail").show();
    }
  );
	$(".lr_right").find(".closelink").click(
    function() {
      $(this).parent().prev().show();
      $(this).parent().hide();
      //$(this).parents(".related").find(".eventdetail").slideUp(600);
      $(this).parents(".related").find(".eventdetail").hide();
    }
  );
  
});

// JS
/* Shadowbox Movie */
function openShadowbox(content, title, width, height){
    Shadowbox.open({
        content:    content,
        player:     'flv',
        title:      title, 
        width:      width, 
        height:     height, 
        options: {
          flashVars: {
            width:         width, 
            height:        height+20, 
            displayheight: height, 
            frontcolor:    '0xFFFFFF',
            backcolor:     '0xFF0000', 
            lightcolor:    '0xFFFFFF', 
            screencolor:   '0x000000', 
            /*overstretch:   'fit', */
            autostart:     true, 
            showicons:     false, 
            showdigits:    false
          }
        }
    });
}

/* TextBild Slideshow */
function switchbox(itemsId){
	this.itemsId = itemsId;
	this.count = '';
	this.actIndex = 0;

	this.show = function (newIndex){
		
		document.getElementById(this.itemsId + 'I' + this.actIndex).style.display = 'none';
		document.getElementById(this.itemsId + 'I' + newIndex).style.display = 'block';
		
    document.getElementById(this.itemsId + 'I' + this.actIndex + '_caption').style.display = 'none';
		document.getElementById(this.itemsId + 'I' + newIndex + '_caption').style.display = 'block';
		
		this.actIndex = newIndex;
	}
	
	this.main = function (direction){
		var newIndex;
		
		newIndex = this.actIndex;
		if(direction == 'down') newIndex++;
		else newIndex--;
		
		if(newIndex < 0) newIndex = this.count-1;
		if(newIndex >= this.count) newIndex = 0;

		this.show(newIndex);
	}
		
	this.next = function (){
		this.main('down');
	}
	
	this.prev = function (){
		this.main('up');
	}
}

