function addEvent(obj, evType, fn) {
    if (obj.addEventListener) {
        obj.addEventListener(evType, fn, true);
        return true;
    } else if (obj.attachEvent) {
        var r = obj.attachEvent("on"+evType, fn);
        return r;
    } else {
        return false;
    }
}

// popup with usability problems
function popup(item, width, height, name) {
	var args = "toolbar=no,scrollbars=yes,resizable=yes,width="+width+",height="+height;
	window.open(item, name, args);
}





// returns true if [v] is not defined, false otherwise
// IE 5.0 does not support the undefined keyword,
// so we cannot do a direct comparison such as v===undefined.
function isUndefined(v) {
	var undef;
	return v===undef;
}

var _POPUP_FEATURES = 'toolbar=0, location=0, statusbar=0, menubar=0, scrollbars=1';
var _POPUP_WINSIZE  = 'width=400, height=300';
function raw_popup(url, target, width, height, features) {
	if (isUndefined(features)) {
		features = _POPUP_FEATURES;
	}
	if (isUndefined(width) || isUndefined(height)) {
		features = features+', '+_POPUP_WINSIZE;
	} else {
		features = features+', width='+width+', height='+height;
	}
	if (isUndefined(target)) {
		target = '_blank';
	}
	var theWindow = window.open(url, target, features);
	theWindow.focus();
	return theWindow;
}

// open new windows from links
// <a href="/domain-registrieren/agb/datenschutz.html" target="datenschutz" onClick="link_popup(this,700,450);return false;" onMouseOver="window.status='Datenschutz';return true" onMouseOut="window.status='';return true">Datenschutz</a>
function link_popup(src, width, height, features) {
	return raw_popup(src.getAttribute('href'), src.getAttribute('target') || '_blank', width, height, features);
}

// open page from link in a popup window
function link_opener(src) {
	opener.location.href = src.getAttribute('href');
	opener.focus();
}

// check all
var checkflag = "false";
function check(field) {
if (checkflag == "false") {
  for (i = 0; i < field.length; i++) {
  field[i].checked = true;}
  checkflag = "true";
  return "Uncheck all"; }
else {
  for (i = 0; i < field.length; i++) {
  field[i].checked = false; }
  checkflag = "false";
  return "Check all"; }
}

// zebra tables
function zebraTable()
{ if (document.getElementsByTagName)
  { tables = document.getElementsByTagName("table");
    for(j=0; j<tables.length; j++)
    {
      if (tables[j].className.indexOf('zebra') > -1)
      { for (k=0; k<tables[j].rows.length; k=k+2)
        {
          tables[j].rows[k].className='odd';
        }
      }
    }
  }
}

// focus on the domainfield for easy access
function setFocus() {
    var domainField = document.getElementById('domainField');
    if (domainField) {
    	domainField.focus ();
    }
}


//check if the input field is empty
function checkform ( form ) {
	if (form.domain.value == "") {
	//  alert( "Bitte geben Sie Ihren Wunschnamen ein." );
	 form.domain.focus();
	 return false ;
	}
	if (form.elements["tlds[smart][0_new_value]"]) {
		form.elements["tlds[smart][0_new_value]"].name = "tls_changed";
	}

	if (form.elements["tlds[multiple][0_new_value]"]) {
		form.elements["tlds[multiple][0_new_value]"].name = "tls_changed";
	}

	// ** END **
	return true ;
}