/**
* @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; iDas Attribut "display" wird dafür auf den Wert
* "block" gesetzt.
*
* @param id {String} Name des DOM-Elemnts, das sichtbar gemacht werden soll
* @param doc {object} Document, in dem das Element sichtbar gemacht werden soll
*
* @return Nothing
*
* @author Gerhard Schuster
* @author Martin Leyrer, 2007
* @version 1.0
*/
function showId(id,doc) {
if (doc.getElementById) {
doc.getElementById(id).style.display='block';
} else {
if (doc.all) {
doc.all[id].style.display='block';
}
}
}
/**
* Macht das HTML/DOM-Element mit der übergebenen id in dem übergebenen
* Dokument unsichtbar.
Das Attribut "display" wird dafür auf den Wert
* "none" gesetzt.
*
* @param id {String} Name des DOM-Elemnts, das unsichtbar gemacht werden soll
* @param doc {object} Document, in dem das Element unsichtbar gemacht werden soll
*
* @return Nothing
*
* @author Gerhard Schuster
* @author Martin Leyrer, 2007
* @version 1.0
*/
function hideId(id,doc) {
if (doc.getElementById) {
doc.getElementById(id).style.display='none';
} else {
if (doc.all) {
doc.all[id].style.display='none';
}
}
}
/**
* Macht das HTML/DOM-Element mit der übergebenen id in dem übergebenen
* Dokument wahlweise sichtbar oder unsichtbar.
Das Attribut "display" wird dafür auf den Wert
* "none" oder "block" gesetzt.
*
* @param id {String} Name des DOM-Elemnts, dessen Sichtbarkeit verändert werden soll
* @param doc {object} Document, in dem das Element (un)sichtbar gemacht werden soll
* @param onoff {Boolean} Parameter zum Einschalten (true) oder Ausschalten (false) der Sichtbarkeit
*
* @return Nothing
*
* @author Susanne Mauritz
* @version 1.0
*/
function toggleDisplay(id,doc, onoff) {
if (doc.getElementById) {
doc.getElementById(id).style.display=onoff ? 'block' : 'none';
} else {
if (doc.all) {
doc.all[id].style.display=onoff ? 'block' : 'none';
}
}
}
/**
* Öffnet ein Hilfefenster in einer bestimmten Größe
*
* @param link {String} Link zum Dokument
* @param w {Integer} Fensterbreite (übergebener Wert oder Bildschirm - 300px)
* @param h {Integer} Fensterbreite (übergebener Wert oder Bildschirm - 300px)
* @param l {Integer} Position links (übergebener Wert oder 100px)
* @param t {Integer} Position oben (übergebener Wert oder 100px)
*
* @return Nothing
*
* @author Susanne Mauritz
* @version 1.0
*/
function helpwin(link,w,h,l,t) {/*open help window*/
var hw=(w) ? w : screen.width-300;
var hh=(h) ? h : screen.height-300;
var hl=(l) ? l : 100;
var ht=(t) ? t : 100;
var helpwindow=window.open(link,'helpwindow',
'menubar=yes,toolbar=yes,scrollbars=yes,resizable=yes,left='+
hl+',top='+ht+',width='+hw+',height='+hh);
helpwindow.focus();
}
/**
* Öffnet ein Bildfenster in einer bestimmten Größe
*
* @param link {String} Link zum Dokument
* @param wid {Integer} Fensterbreite (übergebener Wert oder Bildschirm - 300px)
* @param hei {Integer} Fensterbreite (übergebener Wert oder Bildschirm - 300px)
* @param l {Integer} Position links (übergebener Wert oder 100px)
* @param t {Integer} Position oben (übergebener Wert oder 100px)
*
* @return Nothing
*
* @author Susanne Mauritz
* @version 1.0
*/
function imgwin(link, wid, hei, l, t) {
/*test with EX, BM, public and www.sv. and LN03 !!!*/
/* if wid/hei not avlbl, use 750x500 */
/* if left/top not avlbl, use 50,50 */
var w = wid ? wid : 750;
var h = hei ? hei : 500;
w = Math.min( w + 40, screen.width-100);
h = Math.min( h + 40, screen.height-100);
var hl=(l) ? l : 50;
var ht=(t) ? t : 50;
self.status = 'Bild wird geladen b='+w+', h='+h;
var path = self.location.pathname;
var modlink = link.replace(/\+/g,'%2b').replace(/\#/g,'%23');/*escape + # chars*/
/*old Bekinsolvpub uses relative urls to itself, new EX31 absolute urls to Obj31*/
if ( modlink.search(/\.nsf\//i)<0 ) { /*no .nsf/, relative url*/
path = path.replace( /\.nsf\/.*/i , '.nsf/');/*take current path*/
modlink = path + modlink;
}
var imgwindow=self.open( modlink ,'imgwindow',
'menubar=yes,toolbar=no,scrollbars=yes,resizable=yes,dependent,'+
'left='+hl+',top='+ht+',width='+w+',height='+h);
/*keep https to avoid IE "you are leaving..." msg if on Edikte230*/
/*not necessary if img is 'proloaded' like above*/
// modlink = self.location.protocol + '//' + self.location.host + modlink;
var txt = "Klicken Sie hier zum Schließen des Fensters";
imgwindow.document.open('text/html');
imgwindow.document.writeln('' + self.document.title + '');
imgwindow.document.writeln('');
imgwindow.document.writeln('
');
imgwindow.document.close();
imgwindow.focus();
return;
}/*imgwin*/
/**
* Schaltet auf den nächsten Karteireiter (Tab) nach Eingabeüberprüfung
*
* @param tab {String} Name (=id) des Tabs, auf den gewechselt werden soll
* @param force {Boolean} Optional. Wechseln erzwingen (ohne Eingabeüberprüfung)
*
* @prereq curTab {String} Name (=id) des aktuellen Tabs. Muss implizit gesetzt sein
* @prereq dummy {Button} Schaltfläche "dummy" muss auf dem Form vorhanden sein
*
* @return Nothing
*
* @author Susanne Mauritz
* @version 1.0
*/
function setTab(tab, force) {
document.getElementById("ValidationError").innerHTML='';
ErrMsg = ""
valreturn=true;
if(tab!='00') { /* gleicher Tab 00 ignorieren (Erstladen Dokument) */
if (tab==curTab) return;
}
if (force!=true) { /* Eingabeüberprüfung erwünscht */
/* Button Handle holen, Validieren */
var but = document.getElementById('dummy') // weil tabswitching über Link, nicht über Button
// Validation benötigt eine Umgebung (Form...), die aus dem Button Dummy ermittelt wird.
// Wenn dieser nicht vorhanden, Fehlermeldung, Abbruch
if (but === null) { // kein Dummy-button
setValidationError( 'ValidationError','Anwendungsproblem: die Eingabe kann nicht überprüft werden - Referenzschaltfläche dummy nicht gefunden!');
return;
}
else {
var formx = document.getElementById('FieldList').form.name
if (!validateFields(but,curTab,formx)) { /* allgemeine Validierung */
valreturn=false;
}
}
if (valreturn==false) {
setValidationError( 'ValidationError',ErrMsg);
return;
}
if (document.getElementById("ValidationError")) { // Reset Fehlermeldung
document.getElementById("ValidationError").className = "hide"
document.getElementById("ValidationError").innerHTML = ""
}
} /* force!=true */
/* Images austauschen */
var nsrc = document.images['img'+tab].src;/*new tab source*/
/*replace img tab1x by tab0x */
document.images['img'+tab].src = nsrc.replace(/11\.gif$/, '01.gif' ); /*new img: 0x*/
nsrc = document.images['img'+curTab].src;/*old tab source*/
/*replace img tab0x by tab1x */
document.images['img'+curTab].src = nsrc.replace(/01\.gif$/, '11.gif' ); /*old img: 1x*/
showId(tab,document);
hideId(curTab,document);
curTab=tab;
} /* setTab */