// Open External Links as Blank Targets via Unobtrusive JavaScript
// http://perishablepress.com/press/2007/11/20/open-external-links-as-blank-targets-via-unobtrusive-javascript/

function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (
			anchor.getAttribute("href") && ( 
			anchor.getAttribute("rel") == "external" || 
			anchor.getAttribute("rel") == "external nofollow" || 
			anchor.getAttribute("rel") == "nofollow external" )
			)
		anchor.target = "_blank";
	}
}


Event.observe(window, 'load', function() {

  if (document.location.href.indexOf('24uurvanbruynzeelkeukens',0) === -1) {
    $$('form.customform').each(function(frm_item) {
      $(frm_item).select('input[type!=hidden],textarea,select').each(function(field) {

        $(field).onchange = function (oldonchange) {
          if (this.id == 'postcode' || this.id == 'huisnummer') {
            if (typeof checkadres == 'function') {
              checkadres();
            }
          }
          else if (this.id == 'land') {
            if (typeof checkform == 'function') {
              checkform();
            }
          }
          if (this.value) {
            var value = this.value;
            if (this.type == 'checkbox') {
              value = this.checked ? 'checked' : 'unchecked';
            }

            var regxp = new RegExp('http(s)?:\/\/' + document.domain + '((/frontend)?(_dev)?(.php)?)?');
            var link = document.location.href.replace(regxp, '') + '/' + this.name;
            //console.log(link);
            pageTracker._trackPageview(link);
          }
        }
      });
    });
  }
	
	externalLinks();
});