// iDevices

$(document).ready(function() {
  if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
    $('#video_show, a.lightbox').click(function() {
      $('#overlay').css({'height': + $(document).height() + 'px'});
    });
    $(window).bind('resize', function(){
      $('#overlay').css({'height': + $(document).height() + 'px'});
    });
  }
});

function showCreativeAutomation() {
		$('#video_container embed, #video_container object').show();
		$('#lightbox').hide();
		$('#video_show').hide();
		$('#video_hide').show();
		$('#video_wrap').css({'height': + $(document).height() + 'px'}).stop().animate({
			left: 0,
			width: '100%'
		}, 1000);
		$('#overlay').css({'opacity': 0.8}).fadeIn('slow');
		// Stop Nivosliders
		if ($('.nivoSlider').length > 0) {
			$('.nivoSlider').each(function() {
				$(this).data('nivoslider').stop();
			});
		}
}

// Toggle 

function toggleElem(elm,link) {
  $('#' + elm).toggle("blind");
  if (!$('#' + link).hasClass('feature_act')) {
    $('#' + link).addClass('feature_act');
  } else {
    $('#' + link).removeClass('feature_act');
  }
}

$(document).ready(function(){
  $('.feature_link').live('click', function() {
    var link = $(this).attr('id');
    var elm = $(this).attr('rel');
    toggleElem(elm,link);
  });
});


// Toggle-Links Slideboxen Top

function resetSlidelink() {
  $(".slidelink_pointer_act").addClass('slidelink_pointer');
  $(".slidelink_pointer_act").removeClass('slidelink_pointer_act');
}

$(document).ready(function(){
  $('.slidelink_pointer').live('click', function() {
    var elm = $(this).attr('rel');

    // reset all
    $('.slidebox').hide();
    resetSlidelink();
    $('#' + elm).toggle('blind');
    
    $(this).addClass('slidelink_pointer_act');
    $(this).removeClass('slidelink_pointer');
  });
  
  $("a.close").click(function() {
    var elm = $(this).attr('rel');
    $('#' + elm).hide('blind');
    resetSlidelink();
  });
});  

$(document).ready(function(){
  $(".slidelink_pointer_act").live('click', function() {
    var elm = $(this).attr("rel");
    $('#' + elm).toggle('blind');
    resetSlidelink();
  })    
});  

// Cookie Top-Visual

$(document).ready(function() {
  if ($.cookie("visual") == "closed" && !$('body').hasClass('force_visual')) {
    $("#visual").hide();
    $("#visual_btn").removeClass("visual_close");
    $("#visual_btn").addClass("visual_open");
  }
});


// Buttons Top-Visual

$(document).ready(function() {
  $("#visual_btn").click(function() {
    if (!$('body').hasClass('force_visual')) {
      $("#visual").toggle("blind");
      if( $(this).hasClass("visual_close") ) {
        $(this).removeClass("visual_close");
        $(this).addClass("visual_open");
        $.cookie("visual", "closed", { path: '/' });
      } else {
        $(this).removeClass("visual_open");
        $(this).addClass("visual_close");
        $.cookie("visual", "opened", { path: '/' });
      }
    }
  });
});

/* rgaccord with jquery */
$(document).ready(function() {
  $('div.rgaccord1-nest> div.rgaccord1-content').hide();
  $('div.rgaccord1-nest> div.rgaccord1-toggle-wrap').click(function() {
  
    $(this).next('div.rgaccord1-content').slideToggle('1000');

    // style graphical headline
    if($(this).find('h4').hasClass("act"))
      $(this).find('h4').removeClass("act");
    else {
      $(this).find('h4').addClass("act");
    }
    
    // style normal headline
    if($(this).find('h2').hasClass("act"))
      $(this).find('h2').removeClass("act");
    else {
      $(this).find('h2').addClass("act");
    }
    //schließen, wenn ein anderer geklickt wird
    //.siblings('div:visible').slideUp('fast');
  });
  
  // extra css first/last elem accordeon
  $('div.rgaccord1-nest-graph:last').addClass('rgaccord1-nest-last');
  $('div.rgaccord1-toggle-wrap-graph:first').addClass('rgaccord1-toggle-wrap-first');

  $('div.rgaccord2-nest> div.rgaccord1-content').hide();
  $('div.rgaccord2-nest > div > h4').click(function() {
    $(this).next('div').slideToggle('fast');
        
    if($(this).hasClass("act"))
      $(this).removeClass("act");
    else {
      $(this).addClass("act");
    }
    //schließen, wenn ein anderer geklickt wird
    //.siblings('div:visible').slideUp('fast');
  });
  
  // normal style 1st elem w. border-top
  $('div.rgaccord1-nest:first').addClass('rgaccord1-nest-first');
  
  // extra css news
  $('div.news-list-item:first').addClass('news-list-item-first');
  $('div.news-list-item:last').addClass('news-list-item-last');
});

// Clickbox Functions siehe js kiwi_teaser

//$("#listnavi li._menuaktiv").find('a').mouseenter(function(){    
//  $(this).colorBlend([{ colorList:["#a7acb4", "#efd400"], param:"border-bottom-color", cycles: 1, duration: 400, strobe: false }]);
//});
      
//$("#listnavi li._menuaktiv").find('a').mouseleave(function(){
//  $(this).colorBlend([{ colorList:["#efd400", "#a7acb4"], param:"border-bottom-color", cycles: 1, duration: 400, strobe: false }]);
//});


//$("li.listnavil2").find('a').mouseenter(function(){    
//  $(this).colorBlend([{ colorList:["#FFFFFF", "#efd400"], param:"background-color", cycles: 1, duration: 100, strobe: false }]);
//});
      
//$("li.listnavil2").find('a').mouseleave(function(){
//  $(this).colorBlend([{ colorList:["#efd400", "#FFFFFF"], param:"background-color", cycles: 1, duration: 100, strobe: false }]);
//});



// jquery tools overlay

//$("a[rel]").overlay({
  // custom top position
//  top: 28,
//  effect: 'default',
//  mask: {
//    color: '#000',
//    loadSpeed: 200,
//    opacity: 0.8
//  },
//  // disable this for modal dialog-type of overlays
//  closeOnClick: false,
//  // load it immediately after the construction
//  load: false
//});

//$(function() {
//  $("a[rel]").overlay({ mask: { color: '#000' }, effect: 'apple'});
//});


