/***************************************************************************************
*captura elementos 
*$('objeto'); [captura o objeto "objeto"] 
*$(["id_1","id_2","id_3","..."]); [cria um array dos objetos] 
*$("id_1","id_2","id_3","..."); [cria um array dos objetos] 
***************************************************************************************/
function $(strId){var i, arrReturn,arrStrId;if(arguments.length > 1){arrStrId = new Array();for(i=0; i<arguments.length; i++){arrStrId.push(arguments[i]);};};if(strId instanceof Array){arrStrId = strId;};if(arrStrId instanceof Array){arrReturn = new Array();for(i=0; i<arrStrId.length; i++)arrReturn[i] = document.getElementById(arrStrId[i]);}else{arrReturn = document.getElementById(strId);};return arrReturn;};
/***************************************************************************************
*captura o atributo do elemento
*$att('obj','nome') [pega o atributo nome do objeto obj] 
***************************************************************************************/
function $att(el,att){
	var arrReturn;
	if($(el)){
		arrReturn = $(el).getAttribute(att);
	}else{
		arrReturn = '';
	};
	return arrReturn;
};
/***************************************************************************************
*muda o valor de um atributo do elemento
*$mAtt('obj','nome','jorn') [pega o atributo nome do objeto obj e altera seu valor para jorn] 
***************************************************************************************/
function $mAtt(el,att,nAtt){
	var arrReturn;
	if($(el)){
		$(el).setAttribute(att,nAtt);
		arrReturn = true;
	}else{
		arrReturn = false;
	};
	return arrReturn;
};
/*************************************************************************************
*captura elementos pelas tags 
*$tags('a'); [pega todos os "a"] 
*$tags('a',$('menu')); [pega todos os "a" dentro de "menu"] 
*************************************************************************************/
function $tags(strTagName,objParentNode){if(typeof objParentNode == "undefined"){objParentNode = document;};return objParentNode.getElementsByTagName(strTagName);};
/*************************************************************************************
*exclui elemento 
*$remove($('elemento')); [exclui elemento "elemento"] 
*************************************************************************************/
function $remove(objNode){if(objNode && objNode.parentNode){objNode.parentNode.removeChild(objNode);};};
/*************************************************************************************
*adiciona elemento filho 
*$append($new('hr')); [adiciona um "hr" ao final do body] 
*$append($new('hr'),$('conteudo')); [adiciona um "hr" ao final do elemento "conteudo"] 
*************************************************************************************/
function $append(objNode, objParentNode){var i;if(typeof(objParentNode) == "undefined"){objParentNode = document.body;};if(objNode=="" || objNode == null){return true;};if(objNode instanceof Array){for(i=0; i<objNode.length; i++){$append(objNode[i], objParentNode);};}else{if(typeof(objNode) == "string"){objParentNode.appendChild($newTN(objNode));}else{objParentNode.appendChild(objNode);};};return objParentNode.childNodes.length;};
/*************************************************************************************
*insere elemeno antes
*************************************************************************************/
function $before(objNew,objRefer){return objRefer.parentNode.insertBefore(objNew,objRefer);};
/*************************************************************************************
*insere elemeno depois
*************************************************************************************/
function $after(objNew,objRefer){return objRefer.parentNode.insertBefore(objNew,objRefer.nextSibling);};
/*************************************************************************************
*cria um objeto texto 
*$append($newTN('text.')); 
*************************************************************************************/
function $newTN(strConteudo){if(typeof strConteudo == "string"){return document.createTextNode(strConteudo);}else{return false;};};
/*************************************************************************************
*cria elemento 
*$new('div','id=global','conteúdo'); [cria um "div" com id "global" e conteudo] 
*$new('a',["title=Oi","href=globo.com"],'texto') [cria "a" com titulo, href, e texto] 
*************************************************************************************/
function $new(strTagName, strParams, strContent){var i, j, newElement, arrParameters;var fixIEParams = ["name","enctype"];if(typeof strContent == "undefined"){strContent = strParams;strParams = null;};if(document.all){strTagName = '<'+strTagName+' ';if(strParams instanceof Array){for(i=0; i<strParams.length && (arrParameters = strParams[i].split("=")); i++){for(j=0; j<fixIEParams.length; j++){if(arrParameters[0] == fixIEParams[j]){strTagName += arrParameters[0]+'="'+arrParameters[1]+'" ';};};};}else{if(typeof strParams == "string" && ( arrParameters = strParams.split("=")) ){for(j=0; j<fixIEParams.length; j++){if(arrParameters[0] == fixIEParams[j]){strTagName += arrParameters[0]+'="'+arrParameters[1]+'" ';};};};};strTagName += '>';};newElement=document.createElement(strTagName);if(strParams instanceof Array){for(i=0; i<strParams.length && (arrParameters = strParams[i].split("=")); i++){newElement[arrParameters[0]] = arrParameters[1];};}else{if(typeof strParams == "string" && ( arrParameters = strParams.split("=")) ){newElement[arrParameters[0]] = (arrParameters.length==2) ? arrParameters[1] : "";};};if(strContent instanceof Array){for(i=0; i<strContent.length; i++){(typeof(strContent[i]) =="string") ? $append($newTN(strContent[i]), newElement) : $append(strContent[i], newElement);};}else{$append(strContent, newElement);};return newElement;};
/*************************************************************************************
*substitui um elemento por outro 
*$replace($new('h1','txt'),$('elemento')); [substitui o objeto "elemento" pelo h1] 
*************************************************************************************/
function $replace(objNew,objOld){if(objOld.parentNode){return objOld.parentNode.replaceChild(objNew,objOld);}else{return false;};};
