/*
Site Name: Autoverzekering.nl
Site URI: http://www.autoverzekering.nl
Description: Common js script shared by all pages
*/


/* Common functions
-------------------------------------------------------------- */
this.toggleContent = function(target, activeClass) {
  $(target).fadeIn(750, function(){
    if ($.browser.msie){this.style.removeAttribute('filter');} 
  });
  $('.' + activeClass).hide();
  $('.' + activeClass).removeClass(activeClass);
  $(target).addClass(activeClass);
}
  
function vergelijken(kentekenfield,origin) {
  var field = $('#' + kentekenfield);
  var kenteken = $(field).val();
  window.location.href = '/berekenen/#origin='+ $(field).attr('origin') + '&kenteken=' + kenteken;
}  

/* On document ready
-------------------------------------------------------------- */
  $(document).ready(function() {
    
    $(".kenteken").keypress(function(e) {
      if(e.keyCode == 13) {
         vergelijken($(this).attr('id'), $(this).attr('origin'));
      }
    });

  $('.tabs li').click(function(e) {
    var tgo = $(this).hasClass('active');  
    
    $('.tabs li').each(function() {
      $(this).removeClass('active');
    });
    $(this).addClass('active');
    if(!tgo) {
      toggleContent($('#' + $(this).attr('rel')), 'activeTab');
    }
  });
  
  
  // quotes scroller
  if($("#quotes").length > 0) { 
    quoteScroller(0);
  }
    function quoteScroller(i) {
        var items = $("#quotes li");

        setTimeout(function() {
        $(items[i]).fadeOut(750, function() {
          //$(items[i]).addClass('hide');
          
          i++;
          if (i == items.length)
            i = 0;
          
          $(items[i]).removeClass('hide');
          $(items[i]).fadeIn(750, function() {
            if ($.browser.msie){this.style.removeAttribute('filter');}
            //$(this).removeClass('hide');
          });
          
          quoteScroller(i);                              
        });
        }, (5000));
    }

});
