
function addToCart(book) {
	var bookLink = 'http://www.carlsen.de/web/shop/addToCHCart?book=' + book;
	jQuery('#cart2').attr('src', bookLink);
}

function checkLogin(){
	jQuery.ajax({
	    type: "GET",
		url: "http://www.chickenhouse.de/?type=42",
		dataType: "xml",
		success: function(xml) {
			// is the user logged in?
			jQuery(xml).find('userdata').each(function(){
				if (jQuery(this).find('error').text() == 'nologin'){
					// not logged in
					userLoggedIn = false;
					username = "";
				}
				else{
					// logged in
					userLoggedIn = true;
					username = jQuery(this).find('username').text();
				}
				if (loginInProgress){
					writeHighScore(tempScore);
				}
				
				if (userLoggedIn == true)
				{
					jQuery('#navitop A:first').html('LOGOUT');
					jQuery('#navitop A:first').attr('href','http://www.chickenhouse.de/top-navigation/mein-chicken-house/logout/');
				}
				else
				{
					jQuery('#navitop A:first').html('LOGIN');
					jQuery('#navitop A:first').attr('href','http://www.chickenhouse.de/top-navigation/mein-chicken-house/login/');
				}
			});
		}
	});
}

var userLoggedIn = false;
var username = "";
var loginInProgress = false;
var flashCreated = false;
var tempScore = 0;

jQuery(document).ready(function() {

	checkLogin();
	
	jQuery('.shortcomment').click(function(){
		jQuery(this).siblings('.fullcomment').css('display', 'block');
		jQuery(this).css('display', 'none');
	});
	
	jQuery('.fullcomment').click(function(){
		jQuery(this).siblings('.shortcomment').css('display', 'block');
		jQuery(this).css('display', 'none');
	});
	
	jQuery(".sbklappcontent").slideUp("fast");
	
	jQuery(".kommentare").slideToggle("fast");
		
	jQuery("div.newsklappitem").bind("click", function() {
		jQuery("div.newsklappitem div.newsklappcontent").slideUp("fast");
		jQuery(jQuery(this).find('div.newsklappcontent')).stop().slideToggle("fast");
	});

	
	jQuery(".sbklappitem").bind("click", function() {
		jQuery(".sbklappcontent").slideUp("fast");
		jQuery(jQuery(this).next(".sbklappcontent")).stop().slideToggle("fast");
	});
	
	jQuery("#kommentieren").bind("click", function() {
		jQuery(".sbklappitem div.sbklappcontent").slideUp("fast");
		jQuery(".sbklappcontent").slideUp("fast");
		jQuery(jQuery("#kommentare").find('div.sbklappcontent')).stop().slideToggle("fast");
	});

	jQuery("#weiterempfehlen").bind("click", function() {
		jQuery(".sbklappitem div.sbklappcontent").slideUp("fast");
		jQuery(".sbklappcontent").slideUp("fast");
		jQuery(jQuery("#empfehlen").find('div.sbklappcontent')).stop().slideToggle("fast");
	});	

	jQuery("#hoerprobe").bind("click", function() {
		jQuery(".sbklappitem div.sbklappcontent").slideUp("fast");
		jQuery(".sbklappcontent").slideUp("fast");
		jQuery(jQuery("#hoeren").find('div.sbklappcontent')).stop().slideToggle("fast");
	});
	jQuery("#hoerprobeleft").bind("click", function() {
		jQuery(".sbklappitem div.sbklappcontent").slideUp("fast");
		jQuery(".sbklappcontent").slideUp("fast");
		jQuery(jQuery("#hoeren").find('div.sbklappcontent')).stop().slideToggle("fast");
	});
	
	
	jQuery("div.specialclickAlt").bind("click", function() {
		jQuery("div.specialbottom").toggle();
		jQuery("div.specialtop").toggle();
	});
	
	jQuery("#flutlandLink1Link").bind("click", function() {
		jQuery("div.specialbottom").css('display','block');
		jQuery("div.specialtop").css('display','none');
		jQuery("#flutlandLink1LinkImg").attr('src','fileadmin/content/header/nav/diamondAct.png');
		jQuery("#flutlandLink2LinkImg").attr('src','fileadmin/content/header/nav/geschichtePass.png');
		jQuery("#kassenLink").css('top', '108px');
	});
	
	jQuery("#flutlandLink2Link").bind("click", function() {
		jQuery("div.specialbottom").css('display','none');
		jQuery("div.specialtop").css('display','block');
		jQuery("#flutlandLink1LinkImg").attr('src','fileadmin/content/header/nav/diamondPass.png');
		jQuery("#flutlandLink2LinkImg").attr('src','fileadmin/content/header/nav/geschichteAct.png');
		jQuery("#kassenLink").css('top', '126px');
	});
	
	jQuery("#flutlandLink3Link").bind("click", function() {
		jQuery("div.specialbottom").css('display','none');
		jQuery("div.specialtop").css('display','block');
		jQuery("#flutlandLink3LinkImg").attr('src','fileadmin/content/header/nav/storyPass.png');
		jQuery("#flutlandLink4LinkImg").attr('src','fileadmin/content/header/nav/autorAct.png');
		jQuery("#kassenLink").css('top', '144px');
	});
	
	jQuery("#flutlandLink4Link").bind("click", function() {
		jQuery("div.specialbottom").css('display','block');
		jQuery("div.specialtop").css('display','none');
		jQuery("#flutlandLink3LinkImg").attr('src','fileadmin/content/header/nav/storyAct.png');
		jQuery("#flutlandLink4LinkImg").attr('src','fileadmin/content/header/nav/autorPass.png');
		jQuery("#kassenLink").css('top', '90px');
	});

	jQuery("#chreg").validate();
	
	jQuery("#chupd").validate();
	
	jQuery("#recommendbook").validate();
	
	jQuery(".newshlnorm").find("img:last").hide();
	
	jQuery(".newshlnorm").hover(function() {
			jQuery(this).find("img:first").hide();
			jQuery(this).find("img:last").show();
		}, function() {
			jQuery(this).find("img:last").hide();
			jQuery(this).find("img:first").show();
	});	

	//jQuery(".booklistitem").hide();
	//jQuery(".booklistitema").show();

	jQuery(".seriesletterexists").bind("click", function() {
		jQuery(".seriesletterexists").removeClass("itemactive");
		var letterclass = jQuery(this).attr('class').split(' ').slice(-1);
		var l = letterclass.toString();
		var letter = l.charAt(l.length - 1);
		var ident = ".serieslistitem" + letter;
		jQuery(this).addClass("itemactive");
		jQuery(".serieslistitem").hide();
		jQuery(ident).show();
	});	
	
	jQuery(".letterexists").bind("click", function() {
		jQuery(".letterexists").removeClass("itemactive");
		var letterclass = jQuery(this).attr('class').split(' ').slice(-1);
		var l = letterclass.toString();
		var letter = l.charAt(l.length - 1);
		var ident = ".booklistitem" + letter;
		jQuery(this).addClass("itemactive");
		jQuery(".booklistitem").hide();
		jQuery(ident).show();
	});

	jQuery(".authorletterexists").bind("click", function() {
		jQuery(".authorletterexists").removeClass("itemactive");
		var letterclass = jQuery(this).attr('class').split(' ').slice(-1);
		var l = letterclass.toString();
		var letter = l.charAt(l.length - 1);
		var ident = ".authoritem" + letter;
		jQuery(this).addClass("itemactive");
		jQuery(".authoritem").hide();
		jQuery(ident).show();
	});
	
	jQuery(".authorpicletterexists").bind("click", function() {
		jQuery(".authorpicletterexists").removeClass("itemactive");
		var letterclass = jQuery(this).attr('class').split(' ').slice(-1);
		var l = letterclass.toString();
		var letter = l.charAt(l.length - 1);
		var ident = ".authoritem" + letter;
		jQuery(this).addClass("itemactive");
		jQuery(".authorpicitem").hide();
		jQuery(ident).show();
	});

});

jQuery(document).ready(function() {
	
	//jQuery('.openInLb a').nyroModal();
	
	jQuery('a.leseprobe').nyroModal({
		width: '800',
		height: '494'	
	});
	
	jQuery('.spurImg').animate({
	    opacity: '0.15'
	  }, {
	    duration: 100
	  });
	
	jQuery('.spur').bind('mouseenter', function() {
		jQuery('.spurImg').animate({
		    opacity: '0.4'
		  }, {
		    duration: 100
		  });
		});
	
	jQuery('.spur').bind('mouseleave', function() {
		jQuery('.spurImg').animate({
		    opacity: '0.15'
		  }, {
		    duration: 100
		  });
		});
	
	
	
	
jQuery('#spurensucheTeaser').bind('mouseenter', function() {
		
		jQuery('#stuebiImg').animate({
		    height: '104px'
		    
		  }, {
		    duration: 250
		  });

		});
	
	jQuery('#spurensucheTeaser').bind('mouseleave', function() {
		
		jQuery('#stuebiImg').animate({
		    height: '0px'
		    
		  }, {
		    duration: 250
		  });
		});
	
	
jQuery('#kassenLink').bind('mouseenter', function() {
		
		jQuery('#kassenLinkOver').animate({
		    height: '104px'
		    
		  }, {
		    duration: 250
		  });

		});
	
	jQuery('#kassenLink').bind('mouseleave', function() {
		
		jQuery('#kassenLinkOver').animate({
		    height: '0px'
		    
		  }, {
		    duration: 250
		  });
		});
	
	jQuery('#kassenLinkOver').animate({
	    height: '0px'
	    
	  }, {
	    duration: 250
	  });
	
	
});

jQuery.noConflict();


