function ZW() { this.myh = false; this.myw = false; this.animSpeed = 15; this.LastImgWidth = 0; this.LastImgHeight = 0; this.contentLayer = 'MycontentLayer'; this.myBkgImg = 'myImageDiv'; this.globalObj = 'MyZoomWindow'; this.postEval = false; this.openoverlay = function(maxwidth,maxheight,contentUrl) { this.WidthEnd = maxwidth; this.HeightEnd = maxheight; this.centerObj(this.myBkgImg); this.zoomin(this.myBkgImg,maxwidth,maxheight); AR = new MPHR(); AR.resTarget = this.contentLayer; AR.GET(contentUrl); if(this.postEval) { AR.postEval = this.postEval; } } this.closeoverlay = function() { this.w2w(this.contentLayer,''); this.zoomout(this.myBkgImg,this.WidthEnd,this.HeightEnd); } this.centerObj = function(Obj) { X = this.pageWidth(); Y = this.pageHeight(); Vcl = document.getElementById(Obj); Vcl.style.top = Math.round((Y/2)-(this.HeightEnd/2)); Vcl.style.left = Math.round((X/2)-(this.WidthEnd/2)); Vcl.style.position = "absolute"; } this.pageWidth = function() {return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;} this.pageHeight = function() {return window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;} this.zoomin = function(zimg,maxwidth,maxheight) { var myImgObj = document.getElementById(zimg); myImgObj.style.visibility = 'visible'; myImgObj.width = maxwidth / 2; myImgObj.height = maxheight / 2; this.LastImgWidth = maxwidth; this.LastImgHeight = maxheight; thisObj = this; var t = setTimeout(function() { thisObj.scaleImg.call(thisObj,zimg,maxwidth,maxheight); },10); } this.zoomout = function(zimg,maxwidth,maxheight) { var myImgObj = document.getElementById(zimg); myImgObj.style.visibility = 'visible'; myImgObj.width = maxwidth / 2; myImgObj.height = maxheight / 2; this.LastImgWidth = maxwidth; this.LastImgHeight = maxheight; thisObj = this; var t = setTimeout(function() { thisObj.unscaleImg.call(thisObj,zimg,maxwidth,maxheight); },10); } this.w2w = function(w,s) { document.getElementById(w).innerHTML = s; } this.c2c = function(w) { return document.getElementById(w).innerHTML; } this.gobj = function(w) { return document.getElementById(w); } this.scaleImg = function(zimg,maxwidth,maxheight) { var myImgObj = document.getElementById(zimg); if(maxwidth > maxheight) { var myCoef_W = maxwidth / maxheight; var myCoef_H = 1; } else { var myCoef_H = maxheight / maxwidth; var myCoef_W = 1; } myImgObj.width = myImgObj.width + Math.round(this.animSpeed*(myCoef_W)); myImgObj.height = myImgObj.height + Math.round(this.animSpeed*(myCoef_H)); if (myImgObj.width > maxwidth ) { myImgObj.width = maxwidth; this.myw = true; } if (myImgObj.height > maxheight) { myImgObj.height = maxheight; this.myh = true; } if (this.myh == true && this.myw == true) { this.myh = false; this.myw = false; this.getObjPos(document.getElementById(zimg)); } else { thisObj = this; var t = setTimeout(function() { thisObj.scaleImg.call(thisObj,zimg,maxwidth,maxheight); },10); } } this.unscaleImg = function(zimg,maxwidth,maxheight) { var myImgObj = document.getElementById(zimg); if(maxwidth > maxheight) { var myCoef_W = maxwidth / maxheight; var myCoef_H = 1; } else { var myCoef_H = maxheight / maxwidth; var myCoef_W = 1; } myImgObj.width = myImgObj.width - Math.round(this.animSpeed*(myCoef_W)); myImgObj.height = myImgObj.height - Math.round(this.animSpeed*(myCoef_H)); if (myImgObj.width <= 5 ) { this.myw = true; } if (myImgObj.height <= 5) { this.myh = true; } if (this.myh == true && this.myw == true) { this.myh = false; this.myw = false; this.HideObj(); } else { thisObj = this; var t = setTimeout(function() { thisObj.unscaleImg.call(thisObj,zimg,maxwidth,maxheight); },10); } } this.HideObj = function() { Vo = this.gobj(this.globalObj); Vo.style.visibility = 'hidden'; Vo.style.left = 0; Vo.style.top = 0; Vo = this.gobj(this.myBkgImg); Vo.style.visibility = 'hidden'; Vo = this.gobj(this.contentLayer); Vo.style.visibility = 'hidden'; this.myh = false; this.myw = false; this.animSpeed = 15; this.LastImgWidth = 0; this.LastImgHeight = 0; this.contentLayer = 'MycontentLayer'; this.myBkgImg = 'myImageDiv'; this.globalObj = 'MyZoomWindow'; } this.getObjPos = function(Obj) { var Y = this.findPosY(Obj); var X = this.findPosX(Obj); Vcl = document.getElementById(this.contentLayer); Vcl.style.top = Y; Vcl.style.left = X; Vcl.style.width = this.LastImgWidth; Vcl.style.height = this.LastImgHeight; Vcl.style.visibility = "visible"; Vcl.style.position = "absolute"; } this.findPosY = function(obj) { var curtop = 0; if(obj.offsetParent) { while(1) { curtop += obj.offsetTop; if(!obj.offsetParent) { break; } obj = obj.offsetParent; } } else if(obj.y) { curtop += obj.y; } return curtop; } this.findPosX = function(obj) { var curleft = 0; if(obj.offsetParent) { while(1) { curleft += obj.offsetLeft; if(!obj.offsetParent) { break; } obj = obj.offsetParent; } } else if(obj.x) { curleft += obj.x; } return curleft; } } function MPHR() { this.url = ''; this.busy = false; this.xmlhttp = null; this.resTarget = false; this.resIsJs = false; this.animReq = true; this.postEval = false; // reset object properties this.reset = function() { // set unassigned event handlers this.onloading = function(){ }; this.onloaded = function(){ }; this.oninteractive = function(){ }; // this.oncomplete = function(){ }; this.onabort = function(){ }; this.onerror = function(){ }; this.url = ''; this.busy = false; this.xmlhttp = null; } this.oncomplete = function() { if(this.resIsJs) { eval(this.get_text()); } else { if(this.resTarget) { this.w2w(this.resTarget,this.get_text()); if(this.postEval) { this.EvalString(this.postEval); } } } } this.EvalString = function(eStr) { eval(eStr); } // create HTMLHTTP object this.build = function() { if (window.XMLHttpRequest) this.xmlhttp = new XMLHttpRequest(); else if (window.ActiveXObject) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); else { } } // sedn GET request this.GET = function(url) { this.build(); if (!this.xmlhttp) { this.onerror(this); return false; } if(this.resTarget) { if(this.animReq) { this.w2w(this.resTarget,"Loading"); } } var ref = this; this.url = url; this.busy = true; this.xmlhttp.onreadystatechange = function(){ ref.xmlhttp_onreadystatechange(); }; this.xmlhttp.open('GET','' + url); this.xmlhttp.send(null); }; this.POST = function(url, a_param) { // not implemented yet }; // handle onreadystatechange event this.xmlhttp_onreadystatechange = function() { if(this.xmlhttp.readyState == 1) this.onloading(this); else if(this.xmlhttp.readyState == 2) this.onloaded(this); else if(this.xmlhttp.readyState == 3) this.oninteractive(this); else if(this.xmlhttp.readyState == 4) { try { if (this.xmlhttp.status == 0) { this.onabort(this); } else if(this.xmlhttp.status == 200) { //undoTrans(this.resTarget); this.oncomplete(this); } else { this.onerror(this); } this.busy = false; } catch(err) { this.onerror(this); this.busy = false; } } } // getter method for HTTP headers this.get_header = function(name) { return this.xmlhttp.getResponseHeader(name); }; this.get_text = function() { return this.xmlhttp.responseText; }; this.get_xml = function() { return this.xmlhttp.responseXML; }; this.reset(); this.w2w = function(w,s) { document.getElementById(w).innerHTML = s; } this.c2c = function(w) { return document.getElementById(w).innerHTML; } this.gobj = function(w) { return document.getElementById(w); } } // end class