var confirmMsg  = 'Delete?';

function confirmLink(theLink)
{
    if (confirmMsg == '') {
        return true;
    }
    return confirmLink(theLink, confirmMsg);
}

function confirmLink(theLink, message)
{
    if (message == '') {
        return true;
    }
    var is_confirmed = confirm(message);
    if (is_confirmed) {
        theLink.href += '&confirmed=1';
    }
    return is_confirmed;
}

var popupCount = Math.round(Math.random() * 100);

function openPopup(fileID, width, height) {
	openPopup(fileID, width, height, '0');
}

function openPopup(fileID, width, height, scroll) {
	width += 6;
	height += 5;
 	popupCount ++;
	window.open(fileID , 'fly'+popupCount, "menubar=0,scrollbars=" + scroll + ",toolbar=0,location=0,directories=0,status=0,resizable=0,width=" + width + ",height=" + height + "left=10, top=10");
}

function checkCount(veld, aantal, volgende) {
	if(veld.value.length >= aantal) {
		volgende.focus(); }
}

function onlyNumbers(obj) {
	var checked = "", replace = false;
	for (i = 0; i < obj.value.length; i++) {
		focus = obj.value.substr(i, 1);
		if (focus == ',')
			focus = '.';

		if (isNumber(focus)) {
			checked += focus;
		} else replace = true;
	}
	if (replace) obj.value = checked;
}

function isNumber(c){
	if (c==0||c==1||c==2||c==3||c==4||c==5||c==6||c==7||c==8||c==9||c=='.'||c==','||c=='-') return true;
		else return false;
}

function show(elementId) {
	if (document.getElementById) {
		var theElement = document.getElementById(elementId);
	} else {
		if (document.all) {
			var theElement = document.all[elementId];
		} else {
			var theElement = new Object();
		}
	}
	if (!theElement) { return; }
	if (theElement.style) { theElement = theElement.style; }
	if (typeof(theElement.display) == 'undefined' && !( window.ScriptEngine && ScriptEngine().indexOf( 'InScript' ) + 1 ) ) { return; }

	theElement.display = 'block';
}

function hide(elementId) {
	if (document.getElementById) {
		var theElement = document.getElementById(elementId);
	} else {
		if (document.all) {
			var theElement = document.all[elementId];
		} else {
			var theElement = new Object();
		}
	}
	if (!theElement) { return; }
	if (theElement.style) { theElement = theElement.style; }
	if (typeof(theElement.display) == 'undefined' && !( window.ScriptEngine && ScriptEngine().indexOf( 'InScript' ) + 1 ) ) { return; }

	theElement.display = 'none';
}

function toggle(elementId) {
	if (document.getElementById) {
		theElement = document.getElementById(elementId);
	} else {
		if (document.all) {
			var theElement = document.all[elementId];
		} else {
			var theElement = new Object();
		}
	}
	if (!theElement) { return; }
	if (theElement.style) { theElement = theElement.style; }
	if (typeof(theElement.display) == 'undefined' && !( window.ScriptEngine && ScriptEngine().indexOf( 'InScript' ) + 1 ) ) { return; }
	if (theElement.display == 'none') {
		theElement.display = 'block';
	} else {
		theElement.display = 'none';
	}
}

function clean(elementId, state) {
	if (document.getElementById) {
		theElement = document.getElementById(elementId);
	} else {
		if (document.all) {
			var theElement = document.all[elementId];
		} else {
			var theElement = new Object();
		}
	}
	if (!theElement) { return; }
	childSize = theElement.childNodes.length;
	for (i = 0; i < childSize; i++) {
		if (theElement.childNodes[i].tagName && theElement.childNodes[i].tagName.toLowerCase() == "div") {
			theElement.childNodes[i].display = 'none';
			clean(theElement.childNodes[i].id, state);
		}
		if (theElement.childNodes[i].type && theElement.childNodes[i].type.toLowerCase() == "checkbox") {
			theElement.childNodes[i].checked = state;
		}
	}
}

function switchTab(tabId)
{
	var tabs = document.getElementById("tabs").getElementsByTagName("div");
	var activeTabIndex = -1;
	for(i = 0; i < tabs.length; i++)
	{
		if(tabs[i].id == "tab"+tabId)
		{
			tabs[i].className = "taba";
			activeTabIndex = i;
		} else {
			tabs[i].className = "tabl";			
		}
	}
	
	var tabcontents = document.getElementById("tabcontents").getElementsByTagName("div");
	
	for(i = 0; i < tabcontents.length; i++)
	{
		if(tabcontents[i].className != "tabcontent")
			continue;
		
		if(tabcontents[i].id == "content"+tabId)
		{
			tabcontents[i].style.display = "inline";
		}
		else
		{
			tabcontents[i].style.display = "none";
		}
	}
}