;
ec.nikiWsOnepage || (function($)
{
   var _nikiWsOnepage = {
      init: function()
      {
         //ec.nikiWsOnepage.projectDescriptionExpander();
         // scroll down/up to anchor instead of jumping directly.
         $('.scrollToAnchor').click(ec.nikiWsOnepage.handleAnchorClick);
         if (location.href.indexOf("nikiSaveInterest") != -1)
         {
            ec.nikiWsOnepage.scrollToAnchor("interesse");
         }

          $('.nikiContent').toggleClass('collapsed');

          $('.nikiContent .sizeToggle').removeClass('hidden');
          $('.nikiContent .sizeToggle').click(function(event){
              event.preventDefault();
              $('.nikiContent').toggleClass('collapsed');
          });


         $('.onepage-section .sizeToggle').removeClass('hidden');
         $('.onepage-section .sizeToggle').click(function(event){
             event.preventDefault();
             $(this).parent('.onepage-section').toggleClass('collapsed');
             if (fundament.ec.google.theMap && $(this).parent('.location'))
             {
                initLocation();
             }
         });
      },

      initDetail: function()
      {
         // click event to expend description text.
         ec.nikiWsOnepage.houseTypeDescriptionExpander();
         // toggle opening an closing blocks on page
         $('.scrollToAnchor').click(ec.nikiWsOnepage.scrollToAnchor);
         
         var largeImg = $('#houseTypeSummary .houseTypeImage img');
         $('#houseTypeImages .image a').click(function(event){
             event.preventDefault();
             var src = $(this).attr('href');
             largeImg.attr('src',src);
         })
      },

      handleAnchorClick: function(event)
      {
         //prevent the default action for the click event
         event.preventDefault();
         $(this).parent().parent().find("li").removeClass(("selected"));
         $(this).parent().addClass("selected");
         // show the content
         //get the full url - like mysitecom/index.htm#home
         var fullUrl = this.href;
         //split the url by # and get the anchor target name - home in mysitecom/index.htm#home
         var parts = fullUrl.split("#");
         var anchorName = parts[1];
         //get the top offset of the target anchor
         ec.nikiWsOnepage.scrollToAnchor(anchorName);

      },
      scrollToAnchor: function(anchorName)
      {
         //get the top offset of the target anchor
         var targetOffset = $("a[name='" + anchorName + "']").offset();
         ec.nikiWsOnepage.showContentBlock($("a[name='" + anchorName + "']").parent());
         var targetTop = targetOffset.top - $('.top').height(); //compensate for the 'fixed' header
         //goto that anchor by setting the body scroll top to anchor top
         $('html, body').animate({scrollTop:targetTop}, 500);

      },
      toggleContentBlock: function(contentBlock)
      {
         if ($(contentBlock).children(".nikiWsOnepageBlockContent").is(":visible"))
         {
            ec.nikiWsOnepage.hideContentBlock(contentBlock);
         }
         else
         {
            ec.nikiWsOnepage.showContentBlock(contentBlock);
         }

      },
      hideContentBlock: function(contentBlock)
      {
         $(contentBlock).children(".nikiWsOnepageBlockContent").slideUp();
         var closeSliderLink = $(contentBlock).children(".nikiWsOnepageBlockHeader").children(".closeSlider").children("a:");
         log("hiding: " + closeSliderLink.html());
         closeSliderLink.html("open");
         closeSliderLink.attr("title", "open");
      },
      showContentBlock: function(contentBlock)
      {
         $(contentBlock).children(".nikiWsOnepageBlockContent").slideDown();
         var closeSliderLink = $(contentBlock).children(".nikiWsOnepageBlockHeader").children(".closeSlider").children("a:");
         closeSliderLink.html("verbergen");
         closeSliderLink.attr("title", "verbergen");
      },
      showAllContentBlocks: function()
      {
         $(".nikiWsOnepageBlockContent").each(
               function()
               {
                  ec.nikiWsOnepage.showContentBlock($(this).parent());
               });
      },
      projectDescriptionExpander: function()
      {
//         $('.project .nikiContent p').expander({
//            expandEffect: 'slideDown',
//            expandSpeed: 500,
//            expandText: '<div id="projectDescriptionExpander"><div class="expanderText">Lees de totale projectomschrijving</div><div class="expanderArrowDown">!</div></div>',
//            slicePoint: 250,
//            userCollapseText: '<div id="projectDescriptionExpander"><div class="expanderText"><div class="expanderArrowUp">!</div></div></div>',
//            widow: 2
//         });

      },
      houseTypeDescriptionExpander: function()
      {
         $('#houseTypeDescription p').expander({
            expandEffect: 'slideDown',
            expandSpeed: 500,
            expandText: '<div id="projectDescriptionExpander"><div class="expanderText">Lees de totale omschrijving</div><div class="expanderArrowDown">!</div></div>',
            slicePoint: 1000,
            userCollapseText: '<div id="projectDescriptionExpander"><div class="expanderText"><div class="expanderArrowUp">!</div></div></div>',
            widow: 2
         });
      }

   };
   ec.nikiWsOnepage = _nikiWsOnepage;

})(jQuery);


