/*
(function(){
  // if firefox 3.5+, hide content till load (or 3 seconds) to prevent FOUT
  var d = document, e = d.documentElement, s = d.createElement('style');
  if (e.style.MozTransform === ''){ // gecko 1.9.1 inference
    s.textContent = 'body{visibility:hidden}';
    e.firstChild.appendChild(s);
    function f(){ s.parentNode && s.parentNode.removeChild(s); }
    addEventListener('load',f,false);
    setTimeout(f,3000);
  }
})();
*/

/*
$(function () {
		$('#slider').anythingSlider({
			width 				  : 900,         
			easing				  : 'easeInOutExpo',
			startPanel          : 1,        
			buildArrows         : true,    
	  	buildNavigation     : false,     
			pauseOnHover        : true,    
			hashTags            : false,
			delay               : 50000,   
			animationTime       : 900, 
			resizeContents      : false
		});
});

$(function () {
		$('#slider_tab').anythingSlider({
			width 				  : 502,         
			startPanel          : 1,        
			buildArrows         : true,    
 		  	buildNavigation     : false,     
			pauseOnHover        : true,    
			hashTags            : false,
			autoPlay            : true, 
			delay               : 15000,   
			animationTime       : 1100
		});
});

$(function () {
		$('#slider_tab2').anythingSlider({
			width					  : 500,         
			startPanel          : 1,        
			buildArrows         : true,    
 		  	buildNavigation     : false,     
			pauseOnHover        : true,    
			hashTags            : false,
			autoPlay            : true, 
			delay               : 15000,   
			animationTime       : 1100
		});
});


$(function () {
		$('#slider_anzeigen').anythingSlider({
			width 				  : 170,    
			height              : 450,      
			startPanel          : 1,        
			buildArrows         : false,    
 		  	buildNavigation     : false,     
			pauseOnHover        : true,    
			hashTags            : false,
			autoPlay            : true, 
			delay               : 5000,   
			animationTime       : 600
		});
});


$(function () {
		$('#imageslider').anythingSlider({
			width 				  : 470,    
			height              : 315,      
			startPanel          : 1,        
			buildArrows         : true,    
 		  	buildNavigation     : true,     
			pauseOnHover        : true,    
			hashTags            : false,
			autoPlay            : true, 
			delay               : 10000,   
			animationTime       : 900
		});
});

$(function () {
		$('#slider_rez').anythingSlider({
			width 				  : 184,    
			height              : 301,      
			startPanel          : 1,        
			buildArrows         : false,    
 		  	buildNavigation     : true,     
			pauseOnHover        : true,    
			hashTags            : false,
			autoPlay            : true, 
			delay               : 10000,   
			animationTime       : 900
		});
});
*/

$(document).ready(function() {
	
	
	$('a[rel*=facebox]').fancybox();
	
	$(".more-slide").click(function()
	{
    var id = $(this).attr('id').replace('more-', '');
    
    $('#slide-' + id).slideToggle(1000);
    
    if($('#more-' + id).html() == "mehr")
    {
      $('#more-' + id).html("schließen");
      $('#more-' + id).addClass("close");
    }
    else
    {
      $('#more-' + id).html("mehr");
      $('#more-' + id).removeClass("close");
    }
  }); 



	$(".slide").scrollable({
    next: ".slide-next",
    prev: ".slide-prev", 
    speed: "normal", 
    circular: true
	}).autoscroll({ autoplay: true, interval:8000 });

	
	$(".tab-slider").scrollable({
    next: ".tab-next",
    prev: ".tab-prev", 
    speed: "normal", 
    circular: true
	}).autoscroll({ autoplay: false, interval:8000 });

	
	$(".ad-slide").scrollable({
    next: ".ad-next",
    prev: ".ad-prev", 
    speed: "normal", 
    circular: true
	}).autoscroll({ autoplay: true, interval:4000 });

	
	$(".img-slide").scrollable({
    speed: "normal", 
    circular: true
	}).navigator({
    navi: ".scrollable-navi"
	}).autoscroll({ autoplay: true, interval:4000 });
  
  
  /******************************************************************** Tabs */
	$(".tabs .content").hide(); // Hide all content
	$(".tabs h2:first").addClass("active").show(); //Activate first tab
	$(".tabs .content:first").show(); //Show first tab content

  //On Click Event
	$(".tabs h2 a").click(function()
	{
		$(".tabs h2").removeClass("active"); // Remove any "active" class
		$(this).parent().addClass("active"); // Add "active" class to selected tab
		$(".tabs .content").hide();          // Hide all tab content
	
		var activeTab = $(this).attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});	
	
	
  
/*
	$("#oben .scrollcontainer").hover(function(){
		$(this).find(".overlay").toggle();
	});


	$(".buchempfehlung").mouseover(function(){
		$(this).addClass("hover");				
		$(this).find(".overlay").css({'display' : 'inline-block'});
	}).mouseout(function(){
				$(this).removeClass("hover");				
		$(this).find(".overlay").css({'display' : 'none'});
	});


	$(".listendarstellung").mouseover(function(){
				$(this).addClass("hover");
			}).mouseout(function(){
				$(this).removeClass("hover");
			});
*/


	/*	Tabs
	************/
/*	
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
	
	//On Click Event
	$("ul.tabs li").click(function() {
	
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content
	
		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});
*/

	/*	Accordion
	************/
/*
	$('.accordionueberschrift').click(function() {

		$('.accordionueberschrift').removeClass('aktiv');
	 	$('.accordioninhalt').slideUp(300);
   
		if($(this).next().is(':hidden') == true) {
			$(this).addClass('aktiv');
			$(this).next().slideDown(300);
		} 
	});
	  
	$('.accordionueberschrift').mouseover(function() {
			$(this).addClass('hover');
	}).mouseout(function() {
			$(this).removeClass('hover');										
	});
	$('.accordioninhalt').hide();
*/

});



function setFormParam(id, value, name)
{
	
  $('#' + id).attr('value', value);
  $('#' + id + "-name").html(name);

  p = $('#' + id + "-list").css('left');
  $('#' + id + "-list").css('left', '-1500px');
  setTimeout(function(){
	  $('#' + id + "-list").css('left', p);
  }, 10);
  
  return false;	
}


function showAdvancedSearch()
{
	var id = 'search-advanced';
	
	var status = $('#' + id).css('display');
	
	var value = 'block';
	if (status == 'block')
		value = 'none';
		
  $('#' + id).css('display', value);
}




/* Warenkorb
************/

function addToWishlist(vlbid)
{
	document.location.href = '/merkliste.html?func=add&vlbid=' + vlbid;
}

function addToBasket(vlbid)
{
	if(checkIfShop())
	{
		document.location.href = '/warenkorb.html?func=add&vlbid=' + vlbid;
	}else
	{
		// TODO: Layout aufmachen mit den ganzen Buchhandlungen
		// alert("Hier taucht noch ein layer auf mit den ganzen buchhandlungen");		

		$.ajax({
			type	: "POST",
			cache	: false,
			url		: "/_system/_ajax/_buchhandlungen.html?vlbid="+vlbid,
			data	: $(this).serializeArray(),
			success: function(data) {
				$.fancybox(data,{
	        		'autoDimensions'	: false,
					'width'         	: 600,
					'height'        	: 400,
					'transitionIn'		: 'none',
					'transitionOut'		: 'none'
					}
				);
			}
		});
	
	}
}

function setWishlistCounter(counter)
{
	$("wishlist-count").html(counter);
}

function setBasketCounter(counter)
{
	$("basket-count").html(counter);
}

function checkIfShop()
{
	return kb_wk;
}


/* Warenkorb
************/

function getBuchhandlungsinfo(id,info)
{
	$.ajax({
			type	: "POST",
			cache	: false,
			url		: "/_system/_ajax/_buchhandlungeninfo.html?bhid="+id+"&info="+info,
			data	: $(this).serializeArray(),
			success: function(data) {
				$.fancybox(data,{
	        		'autoDimensions'	: false,
					'width'         	: 600,
					'height'        	: 400,
					'transitionIn'		: 'none',
					'transitionOut'		: 'none'
					}
				);
			}
		});

}


/* Formularreset
*******************/


function resetSearchForm()
{
	setFormParam('search-advanced-period', '', 'Erscheinungszeitraum');
	setFormParam('search-advanced-sort','','Sortieren nach');
	setFormParam('search-advanced-format','','Alle Medien');
	setFormParam('search-advanced-category','','Alle Kategorien');
	
	$('#f-verlag').val("");
	$('#f-titel').val("");
	$('#f-autor').val("");
	$('#f-stichwort').val("");
	
	return;
	
}


















