//DOM ready
// stefan - 07.01.2011 - besprochene Änderungen vom 13.12

$(window).load(function() {

$('#ticker').list_ticker({ speed:4000, effect:'fade' })

// jQuery clickable
$("div.jsClickable").clickable();
$("div.wrap-subcat").clickable();

// NYRO-MODAL
// http://nyromodal.nyrodev.com/#settings
$('a.modal').nyroModal({bgColor: '#FFF' });

$('a.iframe').nyroModal({
	type: 'iframe',
	bgColor: '#FFF', // Background color
	minWidth: 900, // Minimum width
	minHeight: 650, // Minimum height
	resizable: true, // Indicate if the content is resizable. Will be set to false for swf
	autoSizable: true, // Indicate if the content is auto sizable. If not, the min size will be used
	padding: 20 
});

	// LargeDropDown -> http://tympanus.net/Tutorials/UIElements/LargeDropDown/
	if (jQuery.support.leadingWhitespace == true) {
	var $menu = $('#ldd_menu');
				
				/**
				 * for each list element,
				 * we show the submenu when hovering and
				 * expand the span element (title) to 510px
				 */
				$menu.children('li').each(function(){
					var $this = $(this);
					var $span = $this.children('span');
					$span.data('width',$span.width());
					
					$this.bind('mouseenter',function(){
						$menu.find('.ldd_submenu').stop(true,true).hide();
						//$span.stop().animate({'width':'110px'},200,function(){
						$span.stop().animate({'width':$span.data('width')+'px'},200,function(){
						$this.find('.ldd_submenu').slideDown(200);
						});
					}).bind('mouseleave',function(){
						$this.find('.ldd_submenu').stop(true,true).hide();
						$span.stop().animate({'width':$span.data('width')+'px'},200);
					});
				});
				};
});

//oli 27.01.2011
$(document).ready(function(){
	

$(".msg,.errorbox").fadeIn(200).delay(4000).fadeOut(100);

if (jQuery.support.leadingWhitespace == true) {
	 //$('ul.ldd_menu li').hover(function(){($(this)  '.ldd_submenu')).css({'display': 'inherit'}) ;}); //damit slided submenu bei js (ausser ie) (statt nur zu hovern)
};
//$('ul.ldd_menu li').hover(function(){$(this).slideDown(200);}) //damit slided submenu slide out)

// truncate
$('#right-col .longdesc').jTruncate({
length:180,
minTrail:20,
moreText:"[mehr]",
addclass: 'highlight', // adds class
lessText:"[weniger]",
//ellipsisText:" ...",
moreAni:"fast",
lessAni:1000
});

// jQuery FadeIN/FadeOut - http://www.hv-designs.co.uk/tutorials/jquery/all.html
$("#catlist-picture span").fadeTo(2000, 0.0); // This sets the opacity of the thumbs to fade down to 30% when the page loads

// Thumbnails der Aktionen
$(".fade").fadeTo(1000, 0.3); // This sets the opacity of the thumbs to fade down to 30% when the page loads

$(".fade").hover(function(){
$(this).stop().fadeTo("fast", 1.0); // This should set the opacity to 100% on hover
},function(){
$(this).stop().fadeTo("slow", 0.3); // This should set the opacity back to 30% on mouseout
});
});

//$("#topnavi").hover(function(){$(this).fadeIn(400);});

/*
  var msie6 = $.browser == 'msie' && parseFloat($.browser.version) < 7;

*/
  var msie6 = $.browser == 'msie' && parseFloat($.browser.version) < 7;


$(function () {
  //if !msie, jQuery.support.leadingWhitespace kann kein ie 6-8
  if (jQuery.support.leadingWhitespace == true) {
  
    var top = $('#topnavi').offset().top - parseFloat($('#topnavi').css('margin-top').replace(/auto/, 0));
    $(window).scroll(function (event) {
      // what the y position of the scroll is
      var y = $(this).scrollTop();
      
      if (y >= top) {
        // if so, ad the fixed class
        $('#topnavi').addClass('fixed');
		$('#topnavi').css({
			'width': '930px'
		});
       $('#topnavi .logo img').stop().animate({'top':'0','height':'55'},1000); //alter Wert - oli - 2600
        //$('#topnavi .logo img').stop().animate({'height':'55'},600);
        $('#topnavi').stop().animate({'opacity':'0.9'},400); // alter Wert - oli - 0.5
$('#topnavi').hover(
  function () {
    $(this).stop().fadeTo("400", 1);
  },
  function () {
    //$(this).fadeTo("400", 0.1);
  }
);


      } else {
      
        // otherwise remove it
        $('#topnavi').removeClass('fixed');
        $('#topnavi').stop().animate({'opacity':'0.9'},400);
        //$('#topnavi div.logo a img').css('z-index','99999');
       //$('#topnavi .logo img').stop().animate({'top':'-83'},2600);
        //$('#topnavi .logo img').stop().animate({'height':'158'},400);
    $('#topnavi .logo img').stop().animate({'top':'-27','height':'95'},600);

        
      }
    });
    // extra for ie6-8
  } 
  /*else {
    
        $('#topnavi').css('position', 'absolute');
        $('#topnavi').css('left', '0');
        $('#topnavi').css('top', '90');
        $('#topnavi div.logo').css('right', '0').css('z-index', '0');
        $('#action .search').css('position', 'absolute').css('right', '0');
        $('#action').css('width', '150').css('right', '0');
        $('ul.ldd_menu li').css('width', '100').css('float', 'left');
      }
 */
});

$(function () {
		$('img.cat-pic').hide();//hide all the images on the page
		$('img.search-preload').hide();//hide all the images on the page
	});

	var i = 0;//initialize
	var int=0;//Internet Explorer Fix
	$(window).bind("load", function() {//The load event will only fire if the entire page or document is fully loaded
		var int = setInterval("doThis(i)",500);//500 is the fade in speed in milliseconds
	});

	function doThis() {
		var images = $('img').length;//count the number of images on the page
		if (i >= images) {// Loop the images
			clearInterval(int);//When it reaches the last image the loop ends
		}
		$('img:hidden').eq(0).fadeIn(500);//fades in the hidden images one by one
		i++;//add 1 to the count
	}
