
/*
	Authors:		Dan Nye & Jeff Home, Coedit Limited - http://www.coedit.co.uk/
	Description:	Liquid Niugini Gas Limited - Markup enhancing JavaScript
	Copyright:		Copyright 2007 - Coedit Limited - http://www.coedit.co.uk/

	Not to be reproduced without permission of the authors.
*/


attachEventToElement(window, 'load', enhanceMarkup);


function attachEventToElement(nodeToAttachTo, eventToListenFor, functionToAttach) {
	if (nodeToAttachTo.addEventListener) {
		nodeToAttachTo.addEventListener(eventToListenFor, functionToAttach, false);
	} else if (nodeToAttachTo.attachEvent) {
		nodeToAttachTo.attachEvent('on' + eventToListenFor, functionToAttach);
	} else {
		if (typeof nodeToAttachTo[eventToListenFor] == 'function') {
			var _tempOnload = nodeToAttachTo[eventToListenFor];
			nodeToAttachTo[eventToListenFor] = function() {
				_tempOnload();
				functionToAttach();
			}
		} else {
			nodeToAttachTo[eventToListenFor] = function () {
				functionToAttach();
			};
		}
	}
}


/* Stops IE giving the "Click here to active this..." message (part of the Eolas patent ruling) for "Satay"-embedded Flash objects */
function patchEolasPatent() {
	var objects = document.getElementsByTagName('object');
	for (var loop=0; loop<objects.length; loop++) {
		var object = objects[loop];
		if (object.type == 'application/x-shockwave-flash') {
			var _type = object.type;
			var _data = object.data;
			var _width = object.width;
			var _height = object.height;
			var _noFlash = object.innerHTML;
			var _html = '';
			_html += '<object type="application/x-shockwave-flash" data="' + _data + '" width="' + _width + '" height="' + _height + '">';
			_html += '<param name="movie" value="' + _data + '" />';
			_html += _noFlash;
			_html += '</object>';
			object.parentNode.innerHTML = _html;
		}
	}
}



function enhanceMarkup() {
	if (ieWin === true) {
		patchEolasPatent();	// Bypass the Eolas patent malarky
	}
}

