changeset 386:3b710e39823b

latest version of baselib.js and dllib.js
author robcast
date Wed, 07 Dec 2005 16:13:49 +0100
parents 0155f1c3f505
children 4189efa3bfd1
files client/digitallibrary/baselib.js client/digitallibrary/dllib.js
diffstat 2 files changed, 494 insertions(+), 371 deletions(-) [+]
line wrap: on
line diff
--- a/client/digitallibrary/baselib.js	Wed Dec 07 16:07:29 2005 +0100
+++ b/client/digitallibrary/baselib.js	Wed Dec 07 16:13:49 2005 +0100
@@ -23,7 +23,7 @@
 
 function base_init() {
     // init function
-    baseScriptVersion = "1.1.1b";
+    baseScriptVersion = "1.2";
     dlParams = new Object();
     browserType = getBrowserType();
 }
@@ -53,19 +53,19 @@
     bt.versIE = 0;
 
     if ((! document.cssonly && document.layers) || document.all || document.getElementById) {
-	var vers = navigator.appVersion.split('MSIE ');
-	vers = vers[vers.length - 1];
-	bt.versIE = getInt(vers);
-	bt.isIE = navigator.userAgent.indexOf('MSIE') >= 0;
-	bt.isMac = navigator.platform.indexOf('Mac') >= 0;
-	bt.isWin = navigator.platform.indexOf('Win') >= 0;
-	bt.isN4 = (navigator.userAgent.indexOf('Mozilla/4.') >= 0) && ! bt.isIE;
-	bt.isIEWin = bt.versIE > 0 && bt.isWin;
-	if (navigator.appVersion.indexOf('MSIE') < 0 || ! bt.isMac || bt.versIE >= 5) {
-	    bt.doDHTML = true;
-	    bt.isOpera = navigator.userAgent.indexOf(' Opera ') >= 0;
-	    bt.isKonq = navigator.userAgent.indexOf(' Konqueror') >= 0;
-	}
+        var vers = navigator.appVersion.split('MSIE ');
+        vers = vers[vers.length - 1];
+        bt.versIE = getInt(vers);
+        bt.isIE = navigator.userAgent.indexOf('MSIE') >= 0;
+        bt.isMac = navigator.platform.indexOf('Mac') >= 0;
+        bt.isWin = navigator.platform.indexOf('Win') >= 0;
+        bt.isN4 = (navigator.userAgent.indexOf('Mozilla/4.') >= 0) && ! bt.isIE;
+        bt.isIEWin = bt.versIE > 0 && bt.isWin;
+        if (navigator.appVersion.indexOf('MSIE') < 0 || ! bt.isMac || bt.versIE >= 5) {
+            bt.doDHTML = true;
+            bt.isOpera = navigator.userAgent.indexOf(' Opera ') >= 0;
+            bt.isKonq = navigator.userAgent.indexOf(' Konqueror') >= 0;
+        }
     }
     return bt;
 }
@@ -73,13 +73,13 @@
 // fixes for javascript < 1.2
 if (! Array.prototype.push) {
     Array.prototype.push = function(val) {
-	this[this.length] = val;
-	return this.length;
+        this[this.length] = val;
+        return this.length;
     }
     Array.prototype.pop = function() {
-	var val = this[this.length-1];
-	this.length -= 1;
-	return val;
+        var val = this[this.length-1];
+        this.length -= 1;
+        return val;
     }
 }
 
@@ -150,18 +150,18 @@
     // returns the intersection of the given Rectangle and this one
     var sec = rect.copy();
     if (sec.x < this.x) {
-	sec.width = sec.width - (this.x - sec.x);
-	sec.x = this.x;
+        sec.width = sec.width - (this.x - sec.x);
+        sec.x = this.x;
     }
     if (sec.y < this.y) {
-	sec.height = sec.height - (this.y - sec.y);
-	sec.y = this.y;
+        sec.height = sec.height - (this.y - sec.y);
+        sec.y = this.y;
     }
     if (sec.x + sec.width > this.x + this.width) {
-	sec.width = (this.x + this.width) - sec.x;
+        sec.width = (this.x + this.width) - sec.x;
     }
     if (sec.y + sec.height > this.y + this.height) {
-	sec.height = (this.y + this.height) - sec.y;
+        sec.height = (this.y + this.height) - sec.y;
     }
     return sec;
 }
@@ -171,10 +171,10 @@
     sec.x = Math.max(sec.x, this.x);
     sec.x = Math.max(sec.x, this.x);
     if (sec.x + sec.width > this.x + this.width) {
-	sec.x = this.x + this.width - sec.width;
+        sec.x = this.x + this.width - sec.width;
     }
     if (sec.y + sec.height > this.y + this.height) {
-	sec.y = this.y + this.height - sec.height;
+        sec.y = this.y + this.height - sec.height;
     }
     return sec.intersect(this);
 }
@@ -199,13 +199,13 @@
 Transform.prototype.concat = function(traf) {
     // add Transform traf to this Transform
     for (var i = 0; i < 3; i++) {
-	for (var j = 0; j < 3; j++) {
-	    var c = 0.0;
-	    for (var k = 0; k < 3; k++) {
-		c += traf["m"+i+k] * this["m"+k+j];
-	    }
-	    this["m"+i+j] = c;
-	}
+        for (var j = 0; j < 3; j++) {
+            var c = 0.0;
+            for (var k = 0; k < 3; k++) {
+                c += traf["m"+i+k] * this["m"+k+j];
+            }
+            this["m"+i+j] = c;
+        }
     }
     return this;
 }
@@ -214,9 +214,9 @@
     var x = this.m00 * rect.x + this.m01 * rect.y + this.m02;
     var y = this.m10 * rect.x + this.m11 * rect.y + this.m12;
     if (rect.width) {
-	var width = this.m00 * rect.width + this.m01 * rect.height;
-	var height = this.m10 * rect.width + this.m11 * rect.height;
-	return new Rectangle(x, y, width, height);
+        var width = this.m00 * rect.width + this.m01 * rect.height;
+        var height = this.m10 * rect.width + this.m11 * rect.height;
+        return new Rectangle(x, y, width, height);
     }
     return new Position(x, y);
 }
@@ -231,13 +231,13 @@
     // returns a Transform that is a rotation by angle degrees around [pos.x, pos.y]
     var traf = new Transform();
     if (angle != 0) {
-	var t = 2.0 * Math.PI * parseFloat(angle) / 360.0;
-	traf.m00 = Math.cos(t);
-	traf.m01 = - Math.sin(t);
-	traf.m10 = Math.sin(t);
-	traf.m11 = Math.cos(t);
-	traf.m02 = pos.x - pos.x * Math.cos(t) + pos.y * Math.sin(t);
-	traf.m12 = pos.y - pos.x * Math.sin(t) - pos.y * Math.cos(t);
+        var t = 2.0 * Math.PI * parseFloat(angle) / 360.0;
+        traf.m00 = Math.cos(t);
+        traf.m01 = - Math.sin(t);
+        traf.m10 = Math.sin(t);
+        traf.m11 = Math.cos(t);
+        traf.m02 = pos.x - pos.x * Math.cos(t) + pos.y * Math.sin(t);
+        traf.m12 = pos.y - pos.x * Math.sin(t) - pos.y * Math.cos(t);
     }
     return traf;
 }
@@ -264,37 +264,48 @@
 function newParameter(name, defaultValue, detail) {
     // create a new parameter with a name and a default value
     if (defined(dlParams[name])) {
-	alert("Fatal: An object with name '" + name + "' already exists - cannot recreate!");
-	return false;
+        alert("Fatal: An object with name '" + name + "' already exists - cannot recreate!");
+        return false;
     } else {
-	dlParams[name] = new Object();
-	dlParams[name].defaultValue = defaultValue;
-	dlParams[name].hasValue = false;
-	dlParams[name].value = defaultValue;
-	dlParams[name].detail = detail;
-	return dlParams[name];
+        dlParams[name] = new Object();
+        dlParams[name].defaultValue = defaultValue;
+        dlParams[name].hasValue = false;
+        dlParams[name].value = defaultValue;
+        dlParams[name].detail = detail;
+        return dlParams[name];
     }
 }
 
 function getParameter(name) {
     // returns the named parameter value or its default value
-    if (defined(dlParams) && defined(dlParams[name])) {
-	if (dlParams[name].hasValue) {
-	    return dlParams[name].value;
-	} else {
-	    return dlParams[name].defaultValue;
-	}
+    if (defined(dlParams[name])) {
+        if (dlParams[name].hasValue) {
+            return dlParams[name].value;
+        } else {
+            return dlParams[name].defaultValue;
+        }
     } else {
-	return null;
+        return null;
     }
 }
 
-function setParameter(name, value) {
-    // sets parameter value
+function setParameter(name, value, relative) {
+    // sets parameter value (relative values with +/- unless literal)
     if (defined(dlParams[name])) {
-	dlParams[name].value = value;
-	dlParams[name].hasValue = true;
-	return true;
+    	if ((relative)&&(value.slice)) {
+	    	var sign = value.slice(0,1);
+			if (sign == '+') {
+				dlParams[name].value = parseFloat(dlParams[name].value) + parseFloat(value.slice(1));
+			} else if (sign == '-') {
+				dlParams[name].value = parseFloat(dlParams[name].value) - parseFloat(value.slice(1));
+			} else {
+	        	dlParams[name].value = value;
+	        }
+	    } else {
+	        dlParams[name].value = value;
+	    }
+        dlParams[name].hasValue = true;
+        return true;
     }
     return false;
 }
@@ -302,7 +313,7 @@
 function hasParameter(name) {
     // returns if the parameter's value has been set
     if (defined(dlParams[name])) {
-	return dlParams[name].hasValue;
+        return dlParams[name].hasValue;
     }
     return false;
 }
@@ -310,16 +321,16 @@
 function getAllParameters(detail) {
     // returns a string of all parameters in query format
     if (! detail) {
-	detail = 10;
+        detail = 255;
     }
     var params = new Array();
-    for ( param in dlParams ) {
-	if ((dlParams[param].detail <= detail)&&(dlParams[param].hasValue)) {
-	    var val = getParameter(param);
-	    if (val != "") {
-		params.push(param + "=" + val);
-	    }
-	}
+    for (param in dlParams) {
+        if (((dlParams[param].detail & detail) > 0)&&(dlParams[param].hasValue)) {
+            var val = getParameter(param);
+            if (val != "") {
+                params.push(param + "=" + val);
+            }
+        }
     }
     return params.join("&");
 }
@@ -328,10 +339,10 @@
     // gets parameter values from query format string
     var params = query.split("&");
     for (var i = 0; i < params.length; i++) {
-	var keyval = params[i].split("=");
-	if (keyval.length == 2) {
-	    setParameter(keyval[0], keyval[1]);
-	}
+        var keyval = params[i].split("=");
+        if (keyval.length == 2) {
+            setParameter(keyval[0], keyval[1]);
+        }
     }
 }
 
@@ -344,20 +355,20 @@
     // returns the element object with the id tagid
     var e;
     if (document.getElementById) {
-	e = document.getElementById(tagid);
+        e = document.getElementById(tagid);
     } else if (document.all) {
-	alert("document.all!");
-	e = document.all[tagid];
+        alert("document.all!");
+        e = document.all[tagid];
     } else if (document.layers) {
         e = document.layers[tagid];
     } 
     if (e) {
-	return e;
+        return e;
     } else {
-	if (! quiet) {
-	    alert("unable to find element: "+tagid);
-	}
-	return null;
+        if (! quiet) {
+            alert("unable to find element: "+tagid);
+        }
+        return null;
     }
 }
 
@@ -366,36 +377,36 @@
     var x = 0;
     var y = 0;
     if (defined(elem.offsetLeft)) {
-	var e = elem;
-	while (e) {
-	    if (defined(e.clientLeft)) {
-		// special for IE
-		if (browserType.isMac) {
-		    if (e.offsetParent.tagName == "BODY") {
-			// IE for Mac extraspecial
-			x += e.clientLeft;
-			y += e.clientTop;
-			break;
-		    }
-		} else {
-		    if ((e.tagName != "TABLE") && (e.tagName != "BODY")) {
-			x += e.clientLeft;
-			y += e.clientTop;
-		    }
-		}
-	    }
-	    x += e.offsetLeft;
-	    y += e.offsetTop;
-	    e = e.offsetParent;
-	}
+        var e = elem;
+        while (e) {
+            if (defined(e.clientLeft)) {
+                // special for IE
+                if (browserType.isMac) {
+                    if (e.offsetParent.tagName == "BODY") {
+                        // IE for Mac extraspecial
+                        x += e.clientLeft;
+                        y += e.clientTop;
+                        break;
+                    }
+                } else {
+                    if ((e.tagName != "TABLE") && (e.tagName != "BODY")) {
+                        x += e.clientLeft;
+                        y += e.clientTop;
+                    }
+                }
+            }
+            x += e.offsetLeft;
+            y += e.offsetTop;
+            e = e.offsetParent;
+        }
     } else if (defined(elem.x)) {
-	x = elem.x;
-	y = elem.y;
+        x = elem.x;
+        y = elem.y;
     } else if (defined(elem.pageX)) {
-	x = elem.pageX;
-	y = elem.pageY;
+        x = elem.pageX;
+        y = elem.pageY;
     } else {
-	alert("unable to get position of "+elem+" (id:"+elem.id+")");
+        alert("unable to get position of "+elem+" (id:"+elem.id+")");
     }
     return new Position(getInt(x), getInt(y));
 }
@@ -405,16 +416,16 @@
     var width = 0;
     var height = 0;
     if (defined(elem.offsetWidth)) {
-	width = elem.offsetWidth;
-	height = elem.offsetHeight;
+        width = elem.offsetWidth;
+        height = elem.offsetHeight;
     } else if (defined(elem.width)) {
-	width = elem.width;
-	height = elem.height;
+        width = elem.width;
+        height = elem.height;
     } else if (defined(elem.clip.width)) {
-	width = elem.clip.width;
-	height = elem.clip.height;
+        width = elem.clip.width;
+        height = elem.clip.height;
     } else {
-	alert("unable to get size of "+elem+" (id:"+elem.id+")");
+        alert("unable to get size of "+elem+" (id:"+elem.id+")");
     }
     return new Size(getInt(width), getInt(height));
 }
@@ -431,26 +442,26 @@
 function moveElement(elem, rect) {
     // moves and sizes the element
     if (elem.style) {
-	if (defined(rect.x)) {
-	    elem.style.left = Math.round(rect.x) + "px";
-	    elem.style.top = Math.round(rect.y) + "px";
-	}
-	if (defined(rect.width)) {
-	    elem.style.width = Math.round(rect.width) + "px";
-	    elem.style.height = Math.round(rect.height) + "px";
-	}
+        if (defined(rect.x)) {
+            elem.style.left = Math.round(rect.x) + "px";
+            elem.style.top = Math.round(rect.y) + "px";
+        }
+        if (defined(rect.width)) {
+            elem.style.width = Math.round(rect.width) + "px";
+            elem.style.height = Math.round(rect.height) + "px";
+        }
     } else if (document.layers) {
-	if (defined(rect.x)) {
-	    elem.pageX = getInt(rect.x);
-	    elem.pageY = getInt(rect.y);
-	}
-	if (defined(rect.width)) {
-	    elem.clip.width = getInt(rect.width);
-	    elem.clip.height = getInt(rect.height);
-	}
+        if (defined(rect.x)) {
+            elem.pageX = getInt(rect.x);
+            elem.pageY = getInt(rect.y);
+        }
+        if (defined(rect.width)) {
+            elem.clip.width = getInt(rect.width);
+            elem.clip.height = getInt(rect.height);
+        }
     } else {
-    	alert("moveelement: no style nor layer property!");
-	return false;
+        alert("moveelement: no style nor layer property!");
+        return false;
     }
     return true;
 }
@@ -458,19 +469,19 @@
 function showElement(elem, show) {
     // shows or hides the element
     if (elem.style) {
-	if (show) {
-	    elem.style.visibility = "visible";
-	} else {
-	    elem.style.visibility = "hidden";
-	}
+        if (show) {
+            elem.style.visibility = "visible";
+        } else {
+            elem.style.visibility = "hidden";
+        }
     } else if (defined(elem.visibility)) {
-	if (show) {
-	    elem.visibility = "show";
-	} else {
-	    elem.visibility = "hide";
-	}
+        if (show) {
+            elem.visibility = "show";
+        } else {
+            elem.visibility = "hide";
+        }
     } else {
-	alert("showelement: no style nor layer property!");
+        alert("showelement: no style nor layer property!");
     }
     return true;
 }
@@ -481,17 +492,17 @@
     var y;
     evt = (evt) ? evt : window.event;
     if (!evt) {
-	alert("no event found! "+evt);
-	return;
+        alert("no event found! "+evt);
+        return;
     }
     if (defined(evt.pageX)) {
-	x = parseInt(evt.pageX);
-	y = parseInt(evt.pageY);
+        x = parseInt(evt.pageX);
+        y = parseInt(evt.pageY);
     } else if (defined(evt.clientX)) {
-	x = parseInt(document.body.scrollLeft+evt.clientX);
-	y = parseInt(document.body.scrollTop+evt.clientY);
+        x = parseInt(document.body.scrollLeft+evt.clientX);
+        y = parseInt(document.body.scrollTop+evt.clientY);
     } else {
-	alert("evtPosition: don't know how to deal with "+evt);
+        alert("evtPosition: don't know how to deal with "+evt);
     }
     return new Position(x, y);
 }
@@ -499,32 +510,32 @@
 function registerEvent(type, elem, handler) {
     // register the given event handler on the indicated element
     if (elem.addEventListener) {
-	elem.addEventListener(type, handler, false);
+        elem.addEventListener(type, handler, false);
     } else {
-	if (type == "mousedown") {
-	    if (elem.captureEvents) {
-		elem.captureEvents(Event.MOUSEDOWN);
-	    }
-	    elem.onmousedown = handler;
-	} else if (type == "mouseup") {
-	    if (elem.captureEvents) {
-		elem.captureEvents(Event.MOUSEUP);
-	    }
-	    elem.onmouseup = handler;
-	} else if (type == "mousemove") {
-	    if (elem.captureEvents) {
-		elem.captureEvents(Event.MOUSEMOVE);
-	    }
-	    elem.onmousemove = handler;
-	} else if (type == "keypress") {
-	    if (elem.captureEvents) {
-		elem.captureEvents(Event.KEYPRESS);
-	    }
-	    elem.onkeypress = handler;
-	} else {
-	    alert("registerEvent: unknown event type "+type);
-	    return false;
-	}
+        if (type == "mousedown") {
+            if (elem.captureEvents) {
+                elem.captureEvents(Event.MOUSEDOWN);
+            }
+            elem.onmousedown = handler;
+        } else if (type == "mouseup") {
+            if (elem.captureEvents) {
+                elem.captureEvents(Event.MOUSEUP);
+            }
+            elem.onmouseup = handler;
+        } else if (type == "mousemove") {
+            if (elem.captureEvents) {
+                elem.captureEvents(Event.MOUSEMOVE);
+            }
+            elem.onmousemove = handler;
+        } else if (type == "keypress") {
+            if (elem.captureEvents) {
+                elem.captureEvents(Event.KEYPRESS);
+            }
+            elem.onkeypress = handler;
+        } else {
+            alert("registerEvent: unknown event type "+type);
+            return false;
+        }
     }
     return true;
 }
@@ -532,32 +543,32 @@
 function unregisterEvent(type, elem, handler) {
     // unregister the given event handler from the indicated element
     if (elem.removeEventListener) {
-	elem.removeEventListener(type, handler, false);
+        elem.removeEventListener(type, handler, false);
     } else {
-	if (type == "mousedown") {
-	    if (elem.releaseEvents) {
-		elem.releaseEvents(Event.MOUSEDOWN);
-	    }
-	    elem.onmousedown = null;
-	} else if (type == "mouseup") {
-	    if (elem.releaseEvents) {
-		elem.releaseEvents(Event.MOUSEUP);
-	    }
-	    elem.onmouseup = null;
-	} else if (type == "mousemove") {
-	    if (elem.releaseEvents) {
-		elem.releaseEvents(Event.MOUSEMOVE);
-	    }
-	    elem.onmousemove = null;
-	} else if (type == "keypress") {
-	    if (elem.releaseEvents) {
-		elem.releaseEvents(Event.KEYPRESS);
-	    }
-	    elem.onkeypress = null;
-	} else {
-	    alert("unregisterEvent: unknown event type "+type);
-	    return false;
-	}
+        if (type == "mousedown") {
+            if (elem.releaseEvents) {
+                elem.releaseEvents(Event.MOUSEDOWN);
+            }
+            elem.onmousedown = null;
+        } else if (type == "mouseup") {
+            if (elem.releaseEvents) {
+                elem.releaseEvents(Event.MOUSEUP);
+            }
+            elem.onmouseup = null;
+        } else if (type == "mousemove") {
+            if (elem.releaseEvents) {
+                elem.releaseEvents(Event.MOUSEMOVE);
+            }
+            elem.onmousemove = null;
+        } else if (type == "keypress") {
+            if (elem.releaseEvents) {
+                elem.releaseEvents(Event.KEYPRESS);
+            }
+            elem.onkeypress = null;
+        } else {
+            alert("unregisterEvent: unknown event type "+type);
+            return false;
+        }
     }
     return true;
 }
@@ -585,24 +596,24 @@
     // returns a Size with the current window size (mostly from www.quirksmode.org)
     var wsize = new Size(100, 100);
     if (defined(self.innerHeight))  {
-	// all except Explorer
-	if ((self.innerWidth == 0)||(self.innerHeight == 0)) {
-	    // Safari 1.2 bug
-	    if (parent) {
-		parent.innerHeight;
-		parent.innerWidth;
-	    }
-	}
-	wsize.width = self.innerWidth;
-	wsize.height = self.innerHeight;
+        // all except Explorer
+        if ((self.innerWidth == 0)||(self.innerHeight == 0)) {
+            // Safari 1.2 bug
+            if (parent) {
+                parent.innerHeight;
+                parent.innerWidth;
+            }
+        }
+        wsize.width = self.innerWidth;
+        wsize.height = self.innerHeight;
     } else if (document.documentElement && document.documentElement.clientHeight) {
-	// Explorer 6 Strict Mode
-	wsize.width = document.documentElement.clientWidth;
-	wsize.height = document.documentElement.clientHeight;
+        // Explorer 6 Strict Mode
+        wsize.width = document.documentElement.clientWidth;
+        wsize.height = document.documentElement.clientHeight;
     } else if (document.body) {
-	// other Explorers
-	wsize.width = document.body.clientWidth;
-	wsize.height = document.body.clientHeight;
+        // other Explorers
+        wsize.width = document.body.clientWidth;
+        wsize.height = document.body.clientHeight;
     }
     return wsize;
 }
--- a/client/digitallibrary/dllib.js	Wed Dec 07 16:07:29 2005 +0100
+++ b/client/digitallibrary/dllib.js	Wed Dec 07 16:13:49 2005 +0100
@@ -17,7 +17,7 @@
 Authors:
   Christian Luginbuehl, 01.05.2003 (first version)
   DW 24.03.2004 (Changed for digiLib in Zope)
-  Robert Casties, 2.11.2004
+  Robert Casties, 8.11.2005
 
   ! Requires baselib.js !
 
@@ -25,9 +25,9 @@
 
 
 function identify() {
-	// used for identifying a digilib instance
-	// Relato uses that function - lugi
-	return "Digilib 0.6";
+        // used for identifying a digilib instance
+        // Relato uses that function - lugi
+        return "Digilib 0.6";
 }
 
 
@@ -78,16 +78,16 @@
     var ma;
     var mk = getParameter("mk");
     if (mk.indexOf(";") >= 0) {
-	// old format with ";"
-	ma = mk.split(";");
+        // old format with ";"
+        ma = mk.split(";");
     } else {
-	ma = mk.split(",");
+        ma = mk.split(",");
     }
     for (var i = 0; i < ma.length ; i++) {
-	var pos = ma[i].split("/");
-	if (pos.length > 1) {
-	    marks.push(new Position(pos[0], pos[1]));
-	}
+        var pos = ma[i].split("/");
+        if (pos.length > 1) {
+            marks.push(new Position(pos[0], pos[1]));
+        }
     }
     return marks;
 }
@@ -96,7 +96,7 @@
     // returns a string with all marks in query format
     var marks = new Array();
     for (var i = 0; i < dlMarks.length; i++) {
-	marks.push(cropFloat(dlMarks[i].x) + "/" + cropFloat(dlMarks[i].y));
+        marks.push(cropFloat(dlMarks[i].x) + "/" + cropFloat(dlMarks[i].y));
     }
     return marks.join(",");
 }
@@ -130,7 +130,7 @@
 function removeFlag(mode) {
     // remove a mode flag
     if (dlFlags[mode]) {
-	delete dlFlags[mode];
+        delete dlFlags[mode];
     }
     setParameter("mo", getAllFlags());
     return true;
@@ -139,9 +139,9 @@
 function toggleFlag(mode) {
     // change a mode flag
     if (dlFlags[mode]) {
-	delete dlFlags[mode];
+        delete dlFlags[mode];
     } else {
-	dlFlags[mode] = mode;
+        dlFlags[mode] = mode;
     }
     setParameter("mo", getAllFlags());
     return true;
@@ -151,9 +151,9 @@
     // returns a string with all flags in query format
     var fa = new Array();
     for (var f in dlFlags) {
-	if ((f != "")&&(dlFlags[f] != null)) {
-	    fa.push(f);
-	}
+        if ((f != "")&&(dlFlags[f] != null)) {
+            fa.push(f);
+        }
     }
     return fa.join(",");
 }
@@ -163,10 +163,10 @@
     var flags = new Object();
     var fa = getParameter("mo").split(",");
     for (var i = 0; i < fa.length ; i++) {
-	var f = fa[i];
-	if (f != "") {
-	    flags[f] = f;
-	}
+        var f = fa[i];
+        if (f != "") {
+            flags[f] = f;
+        }
     }
     return flags;
 }    
@@ -175,17 +175,37 @@
 function bestPicSize(elem, inset) {
     // returns a Size with the best image size for the given element
     if (! defined(inset)) {
-	inset = 25;
+        inset = 25;
     }
     var ws = getWinSize();
     var es = getElementPosition(elem);
     if (es) {
-	ws.width = ws.width - es.x - inset;
-	ws.height = ws.height - es.y - inset;
+        ws.width = ws.width - es.x - inset;
+        ws.height = ws.height - es.y - inset;
     }
     return ws;
 }
 
+function setDLParam(e, s, relative) {
+	// sets parameter based on HTML event
+	var nam;
+    var val;
+    if (s.type && (s.type == "select-one")) {
+        nam = s.name;
+        val = s.options[s.selectedIndex].value;
+    } else if (s.name && s.value) {
+        nam = s.name;
+        val = s.value;
+    }
+    if (nam && val) {
+        setParameter(nam, val, relative);
+        display();
+    } else {
+        alert("ERROR: unable to process event!");
+    }
+    return true;
+}
+
 
 /* **********************************************
  *     digilib specific routines
@@ -195,9 +215,9 @@
 function dl_param_init() {
     // parameter initialisation before onload
     if (!baseScriptVersion) {
-	base_init();
+        base_init();
     }
-    dlScriptVersion = "1.1b";
+    dlScriptVersion = "1.2b";
     dlArea = new Rectangle(0.0, 0.0, 1.0, 1.0);
     dlMaxArea = new Rectangle(0.0, 0.0, 1.0, 1.0);
     dlTrafo = new Transform();
@@ -219,23 +239,23 @@
 function dl_init() {
     // initalisation on load
     if (!dlScriptVersion) {
-	dl_param_init();
+        dl_param_init();
     }
     elemScaler = getElement("scaler", true);
     picElem = getElement("pic", true);
     if (picElem == null && elemScaler) {
-	// in N4 pic is in the scaler layer
-	picElem = elemScaler.document.images[0];
+        // in N4 pic is in the scaler layer
+        picElem = elemScaler.document.images[0];
     }
     if ((!elemScaler)||(!picElem)) {
-	alert("Sorry, zogilib doesn't work here!");
-	return false;
+        alert("Sorry, digilib doesn't work here!");
+        return false;
     }
     // give a name to the window containing digilib
     if (defined(dlTarget)&&(dlTarget)) {
-	window.name = dlTarget;
+        window.name = dlTarget;
     } else {
-	window.name = "digilib";
+        window.name = "digilib";
     }
     // put the query parameters (sans "?") in the parameters array
     parseParameters(location.search.slice(1));
@@ -254,7 +274,7 @@
 function display(detail) {
     // redisplay the page
     if (! detail) {
-	detail = 9;
+        detail = 255;
     }
     var queryString = getAllParameters(detail);
     location.href = location.protocol + "//" + location.host + location.pathname + "?" + queryString;
@@ -271,25 +291,25 @@
     var mark_count = dlMarks.length;
     // make shure the image is loaded so we know its size
     if (defined(picElem.complete) && picElem.complete == false && ! browserType.isN4 ) {
-	setTimeout("renderMarks()", 100);
+        setTimeout("renderMarks()", 100);
     } else {
-	dlTrafo = parseTrafo(picElem);
-	for (var i = 0; i < 8; i++) {
-	    var me = getElement("dot"+i);
-	    if (i < mark_count) {
-		if (dlArea.containsPosition(dlMarks[i])) {
-		    var mpos = dlTrafo.transform(dlMarks[i]);
-		    // suboptimal to place -5 pixels and not half size of mark-image
-		    mpos.x = mpos.x -5;
-		    mpos.y = mpos.y -5;
-		    moveElement(me, mpos);
-		    showElement(me, true);
-		}
-	    } else {
-		// hide the other marks
-		showElement(me, false);
-	    }
-	}
+        dlTrafo = parseTrafo(picElem);
+        for (var i = 0; i < 8; i++) {
+            var me = getElement("dot"+i);
+            if (i < mark_count) {
+                if (dlArea.containsPosition(dlMarks[i])) {
+                    var mpos = dlTrafo.transform(dlMarks[i]);
+                    // suboptimal to place -5 pixels and not half size of mark-image
+                    mpos.x = mpos.x -5;
+                    mpos.y = mpos.y -5;
+                    moveElement(me, mpos);
+                    showElement(me, true);
+                }
+            } else {
+                // hide the other marks
+                showElement(me, false);
+            }
+        }
     }
 }
 
@@ -297,22 +317,22 @@
 function setMark(reload) {
     // add a mark where clicked
     if ( dlMarks.length > 7 ) {
-	alert("Only 8 marks are possible at the moment!");
-	return;
+        alert("Only 8 marks are possible at the moment!");
+        return;
     }
     window.focus();
 
     function markEvent(evt) {
-	// event handler adding a new mark
-	unregisterEvent("mousedown", elemScaler, markEvent);
-	var p = dlTrafo.invtransform(evtPosition(evt));
-	addMark(p);
-	if (defined(reload)&&(!reload)) {
-	    // don't redisplay
-	    renderMarks();
-	    return;
-	}
-	display();
+        // event handler adding a new mark
+        unregisterEvent("mousedown", elemScaler, markEvent);
+        var p = dlTrafo.invtransform(evtPosition(evt));
+        addMark(p);
+        if (defined(reload)&&(!reload)) {
+            // don't redisplay
+            renderMarks();
+            return;
+        }
+        display();
     }
 
     // starting event capture
@@ -324,9 +344,9 @@
     // remove the last mark
     deleteMark();
     if (defined(reload)&&(!reload)) {
-	// don't redisplay
-	renderMarks();
-	return;
+        // don't redisplay
+        renderMarks();
+        return;
     }
     display();
 }
@@ -343,70 +363,70 @@
     var eck4 = getElement("eck4");
 
     function zoomClick(evt) {
-	// mouse click handler
-	if (click == 1) {
-	    // first click -- start moving
-	    click = 2;
-	    pt1 = evtPosition(evt);
-	    pt2 = pt1;
-	    eck1pos = pt1;
-	    eck2pos = new Position(pt1.x - 12, pt1.y);
-	    eck3pos = new Position(pt1.x, pt1.y - 12);
-	    eck4pos = new Position(pt1.y - 12, pt1.y - 12);
-	    moveElement(eck1, eck1pos);
-	    moveElement(eck2, eck2pos);
-	    moveElement(eck3, eck3pos);
-	    moveElement(eck4, eck4pos);
-	    showElement(eck1, true);
-	    showElement(eck2, true);
-	    showElement(eck3, true);
-	    showElement(eck4, true);
-	    // show moving
-	    registerEvent("mousemove", elemScaler, zoomMove);
-	    registerEvent("mousemove", eck4, zoomMove);
-	    // enable drag-to-zoom
-	    registerEvent("mouseup", elemScaler, zoomClick);
-	    registerEvent("mouseup", eck4, zoomClick);
-	} else {
-	    // second click -- end moving
-	    pt2 = evtPosition(evt);
-	    showElement(eck1, false);
-	    showElement(eck2, false);
-	    showElement(eck3, false);
-	    showElement(eck4, false);
-	    unregisterEvent("mousemove", elemScaler, zoomMove);
-	    unregisterEvent("mousemove", eck4, zoomMove);
-	    unregisterEvent("mousedown", elemScaler, zoomClick);
-	    unregisterEvent("mousedown", eck4, zoomClick);
-	    var p1 = dlTrafo.invtransform(pt1);
-	    var p2 = dlTrafo.invtransform(pt2);
-	    var ww = p2.x-p1.x;
-	    var wh = p2.y-p1.y;
-	    if ((ww > 0)&&(wh > 0)) {
-		setParameter("wx", cropFloat(p1.x));
-		setParameter("wy", cropFloat(p1.y));
-		setParameter("ww", cropFloat(ww));
-		setParameter("wh", cropFloat(wh));
-		parseArea();
-		// zoomed is always fit
-		setParameter("ws", 1);
-		display();
-	    }
-	}
+        // mouse click handler
+        if (click == 1) {
+            // first click -- start moving
+            click = 2;
+            pt1 = evtPosition(evt);
+            pt2 = pt1;
+            eck1pos = pt1;
+            eck2pos = new Position(pt1.x - 12, pt1.y);
+            eck3pos = new Position(pt1.x, pt1.y - 12);
+            eck4pos = new Position(pt1.y - 12, pt1.y - 12);
+            moveElement(eck1, eck1pos);
+            moveElement(eck2, eck2pos);
+            moveElement(eck3, eck3pos);
+            moveElement(eck4, eck4pos);
+            showElement(eck1, true);
+            showElement(eck2, true);
+            showElement(eck3, true);
+            showElement(eck4, true);
+            // show moving
+            registerEvent("mousemove", elemScaler, zoomMove);
+            registerEvent("mousemove", eck4, zoomMove);
+            // enable drag-to-zoom
+            registerEvent("mouseup", elemScaler, zoomClick);
+            registerEvent("mouseup", eck4, zoomClick);
+        } else {
+            // second click -- end moving
+            pt2 = evtPosition(evt);
+            showElement(eck1, false);
+            showElement(eck2, false);
+            showElement(eck3, false);
+            showElement(eck4, false);
+            unregisterEvent("mousemove", elemScaler, zoomMove);
+            unregisterEvent("mousemove", eck4, zoomMove);
+            unregisterEvent("mousedown", elemScaler, zoomClick);
+            unregisterEvent("mousedown", eck4, zoomClick);
+            var p1 = dlTrafo.invtransform(pt1);
+            var p2 = dlTrafo.invtransform(pt2);
+            var ww = p2.x-p1.x;
+            var wh = p2.y-p1.y;
+            if ((ww > 0)&&(wh > 0)) {
+                setParameter("wx", cropFloat(p1.x));
+                setParameter("wy", cropFloat(p1.y));
+                setParameter("ww", cropFloat(ww));
+                setParameter("wh", cropFloat(wh));
+                parseArea();
+                // zoomed is always fit
+                setParameter("ws", 1);
+                display();
+            }
+        }
     }
 
     function zoomMove(evt) {
-	// mouse move handler
-	pt2 = evtPosition(evt);
-	// restrict marks to move right and down
-	eck1pos = pt1;
-	eck2pos = new Position(Math.max(pt1.x, pt2.x)-12, pt1.y);
-	eck3pos = new Position(pt1.x, Math.max(pt1.y, pt2.y)-12);
-	eck4pos = new Position(Math.max(pt1.x, pt2.x)-12, Math.max(pt1.y, pt2.y)-12);
-	moveElement(eck1, eck1pos);
-	moveElement(eck2, eck2pos);
-	moveElement(eck3, eck3pos);
-	moveElement(eck4, eck4pos);
+        // mouse move handler
+        pt2 = evtPosition(evt);
+        // restrict marks to move right and down
+        eck1pos = pt1;
+        eck2pos = new Position(Math.max(pt1.x, pt2.x)-12, pt1.y);
+        eck3pos = new Position(pt1.x, Math.max(pt1.y, pt2.y)-12);
+        eck4pos = new Position(Math.max(pt1.x, pt2.x)-12, Math.max(pt1.y, pt2.y)-12);
+        moveElement(eck1, eck1pos);
+        moveElement(eck2, eck2pos);
+        moveElement(eck3, eck3pos);
+        moveElement(eck4, eck4pos);
     }
 
     // starting event capture
@@ -440,21 +460,21 @@
 function moveCenter() {
     // move visible area so that it's centered around the clicked point
     if ( (dlArea.width == 1.0) && (dlArea.height == 1.0) ) {
-	// noting to do
-	return;
+        // nothing to do
+        return;
     }
     window.focus();
 
     function moveCenterEvent(evt) {
-	// move to handler
-	unregisterEvent("mousedown", elemScaler, moveCenterEvent);
-	var pt = dlTrafo.invtransform(evtPosition(evt));
-	var newarea = new Rectangle(pt.x-0.5*dlArea.width, pt.y-0.5*dlArea.height, dlArea.width, dlArea.height);
-	newarea = dlMaxArea.fit(newarea);
-	// set parameters
-	setParamFromArea(newarea);
-	parseArea();
-	display();
+        // move to handler
+        unregisterEvent("mousedown", elemScaler, moveCenterEvent);
+        var pt = dlTrafo.invtransform(evtPosition(evt));
+        var newarea = new Rectangle(pt.x-0.5*dlArea.width, pt.y-0.5*dlArea.height, dlArea.width, dlArea.height);
+        newarea = dlMaxArea.fit(newarea);
+        // set parameters
+        setParamFromArea(newarea);
+        parseArea();
+        display();
     }
 
     // starting event capture
@@ -462,10 +482,10 @@
 }
 
 function moveBy(movx, movy) {
-    // move visible area by movx and movy (in units of dw, dh)
+    // move visible area by movx and movy (in units of ww, wh)
     if ((dlArea.width == 1.0)&&(dlArea.height == 1.0)) {
-	// nothing to do
-	return;
+        // nothing to do
+        return;
     }
     var newarea = dlArea.copy();
     newarea.x += parseFloat(movx)*dlArea.width;
@@ -477,18 +497,15 @@
     display();
 }
 
-    
-
-
 function getRef() {
     // returns a reference to the current digilib set
     if (! baseUrl) {
-	var baseUrl = location.protocol + "//" + location.host + location.pathname;
+        var baseUrl = location.protocol + "//" + location.host + location.pathname;
     }
     var hyperlinkRef = baseUrl;
-    var par = getAllParameters(9);
+    var par = getAllParameters(7+16); // all without ddpi, pt
     if (par.length > 0) {
-	hyperlinkRef += "?" + par;
+        hyperlinkRef += "?" + par;
     }
     return hyperlinkRef;
 }
@@ -496,7 +513,102 @@
 function getRefWin(type, msg) {
     // shows an alert with a reference to the current digilib set
     if (! msg) {
-	msg = "Link for HTML documents";
+        msg = "Link for HTML documents";
     }
     prompt(msg, getRef());
 }
+
+function getQuality() {
+	// returns the current q setting
+    for (var i = 0; i < 3; i++) {
+        if (hasFlag("q"+i)) {
+        	return i;
+        }
+    }
+    return 1
+}
+
+function setQuality(qual) {
+    // set the image quality
+    for (var i = 0; i < 3; i++) {
+        removeFlag("q"+i);
+        if (i == qual) {
+            addFlag("q"+i);
+        }
+    }
+    setParameter("mo", getAllFlags());
+    display();
+}    
+
+function setQualityWin(msg) {
+	// dialog for setting quality
+	if (! msg) {
+		msg = "Quality (0..2)";
+	}
+	var q = getQuality();
+	var newq = window.prompt(msg, q);
+	if (newq) {
+		setQuality(newq);
+	}
+}
+
+function mirror(dir) {
+    // mirror the image horizontally or vertically
+    if (dir == "h") {
+        toggleFlag("hmir");
+    } else {
+        toggleFlag("vmir");
+    }
+    setParameter("mo", getAllFlags());
+    display();
+}
+
+function gotoPage(gopage, keep) {
+	// goto given page nr (+/-: relative)
+	var oldpn = parseInt(getParameter("pn"));
+	setParameter("pn", gopage, true);
+	var pn = parseInt(getParameter("pn"));
+	if (pn < 1) {
+		alert("No such page! (Page number too low)");
+		setParameter("pn", oldpn);
+		return;
+	}
+	if (hasParameter("pt")) {
+		pt = parseInt(getParameter("pt"))
+		if (pn > pt) {
+			alert("No such page! (Page number too high)");
+			setParameter("pn", oldpn);
+			return;
+		}
+	}
+	if (keep) {
+		display(15+32); // all, no mark
+	} else {	
+		display(3+32); // fn, pn, ws, mo + pt
+	}
+}
+
+function gotoPageWin() {
+	// dialog to ask for new page nr
+	var pn = getParameter("pn");
+	var gopage = window.prompt("Go to page", pn);
+	if (gopage) {
+		gotoPage(gopage);
+	}
+}
+
+function setParamWin(param, text, relative) {
+	// dialog to ask for new parameter value
+	var val = getParameter(param);
+	var newval = window.prompt(text, val);
+	if (newval) {
+		setParameter(param, newval, relative);
+		display();
+	}
+}
+
+function showOptions(show) {
+	// show or hide option div
+	var elem = getElement("dloptions");
+	showElement(elem, show);
+}
\ No newline at end of file