function startHoverTooltip(e, elem) {
    var str_title = $(elem).attr("title");
    var str_text = $(elem).attr("rel");
                
    var html = '<div id="tooltipWrapper"><div id="shader3"></div><div id="tooltip">';
    html += '<p>'+str_text+'</p>';
    html += '</div></div>';

        
    $('body').append(html).children('#tooltipWrapper').hide().fadeIn(800);
    var ttH = $("#tooltip").height();
    $('#tooltipWrapper').css('top', e.pageY - 40 - ttH).css('left', e.pageX - 110);
    $('#shader').css('height', ttH + 30);
}

function stopHoverTooltip() {
    $('#tooltipWrapper').stop().fadeOut(600,function(){
        $(this).remove();
    });
}

$(function() {
    //$('#copy').css({opacity: 0.3});

    // Fix background image caching problem
    // might help -> above code for ie6 extra;s dd
    if (jQuery.browser.msie) {
        try { 
            document.execCommand("BackgroundImageCache", false, true); 
        } catch(err) {}
    }


    init();
    
    function init(){
      $body = $('html,body').attr('scrollTop',0);
      
      //$('#copy').animate({opacity: 1},500);

      $("a.anchorLink").anchorAnimate()
    }

    $("#locationTrigger").click(function() {

    });
    $("#api_buttons a").click(function () {
    //	$("#econtent").slideToggle("slow");
      body.removeClass('page').addClass('home');
    });

    //$("#econtent").hide();
    $("#api_buttons a").click(function () {
      //$("#econtent").slideToggle("slow");
      body.removeClass('page').addClass('home');
    });

  /*
      $('#thumbs a').hover(function() {
        newImg = $(this).attr('href');
          $('#showImage img').fadeOut(100, function(){
            $('#showImage').css({ height: $("#showImage img").height() });
            $('#showImage img').attr({ src: newImg }).css({ margin: "0", visibility: "hidden" }).show();
            $('#showImage').animate({ height: $("#showImage img").height() }, 100, function(){
            $('#showImage img').css({ visibility: "visible", display: "none" }).fadeIn(100);
          });
        });
        return false;
      });
  */

    $('#productLabels a').mousemove(function(e){
        
        $('#tooltipWrapper').css('top', e.pageY - 40 - ttH).css('left', e.pageX - 110);
    });

    //alternating rows
    var $mainBoxLi1 = $('#sidebar ul li:even');
    var $mainBoxLi2 = $('#sidebar ul li:odd');
    $mainBoxLi1.addClass('alternating-1');
    $mainBoxLi2.addClass('alternating-2');

    var $mainBoxTr1 = $('#main table > tbody > tr:odd');
    var $mainBoxTr2 = $('#main table > tbody > tr:even');
    $mainBoxTr1.addClass('alternating-1');
    $mainBoxTr2.addClass('alternating-2');

    $('#pm_people:contains("1 personen")').text("1 persoon");
    
    initExtras();
    function initExtras(){

        //extra product options
        $('#extras dt').stop().animate({opacity: .6});
        $('#extras dt').hover(function(event) {
          
          $(event.target).stop().animate({opacity: 1}, 400);
        }, function(event) {
          if($(event.target).hasClass("active") == false) {
            $(event.target).stop().animate({opacity: .6}, 200);
          }
        });
    }
    $('#extras').find('dd').hide().end().find('dt').click(function() {
      $(this).toggleClass('active').stop().animate({opacity: 1}, 800).next().slideToggle();
    });


    $('#link_location_more').click(function(){
        $('#locationHeader').parent().addClass("expanded");
//        $('#locationHeader').attr('class','active').stop().animate({opacity: 1}, 800).next().slideDown();
    });
  //			function toggler();
  /*
      console.log(num);
  */			
  
    $('#productLabels a, #price_information a, .patch1, .uv-actie a').hover(
      function(e) { startHoverTooltip(e, this); },
      function() { stopHoverTooltip(); }
    );
});
