/*

Notes:

http://www.sitepoint.com/print/javascript-from-scratch
Internet Explorer 6 and versions below will not propagate changes made via setAttribute to the visual display of an element. So any changes that are made to the class, id, or style of an element using setAttribute will not affect the way it's displayed. In order for those changes to take effect, they must be made via the element node's attribute-specific properties.

*/
/*====================================================================
                                                              addEvent
*/
// Add an eventListener to browsers that can do it somehow.
// Originally by the amazing Scott Andrew LePera.
function addEvent(obj, evType, fn)
{
	if (obj.addEventListener)
	{
		obj.addEventListener(evType, fn, false);
		return true;
	}
	else if (obj.attachEvent)
	{
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	}
	else
	{
		return false;
	}
}


/*====================================================================
                                                         createElement
*/
//via http://simon.incutio.com/archive/2003/06/15/javascriptWithXML
var XHTMLNS = "http://www.w3.org/1999/xhtml";

function createElement(ns, element)
{
	if (typeof document.createElementNS != 'undefined')
	{
		return document.createElementNS(ns,element);
	}
	if (typeof document.createElement != 'undefined')
	{
		return document.createElement(element);
	}
	return false;
}


/*====================================================================
                                                           insertAfter
*/
function insertAfter( newElement, targetElement )
{
	var parent = targetElement.parentNode;
	if( parent.lastChild == targetElement )
	{
		parent.appendChild( newElement );
	}
	else
	{
		parent.insertBefore( newElement, targetElement.nextSibling )
	}
}

