function eq_heights() {
    var elems = $(arguments);
    var top_height = 0;
    for (var i = 0; i < arguments.length; i++) {
        var obj = $(arguments[i]);
        obj.each(function () {
            var height = $(this).height();
            if (height > top_height) {
                top_height = height;
            }
        });
    }
    for (var i = 0; i < arguments.length; i++) {
       $(arguments[i]).height(top_height);
    }
}

$(window.document).ready(function () {

$(".actie:nth-child(3n)").css("margin-right","0");
eq_heights('.actie');

$("a[rel=external]").each(function(i){
  $(this).addClass("external");
  //this.target="_blank";
  
  $("#add_car").hide();
	 
	 $("#add_car_cta").click(function() {
	   $("#add_car").show;
	   this.hide();
	 })
	 
});



    if ($('.options_list dd label').tooltip != undefined) {
    	$('.options_list dd label').tooltip({
        track: true,
        delay: 0,
        showURL: false,
        showBody: " - ",
        fade: 250
    	});

    	$('.options_list dd input').tooltip({
        track: true,
        delay: 0,
        showURL: false,
        showBody: " - ",
        fade: 250
    	});
    }

	if (capt = document.getElementById('capcha-li')){
		capt.style.display = 'none';
		var inp = document.createElement('input');
		inp.type = 'hidden';
		inp.name = 'capcha-bypass';
		inp.value = '1234';
		capt.appendChild(inp);
	}

            var searchtext_apk = "XX-XX-XX";

    $(".input_apk").each(function (e) {
        if ($(this).val() == '') {
            $(this).val(searchtext_apk);
        }
    });

  $(".input_apk").focus(function () {
    if ($(this).val() == searchtext_apk) {
      $(this).val('');
    }
  });

  $(".input_apk").blur(function () {
    if ($(this).val() == '') {
      $(this).val(searchtext_apk);
    }
  });
});

/*
 * jQuery ifixpng plugin
 * (previously known as pngfix)
 * Version 2.0  (04/11/2007)
 * @requires jQuery v1.1.3 or above
 *
 * Examples at: http://jquery.khurshid.com
 * Copyright (c) 2007 Kush M.
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 */

 /**
  *
  * @example
  *
  * optional if location of pixel.gif if different to default which is images/pixel.gif
  * $.ifixpng('media/pixel.gif');
  *
  * $('img[@src$=.png], #panel').ifixpng();
  *
  * @apply hack to all png images and #panel which icluded png img in its css
  *
  * @name ifixpng
  * @type jQuery
  * @cat Plugins/Image
  * @return jQuery
  * @author jQuery Community
  */

(function($) {

	/**
	 * helper variables and function
	 */
	$.ifixpng = function(customPixel) {
		$.ifixpng.pixel = customPixel;
	};

	$.ifixpng.getPixel = function() {
		return $.ifixpng.pixel || 'images/pixel.gif';
	};

	var hack = {
		ltie7  : $.browser.msie && $.browser.version < 7,
		filter : function(src) {
			return "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src='"+src+"')";
		}
	};

	/**
	 * Applies ie png hack to selected dom elements
	 *
	 * $('img[@src$=.png]').ifixpng();
	 * @desc apply hack to all images with png extensions
	 *
	 * $('#panel, img[@src$=.png]').ifixpng();
	 * @desc apply hack to element #panel and all images with png extensions
	 *
	 * @name ifixpng
	 */

	$.fn.ifixpng = hack.ltie7 ? function() {
    	return this.each(function() {
			var $$ = $(this);
			var base = $('base').attr('href'); // need to use this in case you are using rewriting urls
			if ($$.is('img') || $$.is('input')) { // hack image tags present in dom
				if ($$.attr('src')) {
					if ($$.attr('src').match(/.*\.png([?].*)?$/i)) { // make sure it is png image
						// use source tag value if set
						var source = (base && $$.attr('src').substring(0,1)!='/') ? base + $$.attr('src') : $$.attr('src');
						// apply filter
						$$.css({filter:hack.filter(source), width:$$.width(), height:$$.height()})
						  .attr({src:$.ifixpng.getPixel()})
						  .positionFix();
					}
				}
			} else { // hack png css properties present inside css
				var image = $$.css('backgroundImage');
				if (image.match(/^url\(["']?(.*\.png([?].*)?)["']?\)$/i)) {
					image = RegExp.$1;
					$$.css({backgroundImage:'none', filter:hack.filter(image)})
					  .children().children().positionFix();
				}
			}
		});
	} : function() { return this; };

	/**
	 * Removes any png hack that may have been applied previously
	 *
	 * $('img[@src$=.png]').iunfixpng();
	 * @desc revert hack on all images with png extensions
	 *
	 * $('#panel, img[@src$=.png]').iunfixpng();
	 * @desc revert hack on element #panel and all images with png extensions
	 *
	 * @name iunfixpng
	 */

	$.fn.iunfixpng = hack.ltie7 ? function() {
    	return this.each(function() {
			var $$ = $(this);
			var src = $$.css('filter');
			if (src.match(/src=["']?(.*\.png([?].*)?)["']?/i)) { // get img source from filter
				src = RegExp.$1;
				if ($$.is('img') || $$.is('input')) {
					$$.attr({src:src}).css({filter:''});
				} else {
					$$.css({filter:'', background:'url('+src+')'});
				}
			}
		});
	} : function() { return this; };

	/**
	 * positions selected item relatively
	 */

	$.fn.positionFix = function() {
		return this.each(function() {
			var $$ = $(this);
			var position = $$.css('position');
			if (position != 'absolute' && position != 'relative') {
				$$.css({position:'relative'});
			}
		});
	};

})(jQuery);


function formatLicence(licence) {
    var licence = licence.replace('-', '');

    var result = '';
    // Gewoon kenteken (vb. df45hj)
    if (licence.match(/([a-z]{2}|[0-9]{2})([a-z]{2}|[0-9]{2})([a-z]{2}|[0-9]{2})/i)) {
        result = licence.substr(0, 2)+'-'+licence.substr(2, 2)+'-'+licence.substr(4, 2);
    }
    // Nieuw kenteken (vb. 4fds56)
    else if (licence.match(/[0-9]{1}[a-z]{3}[0-9]{2}/i)) {
        result = licence.substr(0, 1)+'-'+licence.substr(1, 3)+'-'+licence.substr(4, 2);
    }
    // 45dfs3
    else if (licence.match(/[0-9]{2}[a-z]{3}[0-9]{1}/i)) {
        result = licence.substr(0, 2)+'-'+licence.substr(2, 3)+'-'+licence.substr(5, 1);
    }
    return result;
}
