
    // -- INIT --
    function init_saeco() {
        init_lazyloader();
        init_fake_faux_column();
        init_sense();
        init_knowledge();
        init_recipe();
        init_product();
        init_productInfo();
        setTimeout("init_flash()", 100);
    }
    
    // -- open link in new window <a href="http://www.URL.com" onclick="openInNew(this);"> --
    function openInNew(url){
        window.open(url.href);
    }
    
    // -- lazy-asset-loader --
    var loadedTabs = [0,0,0,0,0];
    
    function init_lazyloader( tab_id ) {
    
        // -- init default aktive tab --
        if ( tab_id == null ) {
            $(".cp_tabmenu li").each(function( index ) {
                if( $(this).hasClass("cp_active") ) {
                    tab_id = index;
                }
            });
        }
        
        // -- load selected tab --
        if ( loadedTabs[tab_id] == 0 ) {  
		
            loadedTabs[tab_id] = 1;          
            
            switch ( tab_id ) {
                case 0 :

                    break;
  
                case 1 :
                    // -- Tab 2 lazy load --
                    $("#tab2_paper").attr("src","/consumerfiles/pageitems/master/categorypages/Saeco_row2011/assets/images/paper_right.png");
                    $("#tab2_polaroid_right").attr("src","/consumerfiles/pageitems/master/categorypages/Saeco_row2011/assets/images/polaroid_right.png");
                    // -- Tab 2 lazy load -- .knowledge
                    $("#storyimg_1").attr("src", "/consumerfiles/pageitems/master/categorypages/Saeco_row2011/assets/images/knowledge_two_types_of_bean.jpg");
                    $("#storyimg_2").attr("src", "/consumerfiles/pageitems/master/categorypages/Saeco_row2011/assets/images/knowledge_harvesting.jpg");
                    $("#storyimg_3").attr("src", "/consumerfiles/pageitems/master/categorypages/Saeco_row2011/assets/images/knowledge_roasting.jpg");
                    $("#storyimg_4").attr("src", "/consumerfiles/pageitems/master/categorypages/Saeco_row2011/assets/images/knowledge_blending.jpg");
                    $("#storyimg_5").attr("src", "/consumerfiles/pageitems/master/categorypages/Saeco_row2011/assets/images/knowledge_brewing.jpg");
                    // -- Tab 2 lazy load -- .recipe
                    $("#recipe_teaser").attr("src", "/consumerfiles/pageitems/master/categorypages/Saeco_row2011/assets/images/recipe_the_bride.jpg");
                    $("#recipe_teaser").attr("alt", "The Bride in a glass");
                    $("#recipe_1").attr("src", "/consumerfiles/pageitems/master/categorypages/Saeco_row2011/assets/images/recipe_the_bride.jpg");
                    $("#recipe_2").attr("src", "/consumerfiles/pageitems/master/categorypages/Saeco_row2011/assets/images/recipe_mamaccino.jpg");
                    $("#recipe_3").attr("src", "/consumerfiles/pageitems/master/categorypages/Saeco_row2011/assets/images/recipe_the_bridegroom.jpg");
                    $("#recipe_4").attr("src", "/consumerfiles/pageitems/master/categorypages/Saeco_row2011/assets/images/recipe_love4ever.jpg");
                    $("#recipe_5").attr("src", "/consumerfiles/pageitems/master/categorypages/Saeco_row2011/assets/images/recipe_honeymoon.jpg");
                    $("#recipe_6").attr("src", "/consumerfiles/pageitems/master/categorypages/Saeco_row2011/assets/images/recipe_green_surprise.jpg");
                    $("#recipe_7").attr("src", "/consumerfiles/pageitems/master/categorypages/Saeco_row2011/assets/images/recipe_baby_latte.jpg");
                    $("#recipe_8").attr("src", "/consumerfiles/pageitems/master/categorypages/Saeco_row2011/assets/images/recipe_childrens_punch.jpg");
                    break;
              
			  	case 2 :
					break;
			  
			  	case 3 :
					break;
			  
                case 4 :     
                    // -- Tab 3 lazy load -- .product
                    $("#tab5_product_01").attr("src","/consumerfiles/pageitems/master/categorypages/Saeco_row2011/assets/images/Saeco_Xelsis_Line.png");
                    $("#tab5_product_02").attr("src","/consumerfiles/pageitems/master/categorypages/Saeco_row2011/assets/images/Saeco_Exprelia_Line.png");
                    $("#tab5_product_03").attr("src","/consumerfiles/pageitems/master/categorypages/Saeco_row2011/assets/images/Saeco_Syntia_Cappuccino.png");
                    $("#tab5_product_04").attr("src","/consumerfiles/pageitems/master/categorypages/Saeco_row2011/assets/images/Saeco_Syntia_Line.png");
                    $("#tab5_product_05").attr("src","/consumerfiles/pageitems/master/categorypages/Saeco_row2011/assets/images/Saeco_Xsmall_Line_chrome.png");
                    break;
              
                default :
                    break;
            }
        }
    }    
    
    
    // -- Flash Slideshow Container --
    function init_flash() {
        
        // create a flash object with swfObject
        var flashvars = {
                swf: "/consumerfiles/pageitems/master/categorypages/Saeco_row2011/assets/flash/slideshow.swf",
                swfConfig: slideshow_xmlpath,
                wrapperConfig: "/consumerfiles/pageitems/master/categorypages/Saeco_row2011/assets/flash/SWFWrapper.xml",
                playButton: "false",
                replayButton: "true"
        };
        var params = {
            menu: "false",
            seamlesstabbing: "false",
            bgcolor:"transparent",
            wmode:"transparent"
        };
        var attributes = {};

        swfobject.embedSWF("/consumerfiles/pageitems/master/categorypages/Saeco_row2011/assets/flash/SWFWrapper.swf", "flashcontent", "960", "492", "10.0.0", "/consumerfiles/pageitems/master/categorypages/Saeco_row2011/assets/flash/expressInstall.swf", flashvars, params, attributes);
			
    }

    
    
    // -- Teaser small height Tab 1 --
    function init_fake_faux_column() { 
        setTimeout("slowed_faux_column()", 200);
    }
    function slowed_faux_column() {
        $(".tab1 .teaser_small .teaser_middle").css("height", "");
        var height = 0;
        var tmp = 0;
        $(".tab1 .teaser_small .teaser_middle").each(function(event) {
            tmp = $(this).innerHeight();
            height = (tmp > height) ? tmp : height;
        });
        $(".tab1 .teaser_small .teaser_middle").each(function(event) {
            $(this).css("height", height + "px");
        });
        
        $(".tab3 .teaser_content_right").css("height", "");
        height = 0;
        tmp = 0;
        $(".tab3 .teaser_content_right").each(function(event) {
            tmp = $(this).innerHeight();
            height = (tmp > height) ? tmp : height;
        });
        $(".tab3 .teaser_content_right").each(function(event) {
            $(this).css("height", height + "px");
        });
    }
    
    
    // -- Sense --
    function init_sense() {
        
        var popup;
        // Mouseover
        $(".cups .cup a").mouseover(function(){
            var id = $(this)[0].className;
            $(".sense_right .popup").each(function(index) {
                if($(this).hasClass(id)) {
                    $(this)[0].style.display = "block";
                    popup = $(this)[0];
                    var positiontop = Math.round($(".cups").position().top);
                    var height = popup.offsetHeight;
                    var postop = positiontop - height + 18;
                    if(navigator.userAgent.search(/MSIE 6.+/) != -1){
                      var postop = postop + 5;
                    }
                    popup.style.top = postop + "px";
                }
                else {
                    $(this)[0].style.display = "none";
                }
            });
            $(".cups .cup").each(function(){ 
                ( $(this).children()[0].className == id ) ? $(this).addClass("hi") : $(this).removeClass("hi"); 
            });
        });
        // Mouseout 
        $(".cups .cup a").mouseout(function() { 
            popup.style.display = "none";
            $(".cups .cup").each(function(){ $(this).removeClass("hi"); }); });
        // Delete Click Event
        $(".cups .cup a").click(function(event){ return false; });
        
    } 
    
    
    
    
    // -- Knowledge --
    function init_knowledge() {

        // Init Default Higlight
        var hi = "nr_01";
        $(".stories li").each(function(){ if ($(this).hasClass("hi")) { hi = ($(this).children()[0].className); } });
        $(".box_right .story").each(function(index) { $(this)[0].style.display = ($(this).hasClass( hi )) ? "block" : "none"; });
 
        // Init Click Event 
        $(".stories li a").click(function(event){
            var id = $(this)[0].className;
            $(".box_right .story").each(function(index) {
                $(this)[0].style.display = ($(this).hasClass(id)) ? "block" : "none";
            });
            $(".stories li").each(function(){ 
                ( $(this).children()[0].className == id ) ? $(this).addClass("hi") : $(this).removeClass("hi"); 
            });
            return false;
        });
                
    }
    
    
     
    // -- Product --
    function init_product() {
        // Init Default Higlight
        var hi = "product_01";
        
        $(".product_list li").each(function(){ 
            if ($(this).hasClass("hi")) { 
                
                hi = ($(this)[0].id);
                $(this).hide();
                $(this).show();
                
            } 
        });
        
        $(".product_right .machine").each(function(index) { 
            if ($(this).hasClass( hi )) {
                $(this).show();             
            } else {
                $(this).hide();             
            }
        });
        
        $(".product_list li div .click").click(function(event){ 
            var fuid = $(this).parent()[0];
            fuid = $(fuid).parent()[0].id;
            
            $(".product_right .machine").each(function(index) {
                if ($(this).hasClass( fuid )) {
                    $(this).show();
                } else {
                    $(this).hide();
                }
            });
            
            $(".product_list li").each(function(){ 
                if ( $(this)[0].id == fuid ) {
                    $(this).addClass("hi");
                    $(this).removeClass("lo"); 
                } else {
                    $(this).addClass("lo");
                    $(this).removeClass("hi"); 
                }
            });
            return false;
        });
        
    }

    
    
    // -- Product name-list hovers --
    function init_all_product_headline() {
        $(".product_list li.lo h3").show();
        $(".product_list li.lo h4").hide();
        $(".product_list li.hi h3").hide();
        $(".product_list li.hi h4").show();
    }
    
    
    
    // -- set Tab --
    function setTab( id ) {
        $(".cp_tab").each(function(index){ 
            if (index == id) {
                $(this)[0].style.display = "block";
                cp_tabChanged( index );
                var length = $(".cp_tabmenu li").length;
                $(".cp_tabmenu li").each(function( i ){
                    $(this).removeClass("cp_active_leftSibling");
                    $(this).removeClass("cp_active_rightSibling");
                    $(this).removeClass("cp_active_firstTab");
                    $(this).removeClass("cp_active_lastTab");
                    $(this).removeClass("cp_active");
                    $(this).removeClass("cp_inactive");
                    if ( id == i ) {
                        $(this).removeClass("cp_inactive");
                        if ( i==0 ) {
                            $(this).addClass("cp_active_firstTab");
                        } else if ( i == length-1 ) {
                            $(this).addClass("cp_active_lastTab");
                        } else {
                            $(this).addClass("cp_active");
                        }
                        if ( id > 0 ) {
                            $(this).prev().addClass("cp_active_leftSibling");
                        } else if ( id < length-1 ) {
                            $(this).next().addClass("cp_active_rightSibling");
                        }
                    } else {
                        $(this).addClass("cp_inactive");
                    }
                });
                $('html, body').animate({scrollTop:0}, 1000);
            } else {
               $(this)[0].style.display = "none"; 
            }
        });
        return false;
    } 

    
    
    
    // -- Recipe --
    function init_recipe() {

        // Init Default Higlight
        var hi = "nr_01";
        var id = 0;
        $(".recipes li").each(function(){ if ($(this).hasClass("hi")) { hi = ($(this).children()[0].className); } });
        $(".recipe_box .recipe_text").each(function(index) { $(this)[0].style.display = ($(this).hasClass( hi )) ? "block" : "none"; });
        $(".recipe .box_middle").addClass("closed");
        // Init Click Event 
        $(".recipes li a").click(function(event){
            id = $(this)[0].className;
            $(".recipe_box .recipe_text").each(function(index) {

                if($(this).hasClass(id)) {
                    $(this)[0].style.display = "block";
                    // Switching src of the Teaser Picture to the active Recipe
                    var img = $(this).find('img');
                    
                    $(".teaser_img img").attr("alt", img.attr("alt"));
                    $(".teaser_img img").attr("src", img.attr("src"));
                    
                }
                else {
                    $(this)[0].style.display = "none";
                }
            });
            $(".recipes li").each(function(){ 
                ( $(this).children()[0].className == id ) ? $(this).addClass("hi") : $(this).removeClass("hi"); 
            });
            return false;
        });
        // Switch
        $(".recipe .switch").click(function(event) {
            if($(".box_middle").hasClass(".closed")) {
                $(".box_middle").removeClass("closed");
                if (id != 0) {
                    $(".recipe_text ."+id).show();
                } else {
                    $(".recipe_text .nr_01").show();
                }
            } else {
                $(".box_middle").addClass("closed");
                if (id != 0) {
                    $(".recipe_text ."+id).hide();
                } else {
                    $(".recipe_text .nr_01").hide();
                }
            }
        });
    }
    
    
    
    // -- Produkt - Hotspot and Infobox 
    function init_productInfo() {

        $(".machine .info .hotspot_out").mouseover(function(){
            $(this).next().show();
            $(this).hide();
        });
        $(".machine .info .hotspot_wrap").mouseover(function(){
            $(this).show();
            $(this).prev().hide();
        });
        $(".machine .info .hotspot_wrap").mouseout(function(){
            $(this).hide();
            $(this).prev().show();
        });
    }
    

