
   /****************************************************************************************************/
   /* Class Gui                                                                                        */
   /*                                                                                                  */
   /* Methods:                                                                                         */
   /*                                                                                                  */
   /* checkAnchor               - Checks the Anchor in the Browseradressline and update the content    */
   /* startAnchorListner        - Start the AnchorListner                                              */
   /* stopAnchorListner         - Stop the AnchorListner                                               */
   /*                                                                                                  */
   /* initializeMenueDropdown   - For initialize the Standardmenu Dropdown-Menue                       */
   /* showMenue                 - Shows the Standardmenue Dropdown-Menu, triggert by onmouseover       */
   /* hideMenue                 - Hide the Standardmenue Dropdown-Menu                                 */
   /*                                                                                                  */
   /* StandardMenuemoveToHead   - Move the Standadmenue to the top                                     */
   /*                                                                                                  */
   /* gotoInsightPage           - Get the Insight-Content from Ajax-Request                            */
   /* InsightContentSlide       - Check in which direction Insight-Content Slide                       */
   /* Insight_scrollLeft        - Slide/Scroll the Insight-Content to Left                             */
   /* Insight_scrollRight       - Slide/Scroll the Insight-Content to Right                            */
   /*                                                                                                  */
   /* gotoStandardPage         - Get the Standard-Content from Ajax-Request and show it                */
   /*                                                                                                  */
   /****************************************************************************************************/

   Gui = $.klass({                                                                                   
      initialize: function(currently_in_menu, current_number, baseurl, tracking, currentpath) {
         
         //tracking_debug
         tracking_debug = false; // switch it to false, if you don´t see debuginformation (js console);
                  
         
         if(tracking == 'true') {
           tracking_google = 'yes';
         } else {
            tracking_google = 'no';
         }
         
         // tracking end
         
         content_standard_normal = '#content-standard-normal';  
         content_standard_footer = '#content-standard-footer';
          
         content_insight         = '#content-insight';
         content_insightboxes    = '#content-insightboxes';
         content_insight_holder  = "#content-insight-holder";
          
         content_insight_scroll  = "#content-insight-scroll";
         content_insight_item    = ".content-insight-item";
          
         standardmenu            = '#standardmenu';
         //insightmenu           = '#insightmenu';
         
         subpage_container       = '#subpage_container_';
         productpane_container   = '#productpane_container_productdetail_';
         productpane_menu_item   = '.productpane_menu_item';
         productpane_menu_itemid = '#productpane_menu_item_';

         headcontainer           = '#head'; // head = ie -> error ??? 
         
         
         // Productdetail
         productdetail_imagecontainer         = '#productdetail-imagecontainer';
         
         /* 
         var splits = document.location.hash.substring(1).split('&');
         var section = splits[0];
         section = section.replace("path=","");
         delete splits[0];
         var params = splits.join('&');
         params =  params.replace("&m="," ");
         in_menu = params.substr(1,1);
         number  = params.substr(2,(params.length-1)).replace("&n=","");
         */
         
         params  = this._locationHashToObject(document.location.hash);
         
         if(!currentpath) {            
            section = params.path;
            //in_menu = params.m;
         } else {
            section = currentpath;
         }
         
         try {
            number  = params.n;
         } catch(e) {}
         
         
         // global variables for all methods
         insight_container_height = "410px";
         lastnumber              = number;
         lasthref                = null;
         
         active                  = false;
         
         //position                = 'down';
          
         currentAnchor           = null;
         active_listner          = null;
         //in_menu                 = params.substr(1,1);
         in_menu                 = currently_in_menu;
         
         if(in_menu == 2) {
            position             = 'down';
         } else {
            position             = 'up';
         }
         
         //number                  = current_number;
         // in_menu              = null;
          
         old_in_menu             = 2;
          
         intervall_timer         = 1000;
         
         tmplocation             = null;
         
         if(baseurl) {           
            orig_baseurl                = baseurl;            
         } else {
            alert("Baseurl not set. Check main template.");
         }
         
         
         _this = this;
         
      },
      
      
      hello: function(){
           alert('hello from class gui');
      },
      
      
      // joins two path segments avoiding double slashes
      concatPathSegments: function(part1, part2) {
         
         //console.log("part1 " +part1);
         //console.log("part2 " +part2);
         
         var tmp_path = part1 + part2;
         
         try {
            if (part1.charAt(part1.length-1) == '/') { 
               part1 = part1.substring(0, part1.length-1); 
            }
         } catch(e) {}
         
         //console.log("after part1 mod " +part1);
         
         //console.trace();
         
         try {
            if (part2.charAt(0) == '/') { 
               part2 = part2.substring(1, part2.length+1); 
            }
         } catch(e) {}
         //console.log("after part2 mod " +part2);
         
         //console.log(part1 + '/' + part2);
         return part1 + '/' + part2;
          
      },
       
       
      
      // for a given (sub)menu class="active" is toggled to highlight
      // only the given item 
      showActiveItem: function(menu_id, item_id) {
         
         $('#'+menu_id+' a').each(function() {
               $(this).removeClass('active');
         });
         
         $('#'+item_id).addClass('active');
         
      },
      
      
       
      // Testmethod for checking anchor
      checkAnchor: function() {

         if (active == false) {
            
            //Check if it has changes
            if (currentAnchor != document.location.hash) {
               currentAnchor = document.location.hash;
                
               
               if (currentAnchor) {
                  
                  //remove flash before ajax call 
                 
                  
                  
                  params = this._locationHashToObject(currentAnchor);
                  section = params.path;
                  in_menu = params.m;
                  number  = params.n;
                  
                  if(section != '/') {
                      try {
                         $("#startpage_animation").remove();
                      } catch(e) {}
                  }
                  
                  try {
                     var sp      = params.sp;
                  } catch(e) {}
                  
                  try {
                     var p       = params.p;
                  } catch(e) {}
                  
                  try {
                     var lty      = params.lty;
                  } catch(e) {}
                  
                  try {
                     var lid      = params.lid;
                  } catch(e) {}
                  
                   try {
                     var pp      = params.pp;
                  } catch(e) {}
                  
                  //console.dir(params);
                  
                  var query = 'http://' + this.concatPathSegments(baseurl, params.path);
                  
               }
               
               
               // Send the petition
               if (currentAnchor) {
                  //alert(document.location.hash);
                 
                  $.post("ajax/gotoPage.php",{href: query, path: section, sp: sp, p: p, lty: lty, lid: lid, pp: pp }, function(msg){               
                        
                        try {
                           $(".insightmenu_active").removeClass("insightmenu_active");
                        } catch(e) {}
                            
                        try {
                           $(".standardmenuitem_active").removeClass("standardmenuitem_active");
                        } catch(e) {}
                                               
                        if (in_menu == 2) {
                           // add active class to active menuitem
                           try {
                              $('.insightmenuitem:eq('+(number-1)+')').addClass("insightmenu_active");
                           } catch(e) {}
                        } else if (in_menu == 1) {
                           if ($(".standardmenuitem_active").toString()) {
                              $("#menu_standard_item_"+number).addClass("standardmenuitem_active");
                           } else {
                              $("#menu_standard_item_"+number).addClass("standardmenuitem_active");
                           }
                        }
                        
                        
                     if (in_menu == old_in_menu && in_menu == 2 && position == 'down') { // Normalfall bei Insightmenu
                        //alert("1");
                        //console.log("break1");
                        $(content_insight_item+':first').html(msg.content);
                        $(content_insightboxes).html(msg.boxes);
                     } else if (in_menu == old_in_menu && in_menu == 1 && position == 'up') { // Normalfall bei Standardmenu
                        //alert("2");
                        //console.log("break2");
                        $(content_standard_normal).html(msg.content); 
                     } else if (in_menu != old_in_menu && in_menu == 2 && position == 'up') {
                        //alert("3");
                        //console.log("break3");
                        //gui.getInsightboxes();
                        try{
                           $(headcontainer).css('border-bottom', '1px solid #9D9D9D');                           
                        } catch(e) {}
                        $(content_insightboxes).html(msg.boxes);
                        $(content_insight).show();
                        $(content_insightboxes).show();
                        $(content_insight_item).html(msg.content);
                        $(content_standard_footer).hide();
                        $(content_standard_normal).hide();
                        position = 'down';
                             
                     } else if (in_menu == 1 && position == 'down') {
                        //alert("4");
                        //console.log("break4");
                        position = 'up';
                        try{
                           $(headcontainer).css('border','0');                           
                        } catch(e) {}
                        
                        $(content_insight).hide();
                        $(content_insightboxes).hide();
                        $(content_standard_normal).show();
                        $(content_standard_normal).html(msg.content);
                        $(content_standard_footer).show();
                     } 
                     old_in_menu = in_menu;
                  });
               }
            }
         }
      },
      
      
      
      startAnchorListner: function() {
         active_listner   = setInterval("gui.checkAnchor()", intervall_timer);
      },
      
      
      stopAnchorListner: function() {
         clearInterval(this.active_listner);
      },
     
      
      // methods for menu
      initializeMenueDropdown: function() {
         config = {    
            sensitivity: 8, // number = sensitivity threshold (must be 1 or higher)    
            interval: 220, // number = milliseconds for onMouseOver polling interval    
            over: this.showMenu, // function = onMouseOver callback (REQUIRED)    
            timeout: 500, // number = milliseconds delay before onMouseOut    
            out: this.hideMenu // function = onMouseOut callback (REQUIRED)    
         };
         $("#standardmenu-dropdown li.headlink").hoverIntent( config );
      },
      
      
      showMenu: function() {
         
         if (position == 'down') {
            
            menuedownoffset = 408; // Offset from the top of page_wrapper to the menue            
            // calculate the current height of the submenue            
            submenueheight = $('ul', this).innerHeight();            
            $('ul', this).css("top", (menuedownoffset-submenueheight)+'px');
         } else {
             //alert('triggert');
            $('ul', this).css("top", "36px");
            
           /*$('ul', this).css("top", "-50px"); */
            
         }
         
         gui.hidevisibleMenu();
         
         $('ul', this).css("opacity", "0.95").fadeIn("slow");               
         
      },
      
    
      hideMenu: function() {
         $('ul', this).css('display', 'none');
      },
      
      hidevisibleMenu: function() {
         try {
            $('ul.submenue:visible').each(function(index) {               
               $(this).css("display", "none");
            });
         } catch(e) {}
      },
      
      StandardMenumoveToHead: function() {
                 
         $(content_insight).slideUp();
         $(standardmenu).css('font-weight', 'bold');
         $(headcontainer).css('border','0');
         $(content_standard_footer).hide();
         position = 'up';
         old_in_menu = 1;
         
      },
       
      
      // for sliding Insight-Content
      gotoInsightPage: function (href, number_target_menuitem) {
         
         //alert(active);
         
         //alert(href);
         
         if (active == false) {
            
            gui.stopAnchorListner();
            gui.hidevisibleMenu();
            
            // alert("gotoInsightPage lastnumber= " + lastnumber);
            
            // number (hint used for menu sliding effects) is optional parameter      
            if (!isNaN(number_target_menuitem)) {
               number = number_target_menuitem;
               // alert("setting number to new value " + number_target_menuitem);
               var myAnchor = '#' + href.split('#')[1];
            } else {
               //alert("no number parameter given, using already found number=" + number);
               var myAnchor = '#' + href.split('#')[1] + "&n="+number;
            }
            
            location.href = myAnchor;
            currentAnchor = myAnchor;
               
            
            try {
                if(this.tmplocation) {
                  this.tmplocation = null;
                }
            } catch(e) {}
           
            //alert(currentAnchor);
            
            params  = this._locationHashToObject(document.location.hash);
            section = params.path;
            
            //alert(params.path);
            
            // Track Pageview
           
            if(tracking_google == 'yes') {
               try {
                  
                  //gui.track_Analytics(href);
                  gui.track_Analytics(section); // new tracking /kinderwunsch/weitereslevel
               } catch(e) {}
            }
            /*
            var splits = currentAnchor.substring(1).split('&');
            var path = splits[0];
            path = path.replace("path=", "");
            delete splits[0];
            */
            
            // remove active class          
            try {
               $(".standardmenuitem_active").removeClass("standardmenuitem_active");
            } catch(e) {}
            
            try {
               $(".insightmenu_active").removeClass("insightmenu_active");
            } catch(e) {}
            
            // add active class to active menuitem
            try {
               $('.insightmenuitem:eq('+(number-1)+')').addClass("insightmenu_active");
            } catch(e) {
               alert("Error class-gui. Can´t add active Class to Menuitem.")
            }
                         
            if (number != lastnumber) {
               //console.log("break 1");
               $.ajax({                
                     url: "ajax/gotoPage.php",
                     global: false,
                     type: "POST",
                     data: ({href : href, path: section}),
                     dataType: "json",
                     success: function(msg) {            
                          
                        if (position == 'up') {                     
                           $(content_standard_normal).hide();
                           $(content_standard_footer).hide();
                           $(content_insight).slideDown("1000", function() {                 
                              gui.InsightContentSlide(number, msg);
                           });
                           position = 'down';
                           $(standardmenu).css('font-weight','normal');
                           $(headcontainer).css('border-bottom', '1px solid #9D9D9D');
                        } else {
                           gui.InsightContentSlide(number, msg);
                        }
                        
                     } 
               });
               
            } else if (position == 'up') {
               //console.log("break 2");
               //console.log(currentAnchor);
               if(section != $(content_insight_item).attr('path')) {
                   //console.log('new content');
                   $.ajax({                
                           url: "ajax/gotoPage.php",
                           global: false,
                           type: "POST",
                           data: ({href : href, path: section}),
                           dataType: "json",
                           success: function(msg) {
                                    $(content_insight_item).html(msg.content).attr('path', section);
                                    $(content_insight_item).fadeIn("slow", function() {
                                      $(content_insight_holder).css("height", "auto");
                                      $(content_insight).slideDown("1000", function() {
                                          if ($(content_insightboxes).is(':hidden')) {
                                             $(content_insightboxes).fadeIn("slow");
                                          }
                                       });
                                    });
                           } 
                   });
               } else {
                  //console.log('old content');
                  
                  // for cms_search 
                  if($(content_insight_item).is(':hidden')) {
                     $(content_insight_item).slideDown();
                  }
                  
               }
               
               $(content_insight).slideDown("1000", function() {
                  if ($(content_insightboxes).is(':hidden')) {
                     $(content_insightboxes).fadeIn("slow");
                  }
               });
                  
               $(content_standard_normal).hide();
               $(content_standard_footer).hide();
               position = 'down';
                  
               $(headcontainer).css('border-bottom', '1px solid #9D9D9D');
            } else {
               if(href != lasthref) {
                  //console.log("break 3");
                  //console.trace();
                  
                  //set active to true
                  active = true;
                  
                  if($(content_insight_item+':last').length != 0) {
                     $(content_insight_item+':last').remove();
                     $(content_insight_holder).append('<div class="content-insight-item"></div>');
                  }
                  
                  
                  
                  $(content_insight_holder).css("height", insight_container_height);
                  $(content_insight_item+':first').fadeOut("slow", function() {
                           //console.log("break 3 ajax call");
                           $.ajax({                
                              url: "ajax/gotoPage.php",
                              global: false,
                              type: "POST",
                              data: ({href : href, path: section}),
                              dataType: "json",
                              success: function(msg) {
                                 $(content_insight_item+':first').html(msg.content).attr('path', section).fadeIn("slow", function() {
                                         $(content_insight_holder).css("height", "auto");
                                         if(msg.boxes) {
                                            //alert("test");
                                            _this.Insight_fadeBoxes(msg);
                                         }
                                         // Insight_fadeBoxes set active to false
                                         //active = false;
                                 });
                                     
                              } 
                           });
                           
                  });
                  
                  
               }
            }
         }
         lasthref = href;
      },
      
      
      /*
      getInsightboxes: function() {       
         
         var splits = currentAnchor.substring(1).split('&');
         var path = splits[0];
         delete splits[0];
          
         var params = splits.join('&');
         params =  params.replace("&in_menu="," ");
         in_menu = params.substr(1,1);
         
         delete splits;
         delete params;
                          
         Insightboxes = $.ajax({
                  url: "ajax/getInsightboxes.php",
                  global: true,
                  type: "POST",
                  data: ({path : path, in_menu: in_menu }),
                  dataType: "html",
                  success: function(msg) {
                     if(msg) {                       
                           $(content_insightboxes).fadeOut("slow");
                           $(content_insightboxes).html(msg);
                           $(content_insightboxes).delay(100).fadeIn("slow");
                     }
                     
                  } 
            });
         
      },
      */
      
      
      
      // fade out boxes, replace content of boxes area and fade in again
      Insight_fadeBoxes: function(msg) {
         
         if ($(content_insightboxes).is(':hidden')) {
                  
            $(content_insightboxes).html(msg.boxes);
             
            // make menu active again after boxes are updated, before fade in
            //active = false;
            //gui.startAnchorListner();
            
            $(content_insightboxes).fadeIn("400", function() {
                  active = false;
                  gui.startAnchorListner();                  
            });
             
         } else {
            
            $(content_insightboxes).fadeOut("slow", function() {
                  
               // make menu active again just before new boxes fade in
               //active = false;
               //gui.startAnchorListner();   
                  
               $(content_insightboxes).html(msg.boxes);
               $(content_insightboxes).fadeIn("400", function() {
                     active = false;
                     gui.startAnchorListner(); 
               });
               
            });
               
         }
      },
      
      
      
      InsightContentSlide: function(number, msg) {
         //this.getInsightboxes();
         if(active == false) {
            active = true;
            if (lastnumber < number) {
               gui.Insight_scrollRight(msg, number);
            } else {       
               gui.Insight_scrollLeft(msg, number);
            }
            
         }
      },
   
     
   
      Insight_scrollRight: function(msg, number) {     
         //console.log('right');
         $(content_insight_item+":last-child").html(msg.content).attr('path', section).show();
         
         $(content_insight_scroll).animate({scrollLeft: 895 }, 1000, function() {
            $(content_insight_holder).append('<div class="content-insight-item"></div>');
            $(content_insight_item+":first-child").remove();
            $(content_insight_scroll).animate({scrollLeft: 0 },0, function() {
               lastnumber = number;
               _this.Insight_fadeBoxes(msg); 
            });
         });
      },
   
   
      Insight_scrollLeft: function(msg, number) {
         //console.log('left');

         $(content_insight_item+":last-child").remove();
         
         $(content_insight_holder).prepend('<div class="content-insight-item"></div>');
         $(content_insight_item+":first-child").html(msg.content).attr('path', section);
         
         $(content_insight_scroll).scrollLeft("895").animate({scrollLeft: 0 }, 1000, function() {
            lastnumber = number;
            $(content_insight_item).next().remove();
            $(content_insight_holder).append('<div class="content-insight-item"></div>');
            _this.Insight_fadeBoxes(msg);
            //active = false;
         });      
      },
      
      

      
      gotoStandardPage: function(href, id) {
         //alert(active);
         
         if (active == false) {
            
            try {
               $('#startpage_animation').remove();
            } catch(e) {}
            
            
            //alert(currentAnchor);
            gui.hidevisibleMenu();
            var myAnchor = '#' + href.split('#')[1];          
            location.href = myAnchor;
            
             if(this.tmplocation) {
                  this.tmplocation = null;
             }
           
         
            if (currentAnchor != myAnchor) {
               active = true;
               gui.stopAnchorListner();
               currentAnchor = myAnchor;
               
               
               params      = this._locationHashToObject(currentAnchor);
               section     = params.path;
               
               
               // remove active class          
               try {
                  $(".insightmenu_active").removeClass("insightmenu_active");
               } catch(e) {}
               
               try {
                  $(".standardmenuitem_active").removeClass("standardmenuitem_active");
               } catch(e) {}
               
               if(id) {
                  if (id.substr(0,12)== 'submenueitem') {
                     number = id.substr(13,2);           
                     $('#menu_standard_item_'+number).addClass("standardmenuitem_active");
                  } else {
                     try {
                        $("#"+id).addClass("standardmenuitem_active");
                     } catch(e) {}
                  }
               }
               
               if(tracking_google == 'yes') {
                  try {                   
                        //gui.track_Analytics(href);
                        product_id = 'false';
                        
                        if(params.p) {
                           product_id = params.p;
                        }
                        
                        if(product_id != 'false') {
                           gui.track_Analytics('/'+section+'/'+product_id);
                           delete(product_id);
                        } else {
                           gui.track_Analytics(section); // tracking path
                        }
                        
                  } catch(e) {}
               }
               
            
               //alert("current Path: "+path +" - Path from new Content: " +href);
            
               $.ajax({
                  url: "ajax/gotoPage.php",
                  global: true,
                  type: "POST",
                  data: ({href : href, path: section }),
                  dataType: "json",
                  success: function(msg) {
                     if (position == 'down') {
                        gui.StandardMenumoveToHead();
                     }
                     
                     //console.log(msg.content);
                     
                     $(content_standard_normal).slideUp("slow", function() {
                           $(content_standard_normal).html(msg.content);
                     });                  
                     
                     if (position == 'up') {                  
                        $(content_insightboxes).hide();
                        $(content_standard_normal).slideDown("slow", function() { 
                              $(content_standard_footer).css("display", "inline");
                              active = false;
                        });  
                     }
                     
                     if(!old_in_menu) {
                        old_in_menu = 1;
                     }                  
                     gui.startAnchorListner();
                  } 
               });
            }
         }
      },
      
      
      
      
      // returns URI Hash string from object
      _objectToLocationHash: function(hashobject) {
         return decodeURIComponent($.param(hashobject));
      },
      
      
      
      // 
      _locationHashToObject: function(hashstring) {
         tmpstring = hashstring.substr(1);
         tmpstring = jQuery.deparam(tmpstring);
         //console.dir(tmpstring);
         
         return tmpstring;
      },
      
      
      
      gotoSubpage: function(path, container_id, node_id) {
         
         if (active == false) {
             active = true;
             gui.stopAnchorListner();             
             //console.log("gotoSubpage Active");
             
             // Track Pageview
            if(tracking_google == 'yes') {
                     // trackingpath = 'http://'+location.hostname+section+'index.html?sp='+node_id; Old for full href !
                     
                     trackingpath = section+'?sp='+node_id; // /path/subpage/?sp=95
                     
                     try {
                        gui.track_Analytics(trackingpath);
                     } catch(e) {}
            }
             
            
            if (document.location.hash && location.hash.indexOf('sp=') <= -1) {             
               
               this.tmplocation = '#'+this._objectToLocationHash(this._locationHashToObject(document.location.hash));
               
               location.href = this.tmplocation+'&sp='+node_id;
               currentAnchor = document.location.hash;
                
            } else {
               
               //alert(this.tmplocation);
               //alert("Bloedsinn --- Current location hash already contains 'subpage_node_id'");
               
               if(this.tmplocation) {
                  //alert("2 a");
                  location.href = this.tmplocation+'&sp='+node_id;
                  currentAnchor = document.location.hash;
               } else {
                  //alert("2 b");
                  // enthält einen Anker
                  if(location.hash.indexOf('#') > -1) {
                     //alert("3 a");
                     if(location.hash.indexOf('sp=') > 1) {
                        tmphash = location.hash.substr(location.hash.indexOf('sp=')-1,(location.hash.length-location.hash.indexOf('sp=')+1));
                        tmphash = location.hash.replace(tmphash, "");
                        this.tmplocation = orig_baseurl+tmphash;
                     } else {
                        tmphash = location.hash;
                        this.tmplocation = location.href;
                     }
                     location.href = tmphash+'&sp='+node_id;
                     currentAnchor = document.location.hash;
                  } else {
                     //alert("3 b");                  
                     //console.log(location.pathname);
                     //console.log(location.hash);
                     tmpanchor = location.pathname.replace(orig_baseurl, "");
                     
                     //console.log(tmpanchor);
                     var anchor = '#path=/'+tmpanchor+'&m='+in_menu;
                     //location.href = anchor+'&subpage_node_id='+container_id+'_'+node_id;
                     this.tmplocation = location.href+anchor;
                     location.href += anchor+'&sp='+node_id; 
                     currentAnchor = document.location.hash;                     
                  }
                 
               }
               
            }
            
            
            
            if(baseurl) {            
               href = this.concatPathSegments(baseurl,path);
            } else {
               href = path;            
            }
            
            $.ajax({
               url: "ajax/gotoPage.php",
               global: true,
               type: "POST",
               data: ({href: href, path:  path, content_limiter: 'NUK-BodyInnerHTML'}),
               dataType: "json",
               success: function(msg) {
                  
                  $(subpage_container+container_id).html(msg.content);
                  
                  if(in_menu == 2 && msg.boxes) {
                     _this.Insight_fadeBoxes(msg);
                  }
                  
                   
               },
               complete: function() {
                  gui.startAnchorListner();                         
                  active = false;
               }
            });
            
          }     
      
      
         },
         
         
         gotoProductPane: function(productpane_id, product_id) {
            if(active == false) {
               
               try {
                  $(productpane_menu_item).removeClass('active');
               } catch(e) {}
               
               //console.log(this);
               
              
               try {
                  $(productpane_menu_itemid+productpane_id).addClass('active');
               } catch(e) {alert(e)}
               
               
               gui.stopAnchorListner();
               active = true;
               
               if(location.hash) {
                  hashparams = this._locationHashToObject(location.hash);
                  hashparams.pp = productpane_id;
                  location.hash = '#'+this._objectToLocationHash(hashparams);
                  currentAnchor = location.hash;
               } else {
                  location.href += '#?pp='+productpane_id; 
               }
               
                                
                // Track Pageview
                if(tracking_google == 'yes') {
                     
                     try {
                        //gui.track_Analytics(location.href);
                        gui.track_event_byAnalytics('Product Pane', 'get Information', 'Product_id:'+product_id+' - Productpane:'+productpane_id);
                     } catch(e) {}
                     
                }
                
              
               
               $.ajax({
                        url: "ajax/getProductPane.php",
                        global: true,
                        type: "POST",
                        data: ({productpane_id: productpane_id, product_id: product_id}),
                        dataType: "json",
                        success: function(msg) {
                           product_id_mod = product_id.replace(/\./g, "-");
                           //alert($(productpane_container+product_id_mod).html());
                           //alert(msg.content);
                           $(productpane_container+product_id_mod).replaceWith(msg.content);
                           gui.startAnchorListner();                         
                           active = false;
                        } 
                     });
            }
         },
         
         gotoProductDetail: function(href, product_id) {
            if(active == false) {
               active = true;
               gui.stopAnchorListner();
               
               if(location.hash) {
                  hashparams = this._locationHashToObject(location.hash);
                  //console.dir(hashparams);
                  hashparams.p = product_id;
                  location.hash = '#'+this._objectToLocationHash(hashparams);
                  currentAnchor = location.hash;
                  section = hashparams.path; // new for tracking path
               }
               
                  // Track Pageview
                 if(tracking_google == 'yes') {
                        try {
                           // gui.track_Analytics(href);
                           if(section) {
                              gui.track_Analytics('/'+section+'/'+product_id); // new for tracking path/subpath
                           }
                        } catch(e) {}
                 }
               
               $.ajax({
                        url: "ajax/gotoPage.php",
                        global: true,
                        type: "POST",
                        data: ({href: href}),
                        dataType: "json",
                        success: function(msg) {
                           $(content_standard_normal).fadeOut("slow", function() {
                                 $(content_standard_normal).html(msg.content).fadeIn("slow");
                           });
                           gui.startAnchorListner();                         
                           active = false;
                        } 
               });
            }
         },
         
         getanotherImage: function(imagefile, width, height, itemnumber) {
            if(active == false) {
               active = true;
            
               if(!width) {
                  try {
                  var width  = $(productdetail_imagecontainer).width();
                  } catch(e) { alert("no width given"); var width="50px";}
               }
               
               if(!height) {
                  try {
                     var height = $(productdetail_imagecontainer).height();
                  } catch(e) { alert("no height given");  var height="50px";}
               }
               
               if(isNaN(itemnumber)) {
                  itemnumber = 99;
               }
               
               if(tracking_google == 'yes') {
                        try {
                           if(location.hash) {
                              hashparams = this._locationHashToObject(location.hash);
                              //console.dir(hashparams);
                              product_id = hashparams.p;
                              section = hashparams.path; // new for tracking path
                           }
                           
                           if(section) {
                              gui.track_event_byAnalytics('Productdetail', 'getanotherImage', 'Productid: '+product_id +' - Imagefile:' +imagefile); // new for tracking path/subpath
                           }
                        } catch(e) {}
                 }
             
               $.ajax({
                        url: "ajax/getPNGImage.php",
                        global: true,
                        type: "POST",
                        data: ({imagefile: imagefile, height: height, width: width}),
                        dataType: "json",
                        success: function(msg) {
                           if(msg.success) {
                              $(productdetail_imagecontainer).fadeOut("slow",function() {
                                    if(itemnumber == 1) {
                                       try {
                                          $('.product_headline').fadeIn("slow");
                                       } catch(e) {}
                                    } else {
                                       try {
                                          $('.product_headline').fadeOut("slow");
                                       } catch(e) {}
                                    }
                                    $(this).html(msg.image);
                                    active = false;
                              }).fadeIn("slow");                           
                           }
                           
                        } 
               });
            }
            
         },
         
         cms_search: function(searchtext) {
            if(active == false) {
               active = true;
               
               if(searchtext) {
                  
                  try {
                     gui.track_event_byAnalytics('Search', 'getSearchResult', 'searching Word:' + searchtext); // new for tracking path/subpath
                  } catch(e) {}
               
                  $.ajax({
                           url: "ajax/getSearchResult.php",
                           global: true,
                           type: "POST",
                           data: ({searchtext: searchtext}),
                           dataType: "json",
                           success: function(msg) {
                              if(msg.success) {
                                 if(position == 'up' && $(content_standard_normal+':visible') ) {
                                    //alert("position up");
                                    //console.log('position:' +position);
                                    $(content_standard_normal).html(msg.content);
                                 } else if (position == 'down' && $(content_insight+':visible')) {
                                    $(content_insight_item).slideUp("slow", function() {
                                         //alert("position down");
                                           //console.log('position:' +position);
                                          $(content_insightboxes).fadeOut("slow", function() {
                                                $(content_standard_normal).html(msg.content).show();
                                          });
                                          position = 'up';
                                    });
                                   
                                 } 
                              
                              }                              
                           },
                           complete: function() {
                              active = false;
                           }
                  });
               }  
            }
            
         },
         
         
         track_Analytics: function(path) {
            
            /* activate it for href tracking 
            if(path.indexOf('#') != -1) {
               path = path.substr(0,path.indexOf('#'));
            }
            */
            
            // debug tracking
            if(tracking_debug) {
               try {
                 console.log('tracking path: ' +path);
               } catch(e) {}
            }
            
            try {
               // old code pageTracker._trackPageview('"'+path+'"');
               _gaq.push(['_trackPageview', ''+path+'']);                
            } catch(e) {}
            
         },
         
         track_event_byAnalytics: function(category,action,name) {
            
            if(tracking_google == 'yes') {
                  if(tracking_debug) {
                     try {
                        console.log('tracking Event| category: ' +category+'|section:'+section+' action: '+ action+'| name: '+name);
                     } catch(e) {}
                  }
                  // section == current path
                  
                  try {
                     _gaq.push(['_trackEvent', ''+category+' | '+section+'', ''+action+'', ''+name+'']);
                  } catch(e) {}
            }
            
         },
         
         tools_getSection: function() {
            return section;
         }
         
   });


