
(function($) { $.fn.equalHeights2 = function() { var targetHeight = 0; this.each(function() { if (this.scrollHeight > targetHeight) targetHeight = this.scrollHeight; }); this.each(function() { $(this).height(targetHeight); });  return this; }; })(jQuery);

//all function within this function will be called after the whole document including graphics are fully loaded
$(window).load(function () {
	var done = false;
	boxSize();
});

$(document).ready(function() {

    /*
	WB.tabs.init();
    WB.dropdowns.init();
    WB.headers.init();
    WB.overviewEffects.init();
	*/


	var teaserheight = 320;


    $(".cc-scrollpane").each(function() {
        var size = $(this).children("ul").children("li").length;
        var item = $(this).children("ul").children("li:first").width();
        var width = (size * item);
        $(this).children("ul").width(width);
        $(this).jScrollHorizontalPane({scrollbarHeight: 17, scrollbarMargin: 0, showArrows: true, arrowSize: 23});
    });

    $(".J-tooltip").each(function() {
        var e = $(this);
        var data = e.children(".tooltip-data");
        if (data.html()) {
            e.qtip({content: data.html(), position: {corner: {target: 'topLeft', tooltip: 'bottomLeft'},adjust: {x: 6, y: -10 }}});
        } else {
            e.qtip({position: {corner: {target: 'topLeft', tooltip: 'bottomLeft'},adjust: {x: 6, y: -10 }}});
        }
    });
    $(".cc-events .J-tooltips").qtip({position: {corner: {target: 'topRight', tooltip: 'bottomRight'}, adjust: {x: -6, y: -10 }}});




    /*
    $("#cc-grid").each(function() {
        //var sum = 28 + $(this).children(".r-1:first").height() + $(this).children(".r-2:first").height() + $(this).children(".r-3:first").height() + $(this).children(".r-4:first").height() + $(this).children(".r-5:first").height() + $(this).children(".r-6:first").height() + $(this).children(".r-7:first").height() + $(this).children(".r-8:first").height() + $(this).children(".r-9:first").height();

		sum=0;
		for(var i=1;i<10;i++){
			if($(this).children(".r-"+i+":first") != null){
				if($(this).children(".r-"+i+":first").height()>0) {
					sum =  $(this).children(".r-"+i+":first").height() + $(this).children(".r-"+i+":first").position().top;
				}
			}
		}

        $(this).height(sum);
    });
*/





	/* setze alle productbrandteaser auf gleiche Höhe*/
	/*$(".cc-product-brands li ul").each(function() {
		if(teaserheight<$(this).height()) teaserheight = $(this).height();
	});
	$(".cc-product-brands li ul").each(function() {
		$(this).height(teaserheight);
	});*/

	/* setze alle productbrandteaser auf gleiche Höhe*/
	var n = $(".cc-product-brands > li").queue("fx");
	function runIt() {

		$(".cc-product-brands > li").each(function() {
			if(teaserheight<$(this).height()) teaserheight = $(this).height();
		});
		$(".cc-product-brands > li").each(function() {
			$(this).height(teaserheight);
		});
	}
	runIt();






    $(".cc-sitemap").each(function() {
        $(".cc-sitemap li a.act").mouseover(function() {
            if ($(this).hasClass("open")) {
                return;
            }

            $(".cc-sitemap .dyn").hide(250);
            $(".cc-sitemap a.act").removeClass("open");
            $(this).next().show(500);
            $(this).addClass("open");
        });
    });

    $(".cc-selector").click(function() {
        $(this).parents(".cc-selector-group").find("input").attr("checked", "checked");
    });

    $(".cc-selector-clear").click(function() {
        $(this).parents(".cc-selector-group").find("input").attr("checked", "");
    });

    /*$("#act-compare").click(function() {

        $.get("produktvergleich.shtml", false, function(data) {
            $("#ov-compare-insert").html(data);
        });



        $("#ov-compare, #ov-compare-bg").show();
    	if ($.browser.msie && parseInt($.browser.version) == 6) {
    	    $("select").hide();
            window.scrollTo(0, 0);
        }
        return false;
    });
	*/
    $("#ov-compare-close, #ov-compare-bg").live("click", function() {
        $("select").show();
        $("#ov-compare, #ov-compare-bg").hide();
    });

    /*$("#ov-compare").each(WB.overlay.resize);
    */

    $(".cc-Tile2Acc .cc-arrow-down ").click(function() {
        $(this).parent().find("ul").toggle(500);
    });

    $(".cc-Tile3Acc .cc-arrow-down ").click(function() {
        $(this).parent().find(".up").toggle(500);
    });


	/* Lightbox */
	 var settings = {
			 	imageLoading:	'/img/10/lightbox-ico-loading.gif',
				imageBtnPrev:	'/img/10/lightbox-btn-prev.gif',
				imageBtnNext:	'/img/10/lightbox-btn-next.gif',
				imageBtnClose: '/img/10/lightbox-btn-close.gif',
				imageBlank: '/img/10/lightbox-blank.gif',
				containerBorderSize: 0
			};

    // enable lightbox for embedded article images
	$('.bigImg').lightBox(settings);

	// enable lightbox for gallery images
    $('.bigGalImg').lightBox(settings);
    $('.gal-img-cont .bigGalImg2').lightBox(settings);
    $('.gal-img-titl .bigGalImg2').lightBox(settings);
    $('.gal-img-titl:not(.product-gal-img-titl)').lightBox(settings);



    /*click event auf Product Thumbnail in ListProduct10*/
    $(".product-gal-img-cont").click(function() {
        document.location.href=$(this).children("a").eq(0).attr("href");
    });





	// generiert den Twitter Link
	$('a.sub-social-tw').click(function() {
		var twitterUrl = 'http://twitter.com/home?status=';
		var hash = ' via @wienerberger';
		var status = this.title + ' ' + document.location + ' '+ hash;

		status = status.replace(new RegExp( /\s/g ), '+');

		window.open(twitterUrl + status);

		return false;
	});
	
	
	
	// HomeOverviewProductSearch suggestion
	prods = $("#productnames").text().split(",");
	$.each(prods,function(key,value){
		prods[key] = value.trim();
	});
	$( "#query" ).autocomplete({
		source: prods
	});

});



(function($) { $.fn.equalHeights = function() { var targetHeight = 0; this.each(function() { if ($(this).height() > targetHeight) targetHeight = $(this).height(); }); this.each(function() { $(this).height(targetHeight); });  return this; }; })(jQuery);
//(function($) { $.fn.equalHeights2 = function() { var targetHeight = 0; this.each(function() { if ($(this).get().scrollHeight > targetHeight) targetHeight = $(this).get().scrollHeight; }); this.each(function() { $(this).height(targetHeight); });  return this; }; })(jQuery);



var helvetica_new = {src: '/swf/Helvetica.swf', ratios: [7, 1.32, 11, 1.31, 13, 1.24, 14, 1.25, 19, 1.23, 27, 1.2, 34, 1.19, 42, 1.18, 47, 1.17, 48, 1.18, 69, 1.17, 74, 1.16, 75, 1.17, 1.16]};
sIFR.activate(helvetica_new);
sIFR.replace(helvetica_new, {
    selector: '.ir .isfr',
    transparent: true,
    css: [
        '.sIFR-root { background-color: transparent; color: #000000; letter-spacing: 0; }',
        'a { text-decoration: none; }',
        'a:link { color: #bd3c41; }',
        'a:hover { color: #bd3c41; }'
    ]
});
sIFR.replace(helvetica_new, {
    selector: '.ir p.isfr-white',
    transparent: true,
    css: [
        '.sIFR-root { background-color: transparent; color: #ffffff; }',
        'a { text-decoration: none; }',
        'a:link { color: #bd3c41; }',
        'a:hover { color: #bd3c41; }'
    ]
});
sIFR.replace(helvetica_new, {
    selector: '.ir h4.isfr-white',
    transparent: true,
    css: [
        '.sIFR-root { background-color: transparent; color: #ffffff; font-weight: bold; }',
        'a { text-decoration: none; }',
        'a:link { color: #bd3c41; }',
        'a:hover { color: #bd3c41; }'
    ]
});


//added: 10.Mai2011
//hide menus on the overview page
function hideMenuContainer(containerId) {
	document.getElementById(containerId).style.display = "none";
}

//adjust the height of the teaserBoxes on the overview page - depending on the height of the biggest box
var done = false;
function boxSize() {
	if(!done){
		var boxCount  = $(".DE-teaserbox").length;
		var textCount = $(".teaserText").length;
		var promoCount  = $(".DE-teaserpromo").length;
		var bannerCount  = $(".DE-teaserbanner").length;
		var maxHeight = 0;
		var diff = 0;
		var currentBoxHeight = 0;
		var currentPromoHeight = 0;
		var currentBannerHeight = 0;
		//find the biggest teaserBox
		for(i=0; i<boxCount; i++){
			currentBoxHeight = $(".DE-teaserbox").eq(i).height();
			if(currentBoxHeight > maxHeight){
				maxHeight = currentBoxHeight;
			}
		}
		for(i=0; i<textCount; i++){
			//each teaserBox must be of the same height - the difference is added to the text area within the teaserBoxes
			diff = maxHeight - $(".DE-teaserbox").eq(i).height();
			var pHeight = $(".teaserText").eq(i).height() + diff;
			$(".teaserText").eq(i).css("height", pHeight);
			$(".faketrans").eq(i).css("height", maxHeight+6);

			/* move big teaserBoxes up
				389 is the height of the surrounding area in which all the teaserBoxes are in (DE-KeyVisualOverview)
				130 is the top position of "O-teaserboxes", it moves the teaserBoxes down
				9 is the bottom padding
			*/
			var position = 236 - maxHeight - 15;
			$(".DE-teaserbox").css("top",position);
		}

		//adjust teaserpromo boxes
		for(i=0; i<promoCount; i++){
			currentPromoHeight = $(".DE-teaserpromo").eq(i).height();
			diff = currentPromoHeight - maxHeight;
			position = 236 - maxHeight - 9 - diff;
			$(".DE-teaserpromo").eq(i).css("margin-top",position);
		}

		//adjust teaserbanner boxes
		for(i=0; i<bannerCount; i++){
			currentBannerHeight = $(".DE-teaserbanner").eq(i).height();
			diff = currentBannerHeight - maxHeight;
			position = 236 - maxHeight - 9 - diff;
			$(".DE-teaserbanner").eq(i).css("margin-top",position);
		}

	}
	done = true;
}

