/* File: dhtml_api_v3.js * Include: * * This code is specific to DOM Level 1, Microsoft Internet Explorer 4+ and Netscape Navigator 4+ * Based upon code found in "JavaScript - The Definitive Guide (3rd Edition)" by David Flanagan * O'Reilly Publishing - Chapter 17, Page 326. * * Modified for my own style and needs. * April 28, 2000 */ // LAST MODIFIED 9/26/2002 // // DEFINE Global Variables// var DL1 = (document.implementation && document.implementation.hasFeature && document.implementation.hasFeature("html","1.0")) ? true : false; var IE4 = ((navigator.appName.indexOf("Microsoft") != -1) && document.all) ? true : false; var NS4 = ((navigator.appName.indexOf("Netscape") != -1) && document.layers) ? true : false; // For old browsers // if (!(DL1) && !(IE4) && !(NS4)) { alert ("This page contains Dynamic elements that your browser does not support."); window.onerror = function() { return true }; } // This is for Navigators resize bug. Stolen from Dreamweaver. // function reloadPage(init) { if (init == true) { if (NS4) { document.pageWidth = innerWidth; document.pageHeight = innerHeight; onresize = reloadPage; } } else if (innerWidth != document.pageWidth || innerHeight != document.pageHeight) location.reload(); } if (NS4) { reloadPage(true); } // Object constructor. // // REMEMBER to call the init() method of the dynLayer after the page loads // function dynLayer(oWin, sName, x, y, w, h, z, DEBUG){ this.window = oWin; this.name = sName; this.id = sName.replace(/\W/g,"") + "Id"; this.x = x; this.y = y; this.w = w; this.h = h; this.z = z; if (DEBUG) { alert("Name: " + sName + " x: " + x + " y: " + y + " w: " + w + " h: " + h + " z: " + z); } } dynLayer.prototype.custEvents = ""; dynLayer.prototype.custCSS = ""; // This is for outputting the Layer CSS information. // dynLayer.prototype.outputStyle = function(VISIBLE, DEBUG) { var isVisible = (VISIBLE) ? "visible" : "hidden"; var debugBorder = (DEBUG) ? "border: 1px Solid Red; " : ""; var HTML = ''; this.window.document.write(HTML); if (DEBUG) { alert(HTML); } } // use this if you want to automatically output the layer // // IMPORTANT: you can only call this from withing the // dynLayer.prototype.outputLayer = function(BODY,DEBUG) { var bodyHtml = (BODY) ? BODY : " "; var HTML = '
' + bodyHtml + '
'; this.window.document.write(HTML); if (DEBUG) { alert(HTML); } } dynLayer.prototype.outputIFrame = function(SRC,SCROLL,MWIDTH,MHEIGHT,DEBUG) { var scrolling = (SCROLL) ? "yes" : "no"; var html = '' this.window.document.write(html); if (DEBUG) { alert(html); } } // DOM Level 1 Portion // if (DL1) { window.status = "Using DOM Level 1"; dynLayer.prototype.init = function() { var doc = this.window.document; this.element = doc.getElementById(this.id); this.style = this.element.style; this.moveTo(this.x,this.y); this.setWidth(this.w); this.setHeight(this.h); } dynLayer.prototype.moveTo = function(x,y) { this.style.left = x + "px"; this.style.top = y + "px"; } dynLayer.prototype.moveBy = function(x,y) { this.style.left = (this.getX() + x) + "px"; this.style.top = (this.getY() + y) + "px"; } dynLayer.prototype.show = function() { this.style.visibility = "visible"; } dynLayer.prototype.hide = function() { this.style.visibility = "hidden"; } dynLayer.prototype.togVisible = function() { if (this.style.visibility == "hidden") this.style.visibility = "visible"; else this.style.visibility = "hidden"; } dynLayer.prototype.setZ = function(z) { this.style.zIndex = z.toString(); } dynLayer.prototype.setBgColour = function(colour) { this.style.backgroundColor = colour; } dynLayer.prototype.setBgImage = function(image) { this.style.backgroundImage = "URL(" + image + ")"; } dynLayer.prototype.setX = function(value) { this.style.left = Math.round(value) + "px"; } dynLayer.prototype.setY = function(value) { this.style.top = Math.round(value) + "px"; } dynLayer.prototype.setWidth = function(value) { this.style.width = Math.round(value) + "px"; } dynLayer.prototype.setHeight = function(value) { this.style.height = Math.round(value) + "px"; } dynLayer.prototype.getX = function() { return parseInt(this.style.left); } dynLayer.prototype.getY = function() { return parseInt(this.style.top); } dynLayer.prototype.getWidth = function() { return parseInt(this.style.width); } dynLayer.prototype.getHeight = function() { return parseInt(this.style.height); } dynLayer.prototype.setBody = function(HTML) { this.element.innerHTML = HTML; } } // Netscape 4 portion // else if (NS4) { window.status = "Using Netscape 4 API"; dynLayer.prototype.init = function() { var doc = this.window.document; this.layer = doc[this.id]; this.moveTo(this.x,this.y); this.setWidth(this.w); this.setHeight(this.h); } dynLayer.prototype.moveTo = function(x,y) { this.layer.moveTo(x,y); } dynLayer.prototype.moveBy = function(x,y) { this.layer.moveBy(x,y); } dynLayer.prototype.show = function() { this.layer.visibility = "show"; } dynLayer.prototype.hide = function() { this.layer.visibility = "hide"; } dynLayer.prototype.togVisible = function() { if (this.layer.visibility == "hide") this.layer.visibility = "show"; else this.layer.visibility = "hide"; } dynLayer.prototype.setZ = function(z) { this.layer.zIndex = z; } dynLayer.prototype.setBgColour = function(colour) { this.layer.bgColor = colour; } dynLayer.prototype.setBgImage = function(image) { this.layer.background.src = image; } dynLayer.prototype.setX = function(value) { this.layer.left = Math.round(value); } dynLayer.prototype.setY = function(value) { this.layer.top = Math.round(value); } dynLayer.prototype.setWidth = function(value) { this.layer.clip.width = Math.round(value); } dynLayer.prototype.setHeight = function(value) { this.layer.clip.height = Math.round(value); } dynLayer.prototype.getX = function() { return this.layer.left; } dynLayer.prototype.getY = function() { return this.layer.top; } dynLayer.prototype.getWidth = function() { return this.layer.clip.width; } dynLayer.prototype.getHeight = function() { return this.layer.clip.height; } dynLayer.prototype.setBody = function() { for (var i = 0; i < arguments.length; i++){ this.layer.document.write(arguments[i]); } this.layer.document.close(); } } // IE 4 portion // else if (IE4) { window.status = "Using Internet Explorer 4 API"; dynLayer.prototype.init = function() { var doc = this.window.document; this.element = doc.all[this.id]; this.style = this.element.style; this.moveTo(this.x,this.y); this.setWidth(this.w); this.setHeight(this.h); } dynLayer.prototype.moveTo = function(x,y) { this.style.pixelLeft = x; this.style.pixelTop = y; } dynLayer.prototype.moveBy = function(x,y) { this.style.pixelLeft += x; this.style.pixelTop += y; } dynLayer.prototype.show = function() { this.style.visibility = "visible"; } dynLayer.prototype.hide = function() { this.style.visibility = "hidden"; } dynLayer.prototype.togVisible = function() { if (this.style.visibility == "hidden") this.style.visibility = "visible"; else this.style.visibility = "hidden"; } dynLayer.prototype.setZ = function(z) { this.style.zIndex = z; } dynLayer.prototype.setBgColour = function(colour) { this.style.backgroundColor = colour; } dynLayer.prototype.setBgImage = function(image) { this.style.backgroundImage = image; } dynLayer.prototype.setX = function(value) { this.style.pixelLeft = Math.round(value); } dynLayer.prototype.setY = function(value) { this.style.pixelTop = Math.round(value); } dynLayer.prototype.setWidth = function(value) { this.style.width = Math.round(value); } dynLayer.prototype.setHeight = function(value) { this.style.height = Math.round(value); } dynLayer.prototype.getX = function() { return this.style.pixelLeft; } dynLayer.prototype.getY = function() { return this.style.pixelTop; } dynLayer.prototype.getWidth = function() { return this.style.pixelWidth; } dynLayer.prototype.getHeight = function() { return this.style.pixelHeight; } dynLayer.prototype.setBody = function() { var body = ""; for (var i = 0; i < arguments.length; i++){ body += arguments[i] + "\n"; } this.element.innerHTML = body; } } //DEFINE API var dhtml_api = true; //uncommment this and paste this into your page - fixes yet another bug in Netcrap 4. //if (typeof dhtml_api == "undefined") window.location.reload();