/*   Exemplo
  addEvent(window, 'load', function() {
    document.getElementById('myfield').focus()
  });
*/

/* Associa um evento a um objeto */
function addEvent( obj, type, fn ) {
  if ( obj.attachEvent ) {
    obj['e'+type+fn] = fn;
    obj[type+fn] = function(){obj['e'+type+fn]( window.event );};
    obj.attachEvent( 'on'+type, obj[type+fn] );
  } else {
    obj.addEventListener( type, fn, false );
  }
}

/* Remove um evento associado a um objeto */
function removeEvent( obj, type, fn ) {
  if ( obj.detachEvent ) {
    obj.detachEvent( 'on'+type, obj[type+fn] );
    obj[type+fn] = null;
  } else {
    obj.removeEventListener( type, fn, false );
  }
}

/* insert an element after a particular node */
function insertAfter(parent, node, referenceNode) {
  parent.insertBefore(node, referenceNode.nextSibling);
}


/* Obtem um objeto via DOM 
	if (document.layers){
	  //Netscape 4 specific code
	}
	if (document.getElementById){
	  //Netscape 6 specific code
	}
	if (document.all){
	  //IE4+ specific code
	}
*/
function xDOM(obj,estilo){
	if (document.layers){
		//Netscape 4 specific code
		prefix = 'document.';
		if(estilo){
			sufix = '';
		} else {
			sufix = '';
		}
	}
	if (document.getElementById){
		//Netscape 6 specific code
		prefix = 'document.getElementById("';
		if(estilo){
			sufix = '").style';
		} else {
			sufix = '';
		}
	}
	if (document.all){
		//IE4+ specific code
		prefix = 'document.all.';
		if(estilo){
			sufix = '.style';
		} else {
			sufix = '';
		}
	}
	return eval(prefix + obj + sufix);
}