Array.prototype.indexOf = function(obj) {
  for (var i = 0; i < this.length; i++) {
    if (this[i] == obj)
      return i;
  }
  return -1;
}

Array.prototype.hasItem = function(obj) {
  return this.indexOf(obj) >= 0;
} 

function emailLink(a, b, c) {
	addr = a+'@'+b+'.'+c;
	return '<a href="mailto:'+addr+'">'+((arguments[3]) ? arguments[3] : addr)+'</a>';
}

function checkOff(which, id) {
	document.getElementById('wells_'+id+'_'+which).checked = '';
}

function checkDate(date, type) {
	report_name = (type == 'daily') ? 'daily report' : 'tank reading';
	report_sname = (type == 'daily') ? 'report' : 'reading';
	
	if(dates_formatted.hasItem(date)) {
		if(confirm('There is already a '+report_name+' for the day you selected. Would you like to modify the '+report_sname+'?\n\nClick OK to modify the '+report_sname+'.\nClick Cancel to select a different date.')) {
			id = dates[date];
			location.href = '/admin/'+type+'/edit.php?id='+id;
		}
	}
}