// timers voor carrousel op homepage
var c=0;
var x=0;
var t;
var timer_is_on=0;
var speed = 7000;
function timedCount(){
   var aantal = $('#carimages a').length-1;   
   $('#carimages a').not('#cimg'+c).fadeOut('fast');
   $('#carimages #cimg'+c).appendTo($('#carimages')).fadeIn('fast');
   
   $('#brandboxhome #intro ul li a.active').removeClass('active').css('opacity','0.5');
   $('#brandboxhome #intro ul li:eq('+c+')').find('a').addClass('active').css('opacity','1');
   // repeat na X images
   if (c==aantal){c=0;} else { c=c+1;};
   t=setTimeout("timedCount()",speed);
}
function doTimer(){
   if (!timer_is_on){
     timer_is_on=1;
     timedCount();
   }
}
function stopCount(){
   clearTimeout(t);
   timer_is_on=0;
}  

function antiSpam(domain, id)
{
  location.href = "mailto:" + id + "@" + domain;
}
   
$(document).ready(function(){

   $('#brandboxhome #intro ul').show().find('a').css('opacity','0.5');
   if($('#carimages').length>0){
      $('#carimages a').each(function(){
         var x = $('#carimages a').index(this);
         $(this).attr('id','cimg'+x);
      });
      $('#brandboxhome #intro ul li').each(function(){
         var x = $('#brandboxhome #intro ul li').index(this);
         $(this).attr('id','cth'+x);
      });
      
      $('#brandboxhome #intro ul li a').hover(function(){
         stopCount();
         $('#brandboxhome #intro ul li a.active').removeClass('active').css('opacity','0.5');
         $(this).addClass('active').css('opacity','1');
         var x = $('#brandboxhome #intro ul li').index($(this).parent());
         $('#carimages a').not('#carimages #cimg'+x).fadeOut('fast');
        $('#carimages #cimg'+x).show();
      },function(){
         t=setTimeout("doTimer()",speed);
      })
      
     timedCount();
   }
   
   $('#inloglink').toggle(function(){
      $('#inlogform').show();
      return false;
   },function(){
      $('#inlogform').hide();
      return false;
   })
   
   $('#acties .actie').css('opacity','0.5').hover(function(){
      $(this).css('opacity','1');
   },function(){
      $(this).css('opacity','0.5');
   })


   $('.newwindow').click(function(){
    window.open(this.href);
    return false;
   });

  
    $("#membership").hide();
    $("#membershiptype").hide();
    
    $("#reason_2").click(function () {
      $("#membership").show();
      $("#membershiptype").show();
    });
    $("#reason_0").click(function () {
       $("#membership").hide();
       $("#membershiptype").hide();
    });
    $("#reason_1").click(function () {
       $("#membership").hide();
         $("#membershiptype").hide();
    });
   

   // na window resize functies herhalen die hoogte- of breedte afhankelijk zijn.
   $(window).resize(function() {

   });

   
});

 $.fn.googleMap = function(location,options) {   
    var defaults = {   
      lat: 53.41,    
      long: -2.99,      
      zoom: 13,   
      mapTypeId: google.maps.MapTypeId.ROADMAP,    
      mapTypeControl: false,       
      controls: ['GSmallZoomControl3D']   
    };             
    options = $.extend(defaults, options || {}); 

    if (location) {
      var value = $.trim(location);
            var point = value.split(',');            
      options.lat = parseFloat(point[0]);
            options.long = parseFloat(point[1]);     
      options.zoom = parseFloat(point[2]);  
    };             
    
    var center = new google.maps.LatLng(options.lat, options.long);             
    var map = new google.maps.Map(this.get(0), $.extend(options, { center: center })); 

    var storeMarker = new google.maps.Marker({
      position: center,            
      map: map        
    });    
  };  
