function confirmLink(theLink, theQuestion)
{
    if (typeof(window.opera) != 'undefined') {
        return true;
    }

    var is_confirmed = confirm(theQuestion);

    return is_confirmed;
}

function displayStatusMsg(msgStr) {
  status=msgStr;
  document.returnValue = true;
}

function openWindow(theURL,winName,features) {
	var win = open(theURL,winName,features);
	win.focus();
}

function openVerklaringWindow (id) {
	var verklaringwin = window.open ('verklaring.php?verklaringid='+id, 'Verklaring_'+id, 'scrollbars=no,resizable=no,width=720,height=400');
	verklaringwin.focus();		
}


function checkProgress () {
	if (window.opener.windowLoaded) {
		opener.focus();
		window.close ();
	} else {
		setTimeout ("checkProgress()", 500);
	}
}

function getAdres (type) {
	var fields;
	
	fields = 'form_postcode=postcode&form_plaats=plaats&form_provincieid=provincieid&form_adres=adres&post_prefix=post';

	if (type == 1) {
		if (document.contacts.landid.value==1) 
			if (document.contacts.postcode.value && document.contacts.huisnr.value) 
				document.adresFrame.location.href='/process.php?action=order&what=contacts&do=postcode&form=contacts&'+fields+'&type='+type+'&pc='+document.contacts.postcode.value+'&nr='+document.contacts.huisnr.value;	
	} else {
		if (document.contacts.post_landid.value==1) 	
			if (document.contacts.post_postcode.value && document.contacts.post_huisnr.value) 
				document.adresFrame.location.href='/process.php?action=order&what=contacts&do=postcode&form=contacts&'+fields+'&type='+type+'&pc='+document.contacts.post_postcode.value+'&nr='+document.contacts.post_huisnr.value;	
		
	}
	
}

function getMijnAdres (type) {
	var fields;

	fields = 'form_postcode=Postcode&form_plaats=Plaats&form_provincieid=ProvincieID&form_adres=Adres&post_prefix=Post';
	
	
	if (type == 1) {
		if (document.klantgegevens.LandID.value==1) 
			if (document.klantgegevens.Postcode.value && document.klantgegevens.Huisnr.value) 
				document.adresFrame.location.href='/process.php?action=order&what=contacts&do=postcode&form=klantgegevens&'+fields+'&type='+type+'&pc='+document.klantgegevens.Postcode.value+'&nr='+document.klantgegevens.Huisnr.value;	
	} else {
		if (document.klantgegevens.Post_LandID.value==1) 	
			if (document.klantgegevens.Post_Postcode.value && document.klantgegevens.Post_Huisnr.value) 
				document.adresFrame.location.href='/process.php?action=order&what=contacts&do=postcode&form=klantgegevens&'+fields+'&type='+type+'&pc='+document.klantgegevens.Post_Postcode.value+'&nr='+document.klantgegevens.Post_Huisnr.value;	
		
	}

}


function updateContacts (theForm, keepWindow) {
	var urlOut;
	
	urlOut = '/process.php?action=order&what=contacts&do=update&window='+keepWindow+'&domeinhouder='+theForm.domeinhoudercontacthandle.value+'&technisch='+theForm.technischcontacthandle.value+'&administratief='+theForm.administratiefcontacthandle.value;
	
	if (keepWindow==1) {
		window.location.href=urlOut;
	} else {
		window.opener.location.href=urlOut;
		window.opener.focus ();
//		setTimeout ("window.opener.focus()", 500);	
//		window.close();
		setTimeout ("window.close()", 500);
	}
}

function setContactType (theForm, contactType) {
	var disabled;
	var theColor;
	if (contactType==1) {
		disabled = false; 
		theColor = '#FFFFEE';
		borderColor = '#000000';
	} else {
		disabled = true
//		theColor = '#DDDDDD';		
		theColor = '#FAFAFA';	
		borderColor = '#DDDDDD';		
	}
		
	theForm.bedrijf.disabled = disabled;
	theForm.functie.disabled = disabled;
	theForm.kvk.disabled = disabled;
	theForm.kvkregio.disabled = disabled;
	theForm.rechtsvorm.disabled = disabled;
	theForm.btwnr.disabled = disabled;	
	
	theForm.bedrijf.style.backgroundColor = theColor;		
	theForm.functie.style.backgroundColor = theColor;		
	theForm.kvk.style.backgroundColor = theColor;		
	theForm.kvkregio.style.backgroundColor = theColor;		
	theForm.rechtsvorm.style.backgroundColor = theColor;		
	theForm.btwnr.style.backgroundColor = theColor;		
	
	theForm.bedrijf.style.borderColor = borderColor;		
	theForm.functie.style.borderColor = borderColor;		
	theForm.kvk.style.borderColor = borderColor;		
	theForm.kvkregio.style.borderColor = borderColor;		
	theForm.rechtsvorm.style.borderColor = borderColor;		
	theForm.btwnr.style.borderColor = borderColor;		
	
}

function setPointer(Row, Action, BGColor)
{
	var newColor = '';

	if (Action=='over') {
		newColor = '#CCFFCC';
	} else if (Action=='click') {
		newColor = '#DAFADA';
	} else {
		newColor = BGColor;	
	}
	
	Row.style.backgroundColor = newColor;
//	Row.style.cursor = 'hand';	
}

var ie4 = (document.all) ? true : false;
var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;

function hidelayer(lay) {
	if (ie4) {document.all[lay].style.visibility = "hidden";}
	if (ns4) {document.layers[lay].visibility = "hide";}
	if (ns6) {document.getElementById([lay]).style.display = "none";}
}
function showlayer(lay) {
	if (ie4) {document.all[lay].style.visibility = "visible";}
	if (ns4) {document.layers[lay].visibility = "show";}
	if (ns6) {document.getElementById([lay]).style.display = "block";}
}
function writetolayer(lay,txt) {
	if (ie4) {
		document.all[lay].innerHTML = txt;
	}
	if (ns4) {
		document[lay].document.write(txt);
		document[lay].document.close();
	}
	if (ns6) {
		over = document.getElementById([lay]);
		range = document.createRange();
		range.setStartBefore(over);
		domfrag = range.createContextualFragment(txt);
		while (over.hasChildNodes()) {
			over.removeChild(over.lastChild);
		}
		over.appendChild(domfrag);
   }
}

function urlencode(str) {
	str = escape(str);
	str = str.replace('+', '%2B');
	str = str.replace('%20', '+');
	str = str.replace('*', '%2A');
	str = str.replace('/', '%2F');
	str = str.replace('@', '%40');
	return str;
}

function urldecode(str) {
	str = str.replace('+', ' ');
	str = unescape(str);
	return str;
}
