function alterImg(id,img) {
	imagem = document.getElementById(id);
	imagem.src = img;
}
function scrollOver()
{
scroller.scrollAmount='1';
scroller.style.cursor='default';
}

function scrollOut()
{
scroller.scrollAmount='4';
}

function checkSBox(box)
{
SBox = eval(box);
SBox.checked = !SBox.checked;
scrollOut();
}
function admin() {
	campo = document.index.classe;
	apelido = document.index.apelido;
	passwd = document.index.passwd;
	height = document.index.height;
	if(campo.value == "usu") {
		window.open('indexusu.php?apelido='+apelido.value+'&passwd='+passwd.value,'_top','');
	} else {
		if(campo.value == "sysusu") {
			window.open('admin/index.php?acao=logar&apelido='+apelido.value+'&passwd='+passwd.value,'_top','');
		} else {
			if(campo.value == "curri") {
				window.open('index.php?page=indexcurri.php&acao=logar&apelido='+apelido.value+'&passwd='+passwd.value,'_top','');
			}
		}
	}
}
function statusBar(valor) {
	window.status = valor;
}
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function positionLayer(strLayer, strVar, strAction, strParentImage){
 var intSiteWidth = 779;
 var intWindowWidth = document.body.clientWidth;
 var intSiteStart = 0;
 var objLayer = MM_findObj(strLayer);
 var objImage = MM_findObj(strParentImage);
 if ((intSiteStart = (intWindowWidth / 2) - (intSiteWidth / 2)) < 0) intSiteStart = 0;
 objLayer.style.left = (((intSiteStart + objImage.offsetLeft)+12) + 'px');
 MM_showHideLayers(strLayer,strVar,strAction);
}
function positionLayerTit(strLayer, strVar, strAction, strParentImage){
 var intSiteWidth = 779;
 var intWindowWidth = document.body.clientWidth;
 var intSiteStart = 0;
 var objLayer = MM_findObj(strLayer);
 var objImage = MM_findObj(strParentImage);
 if ((intSiteStart = (intWindowWidth / 2) - (intSiteWidth / 2)) < 0) intSiteStart = 0;
 objLayer.style.left = (((intSiteStart + objImage.offsetLeft)+225) + 'px');
 MM_showHideLayers(strLayer,strVar,strAction);
}
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_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_findObj(n, d) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); 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 altTabs(n,div,w,b) {
	table = document.getElementById(div);
	for(i=0;i<n;i++) {
		j = i+1;
		tabela = 'table'+j;
		//alert(tabela);
		if(table.id == tabela ) {
			table.style.display = 'block';
		} else {
			oTable = document.getElementById(tabela);
			oTable.style.display = 'none';
		}
	}
	
	for(x=0;x<w;x++) {
		y = x+1;
		nome = 'tab'+y;
		tab = document.getElementById(nome);
		url = 'http://www.abrhflorianopolis.com.br/vetor/admin/img/';
		if(tab.src == url+'inio.gif') {
			tab.src = url+'inid.gif';		
		} else {
			if(tab.src == url+'fimo.gif') {
				tab.src = url+'fimd.gif';		
			}						
		}
		if(tab.background == '../img/1x1o.gif') {
			tab.background = '../img/1x1d.gif';			
		}
	}

	for(a=0;a<n;a++) {
		c = a+1;
		cc = Math.abs(c);
		bb = Math.abs(b);
		d = bb + cc;
		name = 'tab'+d;
		tab = document.getElementById(name);
		url = 'http://www.abrhflorianopolis.com.br/vetor/admin/img/';
		if(tab.src == url+'inid.gif') {
			tab.src = url+'inio.gif';		
		}

		if(tab.background == '../img/1x1d.gif') {
			tab.background = '../img/1x1o.gif';			
		} 

		if(tab.src == url+'fimd.gif') {
			tab.src = url+'fimo.gif';						
		}
	}
}

function changeColor(id,cor) {
	linha = document.getElementById(id);
	linha.bgColor = cor;
	//alert(linha.bgcolor);
}

function viewNormal(id_mod,page) {
 window.open('edit.php?id='+id_mod+'&pagina='+page, '_blank' ,'height=550,width=750,status=no,toolbar=no,center=yes,help=no,resizable=no');
 //window.open('edit-'+mod+'.php?id='+id_mod+'&pagina='+page,'main','')
}

function view(id,page,doc,width,height) {
 window.showModalDialog(''+doc+'?id='+id+'&pagina='+page, window ,' dialogWidth: '+width+'px; dialogHeight: '+height+'px;  center: Yes; help: no; status: no; resizable: no');
 //window.open('edit-'+mod+'.php?id='+id_mod+'&pagina='+page,'main','')
}

function novo(page,doc,width,height) {
 window.showModalDialog(''+doc+'?pagina='+page, window ,' dialogWidth: '+width+'px; dialogHeight: '+height+'px;  center: yes; help: no; resizable: Yes; status: no');
 //window.open('novo-'+mod+'.php?pagina='+page, 'main', '')
}

function novoNormal(page) {
 window.open('novo.php?pagina='+page, '_blank' ,'height=550,width=750,status=no,toolbar=no,center=yes,help=no,resizable=no,');
 //window.open('novo-'+mod+'.php?pagina='+page, 'main', '')
}

function legenda(id) {
 window.open('legenda.php?id='+id, '_blank' ,'height=80,width=330,status=no,toolbar=no,center=yes,help=no,resizable=no,');
 //window.open('novo-'+mod+'.php?pagina='+page, 'main', '')
}
function ordem(id) {
 window.open('ordem.php?id='+id, '_blank' ,'height=80,width=80,status=no,toolbar=no,center=yes,help=no,resizable=no,');
 //window.open('novo-'+mod+'.php?pagina='+page, 'main', '')
}

function formataValor(campo,tammax,teclapres,decimais) {
	var tecla = teclapres.keyCode;
//	vr = document.form[campo].value;
	vr = event.srcElement.value;

	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	tam = vr.length;
	
	decimais =  decimais
	
        if (decimais == 0){
		return false
	}
	
	
	if (decimais==undefined){
		decimais = 0
	}
	
	if (decimais==2){
		decimais = 0
	}

	if (decimais==4){
		decimais = 2
	}
	
	if (decimais==3){
		decimais = 1
	}
	

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }	
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= (2+decimais) ){ 
	 		// document.form[campo].value = vr ; 
	 		event.srcElement.value = vr ; 
		}
	 	if ( (tam > (2+decimais)) && (tam <= (5+decimais)) ){
	 		event.srcElement.value = vr.substr( 0, tam - (2+decimais) ) + ',' + vr.substr( tam - (2+decimais), tam ) ; 
		}
	 	if ( (tam >= (6+decimais)) && (tam <= (8+decimais)) ){
	 		event.srcElement.value = vr.substr( 0, tam - (5+decimais) ) + '.' + vr.substr( tam - (5+decimais), 3 ) + ',' + vr.substr( tam - (2+decimais), tam ) ; 
		}
	 	if ( (tam >= (9+decimais)) && (tam <= (11+decimais)) ){
	 		event.srcElement.value = vr.substr( 0, tam - (8+decimais) ) + '.' + vr.substr( tam - (8+decimais), 3 ) + '.' + vr.substr( tam - (5+decimais), 3 ) + ',' + vr.substr( tam - (2+decimais), tam ) ; 
		}
	 	if ( (tam >= (12+decimais)) && (tam <= (14+decimais)) ){
	 		event.srcElement.value = vr.substr( 0, tam - (11+decimais) ) + '.' + vr.substr( tam - (11+decimais), 3 ) + '.' + vr.substr( tam - (8+decimais), 3 ) + '.' + vr.substr( tam - (5+decimais), 3 ) + ',' + vr.substr( tam - (2+decimais), tam ) ; 
		}
	 	if ( (tam >= (15+decimais)) && (tam <= (17+decimais)) ){
	 		event.srcElement.value = vr.substr( 0, tam - (14+decimais) ) + '.' + vr.substr( tam - (14+decimais), 3 ) + '.' + vr.substr( tam - (11+decimais), 3 ) + '.' + vr.substr( tam - (8+decimais), 3 ) + '.' + vr.substr( tam - (5+decimais), 3 ) + ',' + vr.substr( tam - (2+decimais), tam ) ;
		}		
	}		
	
}
function sendmail(){
	if (document.novomensagem.dest.value == "") {
	  window.alert (" O campo Para deve ser preenchido ! ");
	  document.novomensagem.dest.focus();
	  return ( false ); 
	}
	if (document.novomensagem.assunto.value == "") {
	  window.alert (" O campo Assunto deve ser preenchido ! ");
	  document.novomensagem.assunto.focus();
	  return ( false ); 
	}
	if(!window.confirm('Confirma o envio da mensagem?')){
	  return ( false ); 
	}
	document.novomensagem.target = '_self';
	document.novomensagem.submit();
}
function subForm() {
	cmp = document.forms[0].del;
	cmp.value = "1";
	document.forms[0].submit();
}

function loadPage(page) {
	window.open(page,'_self','');
}

function setValue(cid) {
	cmp = parent.window.document.forms[0].cidade;
	cmp.value = cid;
}

function markCidade(id) {
	window.open('../include/cidades.php?id='+id,'icidade','')
}

function markTarget(cmp,value) {
	campo = document.getElementById(cmp);
	campo.value = value;
}

function showHide(ttr1,ttr2,ttr3) {
	tr1 = document.getElementById(ttr1);
	tr2 = document.getElementById(ttr2);
	tr3 = document.getElementById(ttr3);

	if(tr1.style.display == "none") {
		tr1.style.display = "block";
	} else {
		tr1.style.display = "none";
	}
	if(tr2.style.display == "none") {
		tr2.style.display = "block";
	} else {
		tr2.style.display = "none";
	}
	if(tr3.style.display == "none") {
		tr3.style.display = "block";
	} else {
		tr3.style.display = "none";
	}
}
function altPasswd(cmp) {
	campo = eval(cmp);
	if(campo.value == "0") {
		campo.value = "1";
	} else {
		campo.value = "0";
	}
}
function verifyPasswd(passwd,passwdconf) {
	campo1 = eval(passwd);
	campo2 = eval(passwdconf);
	if ( campo1.value == campo2.value ) {
	} else {
		alert("Campos de senhas não conferem!");
		campo1.value = "";
		campo2.value = "";
		campo1.focus();
	}
}
function Mascara(formato, keypress, objeto) {
campo = eval (objeto); 
	if (formato=='cpf'){ 
		separador1 = '.'; 
		separador2 = '-'; 
		conjunto1 = 3; 
		conjunto2 = 7; 
		conjunto3 = 11; 
		if (campo.value.length == conjunto1){ 
			campo.value = campo.value + separador1; 
		} 
		if (campo.value.length == conjunto2){ 
			campo.value = campo.value + separador1; 
		} 
		if (campo.value.length == conjunto3){ 
			campo.value = campo.value + separador2; 
		} 
	} else {
		if (formato=='data'){ 
			separador1 = '/'; 
			conjunto1 = 2; 
			conjunto2 = 5; 
			if (campo.value.length == conjunto1){ 
				campo.value = campo.value + separador1; 
			} 
			if (campo.value.length == conjunto2){ 
				campo.value = campo.value + separador1; 
			} 
		} else {
			if (formato=='cep'){ 
				separador1 = '-'; 
				conjunto1 = 5; 
				if (campo.value.length == conjunto1){ 
					campo.value = campo.value + separador1; 
				} 
			} else {
				if (formato=='tel'){ 
					separador1 = '('; 
					separador2 = ')'; 
					separador3 = '-'; 
					conjunto1 = 0; 
					conjunto2 = 3; 
					conjunto3 = 8; 
					if (campo.value.length == conjunto1){ 
						campo.value = campo.value + separador1; 
					} 
					if (campo.value.length == conjunto2){ 
						campo.value = campo.value + separador2; 
					} 
					if (campo.value.length == conjunto3){ 
						campo.value = campo.value + separador3; 
					} 
				} else {
					if (formato=='cnpj'){ 
						separador1 = '.'; 
						separador2 = '/'; 
						separador3 = '-'; 
						conjunto1 = 3; 
						conjunto2 = 7; 
						conjunto3 = 11; 
						conjunto4 = 15; 
						if (campo.value.length == conjunto1){ 
							campo.value = campo.value + separador1; 
						} 
						if (campo.value.length == conjunto2){ 
							campo.value = campo.value + separador1; 
						} 
						if (campo.value.length == conjunto3){ 
							campo.value = campo.value + separador2; 
						}
						if (campo.value.length == conjunto4){ 
							campo.value = campo.value + separador3; 
						}
					}
				} 
			} 
		} 
	} 
}

function perm(campo1, campo2) {
	check = document.getElementById(campo1);
	hidden = document.getElementById(campo2);
	if(check.checked) {
		hidden.value = "";
		hidden.value = "1";
	} else {
		hidden.value = "";
		hidden.value = "0";
	}
}


//==================================================================================================
//CHAMADA		<input type="text" name="dt_feriado" size="10" maxlength="10" onKeyDown="javascript:if(window.event.keyCode==13){window.event.keyCode=9};" onKeyUp="javascript: this.value=data(this.value);" style="" value=<?echo "$dt_feriado";?>>
//==================================================================================================
function format_data(valor)
	{
	var aceita = '0123456789/';
	var resultado = '';
	for (i=0; i<=valor.length; i++)
		{
		for (j=0; j<=aceita.length; j++)
			{
			if (valor.charAt(i)==aceita.charAt(j))
				{
				if ((i==0)&&(valor.charAt(i)=='/'))
					{
					}
				else
					{
					if ((i==1)&&(valor.charAt(i)=='/'))
						{ 
						resultado = '0' + resultado;
						}
					if ((i==3)&&(valor.charAt(i)=='/'))
						{
						}
					else
						{
						if ((i==3)&&(valor.charAt(4)=='/'))
							{ 
							resultado = resultado + '0';
							}
						if ((i>=6)&&(valor.charAt(i)=='/'))
							{
							}
						else
							{
							resultado = resultado + valor.charAt(i);
							}
						}
					}
				}
			}
		}
	valor = resultado;
	resultado = '';
	for (i=0; i<=valor.length; i++)
		{
		if ((i==2)&&(valor.charAt(2)!='/')&&(valor.charAt(2)!=''))
			{
			resultado = resultado + '/';
			}
		if ((i==5)&&(valor.charAt(5)!='/')&&(valor.charAt(5)!=''))
			{
			resultado = resultado + '/';
			}
		resultado = resultado + valor.charAt(i);
		}
	return(resultado);
	}

function valid(form) {
  if (form.email.value == '') 
  	{
    alert("Você deve preencher o campo email.");
    form.email.focus();
	return false;
	}
}	

function valid_cadastro(form) {
  if (form.nome.value == '') 
  	{
    alert("Você deve preencher o campo nome.");
    form.nome.focus();
	return false;
	}

  if (form.endereco.value == '') 
  	{
    alert("Você deve preencher o campo endereço.");
    form.endereco.focus();
	return false;
	}
	
  if (form.bairro.value == '') 
  	{
    alert("Você deve preencher o campo bairro.");
    form.bairro.focus();
	return false;
	}

  if (form.cidade.value == '') 
  	{
    alert("Você deve preencher o campo cidade.");
    form.cidade.focus();
	return false;
	}
	
  if (form.uf.value == '') 
  	{
    alert("Você deve preencher o campo estado.");
    form.uf.focus();
	return false;
	}
	
  if (form.cep.value == '') 
  	{
    alert("Você deve preencher o campo cep.");
    form.cep.focus();
	return false;
	}
}	



//***********
//combo ajax
//***********

var req;

function loadXMLDoc(url,valor){ 
req = null; 
if (window.XMLHttpRequest) { 
	req = new XMLHttpRequest(); 
	req.onreadystatechange = processReqChange; 
	req.open("GET", url+'?estado='+valor, true); 
	req.send(null);
} else if (window.ActiveXObject) { 
	req = new ActiveXObject("Microsoft.XMLHTTP"); 
	if (req) { 
		req.onreadystatechange = processReqChange; req.open("GET", url+'?estado='+valor, true); 
		req.send();
	}
}
}


function processReqChange(){
	if(req.readyState == 4){
		if (req.status == 200) {
			document.getElementById('cidades').innerHTML = req.responseText;
} else { 
alert("Houve um problema ao obter os dados:\n" + req.statusText);
}
}
}


function Atualiza(valor){
	if(valor == 'nenhum'){
		document.getElementById('cidades').innerHTML = '';
		}else{
			loadXMLDoc("cidades.php",valor);
	}
}
			
function loading(){
	document.getElementById('cidades').innerHTML = "<img src='lendo.gif' width='10' height='10'> lendo informações...";
	}