comparison client/digitallibrary/navigation_ie.js @ 31:84a481a388bb

first update of new client-version
author luginbue
date Thu, 21 Feb 2002 02:27:06 +0100
parents d407cb901df4
children 930413351738
comparison
equal deleted inserted replaced
30:054ebc851059 31:84a481a388bb
1 /* navigation_ie -- JS library for digilib (IE version) 1 // this global variable has to be initialised before the frist use of the functions below
2 2 // to fill in the attributes you can use the function init provided below
3 Digital Image Library servlet components
4
5 Copyright (C) 2001, 2002 Christian Luginbuehl (luginbuehl@student.unibe.ch)
6
7 This program is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2 of the License, or (at your
10 option) any later version.
11
12 Please read license.txt for the full details. A copy of the GPL
13 may be found at http://www.gnu.org/copyleft/lgpl.html
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 */
20
21 // these two global variables have to be initialised before the frist use of the functions below
22 // to fill in the attributes you can use the function initPicture provided below
23 // - array with all attributes 3 // - array with all attributes
24 var att = new Array(); 4 var att = new Array();
25 5
26 // - variable to store the path to the frame, in which the pictures should be created 6 // fill in the values of the "att"-array
27 var whichFrame = parent.mainFrame; 7 function init(fn, pn, ws, mo, mk, wx, wy, ww, wh) {
28 8
29 // give a name to the window containing digilib - this way one can test if there is already a 9 // debug window to check the parameters passed
30 // digilib-window open and replace the contents of it (ex. digicat) 10 //alert ("DEBUG message (parameters in init):\n\npu = " + pu + "\npn = " + pn + "\nws = " + ws + "\nmo = " + mo + "\nmk = " + mk + "\nwx = " + wx + "\nwy = " + wy + "\nww = " + ww + "\nwh = " + wh);
31 window.name = "digilib"; 11
32 12 // attaching the values to the att-array
33 // function that launches the ScaleServlet 13 att[0] = fn;
34 // the different detailGrades: 14 att[1] = parseInt(pn);
35 // 0 -> back, next, page 15 att[2] = parseFloat(ws);
36 // 1 -> zoomout 16 att[3] = mo;
37 // 2 -> zoomarea, zoompoint, moveto, scaledef 17 att[4] = mk;
38 18 att[5] = parseFloat(wx);
39 function loadPicture(detailGrade, keepArea) { 19 att[6] = parseFloat(wy);
40 20 att[7] = parseFloat(ww);
41 // alert("wx: " + att[5] + "\tww: " + att[7] + "\nwy: " + att[6] + "\twh: " + att[8]); 21 att[8] = parseFloat(wh);
42
43 // sorry about that, but IE needs to have a document body to calc the frames width and height
44 whichFrame.document.open();
45 whichFrame.document.write('<html><head></head><body bgcolor="#666666" topmargin="10" leftmargin="10" marginwidth="10" magrinheight="10">');
46
47 var newPicture = "http://" + location.host + "/docuserver/digitallibrary/servlet/Scaler/"
48 newPicture += att[0] + "?" + "pn=" + att[1] + "&ws=" + att[2];
49 newPicture += "&dw=" + (whichFrame.document.body.clientWidth-30) + "&dh=" + (whichFrame.document.body.clientHeight-30);
50 newPicture += "&mo=" + att[3];
51
52 if (detailGrade == 0) {
53 att[4] = "0/0";
54 }
55
56 if ((detailGrade == 1) || (detailGrade == 0 && !keepArea)) {
57 att[5] = 0;
58 att[6] = 0;
59 att[7] = 1;
60 att[8] = 1;
61 }
62 newPicture += "&wx=" + att[5] + "&wy=" + att[6] + "&ww=" + att[7] + "&wh=" + att[8];
63
64 whichFrame.document.write('<div ID="lay1" style="position:absolute; left:10; top:10; visibility:visible"><img name="pic" src="' + newPicture + '"></div>');
65 whichFrame.document.write('<div ID="dot0" style="position:absolute; left:-20; top:100; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/mark1.gif"></div>');
66 whichFrame.document.write('<div ID="dot1" style="position:absolute; left:-20; top:100; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/mark2.gif"></div>');
67 whichFrame.document.write('<div ID="dot2" style="position:absolute; left:-20; top:100; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/mark3.gif"></div>');
68 whichFrame.document.write('<div ID="dot3" style="position:absolute; left:-20; top:100; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/mark4.gif"></div>');
69 whichFrame.document.write('<div ID="dot4" style="position:absolute; left:-20; top:100; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/mark5.gif"></div>');
70 whichFrame.document.write('<div ID="dot5" style="position:absolute; left:-20; top:100; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/mark6.gif"></div>');
71 whichFrame.document.write('<div ID="dot6" style="position:absolute; left:-20; top:100; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/mark7.gif"></div>');
72 whichFrame.document.write('<div ID="dot7" style="position:absolute; left:-20; top:100; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/mark8.gif"></div>');
73 whichFrame.document.write('<div ID="eck1" style="position:absolute; left:-20; top:120; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/olinks.gif"></div>');
74 whichFrame.document.write('<div ID="eck2" style="position:absolute; left:-20; top:140; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/orechts.gif"></div>');
75 whichFrame.document.write('<div ID="eck3" style="position:absolute; left:-20; top:160; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/ulinks.gif"></div>');
76 whichFrame.document.write('<div ID="eck4" style="position:absolute; left:-20; top:180; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/urechts.gif"></div>');
77
78 whichFrame.document.write('</body></html>');
79 22
80 whichFrame.document.close(); 23 // compatablility issue
81
82 initScripts();
83
84 pageInfo();
85
86 setmark();
87 }
88
89
90 function Backpage(keepArea) {
91
92 att[1] = parseInt(att[1]) - 1;
93
94 if (att[1] > 0) {
95 loadPicture(0, keepArea);
96 } else {
97 att[1] = parseInt(att[1]) + 1;
98 alert("You are already on the first page!");
99 }
100 }
101
102
103 function Nextpage(keepArea) {
104
105 att[1] = parseInt(att[1]) + 1;
106
107 if (att[1] <= parent.numPages) {
108 loadPicture(0, keepArea);
109 } else {
110 att[1] = parseInt(att[1]) - 1;
111 alert("You are already on the last page!");
112 }
113 }
114
115
116 function Page(keepArea) {
117
118 do {
119 page = prompt("Goto Page (1 - " + parent.numPages + "):", 1);
120 } while ((page != null) && ((page < 1) || (page > parent.numPages)));
121
122 if (page != null && page != att[1]) {
123 att[1] = page;
124 loadPicture(0, keepArea);
125 }
126 }
127
128
129 function Digicat() {
130 var url = "http://" + location.host + "/docuserver/digitallibrary/digicat.html?" + att[0] + "+" + att[1];
131 win = window.open(url, "digicat");
132 win.focus();
133 }
134
135
136 function Ref(refselect) {
137
138 var hyperlinkRef = "http://" + location.host + "/docuserver/digitallibrary/digilib.jsp?";
139 hyperlinkRef += att[0] + "+" + att[1] + "+" + att[2] + "+" + att[3] + "+" + att[4];
140
141 if ((att[5] != 0) || (att[6] != 0) || (att[7] != 1) || (att[8] != 1)) {
142 hyperlinkRef += "+" + att[5] + "+" + att[6] + "+" + att[7] + "+" + att[8];
143 }
144
145 if (refselect == 1) {
146 prompt("Link for HTML--documents", hyperlinkRef);
147 } else {
148 prompt("Link for LaTeX--documents", "\\href{" + hyperlinkRef + "}{TEXT}");
149 }
150 }
151
152
153 function Mark(refselect) {
154
155 if (att[4].split(";").length > 7) {
156 alert("Only 8 marks are possible at the moment!");
157 return;
158 }
159
160 whichFrame.document.all.lay1.onmousedown = function() {
161 e = whichFrame.event;
162
163 if ((att[4] != "") && (att[4] != "0/0")) {
164 att[4] += ";";
165 } else {
166 att[4] = "";
167 }
168
169 markX = cropFloat(att[5]+att[7]*(whichFrame.document.body.scrollLeft+e.x-parseInt(whichFrame.document.all.lay1.style.left))/whichFrame.document.all.lay1.offsetWidth);
170 markY = cropFloat(att[6]+att[8]*(whichFrame.document.body.scrollTop+e.y-parseInt(whichFrame.document.all.lay1.style.top))/whichFrame.document.all.lay1.offsetHeight);
171
172 att[4] += markX + "/" + markY;
173
174 whichFrame.document.all.lay1.cancleBubble = true;
175
176 setmark();
177 }
178 }
179
180
181 function Zoomrect() {
182 var state = 0;
183 var x1, y1, x2, y2;
184
185 function Click() {
186 e = whichFrame.event;
187
188 if (state == 0) {
189 state = 1;
190
191 x1 = whichFrame.document.body.scrollLeft+e.x;
192 y1 = whichFrame.document.body.scrollTop+e.y;
193 x2 = x1;
194 y2 = y1;
195
196 whichFrame.document.all.eck1.style.left = x1;
197 whichFrame.document.all.eck1.style.top = y1;
198 whichFrame.document.all.eck2.style.left = x2-12;
199 whichFrame.document.all.eck2.style.top = y1;
200 whichFrame.document.all.eck3.style.left = x1;
201 whichFrame.document.all.eck3.style.top = y2-12;
202 whichFrame.document.all.eck4.style.left = x2-12;
203 whichFrame.document.all.eck4.style.top = y2-12;
204
205 whichFrame.document.all.eck1.style.visibility="visible";
206 whichFrame.document.all.eck2.style.visibility="visible";
207 whichFrame.document.all.eck3.style.visibility="visible";
208 whichFrame.document.all.eck4.style.visibility="visible";
209
210 whichFrame.document.all.lay1.onmousemove = Move;
211 whichFrame.document.all.eck4.onmousemove = Move;
212
213 } else {
214
215 x1 -= parseInt(whichFrame.document.all.lay1.style.left);
216 y1 -= parseInt(whichFrame.document.all.lay1.style.top);
217
218 x2 = whichFrame.document.body.scrollLeft+e.x-parseInt(whichFrame.document.all.lay1.style.left);
219 y2 = whichFrame.document.body.scrollTop+e.y-parseInt(whichFrame.document.all.lay1.style.left);
220
221 whichFrame.document.all.eck1.visibility="hidden";
222 whichFrame.document.all.eck2.visibility="hidden";
223 whichFrame.document.all.eck3.visibility="hidden";
224 whichFrame.document.all.eck4.visibility="hidden";
225
226 whichFrame.document.all.lay1.cancleBubble = true;
227 whichFrame.document.all.eck4.cancleBubble = true;
228
229 att[5] = cropFloat(att[5]+att[7]*((x1 < x2) ? x1 : x2)/whichFrame.document.all.lay1.offsetWidth);
230 att[6] = cropFloat(att[6]+att[8]*((y1 < y2) ? y1 : y2)/whichFrame.document.all.lay1.offsetHeight);
231
232 att[7] = cropFloat(att[7]*Math.abs(x1-x2)/whichFrame.document.all.lay1.offsetWidth);
233 att[8] = cropFloat(att[8]*Math.abs(y1-y2)/whichFrame.document.all.lay1.offsetHeight);
234
235 if (att[7] != 0 && att[8] != 0) {
236 loadPicture(2);
237 }
238 }
239 }
240
241 function Move() {
242 e = whichFrame.event;
243
244 x2 = whichFrame.document.body.scrollLeft+e.x;
245 y2 = whichFrame.document.body.scrollTop+e.y;
246
247 whichFrame.document.all.eck1.style.left = ((x1 < x2) ? x1 : x2);
248 whichFrame.document.all.eck1.style.top = ((y1 < y2) ? y1 : y2);
249 whichFrame.document.all.eck2.style.left = ((x1 < x2) ? x2 : x1)-12;
250 whichFrame.document.all.eck2.style.top = ((y1 < y2) ? y1 : y2);
251 whichFrame.document.all.eck3.style.left = ((x1 < x2) ? x1 : x2);
252 whichFrame.document.all.eck3.style.top = ((y1 < y2) ? y2 : y1)-12;
253 whichFrame.document.all.eck4.style.left = ((x1 < x2) ? x2 : x1)-12;
254 whichFrame.document.all.eck4.style.top = ((y1 < y2) ? y2 : y1)-12;
255 }
256
257 whichFrame.document.all.lay1.onmousedown = Click;
258 whichFrame.document.all.eck4.onmousedown = Click;
259 }
260
261
262 function Zoomin() {
263
264 whichFrame.document.all.lay1.onmousedown = function() {
265 e = whichFrame.event;
266
267 att[5] = cropFloat(att[5]+att[7]*(whichFrame.document.body.scrollLeft+e.x-parseInt(whichFrame.document.all.lay1.style.left))/whichFrame.document.all.lay1.offsetWidth-0.5*att[7]*0.7);
268 att[6] = cropFloat(att[6]+att[8]*(whichFrame.document.body.scrollTop+e.y-parseInt(whichFrame.document.all.lay1.style.top))/whichFrame.document.all.lay1.offsetHeight-0.5*att[8]*0.7);
269
270 att[7] = cropFloat(att[7]*0.7);
271 att[8] = cropFloat(att[8]*0.7);
272
273 if (att[5] < 0) {
274 att[5] = 0;
275 }
276 if (att[6] < 0) {
277 att[6] = 0;
278 }
279 if (att[5]+att[7] > 1) {
280 att[5] = 1-att[7];
281 }
282 if (att[6]+att[8] > 1) {
283 att[6] = 1-att[8];
284 }
285
286 whichFrame.document.all.lay1.cancleBubble = true;
287
288 loadPicture(2);
289 }
290 }
291
292
293 function Zoomout() {
294 loadPicture(1);
295 }
296
297
298 function Moveto() {
299
300 whichFrame.document.all.lay1.onmousedown = function() {
301 e = whichFrame.event;
302
303 att[5] = cropFloat(att[5]+att[7]*(whichFrame.document.body.scrollLeft+e.x-parseInt(whichFrame.document.all.lay1.style.left))/whichFrame.document.all.lay1.offsetWidth-0.5*att[7]);
304 att[6] = cropFloat(att[6]+att[8]*(whichFrame.document.body.scrollTop+e.y-parseInt(whichFrame.document.all.lay1.style.top))/whichFrame.document.all.lay1.offsetHeight-0.5*att[8]);
305
306 if (att[5] < 0) {
307 att[5] = 0;
308 }
309 if (att[6] < 0) {
310 att[6] = 0;
311 }
312 if (att[5]+att[7] > 1) {
313 att[5] = 1-att[7];
314 }
315 if (att[6]+att[8] > 1) {
316 att[6] = 1-att[8];
317 }
318
319 whichFrame.document.all.lay1.cancleBubble = true;
320
321 loadPicture(2);
322 }
323 }
324
325
326 function Scaledef(scaledef) {
327
328 att[2] = scaledef;
329 loadPicture(2);
330 }
331
332
333 function setmark() {
334 if ((att[4] != "") && (att[4] != "0/0")) {
335 var mark = att[4].split(";");
336
337 var countMarks = mark.length;
338
339 // maximum of marks is 8
340 // we do not report this error because this is already done in func. "Mark"
341 if (countMarks > 8) countMarks = 8;
342
343 var picWidth = whichFrame.document.all.lay1.offsetWidth;
344 var picHeight = whichFrame.document.all.lay1.offsetHeight;
345
346 // catch the cases where the picture had not been loaded already and
347 // make a timeout so that the coordinates are calculated with the real dimensions
348 if (picWidth > 30) {
349
350 var xoffset = parseInt(whichFrame.document.all.lay1.style.left);
351 var yoffset = parseInt(whichFrame.document.all.lay1.style.top);
352
353 for (var i = 0; i < countMarks; i++) {
354 mark[i] = mark[i].split("/");
355
356 if ((mark[i][0] > att[5]) && (mark[i][1] > att[6]) && (mark[i][0] < (att[5]+att[7])) && (mark[i][1] < (att[6]+att[8]))) {
357
358 mark[i][0] = parseInt(xoffset+picWidth*(mark[i][0]-att[5])/att[7]);
359 mark[i][1] = parseInt(yoffset+picHeight*(mark[i][1]-att[6])/att[8]);
360
361 whichFrame.document.getElementById("dot" + i).style.left = mark[i][0]-5;
362 whichFrame.document.getElementById("dot" + i).style.top = mark[i][1]-5;
363 whichFrame.document.getElementById("dot" + i).style.visibility = "visible";
364 }
365 }
366 } else {
367 setTimeout("setmark()", 100);
368 }
369 }
370 }
371
372
373 // capturing keypresses for next and previous page
374 function parseKeypress() {
375 e = whichFrame.event;
376
377 if (e.keyCode == 110) {
378 Nextpage();
379 }
380 if (e.keyCode == 98) {
381 Backpage();
382 }
383 whichFrame.document.cancleBubble = true;
384 }
385
386
387 // auxiliary function to crop senseless precicsion
388 function cropFloat(tmp) {
389 return parseInt(10000*tmp)/10000;
390 }
391
392
393 // initialize browser specific things (keypress caputring)
394 function initScripts() {
395 whichFrame.document.onkeypress = parseKeypress;
396 whichFrame.focus();
397 }
398
399
400 // fill in the values of the "att"-array
401 function initPicture(picURL) {
402 att = picURL.split("+");
403
404 if (att[0].lastIndexOf("/") == att[0].length-1) {
405 att[0] = att[0].substring(0, att[0].length-1);
406 }
407
408 if (att.length < 2 || att[1] == "") {
409 att[1] = 1;
410 }
411 if (att.length < 3 || att[2] == "") {
412 att[2] = "1.0";
413 }
414
415 if (att.length < 4) {
416 att[3] = "";
417 }
418
419 if (att[3].indexOf("f") > -1) { 24 if (att[3].indexOf("f") > -1) {
420 att[3] = "fit"; 25 att[3] = "fit";
421 } 26 }
422 27
423 if (att.length < 5 || att[4] == "") {
424 att[4] = "0/0";
425 }
426
427 // converts the old mark format (0-1000) to new format(0.0 - 1.0) 28 // converts the old mark format (0-1000) to new format(0.0 - 1.0)
29 // could even be useless now
428 if (att[4] != "0/0") { 30 if (att[4] != "0/0") {
429 var tmp = att[4].split(";"); 31 var tmp = att[4].split(";");
430 32
431 att[4] = ""; 33 att[4] = "";
432 34
440 42
441 att[4] += tmp[i][0] + "/" + tmp[i][1] + ";"; 43 att[4] += tmp[i][0] + "/" + tmp[i][1] + ";";
442 } 44 }
443 att[4] = att[4].slice(0, -1); 45 att[4] = att[4].slice(0, -1);
444 } 46 }
47
48 // initialisation stuff
49 // ====================
445 50
446 if (att.length < 7) { 51 setMarks();
52
53 this.document.onkeypress = parseKeypress;
54 focus();
55
56 // give a name to the window containing digilib - this way one can test if there is already a
57 // digilib-window open and replace the contents of it (ex. digicat)
58 top.window.name = "digilib";
59 }
60
61
62 // function that launches the ScaleServlet
63 // the different detailGrades:
64 // 0 -> back, next, page
65 // 1 -> zoomout
66 // 2 -> zoomarea, zoompoint, moveto, scaledef
67
68 function loadPicture(detailGrade, keepArea) {
69
70 var newURL = "dlImage.jsp?"
71 newURL += "fn=" + att[0] + "&pn=" + att[1] + "&ws=" + att[2] + "&mo=" + att[3];
72
73 if (detailGrade == 0) {
74 att[4] = "0/0";
75 }
76
77 if ((detailGrade == 1) || (detailGrade == 0 && !keepArea)) {
447 att[5] = 0; 78 att[5] = 0;
448 att[6] = 0; 79 att[6] = 0;
449 att[7] = 1; 80 att[7] = 1;
450 att[8] = 1; 81 att[8] = 1;
451 } else { 82 }
452 att[5] = parseFloat(att[5]); 83
453 att[6] = parseFloat(att[6]); 84 newURL += "&mk=" + att[4] + "&wx=" + att[5] + "&wy=" + att[6] + "&ww=" + att[7] + "&wh=" + att[8];
454 att[7] = parseFloat(att[7]); 85 newURL += "&dw=" + (document.body.clientWidth-30) + "&dh=" + (document.body.clientHeight-30);
455 att[8] = parseFloat(att[8]); 86
456 } 87 // debug window - checking the parameters passed to the next image
457 } 88 //alert ("DEBUG MESSAGE (complete URL in loadPicture):\n\n" + newURL);
458 89
459 90 location.href = newURL;
460 function pageInfo() { 91 }
92
93
94 function backPage(keepArea) {
95
96 att[1] = parseInt(att[1]) - 1;
97
98 if (att[1] > 0) {
99 loadPicture(0, keepArea);
100 } else {
101 att[1] = parseInt(att[1]) + 1;
102 alert("You are already on the first page!");
103 }
104 }
105
106
107 function nextPage(keepArea) {
108
109 att[1] = parseInt(att[1]) + 1;
110
111 loadPicture(0, keepArea);
112 }
113
114
115 function page(keepArea) {
116
117 do {
118 page = prompt("Goto Page:", 1);
119 } while ((page != null) && (page < 1));
120
121 if (page != null && page != att[1]) {
122 att[1] = page;
123 loadPicture(0, keepArea);
124 }
125 }
126
127
128 function digicat() {
129 var url = "http://" + location.host + "/docuserver/digitallibrary/digicat.html?" + att[0] + "+" + att[1];
130 win = window.open(url, "digicat");
131 win.focus();
132 }
133
134
135 function ref(refselect) {
136
137 var hyperlinkRef = "http://" + location.host + "/docuserver/digitallibrary/digilib.jsp?";
138 hyperlinkRef += att[0] + "+" + att[1] + "+" + att[2] + "+" + att[3] + "+" + att[4];
461 139
462 // bug in netscape 4.xx (confunding px and pt) 140 if ((att[5] != 0) || (att[6] != 0) || (att[7] != 1) || (att[8] != 1)) {
463 var fontsize = document.layers ? "11pt" : "11px"; 141 hyperlinkRef += "+" + att[5] + "+" + att[6] + "+" + att[7] + "+" + att[8];
464 142 }
465 if (window.pageFrame) { 143
466 pageFrame.document.open(); 144 if (refselect == 1) {
467 pageFrame.document.write('<html><head></head><body bgcolor="#CCCCCC" topmargin="5" marginheight="5">'); 145 prompt("Link for HTML--documents", hyperlinkRef);
468 pageFrame.document.write('<p style="font-family: Verdana, Arial, Helvetica, sans-serif; text-align: center; color: #CC3333; font-size: ' + fontsize + '">'); 146 } else {
469 pageFrame.document.write(att[1] + '<b> of </b>' + numPages + '</p></body></html>'); 147 prompt("Link for LaTeX--documents", "\\href{" + hyperlinkRef + "}{TEXT}");
470 pageFrame.document.close(); 148 }
471 } 149 }
472 } 150
151
152 function mark(refselect) {
153
154 if (att[4].split(";").length > 7) {
155 alert("Only 8 marks are possible at the moment!");
156 return;
157 }
158
159 document.all.lay1.onmousedown = function() {
160 e = event;
161
162 if ((att[4] != "") && (att[4] != "0/0")) {
163 att[4] += ";";
164 } else {
165 att[4] = "";
166 }
167
168 markX = cropFloat(att[5]+att[7]*(document.body.scrollLeft+e.x-parseInt(document.all.lay1.style.left))/document.all.lay1.offsetWidth);
169 markY = cropFloat(att[6]+att[8]*(document.body.scrollTop+e.y-parseInt(document.all.lay1.style.top))/document.all.lay1.offsetHeight);
170
171 att[4] += markX + "/" + markY;
172
173 document.all.lay1.cancleBubble = true;
174
175 setMarks();
176 }
177 }
178
179
180 function zoomArea() {
181 var state = 0;
182 var x1, y1, x2, y2;
183
184 function click() {
185 e = event;
186
187 if (state == 0) {
188 state = 1;
189
190 x1 = document.body.scrollLeft+e.x;
191 y1 = document.body.scrollTop+e.y;
192 x2 = x1;
193 y2 = y1;
194
195 document.all.eck1.style.left = x1;
196 document.all.eck1.style.top = y1;
197 document.all.eck2.style.left = x2-12;
198 document.all.eck2.style.top = y1;
199 document.all.eck3.style.left = x1;
200 document.all.eck3.style.top = y2-12;
201 document.all.eck4.style.left = x2-12;
202 document.all.eck4.style.top = y2-12;
203
204 document.all.eck1.style.visibility="visible";
205 document.all.eck2.style.visibility="visible";
206 document.all.eck3.style.visibility="visible";
207 document.all.eck4.style.visibility="visible";
208
209 document.all.lay1.onmousemove = move;
210 document.all.eck4.onmousemove = move;
211
212 } else {
213
214 x1 -= parseInt(document.all.lay1.style.left);
215 y1 -= parseInt(document.all.lay1.style.top);
216
217 x2 = document.body.scrollLeft+e.x-parseInt(document.all.lay1.style.left);
218 y2 = document.body.scrollTop+e.y-parseInt(document.all.lay1.style.left);
219
220 document.all.eck1.visibility="hidden";
221 document.all.eck2.visibility="hidden";
222 document.all.eck3.visibility="hidden";
223 document.all.eck4.visibility="hidden";
224
225 document.all.lay1.cancleBubble = true;
226 document.all.eck4.cancleBubble = true;
227
228 att[5] = cropFloat(att[5]+att[7]*((x1 < x2) ? x1 : x2)/document.all.lay1.offsetWidth);
229 att[6] = cropFloat(att[6]+att[8]*((y1 < y2) ? y1 : y2)/document.all.lay1.offsetHeight);
230
231 att[7] = cropFloat(att[7]*Math.abs(x1-x2)/document.all.lay1.offsetWidth);
232 att[8] = cropFloat(att[8]*Math.abs(y1-y2)/document.all.lay1.offsetHeight);
233
234 if (att[7] != 0 && att[8] != 0) {
235 loadPicture(2);
236 }
237 }
238 }
239
240 function move() {
241 e = event;
242
243 x2 = document.body.scrollLeft+e.x;
244 y2 = document.body.scrollTop+e.y;
245
246 document.all.eck1.style.left = ((x1 < x2) ? x1 : x2);
247 document.all.eck1.style.top = ((y1 < y2) ? y1 : y2);
248 document.all.eck2.style.left = ((x1 < x2) ? x2 : x1)-12;
249 document.all.eck2.style.top = ((y1 < y2) ? y1 : y2);
250 document.all.eck3.style.left = ((x1 < x2) ? x1 : x2);
251 document.all.eck3.style.top = ((y1 < y2) ? y2 : y1)-12;
252 document.all.eck4.style.left = ((x1 < x2) ? x2 : x1)-12;
253 document.all.eck4.style.top = ((y1 < y2) ? y2 : y1)-12;
254 }
255
256 document.all.lay1.onmousedown = click;
257 document.all.eck4.onmousedown = click;
258 }
259
260
261 function zoomPoint() {
262
263 document.all.lay1.onmousedown = function() {
264 e = event;
265
266 att[5] = cropFloat(att[5]+att[7]*(document.body.scrollLeft+e.x-parseInt(document.all.lay1.style.left))/document.all.lay1.offsetWidth-0.5*att[7]*0.7);
267 att[6] = cropFloat(att[6]+att[8]*(document.body.scrollTop+e.y-parseInt(document.all.lay1.style.top))/document.all.lay1.offsetHeight-0.5*att[8]*0.7);
268
269 att[7] = cropFloat(att[7]*0.7);
270 att[8] = cropFloat(att[8]*0.7);
271
272 if (att[5] < 0) {
273 att[5] = 0;
274 }
275 if (att[6] < 0) {
276 att[6] = 0;
277 }
278 if (att[5]+att[7] > 1) {
279 att[5] = 1-att[7];
280 }
281 if (att[6]+att[8] > 1) {
282 att[6] = 1-att[8];
283 }
284
285 document.all.lay1.cancleBubble = true;
286
287 loadPicture(2);
288 }
289 }
290
291
292 function zoomOut() {
293 loadPicture(1);
294 }
295
296
297 function moveTo() {
298
299 document.all.lay1.onmousedown = function() {
300 e = event;
301
302 att[5] = cropFloat(att[5]+att[7]*(document.body.scrollLeft+e.x-parseInt(document.all.lay1.style.left))/document.all.lay1.offsetWidth-0.5*att[7]);
303 att[6] = cropFloat(att[6]+att[8]*(document.body.scrollTop+e.y-parseInt(document.all.lay1.style.top))/document.all.lay1.offsetHeight-0.5*att[8]);
304
305 if (att[5] < 0) {
306 att[5] = 0;
307 }
308 if (att[6] < 0) {
309 att[6] = 0;
310 }
311 if (att[5]+att[7] > 1) {
312 att[5] = 1-att[7];
313 }
314 if (att[6]+att[8] > 1) {
315 att[6] = 1-att[8];
316 }
317
318 document.all.lay1.cancleBubble = true;
319
320 loadPicture(2);
321 }
322 }
323
324
325 function scale(scaledef) {
326
327 att[2] = scaledef;
328 loadPicture(2);
329 }
330
331
332 function setMarks() {
333 if ((att[4] != "") && (att[4] != "0/0")) {
334 var mark = att[4].split(";");
335
336 var countMarks = mark.length;
337
338 // maximum of marks is 8
339 // we do not report this error because this is already done in func. "Mark"
340 if (countMarks > 8) countMarks = 8;
341
342 var picWidth = document.all.lay1.offsetWidth;
343 var picHeight = document.all.lay1.offsetHeight;
344
345 // catch the cases where the picture had not been loaded already and
346 // make a timeout so that the coordinates are calculated with the real dimensions
347 if (picWidth > 30) {
348
349 var xoffset = parseInt(document.all.lay1.style.left);
350 var yoffset = parseInt(document.all.lay1.style.top);
351
352 for (var i = 0; i < countMarks; i++) {
353 mark[i] = mark[i].split("/");
354
355 if ((mark[i][0] > att[5]) && (mark[i][1] > att[6]) && (mark[i][0] < (att[5]+att[7])) && (mark[i][1] < (att[6]+att[8]))) {
356
357 mark[i][0] = parseInt(xoffset+picWidth*(mark[i][0]-att[5])/att[7]);
358 mark[i][1] = parseInt(yoffset+picHeight*(mark[i][1]-att[6])/att[8]);
359
360 document.getElementById("dot" + i).style.left = mark[i][0]-5;
361 document.getElementById("dot" + i).style.top = mark[i][1]-5;
362 document.getElementById("dot" + i).style.visibility = "visible";
363 }
364 }
365 } else {
366 setTimeout("setMarks()", 100);
367 }
368 }
369 }
370
371
372 // capturing keypresses for next and previous page
373 function parseKeypress() {
374 e = event;
375
376 if (e.keyCode == 110) {
377 Nextpage();
378 }
379 if (e.keyCode == 98) {
380 Backpage();
381 }
382 document.cancleBubble = true;
383 }
384
385
386 // auxiliary function to crop senseless precicsion
387 function cropFloat(tmp) {
388 return parseInt(10000*tmp)/10000;
389 }