
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) 
{
	window.open(theURL,winName,features);
}

function $(id) { return document.getElementById(id); }

// Menu CSS...
var initMenuCSS = function()
{
 	if (document.all && document.getElementById)
	{
		var menu = document.getElementById('menu');
		if (!menu)
		{
			return false;
		}	
		var lis  = menu.getElementsByTagName('li');
				
		for (i = 0; i < lis.length; i++)
		{
			lis[i].onmouseover = function()
			{
				this.className += ' iover';
				showSelects(false);
			}
			lis[i].onmouseout = function()
			{
				this.className = this.className.replace(' iover', '');
				showSelects(true);
			}
		}
	}
}
window.onload = initMenuCSS;

var mantemHide = false;
function showSelects(show)
{
	if (mantemHide)
	{
		return false;
	}

	var status = (show ? 'visible' : 'hidden');
	var e1 = document.getElementsByTagName('select');
	
	for (i = 0; i < e1.length; i++)
	{
		e1[i].style.visibility = status;
	}
}

function getMultiElementsById(id)
{
	var cs = document.getElementsByTagName('input');
	var fs = new Array();
	for (i = 0; i < cs.length; i++)
	{
		if (cs[i].id == id)
			fs[fs.length] = cs[i];
	}
	return fs;
}
function getMultiElementsByName(name)
{
	var cs = document.getElementsByTagName('input');
	var fs = new Array();
	for (i = 0; i < cs.length; i++)
	{
		if (cs[i].name == name)
			fs[fs.length] = cs[i];
	}
	return fs;
}

function centerPopUp(width, height)
{
	var left   = (screen.width) / 2 - (width / 2);
	var top    = (screen.height) / 2 - (height / 2) - 20;
	
	return 'top=' + top + ',left=' + left + ',width=' + width + ',height=' + height;
}

// mascaras
var v_obj = null;
var v_fun = null;
function mascara(o,f){
    v_obj=o;
    v_fun=f;
    setTimeout("execmascara()",1);
}
function execmascara(){
    v_obj.value=v_fun(v_obj.value);
}

function maskTelefone(v){
    v=v.replace(/\D/g,"");                 //Remove tudo o que não é dígito
    //v=v.replace(/^(\d\d)(\d)/g,"($1) $2"); //Coloca parênteses em volta dos dois primeiros dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2");    //Coloca hífen entre o quarto e o quinto dígitos
    return v;
}
function maskTelefoneWithDDD(v){
    v=v.replace(/\D/g,"");                 //Remove tudo o que não é dígito
    v=v.replace(/^(\d\d)(\d)/g,"($1) $2"); //Coloca parênteses em volta dos dois primeiros dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2");    //Coloca hífen entre o quarto e o quinto dígitos
    return v;
}

function maskCPF(v){
    v=v.replace(/\D/g,"");                    //Remove tudo o que não é dígito
    v=v.replace(/(\d{3})(\d)/,"$1.$2");       //Coloca um ponto entre o terceiro e o quarto dígitos
    v=v.replace(/(\d{3})(\d)/,"$1.$2");       //Coloca um ponto entre o terceiro e o quarto dígitos
                                             //de novo (para o segundo bloco de números)
    v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2"); //Coloca um hífen entre o terceiro e o quarto dígitos
    return v;
}


// funcoes para scroll de layers

var loop = false;
var time;

function moveLayer(pai, filho, dir)
{
	if (pai == 'box3_pai')
		paused = true;
	
	speed = 2;
	loop = true;
	var layerPai = document.getElementById(pai);
	var layerFilho = document.getElementById(filho);
	if (loop)
	{
		pos = parseInt(layerFilho.style.top);
		offset = 0 - parseInt(layerFilho.offsetHeight);
		heightPai = parseInt(layerPai.style.height);
		if (dir == 'up' && pos > (offset + heightPai))
		{
			layerFilho.style.top = (pos - speed);
		}
		if (dir == 'dn')
		{
			if (pos >= 0) {	return; } else { layerFilho.style.top = (pos + speed); }
		}
		time = setTimeout("moveLayer('" + pai + "', '" + filho + "', '" + dir + "')", 10);
	}
}

function stopLayer()
{
	paused = false;
	loop = false;
	clearTimeout(time);
}

var paused = false;
function moveLayer2(pai, filho)
{
	var speed      = 1;
	var layerPai   = document.getElementById(pai);
	var layerFilho = document.getElementById(filho);
	
	if (!paused)
	{
		var pos       = parseInt(layerFilho.style.top);
		var offset    = 0 - parseInt(layerFilho.offsetHeight);
		var heightPai = parseInt(layerPai.style.height);
		layerFilho.style.top = (pos - speed);
		if (pos == offset)
			layerFilho.style.top = heightPai + 'px';
	}
	setTimeout("moveLayer2('" + pai + "', '" + filho + "')", 100);
}

//
function deleteItem(tipo, msg, id)
{
	del = confirm(msg);
	if (del)
		location.href = '?page=' + tipo + '&action=del&id=' + id;
}

function changeSiteStatus(status)
{
	var retorno = function(o)
	{
		if (o['message'])
			alert(o['message']);
	}
	
	var ajaxId = ajaxCall.init();
	ajaxCall.setURL(ajaxId, 'procs/ajax.php');
	ajaxCall.setResponseFunction(ajaxId, retorno);
	ajaxCall.setResponseType(ajaxId, 'OBJ');
	ajaxCall.addParam(ajaxId, 'action', 'changeSiteStatus');
	ajaxCall.addParam(ajaxId, 'status', status);
	ajaxCall.doCall(ajaxId);
}
function changeItemStatus(page, id, status)
{
	var retorno = function(o)
	{
		
		if (o['message'])
			alert(o['message']);
			
		if (o['reload'])
			location.href = location.href;
	}

	var ajaxId = ajaxCall.init();
	ajaxCall.setURL(ajaxId, 'procs/ajax.php');
	ajaxCall.setResponseFunction(ajaxId, retorno);
	ajaxCall.setResponseType(ajaxId, 'OBJ');
	ajaxCall.addParam(ajaxId, 'action', 'activation');
	ajaxCall.addParam(ajaxId, 'page', page);
	ajaxCall.addParam(ajaxId, 'id', id);
	ajaxCall.addParam(ajaxId, 'status', status);
	ajaxCall.doCall(ajaxId);
}
function changeMetatagStatus(page, pagina, conteudo, status)
{
	var retorno = function(o)
	{
		
		if (o['message'])
			alert(o['message']);
			
		if (o['reload'])
			location.href = location.href;
	}

	var ajaxId = ajaxCall.init();
	ajaxCall.setURL(ajaxId, 'procs/ajax.php');
	ajaxCall.setResponseFunction(ajaxId, retorno);
	ajaxCall.setResponseType(ajaxId, 'OBJ');
	ajaxCall.addParam(ajaxId, 'action', 'activation');
	ajaxCall.addParam(ajaxId, 'page', page);
	ajaxCall.addParam(ajaxId, 'pagina', pagina);
	ajaxCall.addParam(ajaxId, 'conteudo', conteudo);
	ajaxCall.addParam(ajaxId, 'status', status);
	ajaxCall.doCall(ajaxId);
}
function changeNoticia(id, status)
{
	var retorno = function(o)
	{
		if (o['message'])
			alert(o['message']);
			
		if (o['reload'])
			location.href = location.href;
	}

	var ajaxId = ajaxCall.init();
	ajaxCall.setURL(ajaxId, 'procs/ajax.php');
	ajaxCall.setResponseFunction(ajaxId, retorno);
	ajaxCall.setResponseType(ajaxId, 'OBJ');
	ajaxCall.addParam(ajaxId, 'action', 'changeNoticia');
	ajaxCall.addParam(ajaxId, 'id', id);
	ajaxCall.addParam(ajaxId, 'status', status);
	ajaxCall.doCall(ajaxId);
}
function changeNoticiaPrioridade(id, c)
{
	var retorno = function(o)
	{
		if (o['reload'])
			location.href = location.href;
	}
	
	var ajaxId = ajaxCall.init();
	ajaxCall.setURL(ajaxId, 'procs/ajax.php');
	ajaxCall.setResponseFunction(ajaxId, retorno);
	ajaxCall.setResponseType(ajaxId, 'OBJ');
	ajaxCall.addParam(ajaxId, 'action', 'changeNoticiaPrioridade');
	ajaxCall.addParam(ajaxId, 'id', id);
	ajaxCall.addParam(ajaxId, 'prioridade', c.options[c.selectedIndex].value);
	ajaxCall.doCall(ajaxId);
}
function changeFixedBanner(id)
{
	var retorno = function(o)
	{
		if (o['message'])
			alert(o['message']);
	}
	
	var ajaxId = ajaxCall.init();
	ajaxCall.setURL(ajaxId, 'procs/ajax.php');
	ajaxCall.setResponseFunction(ajaxId, retorno);
	ajaxCall.setResponseType(ajaxId, 'OBJ');
	ajaxCall.addParam(ajaxId, 'action', 'changeFixedBanner');
	ajaxCall.addParam(ajaxId, 'id', id);
	ajaxCall.doCall(ajaxId);
}

function mostraDivEmpresa(id)
{
	var divs = new Array('texto_01', 'texto_02', 'texto_03', 'texto_04', 'texto_05', 'texto_06', 'texto_07', 'texto_08', 'texto_09');
	var div = document.getElementById(id);
	if (div.style.display == 'none')
		div.style.display = 'block';
	else
		div.style.display = 'none';
		
	for (i = 0; i < divs.length; i++)
	{
		if (divs[i] != id)
		{
			var div = document.getElementById(divs[i]);
			div.style.display = 'none';
		}
	}
}

function validaFormInteresse()
{
	var nome          = document.interesse.nome.value;
	var profissao     = document.interesse.profissao.value;
	var empresa       = document.interesse.empresa.value;
	var municipio     = document.interesse.municipio.value;
	var uf            = document.interesse.uf.value;
	var dddComercial  = document.interesse.dddComercial.value;
	var telComercial  = document.interesse.telComercial.value;
	var email         = document.interesse.email.value;
	var emailConfirma = document.interesse.emailConfirma.value;
	var mensagem      = document.interesse.mensagem.value;
	var conhecia      = getMultiElementsById('conhecia');
	
	var erros = "";
	
	if (!nome)
		erros += " - Informe o Nome Completo.\n";
		
	if (!profissao)
		erros += " - Informe a profissão.\n";
		
	if (!empresa)
		erros += " - Informe a empresa.\n";
		
	if (!municipio)
		erros += " - Informe o município.\n";
		
	if (!uf)
		erros += " - Selecione o estado.\n";
		
	if (!dddComercial || !telComercial)
		erros += " - Informe um DDD/Telefone.\n";
		
	if (!email)
		erros += " - Informe um email.\n";
	else if (email != emailConfirma)
		erros += " - Email não confere com a confirmação.\n";
		
	if (!mensagem)
		erros += " - Digite uma mensagem.\n";
	
	var cc = false;
	for (i = 0; i < conhecia.length; i++)
	{
		if (conhecia[i].checked)
			cc = true
	}
	if (!cc)
		erros += " - Informe se você já conhecia o ILTC.\n";
		
	if (erros)
	{
		alert("* Os seguintes erros foram encontrados:\n\n" + erros);
		return false;
	}
	return true;
}

function formatNumber(num,dec,thou,pnt,curr1,curr2,n1,n2) {var x = Math.round(num * Math.pow(10,dec));if (x >= 0) n1=n2='';var y = (''+Math.abs(x)).split('');var z = y.length - dec; if (z<0) z--; for(var i = z; i < 0; i++) y.unshift('0'); if (z<0) z = 1; y.splice(z, 0, pnt); if(y[0] == pnt) y.unshift('0'); while (z > 3) {z-=3; y.splice(z,0,thou);}var r = curr1+n1+y.join('')+n2+curr2;return r;}








