//
// Javascript routines used to extend the Javascript language for earlier versions.
//
// (c) 2003
//
// All material in this document is copyright Mark Bertenshaw.  None of this can be reproduced in any manner without the express permission of the author.
//

// Required for compatibility with Javascript 1.2.
var undefined;


// Code used to temporarily turn off and on default error handling.
var oldErrorHandler;

function errorsOff()
{
	oldErrorHandler = window.onerror;
	alert("errorsOff");
	window.onerror = function () {
		return false;
	};
	alert("errorsOff done");
}

function errorsOn()
{
	alert("errorsOn");
	window.onerror = oldErrorHandler;
}

// This function loads the XML document from the specified URL, and when
// it is fully loaded, passes that document and the url to the specified
// handler function.  This function works with any XML document
function loadXML(url, handler) {
	// Use the standard DOM Level 2 technique, if it is supported
	if (document.implementation && document.implementation.createDocument) {
		// Create a new Document object
		var xmldoc = document.implementation.createDocument("", "", null);
		// Specify what should happen when it finishes loading
		xmldoc.onload = function() { handler(xmldoc, url); };
		// And tell it what URL to load
		xmldoc.load(url);
	}
	// Otherwise use Microsoft's proprietary API for Internet Explorer
	else if (window.ActiveXObject) { 
		var xmldoc = new ActiveXObject("Microsoft.XMLDOM");   // Create doc.
		xmldoc.onreadystatechange = function() {              // Specify onload
			if (xmldoc.readyState == 4) handler(xmldoc, url);
		}
		xmldoc.load(url);                                     // Start loading!
	}
}

/*
function it()
{
	alert("HERE");
	handler(frames["htmlSample"], url);
}
*/

/*
function loadHTML(url, handler) {
	if (document.implementation && document.implementation.createHTMLDocument) {
		// Create a new HTML Document onbject.
		var htmlDoc = document.implementation.createDocument("sample");
		// Specify what should happen when it finishes loading
		htmlDoc.onload = function() { handler(htmlDoc, url); };
		// And tell it what URL to load
		
		htmlDoc.load(url);
	} else {
		var iframe = document.createElement("IFRAME");
		//iframe.style.display = "none";
		document.documentElement.appendChild(iframe);
		iframe.name = "htmlSample";
		iframe.id = "htmlSample";
		//iframe.onload = function() { handler(frames["htmlSample"], url); };
		//iframe.addEventListener("load", function() { handler(frames["htmlSample"], url); }, false);
		iframe.onreadystatechange = function() { handler(frames["htmlSample"], url); };
		alert(frames["htmlSample"]);
		//frames["htmlSample"].onload = function() {alert("hello");};
		//function() { handler(frames["htmlSample"], url); };
		iframe.src = url;
		
		//window.setTimeout( function() 
		//	{
		//		alert(iframe.contentWindow);
		//		alert(iframe.contentDocument);
		//	}, 2000);
	}
}
*/