$(document).ready(function() { 

  // Add all external links in a new tab/window
  $("a[href*='http://']:not([href*='"+location.hostname+"']),[href*='https://']:not([href*='"+location.hostname+"'])")
    .addClass("external")
    .attr("target","_blank");


  $("#wrapperImage span.overlay span").css({
    'background-color': '#89806f',
    '-moz-opacity': '.50',
    '-ms-filter': '"alpha(opacity=50)"',
    'filter': 'alpha(opacity=50)',
    'opacity': '0.5'
  });

  $("body.frontpage #wrapperImage span.overlay span").css({
    'background-color': '#89806f',
    '-moz-opacity': '.50',
    '-ms-filter': '"alpha(opacity=50)"',
    'filter': 'alpha(opacity=50)',
    'opacity': '0.5'
  });

  function imgAppend() {
    if($("body").hasClass("frontpage")){
      $("#wrapperImageContainer").prepend('<img src="/wp-content/themes/dcyr/images/fotos-frontpage/foto-0' + Math.floor(Math.random()*(8+1)) + '.jpg" height="305" width="422" alt="foto" style="z-index: 0;" />');
    } else {
      $("#wrapperImageContainer").prepend('<img src="/wp-content/themes/dcyr/images/fotos/foto-0' + Math.floor(Math.random()*(8+1)) + '.jpg" height="440" width="345" alt="foto" style="z-index: 0;" />');
    }
  };
  function imgFade() {
    $("#wrapperImageContainer img:last-child").animate({'opacity': 0 },1500);
  };
  function imgRemove() {
    $("#wrapperImageContainer img:last-child").remove()
    $("#wrapperImageContainer img").css({'z-index': 1})
  };
/*
  $("a.imgAppend").click(function() {
    $("#wrapperImageContainer").prepend('<img src="/wp-content/themes/dcyr/images/fotos/foto-0' + Math.floor(Math.random()*8) + '.jpg" height="440" width="345" alt="foto" style="z-index: 0;" />');
  });
  $("a.imgFade").click(function() {
    $("#wrapperImageContainer img:last-child").animate({'opacity': 0 },1500);
  });
  $("a.imgRemove").click(function() {
    $("#wrapperImageContainer img:last-child").remove()
    $("#wrapperImageContainer img").css({'z-index': 1})
  });
*/

  function imgRotator(){
    imgAppend();
    setTimeout(imgFade,4000);
    setTimeout(imgRemove,6000);
    setTimeout(imgRotator,7000);
  };
  imgRotator();
  $("form#cformsform li span").each(function () {
    $(this).html($(this).html().replace('Grootzeil ',''));
    $(this).html($(this).html().replace('Voordriehoek ',''));
    $(this).html($(this).html().replace('Bezaan ',''));
  });
/*
cf_field_35 span, cf_field_36 span, cf_field_42 span, cf_field_67 span, cf_field_68 span 
 
*/

  $("#li--35 span:first-child, #li--36 span:first-child, #li--37 span:first-child, #li--43 span:first-child, #li--68 span:first-child, #li--69 span:first-child").append(" <a href=\"/wp-content/themes/dcyr/images/misc/details-schip.jpg\" class=\"info\" title=\"Legenda scheepsmaten\">?</a>");

  $("a[rel='colorbox']").colorbox({transition:"fade"});
  $("a.info").colorbox({transition:"fade", loop:"false",opacity: "0.55"});

//  $("form#cformsform li span").text().replace("Grootzeil ", "");


});



