/* © Atradius 2006 *//* WINDOWS */ window.aryOnloads = new Array(); function winAddOnload ( objFunction ) { if ( window.onload ) { if ( window.onload != winDoOnloads ) { window.OriginalOnload = window.onload; window.onload = winDoOnloads; }; } else { window.onload = winDoOnloads; }; window.aryOnloads[window.aryOnloads.length] = objFunction; }; function winDoOnloads () { for ( thisOnload=0; thisOnload<window.aryOnloads.length; thisOnload++ ) { if ( typeof ( window.aryOnloads[thisOnload] ) == "function" ) { window.aryOnloads[thisOnload](); } else if ( typeof ( window.aryOnloads[thisOnload] ) == "string" ) { eval ( window.aryOnloads[thisOnload] ); }; }; if ( window.OriginalOnload ) { window.OriginalOnload(); }; }; /* ***************************************************************** * * target : To strip a property and it's value from a string holding * many of such combinations. * object : Function * params : str - String variable to be stripped * idx - Numerical nth position of required Property/Value * combo, or Property name to search against. * return : String * ***************************************************************** */ function strip ( str, idx ) { if ( isNaN ( parseInt ( idx ) ) ) { str = str.substring ( str.indexOf ( '&' + idx ) + 1, str.length ); if ( str.indexOf ( idx ) == -1 ) { str = "" }; } else { for ( i = 0; i < idx; i++ ) { str = str.substring ( str.indexOf ( '&' ) + 1, str.length ); }; }; if ( str.indexOf ( '&' ) != -1 ) { str = str.substring ( 0, str.indexOf ( '&' ) ); }; return str; }; function getProperty ( str, idx ) { s = str; s = strip ( s, idx ); s = s.substring ( 0, s.indexOf ( '=' ) ); return s; }; function getValue ( str, idx ) { s = str; s = strip ( s, idx ); s = s.substring ( s.indexOf ( '=' ) + 1, s.length ); if ( s != "" ) { return s; }; }; /* LINKS */ function winPopup ( strWinID, intWidth, intHeight ) { if ( arguments.length == 1 ) { intWidth = 800; intHeight = 600; } else if ( arguments.length != 3 ) { throw new Error ( 'Function winPopup must be called with 1 or 3 values.\n[' + arguments.length + ' values passed in this call.]' ); }; strFeatures = 'height=' + intHeight + ',scrollbars,width=' + intWidth; window.open ( "", strWinID, strFeatures ); }; function iniLinks() { var strLocalHost = document.location.hostname; var strFormDirectory = "/forms/"; var strDSBDirectory = "dutchstatebusiness"; var intFormWidth = "620"; var intFormHeight = "600"; for ( thisLink=0; thisLink<document.links.length; thisLink++ ) { objThisLink = document.links[thisLink]; strLinkHTML = objThisLink.outerHTML; if ( strLinkHTML != null ) { strNewLinkHTML = strLinkHTML.substring ( 0, 3 ) + "onFocus=\"this.blur();\" " + strLinkHTML.substring ( 3 ); }; if ( strLocalHost != "" ) { if ( objThisLink.hostname != strLocalHost ) { objThisLink.target = "_blank"; }; }; if ( objThisLink.href.indexOf ( strFormDirectory ) != -1 ) { if ( objThisLink.href.indexOf ( strDSBDirectory ) != -1 ) { intFormWidth = "640"; }; UniqueID = Math.random(); UniqueID = UniqueID.toString(); strWinID = "win" + UniqueID.slice(2, 8); if ( strLinkHTML != null ) { strNewLinkHTML = strLinkHTML.substring ( 0, 3 ) + "onClick=\"winPopup('"+strWinID+"'," + intFormWidth + "," + intFormHeight + ");\" " + "target=\""+strWinID+"\" " + strLinkHTML.substring ( 3 ); objThisLink.outerHTML = strNewLinkHTML; }; }; }; }; /* IMAGES */ function imgChange ( objImage ) { strImageSource = objImage.src; strNewImageSource = strImageSource; strImageName = strImageSource.substring ( 0, strImageSource.lastIndexOf ( '.' ) ); strImageType = strImageSource.substring ( strImageSource.lastIndexOf ( '.' ) + 1 ); if ( strImageName.indexOf ( '-over' ) != -1 ) { strNewImageSource = strImageName.substring ( 0, strImageName.indexOf ( '-over' ) ) + '-off.' + strImageType; } else if ( strImageName.indexOf ( 'off' ) != -1 ) { strNewImageSource = strImageName.substring ( 0, strImageName.indexOf ( '-off' ) ) + '-over.' + strImageType; }; objImage.src = strNewImageSource; return null; }; function ResolveIdentifier ( uri ) { uri = escape ( uri ); uriNew = uri; if ( document.charset != "iso-8859-1" ) { intIndex = 0; uriNew = ""; var ptnUnicodeCharacterEscapeSequence = /%u\d{3}[a-zA-Z]/g; while ( ( match = ptnUnicodeCharacterEscapeSequence.exec( uri ) ) != null ) { strLast = uri.substring(intIndex,match.index); intIndex = ptnUnicodeCharacterEscapeSequence.lastIndex; chrEscaped = match[0]; chrEscaped = chrEscaped.charAt(chrEscaped.length - 1); uriNew += strLast + chrEscaped; }; uriNew += uri.substring(intIndex); }; return uriNew; }; /* REQUEST JavaScript */ function GetRequestParametersArray() { aryQueryData = new Array(); strQueryData = window.location.href; if ( strQueryData.indexOf ( "?" ) != -1 ) { i = 0; strQueryData = strQueryData.substring ( strQueryData.indexOf ( "?" ) + 1 ); strQueryData += "&"; while ( strQueryData.length > 0 ) { strQueryPair = strQueryData.substring ( 0, strQueryData.indexOf ( "&" ) ); strQueryName = strQueryPair.substring ( 0, strQueryPair.indexOf ( "=" ) ); strQueryValue = strQueryPair.substring ( strQueryPair.indexOf ( "=" ) + 1 ); aryQueryData[i] = new Option ( strQueryName, strQueryValue ); strQueryData = strQueryData.substring ( strQueryData.indexOf ( "&" ) + 1 ); if ( strQueryData.length > 0 ) { i++; }; }; }; return aryQueryData; }; GaryRequestParameters = GetRequestParametersArray(); function GetRequestString ( strExcludeParameters ) { if ( strExcludeParameters == undefined ) { strExcludeParameters = ""; }; strQueryString = ""; for ( i=0; i < GaryRequestParameters.length; i++) { if ( strExcludeParameters.indexOf ( GaryRequestParameters[i].text ) == -1 ) { strQueryString += GaryRequestParameters[i].text + "=" + GaryRequestParameters[i].value; if ( ( i + 1 ) != GaryRequestParameters.length ) { strQueryString += "&"; }; }; }; return strQueryString; }; function GetRequestParameterValue ( strParameterName ) { strParameterValue = ""; for ( i=0; i < GaryParameters.length; i++) { if ( GaryParameters[i].text == strParameterName ) { strParameterValue = GaryParameters[i].value; break; }; }; return strParameterValue; }; function SetRequestParameterValue ( strParameterName, strParameterValue ) { var bolFoundRequestParameter = false; for ( i=0; i < GaryRequestParameters.length; i++) { if ( GaryRequestParameters[i].text == strParameterName ) { GaryRequestParameters[i].value = strParameterValue; bolFoundRequestParameter = true; break; }; }; if ( !bolFoundRequestParameter ) { GaryRequestParameters[GaryRequestParameters.length] = new Option ( strParameterName, strParameterValue ); }; }; function AddRequestParameter ( strName, strValue ) { strNewLocation = window.location.href; if ( strName != "" && strValue != "" ) { strRequestParameters = ""; if ( GaryRequestParameters.length != 0 ) { strNewLocation = strNewLocation.substring ( 0, strNewLocation.indexOf ( "?" ) ); }; SetRequestParameterValue ( strName, strValue ); strRequestParameters = GetRequestString(); strNewLocation += "?" + strRequestParameters; }; return strNewLocation; }; function DelRequestParameter ( strName ) { intSpliceMark = -1; if ( strName != "" ) { for ( i=0; i < GaryRequestParameters.length; i++ ) { if ( GaryRequestParameters[i].text == strName ) { intSpliceMark = i; break; }; }; if ( intSpliceMark != -1 ) { objSplice = GaryRequestParameters.splice ( intSpliceMark, 1 ); }; }; }; function SubmitRequest ( strName, strValue, objLink ) { strRequestLocation = AddRequestParameter ( strName, strValue ); if ( objLink == null ) { window.location.href = strRequestLocation; } else { objLink.href = strRequestLocation; if ( objLink.target != "" ) { DelRequestParameter ( strName ); }; }; }; /* STATIC FORMS */ function ShowLayer ( objLayer ) { objLayer.style.display = 'block'; }; /* Return the index of the selected branch radiobutton */ function SelectedFilliaal(form) { /* (form.filiaal.length - 1) = only return a value if the branch is known by the customer */ for (i = 0; i < (form.filiaal.length - 1); i++) { if ( form.filiaal[i].checked == true) { return i; }; }; return -1; }; /* Return the name of the selected branch/filliaal */ function ReturnFilliaal(form) { var n = SelectedFilliaal(form); if ( n >= 0) { return (', ' + form.filiaal[n].value); }; return ""; }; /* Add the customernumber and branch to the subject field */ function SetRcpEmailCollect(form) { var email=""; var n = SelectedFilliaal(form); switch (n) { case 0: email = "wvb\@atradius.com"; break; case 1: email = "incasso.nl\@atradius.com"; break; default: email = "wvb\@atradius.com"; }; form.to.value = email; }; /* Add the customernumber and branch to the subject field */ function SetRcpEmailIncasso(form) { var email=""; var n = SelectedFilliaal(form); switch (n) { case 0: email = "wvb\@atradius.com"; break; case 1: email = "claims.nl\@atradius.com"; break; case 2: email = "incasso.nl\@atradius.com"; break; default: email = "incasso.nl\@atradius.com"; }; form.to.value = email; }; /* Set the resultpage, based selected branch (filliaal)*/ function SetResultPageCollect(form) { var result_page=""; var n = SelectedFilliaal(form); switch (n) { case 0: result_page = "/response/response_page_collect_gouda.html"; break; case 1: result_page = "/response/response_page_collect_ommen.html"; break; default: result_page = "/response/response_page_collect.html"; }; form.redirect.value = result_page; }; /* Set the resultpage, based selected branch (filliaal)*/ function SetResultPageIncasso(form) { var result_page=""; var n = SelectedFilliaal(form); switch (n) { case 0: result_page = "/response/response_page_incasso_gouda.html"; break; case 1: result_page = "/response/response_page_incasso_adam.html"; break; case 2: result_page = "/response/response_page_incasso_ommen.html"; break; default: result_page = "/response/response_page_incasso.html"; }; form.redirect.value = result_page; }; /*Add the customernumber and branch to the subject field */ function AddRcpToSubject(form) { form.subject.value = form.subject.value + ', klantnummer: ' + form.klantnummer.value + ReturnFilliaal(form); alert (form.subject.value); }; function filterNonNumeric(field) { var result = new String(); var numbers = "0123456789."; var chars = field.value.split(""); /* create array */ for (i = 0; i < chars.length; i++) { if (numbers.indexOf(chars[i]) != -1) result += chars[i]; }; if (field.value != result ) { field.value = result; }; }; function cent(amount) { return (amount == Math.floor(amount)) ? amount + '.00' : ( (amount*10 == Math.floor(amount*10)) ? amount + '0' : amount); }; /* add all values in the "bedrag" colums */ function total( form, field) { var Totaal = 0; var index; var bedrag_name; var number = 10; /* number of fields */ /* strip trailing number in name */ bedrag_name = field.name.substring(0, 16); for (var i=1;i<=number;i++) { if(i< 10) { index = "0" + i; } else { index = "" + i; }; if (form.elements[bedrag_name + index].value == '') { form.elements[bedrag_name + index].value == '0.00'; /* fix for Opera. */ }; Totaal += (form.elements[bedrag_name + index].value - 0); }; form.elements['debiteur' + field.name.charAt(8) + '_hoofdsom-vordering'].value = cent(Math.round(Totaal*Math.pow(10,2))/Math.pow(10,2)); }; /* avoid submitting a form accidently by pressing "enter" in a textfield */ function noenter() { return !(window.event && window.event.keyCode == 13); }; 