
function preHover(outClass,overClass) {
var eTx = 'class="'+outClass+'" onmouseover="this.className=\''+overClass+'\';" onmouseout="this.className=\''+outClass+'\';"';
return eTx;
}

function ConfirmCom(id,name,eNr){
	var EF =document.getElementById('myFrame'); var tst=document.getElementById('confirmDiv');
	if (tst) ClosePop(EF,tst);
	var dvC = document.createElement('div');
	dvC.id='confirmDiv';dvC.className='wFrame';
	dvC.innerHTML = '<div class="nTitle">Bevestiging</div>' +
			'<div class="wForm"">Bent u eigenaar of werkzaam bij <b style="color:#FF6600;">'+name+'</b>' +
			'?</div><div class="btnArea">' +
			'<input type="button" value=" Ja " style="margin-right:10px;width:73px;" ' +
			'onclick="ClosePopAuto(\'myFrame\',\'confirmDiv\');isCom(\''+id+'\',\''+eNr+'\',\'form1\');" />' +
			'<input type="button" value=" Nee " style="margin-right:10px;width:73px;" ' +
			'onclick="ConfirmOldOther(\''+eNr+'\');" />'+ 
			'<input type="button" value="Annuleren" onclick="ClosePopAuto(\'myFrame\',\'confirmDiv\');" /></div>';
			
	dvC.style.position= "relative";	dvC.style.marginTop = -100; dvC.style.top=-100; dvC.style.left = 125; 
	dvC.style.width=390; dvC.style.zindex=2;dvC.float="left"; EF.appendChild(dvC);
}

function ConfirmComEz(id,name,eNr){
	var EF =document.getElementById('myFrame'); var tst=document.getElementById('confirmDiv');
	if (tst) ClosePop(EF,tst);
	var dvC = document.createElement('div');
	dvC.id='confirmDiv';dvC.className='wFrame';
	dvC.innerHTML = '<div class="nTitle">Bevestiging</div>' +
			'<div class="wForm"">Bent u eigenaar of werkzaam bij <b style="color:#FF6600;">'+name+'</b> ' + 
			'?</div><div class="btnArea">' +
			'<input type="button" value=" Ja " style="margin-right:10px;width:73px;" ' +
			'onclick="ClosePopAuto(\'myFrame\',\'confirmDiv\');isCom(\''+id+'\',\''+eNr+'\',\'form1\');" />'+
			'<input type="button" value=" Nee " style="margin-right:10px;width:73px;" ' + 
			'onclick="ClosePopAuto(\'myFrame\',\'confirmDiv\');" /></div>';
			
	dvC.style.position= "relative";	dvC.style.marginTop = -100; dvC.style.top=-100; dvC.style.left = 125; 
	dvC.style.width=390; dvC.style.zindex=2;dvC.float="left";
	EF.appendChild(dvC);	

}


function ConfirmOldOther(eNr){
	var EF =document.getElementById('myFrame'); var tst=document.getElementById('confirmDiv');
	if (tst) ClosePop(EF,tst);
	var dvC = document.createElement('div');
	dvC.id='confirmDiv';dvC.className='wFrame';
	dvC.innerHTML = '<div class="nTitle" style="background-color:#1E4F7D;">Bedrijf verhuisd?</div>' +
			'<div class="wForm">' +
			'	Had u in het verleden <b>een ander vestigingsadres</b>?' +
			'</div>' + 
			'<div class="btnArea">' +
			'<input type="button" value="Ja" style="margin-right:10px;width:73px;" onclick="RetrySearch();" /> ' +
			'<input type="button" value="Nee" style="margin-right:10px;width:73px;" onclick="ConfirmPObox(\''+eNr+'\');" />' + 
			'<input type="button" value="Annuleren" style="margin-right:10px;width:73px;" onclick="ClosePopAuto(\'myFrame\',\'confirmDiv\');" /></div>';
	dvC.style.position= "relative";	dvC.style.marginTop = -100; dvC.style.top=-120; dvC.style.left = 125; 
	dvC.style.width=390; dvC.style.zindex=2;dvC.float="left";
	EF.appendChild(dvC);	
}

function ConfirmPObox(eNr){
	var EF =document.getElementById('myFrame'); var tst=document.getElementById('confirmDiv');
	if (tst) ClosePop(EF,tst);
	var dvC = document.createElement('div');
	dvC.id='confirmDiv';dvC.className='wFrame';
	dvC.innerHTML = '<div class="nTitle" style="background-color:#1E4F7D;">Bedrijf postbus-adres?</div>' +
			'<div class="wForm">' +
			'	Maakt uw bedrijf gebruik van een <b>postbus-adres</b>?' +
			'</div>' + 
			'<div class="btnArea">' +
			'<input type="button" value="Ja" style="margin-right:10px;width:73px;" onclick="RetrySearch();" /> ' +
			'<input type="button" value="Nee" style="margin-right:10px;width:73px;" ' +
			'onclick="ClosePopAuto(\'myFrame\',\'confirmDiv\');isCom(\'-1\',\''+eNr+'\',\'form1\');" /> ' +
			'<input type="button" value="Annuleren" style="margin-right:10px;width:73px;" onclick="ClosePopAuto(\'myFrame\',\'confirmDiv\');" /></div>';
	dvC.style.position= "relative";	dvC.style.marginTop = -100; dvC.style.top=-120; dvC.style.left = 125; 
	dvC.style.width=390; dvC.style.zindex=2;dvC.float="left";
	EF.appendChild(dvC);	
}

function RetrySearch(){
	var EF =document.getElementById('myFrame'); var tst=document.getElementById('confirmDiv');
	if (tst) ClosePop(EF,tst); 
	var dvC = document.createElement('div'); dvC.id='confirmDiv';dvC.className='wFrame'; EditValue('u_post',''); 

EditValue('u_hnr','');
	dvC.innerHTML = '<div class="nTitle">Aanbevolen Zoeksuggestie</div>' +
			'<div class="wForm"">Probeer uw bedrijf nogmaals te zoeken door uw oude <br>' + 
		    'adres- of postbusgegevens (postbusnummer als huisnr) in te voeren.</div><div class="btnArea">' +
			'<input type="button" onclick="ClosePopAuto(\'myFrame\',\'confirmDiv\');RePost(\'form1\');" ' +
			'value="  OK  " /></div>';

	dvC.style.position= "relative";	dvC.style.marginTop = -100; dvC.style.top=-100; dvC.style.left = 125; 
	dvC.style.width=390; dvC.style.zindex=2;dvC.float="left";
	EF.appendChild(dvC);	
}

function RePost(fz){var f=document.getElementById(fz);var eFrm =get(f);frmsyn(mapi,"checkpointer",eFrm);}

function isCom(cN,hr,fz) { 
	hr = hr.replace(/[^\d]/g,''); EditValue('GCD',cN); 
	EditValue('u_hnr',hr); var f=document.getElementById(fz);var eFrm=get(f); frmsyn(mapi,"checkpointer",eFrm);}

function EditValue(el,val) { var tstB=document.getElementById(el); 
		if (tstB){ tstB.value = val;} else {alert('cannot find '+el);}}

function ClosePop(parnt,el) { if (!parnt || !el) return false; parnt.removeChild(el); return true;}
function ClosePopAuto(parnt,el) {var tstB=document.getElementById(parnt); var tstA=document.getElementById(el);
		if (tstA && tstB) ClosePop(tstB,tstA); return false;
}

function ClearAppForm(f) {
 var EF =document.getElementById('myFrame'); var tst=document.getElementById('confirmDiv'); if (tst) 

ClosePop(EF,tst); var dvC = document.createElement('div'); dvC.id='confirmDiv';dvC.className='wFrame';
 dvC.innerHTML = '<div class="nTitle">Veldwaarden wissen</div>' + '<div class="wForm"">'+ 
				 'Weet u zeker dat u de gegevens van het formulier wilt wissen?</div><div class="btnArea">' +
				 '<div '+preHover('btnN','btnS')+' style="margin-top:-20px;" '+
				 'onclick="ClosePopAuto(\'myFrame\',\'confirmDiv\');">NEE</div>' +
				 '<div '+preHover('btnN','btnS')+' style="margin-top:-20px;" ' +

				'onclick="ClosePopAuto(\'myFrame\',\'confirmDiv\');ClearAppFormConfirm('+f+');">JA</div></div>';

	dvC.style.position= "relative";	dvC.style.marginTop = -105; dvC.style.top=-200; dvC.style.left = 125; 
	dvC.style.width=390; dvC.style.zindex=2;dvC.float="left";dvC.style.borderWidth=2;
	EF.appendChild(dvC);
}



function ClearAppFormConfirm(f) { var oForm=document.getElementById(f); var elmn;
 if (oForm==null) { elmn = f.elements; } else { elmn = oForm.elements;}  for(i=0; i<elmn.length; i++) { 
 field_type = elmn[i].type.toLowerCase(); switch(field_type) { 
 case "text": case "password": case "textarea": case "hidden": elmn[i].value = ""; break;
 case "radio": case "checkbox": if (elmn[i].checked) {elmn[i].checked = false;} break; 
 case "select-one": case "select-multi": elmn[i].selectedIndex = -1; break; default: break;}} 
}

function Verifymail(origin,verif,verifDiv, errDiv) { var tstA=document.getElementById(origin); if (!tstA) return false; 
 var tstB=document.getElementById(verif); var eDiv=document.getElementById(errDiv); 
 var vDiv=document.getElementById(verifDiv);
 
 if (!tstB || !eDiv || !vDiv) return false;  if (tstA.value.length > 0) { vDiv.style.display='';
 if (tstB.value.length > 0) { if (tstB.value==tstA.value) {eDiv.style.display='none';} else {eDiv.style.display='';}} 
 else {eDiv.style.display='none';}} else {tstB.value='';vDiv.style.display='none';}}

function VerifyThree(f) { var oForm=document.getElementById(f); var elmn; var err='';
 if (oForm==null) { elmn = f.elements; } else { elmn = oForm.elements;}  for(i=0; i<elmn.length; i++) {
	fnm = elmn[i].id.toLowerCase();switch(fnm) { 
  case "bv_a": if(elmn[i].value.length<2){err+='<br> - Handelsnaam';}break;
  case "bv_b": if(elmn[i].value.length<4){err+='<br> - Straatnaam';}break;
  case "bv_c": if(elmn[i].value.length<1){err+='<br> - Huisnummer';}break;
  case "bv_d": if(elmn[i].value.length<6){err+='<br> - Postcode';}break;
  case "bv_e": if(elmn[i].value.length<3){err+='<br> - (vestigings)plaats';}break;
  case "bv_f": if(elmn[i].value.length<6){err+='<br> - Telefoonnummer';}break;
  case "br_a": if(elmn[i].selectedIndex<1){err+='<br> - geen branche geselecteerd';}break; 
  case "web_ba":if(!(elmn[i-1].value==elmn[i].value)){err+='<br> - Emailadres (verificatie) komt niet overeen';}break;
  case "web_b":if(elmn[i].value.length>1){if (EmValid(elmn[i])==false){err+='<br> - emailadres is ongeldig';};}break; 
  default: break;} }
if (err.length>0) {
	ErrAppPop('<b>Het formulier kan niet worden verzonden,<br>omdat de volgende gegevens missen of onjuist zijn ingevuld:</b>'+err);}
else {
	mapi=mapi.replace('_chk01','_chk03'); var oForm=document.getElementById(f); var eFrm =get(oForm);
	frmsyn(mapi,"checkpointer",eFrm);
	}
}


function VerifyFour(f) { var oForm=document.getElementById(f); var elmn; var err='';
 if (oForm==null) { elmn = f.elements; } else { elmn = oForm.elements;}  for(i=0; i<elmn.length; i++) {
	fnm = elmn[i].id.toLowerCase();switch(fnm) { 
  case "whoc": if(elmn[i].value.length<2){
	  	err+='<br> - U dient het veld \'Functie binnen het bedrijf\' in te vullen';
		}break;
  case "whob": if(elmn[i].value.length<2){
	  	err+='<br> - U dient uw naam (voorletter en achternaam) in te vullen';
		}break;
  case "whoa": if(elmn[i].selectedIndex<1){
	  	err+='<br> - geen aanhef geselecteerd';
		}break; 
  default: break;} 
  }
  
if (err.length>0) {
	ErrAppPop('<b>Het formulier kan niet worden verzonden,<br>omdat de volgende gegevens missen of onjuist zijn ingevuld:</b>'+err);
	}
else {
	mapi=mapi.replace('_chk03','_chk04'); var oForm=document.getElementById(f); var eFrm =get(oForm);
	frmsyn(mapi,"checkpointer",eFrm);
	}
}

function ErrAppPop(t) {
 var lines = t.split("<br>"); var spH = Math.round(((lines.length+1)*14)+((lines.length+1)/2))
 var EF =document.getElementById('myFrame'); var tst=document.getElementById('confirmDiv'); 
 if (tst) ClosePop(EF,tst); 
 var dvC = document.createElement('div'); dvC.id='confirmDiv';dvC.className='wFrame';
 dvC.innerHTML = '<div class="nTitle" style="clear:both;">Fout tijdens verzenden</div>' + 
 				 '<div class="wForm"" style="clear:both;">' + t + '</div><div class="btnArea">' +
				 '<div '+preHover('btnN','btnS')+' style="float:right;margin-top:0px;" ' +
				 'onclick="ClosePopAuto(\'myFrame\',\'confirmDiv\');">OK</div></div>';
				 
 dvC.style.position= "relative"; dvC.style.cssFloat="left";dvC.style.top=0-(spH+350); dvC.style.left = 125; 
 dvC.style.width=390; dvC.style.zindex=2;dvC.style.borderWidth=2;
 EF.appendChild(dvC);
}

function EmValid(Emn) {
    if (typeof(Emn) != "object") { return(false); }
    var nVal = Emn.value ; var message; if (nVal=='') return true;
    if (AtSign(nVal) || noLeftBracket(nVal) || noRightBracket(nVal) || noValidPeriod(nVal) || noValidSuffix(nVal)) {
	return false; } else {return true;
	}

function AtSign (fld) {if (fld.indexOf ('@', 0) == -1 || fld.indexOf ( '@', 0 ) < 1) {return(true)} else {return 

(false); }}
function noLeftBracket (fld) {if ( fld.indexOf ( '[', 0 ) == -1 && fld.charAt (fld.length - 1) == ']') {return ( true 

)} else {return ( false );}}
function noRightBracket (fld) {if (fld.indexOf ( '[', 0 ) > -1 && fld.charAt (fld.length - 1) != ']') {return ( true 

);} else {return ( false );}}
function noValidPeriod (fld) {if (fld.indexOf ( '@', 0 ) > 1 && fld.charAt (fld.length - 1 ) == ']') return ( false 

);if (fld.indexOf ( '.', 0 ) == -1) return ( true ); return ( false );}
function noValidSuffix(fld) {
	if (fld.indexOf('@', 0) > 1 && fld.charAt(fld.length - 1) == ']') return (false); 
	var len = fld.length; var pos = fld.lastIndexOf ( '.', len - 1 ) + 1;
	if ((len-pos) < 2 || (len-pos) > 4) {return ( true );} else {return ( false );}}}