function LayerInfo (_layerId) { this.layerId = _layerId; this.setView = function(view){ this.view = view; this.layer = view.__ownerDocument.createElement ("img"); this.layer.style.position = "absolute"; this.layer.style.left = "0px"; this.layer.style.top = "0px"; this.layer.style.border='0px'; this.layer.id = "layerFor_" + this.layerId; this.layer.layerInfo = this; this.layer.onload = function () { view.leftToLoad --; if (! view.leftToLoad) { view.finalizeImage (); } }; } this.initializeImage = function (){ // This allows us to order appropriately and not have the screen go blank // We load the new image layers on top, then remove the extinct ones for(var index = 0; index < this.view.layerInfos.length; index++){ var cur = this.view.layerInfos [index]; if(this.layerId == cur.layerId){ this.view.extinctLayers.push(cur.layer); break; } } this.view.imageHolder.appendChild (this.layer); }; this.refreshImage = function () { var currentBaseUrl = this.layer.src; if (this.url != currentBaseUrl){ this.layer.src = this.url; } else { this.view.leftToLoad --; } if (! this.view.leftToLoad) { this.view.finalizeImage(); } }; this.regenerateUrl = function(){ var newIMGRAND = "IMGRAND=" + Math.round(Math.random() * 9999999999); if(this.url.indexOf("IMGRAND") >= 0){ this.url = this.url.replace(/IMGRAND=\d+/, newIMGRAND); }else{ this.url = this.url + "&" + newIMGRAND; } if(this.url.indexOf("layerId") < 0){ this.url = this.url + "&layerId=" + this.layerId; } if(this.url.indexOf("force") < 0){ this.url = this.url + "&force=true"; } } this.clone = function(){ var result = new LayerInfo(); result.visibility = this.visibility; result.layerId = this.layerId; result.regenerateUrl(); result.setView(this.view); return result; } this.deleteLayer = function(){ if(this.layer && this.layer.parentNode){ this.layer.parentNode.removeChild (this.layer); this.layer = null; } } } // Wrapper for IE, in order to be able to create LayerInfo objects // from a popup frame, for ex. function createLayerInfo (layerId) { return new LayerInfo (layerId); }