function ChangeImg(NameImg, NewImg){
	document.images[NameImg].src = NewImg;
}
function Del(Id, Pagina){
	if(window.confirm("Deseja realmente apagar esse registro?")){
		window.location.href= Pagina + "?ac=Del&Id=" + Id;
	}
}

function AbreJan(Arquivo, Target, Opcoes){
	var Jan = window.open(Arquivo, Target, Opcoes);
	Jan.focus();
}


/*********************************************
'##  FormatTodDoubleJS(String campo)
'##  Retorna campo formatado para double (x.xxx,xx)
*********************************************/
function FormatToDoubleJS(campo){
	return campo.replace(".", "").replace(",", ".");
}

function getElementsById(sId)
 {
    var outArray = new Array();	
	if(typeof(sId)!='string' || !sId)
	{
		return outArray;
	};
	
	if(document.evaluate)
	{
		var xpathString = "//*[@id='" + sId.toString() + "']";//**/
		var xpathResult = document.evaluate(xpathString, document, null, 0, null);
		while ((outArray[outArray.length] = xpathResult.iterateNext())) { }
		outArray.pop();
	}
	else if(document.all)
	{
		
		for(var i=0,j=document.all[sId].length;i<j;i+=1){
		outArray[i] =  document.all[sId][i];}
		
	}else if(document.getElementsByTagName)
	{
	
		var aEl = document.getElementsByTagName( '*' );	
		for(var i=0,j=aEl.length;i<j;i+=1){
		
			if(aEl[i].id == sId )
			{
				outArray.push(aEl[i]);
			};
		};	
		
	};
	
	return outArray;
 }
function CheckCampos(oF, vtCampos, vtMsg){
	var msgErro = "";
	for(i=0;i<=vtCampos.length - 1;i++){
		if(document.forms[oF].elements[vtCampos[i]].value == ""){
			msgErro += vtMsg[i] + "\n";
		}
	}
	return msgErro;
}

function checkMail(mail){
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if(typeof(mail) == "string"){
        if(er.test(mail)){ return true; }
    }else if(typeof(mail) == "object"){
        if(er.test(mail.value)){
                    return true;
                }
    }else{
        return false;
        }
}

/*********************************************
'##  getCamposValores(Strinb formName)
'##  Retorna a relação de campos de valores no formato campo=valor
*********************************************/
function getCamposValores(formName){
	var str = "";
	for(var i=0;i<=document.forms[formName].elements.length-1;i++){
		if(str != ""){
			str += "&";
		}
		str += document.forms[formName].elements[i].name + "=" + document.forms[formName].elements[i].value;
	}
	return str;
}

function addLinha(nomeTB, vtValores, vtAlign, vtClass, vtWidth){
	//var tabela = window.opener.document.getElementById(nomeTB);
	var tabela = nomeTB;
	var newRow = tabela.insertRow(tabela.rows.length);
	//newRow.style.cursor = "pointer";
	//newRow.onclick = function(){eval(slink);}
	//alert(vtValores);
	for(var i=0;i<=vtValores.length-1;i++){
		var c = newRow.insertCell(i);
		if(vtAlign){
			if(vtAlign[i]){
				c.align = vtAlign[i];
			}
		}
		if(vtClass){
			if(vtClass[i]){
				c.className = vtClass[i];
			}
		}
		if(vtWidth){
			if(vtWidth[i]){
				c.style.width = vtWidth[i];
			}			
		}
		c.innerHTML = vtValores[i];
	}
}
function limpaTB(tab){
	//var tab = window.opener.document.getElementById("lstArq");
	for(i=tab.rows.length-1;i>0;i--){
		tab.deleteRow(i);
	}
}

function countBanner(i){
	var oXml = new biancuzziAjax("xml_banners.ecm?bn=" + i, countBanner_CallBack, false);
	oXml.exec();
}
function countBanner_CallBack(oRet){

}
