/** * @fileoverview Allgemeine Funktionen für die Ediktsdatei des * Bundesministeriums für Justiz * @link http://www.edikte.justiz.gv.at * * @author Susanne Mauritz BRZ/IBM support.edikte@justiz.gv.at * @author Martin Leyrer * @version 1.1 */ /* Funktionen function setFocus(fieldname) function getBL(gbnr) function calcprufzeichen(but,suff) function calwin1(link,w,h,l,t) function showId(id,doc) { function hideId(id,doc) { function toggleDisplay(id,doc, onoff) { function helpwin(link,w,h,l,t) function formatCurrency(number) clearOtherFields(fld,fldarray) */ /* 2009-11-05 calcprufzeichen: Suffix auch beim Gericht berücksichtigen */ /* Globale Variablen */ var blTab = new Array('Wien','Niederösterreich','Burgenland','Oberösterreich', 'Salzburg','Steiermark','Kärnten','Tirol','Vorarlberg','','?'); /* String Prototypes */ String.prototype.right = right;/*define right function*/ String.prototype.rightC = rightC;/*define rightC function*/ String.prototype.toProperCase = function() { /* www.codeproject.com */ return this.toLowerCase().replace(/^(.)|\s(.)/g, function($1) { return $1.toUpperCase(); }); } String.prototype.trim = function () { /* javascript.crockford.com */ return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1"); }; String.prototype.enAmpersand = function () { /* & durch & ersetzen */ return this.deAmpersand().replace(/\&/g, "&"); }; String.prototype.deAmpersand = function () { /* & durch & ersetzen */ return this.replace(/\&/g,"&"); }; /* Date Prototypes */ Date.prototype.formatDate = function( strMask ){ // Create the values for each part of the potential date mask. var objParts = { "T": this.getDate(), "TT": (this.getDate().toString().length == 1) ? ("0" + this.getDate()) : this.getDate(), "TTT": [ "Sun","Mon","Tue","Wed","Thr","Fri","Sat" ][ this.getDay() ], "TTTT": [ "Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday" ][ this.getDay() ], "M": this.getMonth() + 1, "MM": ((this.getMonth()+1).toString().length == 1) ? ("0" + (this.getMonth()+1)) : (this.getMonth() +1), "MMM": [ "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" ][ this.getMonth() + 1 ], "MMMM": [ "Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember" ][ this.getMonth() + 1 ], "JJ": this.getYear().toString().substring( 1, 3 ), "JJJJ": this.getFullYear() } // Check to see if we have special date formatting options. switch ( strMask ){ case "short": return( objParts[ "M" ] + "/" + objParts[ "T" ] + "/" + objParts[ "JJJJ" ] ); break; case "medium": return( objParts[ "MMM" ] + " " + objParts[ "T" ] + ", " + objParts[ "JJJJ" ] ); break; case "long": return( objParts[ "MMMM" ] + " " + objParts[ "T" ] + ", " + objParts[ "JJJJ" ] ); break; case "full": return( objParts[ "TTTT" ] + ", " + objParts[ "MMMM" ] + " " + objParts[ "T" ] + ", " + objParts[ "JJJJ" ] ); break; default: // There was no special date formatting, so just use the mask. return( strMask.replace( new RegExp( "(T{1,4}|M{1,4}|J{4}|J{2})", "gi" ), function( $1 ){ return( objParts[ $1 ] ); }) ); break; } /* End switch */ return true; } /* End Date.prototype function */ // Formats the time with the given time mask. The mask is returned // and the internal date is not altered. Date.prototype.formatTime = function( strMask ){ // Create the values for each part of the potential time mask. var objParts = { "h": ((this.getHours() % 12) == 0) ? "12" : (this.getHours() % 12), "hh": ((this.getHours() % 12) == 0) ? "12" : (((this.getHours() % 12).toString().length == 1) ? ("0" + (this.getHours() % 12)) : (this.getHours() % 12) ), "H": this.getHours(), "HH": (this.getHours().toString().length == 1) ? ("0" + this.getHours()) : this.getHours(), "m": this.getMinutes(), "mm": (this.getMinutes().toString().length == 1) ? ("0" + this.getMinutes()) : this.getMinutes(), "s": this.getSeconds(), "ss": (this.getSeconds().toString().length == 1) ? ("0" + this.getSeconds()) : this.getSeconds(), "l": this.getMilliseconds(), "L": this.getMilliseconds().toString().substring( 0, 2 ), "t": (this.getHours() < 12) ? "A" : "P", "tt": (this.getHours() < 12) ? "AM" : "PM" } // Check to see if we have special time formatting options. switch ( strMask ){ case "short": return( objParts[ "h" ] + ":" + objParts[ "MM" ] + " " + objParts[ "tt" ] ); break; case "medium": return( objParts[ "h" ] + ":" + objParts[ "MM" ] + ":" + objParts[ "ss" ] + " " + objParts[ "tt" ] ); break; default: // There was no special time formatting, so just use the mask. return( strMask.replace( new RegExp( "(h{1,2}|H{1,2}|M{1,2}|s{1,2}|l{1}|L{1}|t{1,2})", "g" ), function( $1 ){ return( objParts[ $1 ] ); }) ); break; } /* End switch */ return true; } /* End Date.prototype function */ function calcPrufZeichen(but,suff) {/*calc Prüfzeichen dep on GZ*/ /*suff for 2nd set of fields*/ var gzcode; if (suff==null) suff = ''; var pz = 'abdfghkmpistvwxyz'; var elem = but ? but.form.elements : self.document.forms[0].elements; var ger = Number(elem['Ger'+suff].value);/* 2009-11-05 SM Suffix auch für Gericht*/ var ga = Number('0' + elem['GA'+suff].value);/*06032003*/ var gz = elem['GZ'+suff];/*select-one/input*/ gz = gz.type=='select-one' ? gz.options[gz.selectedIndex].value : gz.value; var zahl = ('00000' + elem['Zahl'+suff].value).right(5); var jahr = elem['Jahr'+suff];/*select!*/ jahr = jahr.options[jahr.selectedIndex].value.right(2); switch (gz.toUpperCase()) { case 'A' : case 'CG' : case 'U' : case 'UR' : case 'HR' : gzcode = 1; break; /*4*/ case 'FAM' : gzcode = 2; break; /* 02.02.2005 SM */ case 'BAZ' : case 'CGA' : case 'E' : case 'HV' : case 'ST' : case 'UT' : case 'PG' : case 'PS': case 'PU': gzcode = 3; break; /*6*/ case 'BE' : case 'CGS' : case 'F' : case 'FSC' : case 'FSS' : case 'HC' : case 'HS' : case 'MSCH' : case 'NC' : case 'NS' : case 'PSCH' : case 'RV' : case 'S' : case 'SA' : case 'SE' : case 'SEU' : case 'SVV' : case 'T' : case 'UB' : case 'HST' : gzcode = 5; break; /*19*/ case 'BL' : case 'BS' : case 'OS' : case 'P' : case 'SW' : case 'JV': case 'EUM': gzcode = 7; break; /*5*/ case 'OB' : case 'OBA' : case 'OBS' : case 'R' : case 'RA' : case 'RS' : case 'HA' : gzcode = 9; break; /*6*/ default : gzcode = 0; /*43*/ }/*switch*/ /*whole number too large, split it:*/ var part1 = ger*1000 + gzcode*100 + ga;/* max 981 8aa */ /*06032003*/ var part2 = zahl + jahr;/* max 9 999 9jj */ var part1mod = part1 % 17;/*wasNumber( 06032003*/ var num = part1mod.toString() + part2;/* max 169 999 9jj */ num = Number(num) % 17; if (but) elem['PZ'+suff].value = pz.substr(num,1); return(pz.substr(num,1)); } /** * Ermittelt abhängig von der Grundbuchnummer das Bundesland *
* * @param gbnr Grundbuchnummer (5-stelliger numerischer string) * @return Zahl (Index der Grundbuchnummer * * @author Gerhard Schuster/Susanne Mauritz * @version 1.0 */ function getBL(gbnr) {/* */ if (gbnr.length!=5) return 9; var igb = Number(gbnr); if (igb>= 1000 && igb<= 1699 || igb>=1800 && igb<=1899 || igb==2001) return 0;/*W*/ if (igb>=30000 && igb<=39999) return 2;/*B*/ if (igb>=40000 && igb<=54999 || igb==2102) return 3;/*OÖ*/ if (igb>=55000 && igb<=59999 || igb==2201) return 4;/*SBG*/ if (igb>=60000 && igb<=71999 || igb==2301) return 5;/*ST*/ if (igb>=72000 && igb<=79999 || igb==2401) return 6;/*K*/ if (igb>=80000 && igb<=89999 || igb==2501) return 7;/*T*/ if (igb>=90000 && igb<=99999 || igb==2601) return 8;/*V*/ if (igb>= 1700 && igb<= 1799 || igb>=1900 && igb<=29999) return 1;/*NÖ*/ return 9; } /** * Formatieren eines Zahlenstrings im Währungsformat
* mit Tausender-Punkten und optional Nachkommastellen * * @param field {Feldobjekt} Zu formatierendes Feld * @param integ {Boolean} Nur Integer (true) oder Decimals * * @return Feld mit korrekt formatiertem Zahlenstring * * @author Susanne Mauritz, 2008 * @version 1.0 */ function formatCurrency(field,integ) {/*integ==true -> no decimals*/ var orignum = field.value; var num = orignum.replace(/^\s*/,'').replace(/\s*$/,'');/*trim*/ if (num.length==0) return( field.value='' ); if (! Fields[field.name].isValid()) return false; num = orignum.replace(/\./gi, '').replace(/,/gi, '.'); if(isNaN(num)) return false /*orignum*/; var sign = (num == (num = Math.abs(num))); num = Math.floor(num*100+0.50000000001); var cents = num%100; num = Math.floor(num/100).toString(); if (cents<10) cents = '0' + cents; if (integ && cents=='00') cents = ''; else cents = ','+cents; for (var i=0; i < Math.floor((num.length-(1+i))/3); i++) num = num.substring(0,num.length-(4*i+3))+'.'+ num.substring(num.length-(4*i+3)); field.value = (((sign)?'':'-') + num + cents); return true; } /* formatCurrency */ /** * Löschen des Feldinhaltes anderer Felder bei Änderung eines Felds
* z.B. Ort, PLZ, Bundesland - nur eines darf gefüllt sein, andere leeren * * @param fld {string} Names des aktuellen (= nicht zu leerenden) Felds * @param fldarray {string array} Feldnamen aller Felder * * @return N/A - andere Felder sind gelöscht * * @author Susanne Mauritz, 2008 * @version 1.0 */ function clearOtherFields(fld,fldarray) {/*erase other fields if one changed*/ for (var i in fldarray){ if (fldarray[i]==fld.name) continue; /* aktuelles Feld */ with (fld.form.elements[fldarray[i]]) { if (type=='text') value=''; else if (type=='select-one') selectedIndex=0; else if (type=='select-multiple') selectedIndex=0; } } /* for */ } /* clearOtherFields */ /** * Übernimmt den Feldwert eines Formularfeldes in ein anderes. *
Usage: onClick="bis2ab(this,'SDatWert4','SDatWert3')" * * @param but {Button} Schaltfläche, über welche die Aktion ausgelöst wurde * @param target {String} Name des Zielfeldes * @param source {String} Name des Quellfeldes * * @return Nothing * * @author Gerhard Schuster * @author Martin Leyrer, 2007 * @version 1.0 */ function bis2ab(but,target,source) { but.form.elements[target].value = but.form.elements[source].value; } function right(num) {/*@Right*/ return this.substr( this.length-num ); } function rightC(str) {/*@Right*/ return this.substr( 1+this.lastIndexOf(str) ); } function printObj(obj) { if (obj==null) {alert('NULL');return false;} var result=''; if (obj.name) result+= 'NAME: '+obj.name+'\n'; if (obj.id) result+= 'ID: '+obj.id+'\n'; for (var i in obj){result+=i+': '+obj[i]+'\n';} alert(result); return true; } function printObjW(obj) { var result=''; var newwindow=window.open("","printObjW") for (var i in obj){result+=i+': '+obj[i]+'
';} newwindow.document.write(result); newwindow.document.close(); } function setHtml(id,value,alrt) {/*if can't set, alert if alrt*/ var doc = document; if (doc.getElementById) { doc.getElementById(id).innerHTML = value; } else if (doc.all) { doc.all[id].innerHTML = value; } else { if (alrt) alert(value.replace(/|<\/strong>||<\/b>/gi,'').replace(/
/gi,'\n')); } } /** * Setzt den Focus in das erste Eingabefeld oder ein bestimmtes Feld *
* * @param fieldname Name eines Feldes oder leer (= erstes Eingabefeld) * @return Cursor steht in dem Feld */ function setFocus(fieldname) { if (self.document.forms.length === 0) return; var elem; if( self.document.forms['Main'] ) { // 20080101 WAI-Formular elem = self.document.forms['Main'].elements; } else { elem = self.document.forms[0].elements; } // Feldname übergeben => Fokus darauf if (fieldname) { try { elem[fieldname].focus(); } catch (ex) { //alert(ex.description) } return; } // Kein Feldname übergeben for (var i=0; i