var dC = {
  // initialisation function, call with load
  init: function() {
    if (!document.getElementById) return;    
	    
	  dC.filter_startdate = document.getElementById('filter_startdate');
	  dC.filter_enddate = document.getElementById('filter_enddate');
	  
	    
    dC.addEvent(dC.filter_startdate, 'keyup', dC.datefunction, false);
  },
  
  
  datefunction: function() {
  	if (dC.filter_enddate.value == 'yyyy') {  
  		if (dC.filter_startdate.value.match(/\d\d\d\d/)) {
  			dC.filter_enddate.value = dC.filter_startdate.value;
  		}  	
  	} 
  },
  
	
	// function to add event listener, also caches events so they can be removed when the
	// page unloads to avoid memory leaks in IE
  addEvent: function(elm, evType, fn, useCapture) {
		// for W3C DOM complience
    if (elm.addEventListener) {
      elm.addEventListener(evType, fn, useCapture);
      return true;
    } 
		// for IE...
		else if (elm.attachEvent) {
      var r = elm.attachEvent('on' + evType, fn);
      //EventCache.add(elm, evType, fn);
      return r;
    } else {
			// for anyone else not IE or Moz... Safari etc
      elm['on' + evType] = fn;
    }
  }
	
}

dC.addEvent(window, 'load', dC.init, false);
