
function svStrReplace(str, search, replace)
{
	var idx = str.indexOf(search);
	if (idx==-1) return str;
	return str.substr(0, idx) + replace + str.substr(idx + search.length);
}


function OnLoadWindow()
{

	var tableSet = document.getElementsByTagName("table");

	var i;
	for(i=0;i<tableSet.length;i++)
	{
		if (tableSet[i].className && tableSet[i].className == "overview")
		{
			var trSet = tableSet[i].getElementsByTagName("tr");
			
			for(var j=0;j<trSet.length;j++)
			{
				trSet[j].onmouseover = 
						function() 
						{

							this.className += " hoverstyle"; 
						};
				trSet[j].onmouseout = 
						function() {
	
						this.className = svStrReplace(this.className, " hoverstyle", "");
						this.className = svStrReplace(this.className, "hoverstyle", "");

						};
			}
		}
	}
}
function addlocation()
{
	val = prompt('Geef de naam van de locatie:', '');
	if (val == null)
		return false;
		
	document.getElementById("_scriptVal").value = val;
	return true;
}
function ConfirmDeleteArea()
{
	return confirm("Weet u zeker dat u dit gebied wilt verwijderen?");
}
function ConfirmDeleteArea()
{
	return confirm("Weet u zeker dat u deze locatie wilt verwijderen?");
}
function SwitchlocationEdit()
{
	obj = document.getElementById('locationEdit');
	obj.style.display = (obj.style.display == '') ? 'none' : '';
}
function overviewSelectAll()
{
	var tableSet = document.getElementsByTagName("table");

	var i;
	for(i=0;i<tableSet.length;i++)
	{
		if (tableSet[i].className && tableSet[i].className == "overview")
		{
			var tab = tableSet[i];
			var inputs = tab.getElementsByTagName("input");
			var j;
			for (j=0;j<inputs.length;j++)
			{
				if (inputs[j].type == "checkbox")
				{
					inputs[j].checked = true;
					inputs[j].onclick();
				}
			
			}
			return;
		}
	}
}

window.onload = OnLoadWindow;
popupCal = new CalendarPopup("calendarDiv");
popupCal.setCssPrefix("CAL");
currentCalID = null;

popupCal.setReturnFunction("setCalendarVals");
function setCalendarVals(yyyy,mm,dd) 
{
	yearObj = document.getElementById(currentCalID + "_txtYear");
	if (yearObj)
		yearObj.value = yyyy;
	monthObj = document.getElementById(currentCalID + "_txtMonth");
	if (monthObj)
		monthObj.value = mm;
	dayObj = document.getElementById(currentCalID + "_txtday");
	if (dayObj)
		dayObj.value = dd;
}
	


function doCalendar(id)
{
	currentCalID = id;
	
	var curDate = "";
	yearObj = document.getElementById(id + "_txtYear");
	if (yearObj)
		curDate += yearObj.value;
	monthObj = document.getElementById(id + "_txtMonth");
	curDate += "-";
	if (monthObj)
		curDate += monthObj.value;
	curDate += "-";
	dayObj = document.getElementById(id + "_txtDay");
	if (dayObj)
		curDate += dayObj.value;
		
	if (parseDate(curDate) != null)
		popupCal.showCalendar(id + "_calendarLink", curDate);
	else
		popupCal.showCalendar(id + "_calendarLink");
	return false;
}

selectedIDs = Array();
function onTaggedCheckBoxClick(id, obj)
{
	selectedIDs[id] = obj.checked;
	var out = "";
	for (var key in selectedIDs)
	{
		if (selectedIDs[key])
		{
			if (out!="") out += ",";
			out += key;
		}
	}
	hiddenData = document.getElementById("selectedIDs");
	if (hiddenData)
	{
		hiddenData.value = out;
	}
}
function enableDateField(id, enable)
{
	d = document.getElementById(id + "_txtDay");
	m = document.getElementById(id + "_txtMonth");
	y = document.getElementById(id + "_txtYear");
	l = document.getElementById(id + "_calendarLink");
	d.disabled = !enable;
	m.disabled = !enable;
	y.disabled = !enable;

	l.style['display'] = (enable ? '' : 'none');
}

function birdTypeCheck()
{
	radioTP = document.getElementById("radioBirdType_0");
	radioOV = document.getElementById("radioBirdType_1");
	radioOV.onclick = function()
		{

			enableDateField("endDate", false);
		};
	radioTP.onclick = function()
		{

			enableDateField("endDate", true);
		};
	if (radioOV.checked)
		enableDateField("endDate", false);
}
