$(document).ready(function() {
	$.fn.wait = function (time, type) {
        time = time || 1000;
        type = type || "fx";
        return this.queue(type, function wait() {
            var self = this;
            setTimeout(function() {
                $(self).dequeue();
            }, time);
        });
    };
	$("#bg-block").animate({
		opacity: 0.8
	}, 0, 'swing', function(){
		$("#adds-adds").css('display', 'block');	
	});
	var posout = (-462 * $("#adds-adds .content #images img.image-werbeblock").length) + 'px';
	var width = ((462 * $("#adds-adds .content #images img.image-werbeblock").length) + 45) + 'px';
	$("#bg-block").css('width', width);
	var posin = "0px";
	if(window.location.pathname.indexOf('cl/alist/cnid/f8d47a09d6b4c42b1.01056343') != -1){
		$("#adds-adds .clickarea img").attr('src', basePath + '0/templates/images/pfeil2.gif');
		$("#adds-adds")
			.css('left', '0px')
			.click( function(){
				var q = $(this).queue('fx');
				if(q[0] &&  q[0].name == 'wait'){
					$(this).queue([]);
					$(this).animate({left: posout }, 1500, 'swing', function(){
						$("#adds-adds .clickarea img").attr('src', basePath + '0/templates/images/pfeil1.gif');
					});					
				}
			})
			.wait(1500)
			.animate({left: posout }, 1500, 'swing', function(){
					$("#adds-adds .clickarea img").attr('src', basePath + '0/templates/images/pfeil1.gif');
			});
	}	
	$("#adds-adds .clickarea img").click(function(){
		if($("#adds-adds").css('left') == posin){
			$("#adds-adds")
				.animate({
				left: posout
			}, 1500, 'swing', function(){
				$("#adds-adds .clickarea img").attr('src', basePath + '0/templates/images/pfeil1.gif');
			});
		}else{
			$("#adds-adds").animate({
				left: posin
			}, 1500, 'swing', function(){
				$("#adds-adds .clickarea img").attr('src', basePath + '0/templates/images/pfeil2.gif');
			});
		}
	});



});