function ano(form) 
{
  if (form.anonasc.value <= "1920")
   {
    alert("Preencha o ano de nascimento corretamente!")
    form.anonasc.focus();
   }
}

function ano2(form) 
{

  if (form.anonasc.value <= "1920"  || isNaN(form.anonasc.value))
   {
    alert("Preencha o ano de nascimento corretamente!")
    form.anonasc.focus();
   }
}

function ddd(form) 
{
  if (isNaN(form.ddd.value))
   {
    alert("Preencha o ddd somente com digitos!")
    form.ddd.focus();
   }
}

function fone(form) 
{
  if (isNaN(form.fone.value))
   {
    alert("Preencha o telefone somente com digitos!")
    form.fone.focus();
   }
}


function opentom (form) 
{
i = form.url.selectedindex;
if (form.url.options[i].value == "n")
{
form.url.selectedindex = 0;
return;
}
newwin = window.open(form.url.options[i].value, "tom2000","resizable=no,width=640,height=480,status=no,location=no,scrollbars=1,toolbar=yes,top=30,left=60");
form.url.selectedindex = 0;
newwin.focus();
return;
}  

function openwin (url, WindowName, Largura, Altura) {
newWin = window.open(url, WindowName,"resizable=no,width=" + Largura + ",height=" + Altura + ",status=no,location=no,scrollbars=1,toolbar=no,top=30,left=60");
newWin.focus();
}

function openwin2 (url, WindowName, Detalhe) {
newWin = window.open(url, WindowName,"resizable=no," + Detalhe);
newWin.focus();
}


function opencontrato (url, WindowName, Largura, Altura) {
newWin = window.open(url, WindowName,"resizable=no,width=" + Largura + ",height=" + Altura + ",status=no,location=no,scrollbars=1,toolbar=no,top=30,left=60");
newWin.focus();
}

function openanexo (url, WindowName, Largura, Altura) {
newWin = window.open(url, WindowName,"resizable=no,width=" + Largura + ",height=" + Altura + ",status=no,location=no,scrollbars=1,toolbar=no,top=30,left=60");
newWin.focus();
}

function openvantagem (url, WindowName, Largura, Altura) {
newWin = window.open(url, WindowName,"resizable=no,width=" + Largura + ",height=" + Altura + ",status=no,location=no,scrollbars=1,toolbar=no,top=30,left=60");
newWin.focus();
}

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_showHideLayers() { //v3.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 MudaPlano() {
  var texto = new String(document.form1.planos.options[document.form1.planos.selectedIndex].text);
  for ( var i = 0; i < texto.length - 1; i++){
    if (texto.charCodeAt(i) == 32){
      var aux1 = new String(texto.substring(0, i));
      var aux2 = new String(texto.substring(i + 1, texto.length))
      texto = aux1.concat(aux2);
    }  
  }
  document.img.src = document.form1.planos.options[document.form1.planos.selectedIndex].value;
  document.img.useMap = '#' + texto;
}



	function ReplaceBadChar(theString)
	{
		thePeaces = theString.split("á"); if (thePeaces.length != 0) theString = thePeaces.join("a");
		thePeaces = theString.split("é"); if (thePeaces.length != 0) theString = thePeaces.join("e");
		thePeaces = theString.split("ê"); if (thePeaces.length != 0) theString = thePeaces.join("e");
		thePeaces = theString.split("í"); if (thePeaces.length != 0) theString = thePeaces.join("i");
		thePeaces = theString.split("ó"); if (thePeaces.length != 0) theString = thePeaces.join("o");
		thePeaces = theString.split("ú"); if (thePeaces.length != 0) theString = thePeaces.join("u");
		thePeaces = theString.split("ç"); if (thePeaces.length != 0) theString = thePeaces.join("c");
		thePeaces = theString.split("ñ"); if (thePeaces.length != 0) theString = thePeaces.join("n");		
		thePeaces = theString.split("õ"); if (thePeaces.length != 0) theString = thePeaces.join("o");			
		thePeaces = theString.split("ã"); if (thePeaces.length != 0) theString = thePeaces.join("a");		
		thePeaces = theString.split("â"); if (thePeaces.length != 0) theString = thePeaces.join("a");			
		thePeaces = theString.split(" "); if (thePeaces.length != 0) theString = thePeaces.join("_");			
		return theString;
	}
	
	
	function WhatStateNumber()
	{
		var index;
		for (index = 0; index < document.TheForm.uf.length; index++)
			if (document.TheForm.cidade.value.substring(0,2) == document.TheForm.uf.options[index].value)
			{
				document.TheForm.uf.options[index].selected = true; 
				break;
			}
	}	

	function WhatStateNumberav()
	{
		var index;
		for (index = 0; index < document.TheForm.ufav.length; index++)
			if (document.TheForm.cidadeav.value.substring(0,2) == document.TheForm.ufav.options[index].value)
			{
				document.TheForm.ufav.options[index].selected = true; 
				break;
			}
	}	

	function WhatCityNumberav()
	{
		var index = 0; var index2 = 0;
		while (index < data.length) 
		{
			if (document.TheForm.cidadeav.value.substring(0,2) == data[index].substring(0,2))
			{
				if (document.TheForm.cidadeav.value == data[index]) 
				{
					document.TheForm.cidadeav.options[index2].selected = true;
					break;
				}
				index2++;
			}
			index++;
		}
	}	


	function WhatCityNumber()
	{
		var index = 0; var index2 = 0;
		while (index < data.length) 
		{
			if (document.TheForm.cidade.value.substring(0,2) == data[index].substring(0,2))
			{
				if (document.TheForm.cidade.value == data[index]) 
				{
					document.TheForm.cidade.options[index2].selected = true;
					break;
				}
				index2++;
			}
			index++;
		}
	}	



	function WhatCountryNumber()
	{
		var index;
		for (index = 0; index < document.TheForm.uf.length; index++)
			if (document.TheForm.cidade.value.substring(0,2) == document.TheForm.uf.options[index].value)
			{
				document.TheForm.uf.options[index].selected = true; 
				break;
			}
	}	

	function WhatCountryNumberav()
	{
		var index;
		for (index = 0; index < document.TheForm.ufav.length; index++)
			if (document.TheForm.cidadeav.value.substring(0,2) == document.TheForm.ufav.options[index].value)
			{
				document.TheForm.ufav.options[index].selected = true; 
				break;
			}
	}	

    
    
	function WhatCityInternationalNumber()
	{
		var index = 0; var index2 = 0;
		while (index < datai.length) 
		{
			if (document.TheForm.cidade.value.substring(0,2) == datai[index].substring(0,2))
			{
				if (document.TheForm.cidade.value == datai[index]) 
				{
					document.TheForm.cidade.options[index2].selected = true;
					break;
				}
				index2++;
			}
			index++;
		}
	}	

	function WhatCityInternationalNumberav()
	{
		var index = 0; var index2 = 0;
		while (index < datai.length) 
		{
			if (document.TheForm.cidadeav.value.substring(0,2) == datai[index].substring(0,2))
			{
				if (document.TheForm.cidadeav.value == datai[index]) 
				{
					document.TheForm.cidadeav.options[index2].selected = true;
					break;
				}
				index2++;
			}
			index++;
		}
	}	
    
    
	function Fill(source, boxTarget, state)
	{
		boxTarget.length = 0;
		for (index = 0; index < source.length; index++)
			if (state == source[index].substring(0,2))
				boxTarget.options[boxTarget.options.length] = new Option(source[index].substring(2,source[index].length), ReplaceBadChar(source[index]));		
	}


    function imprime()
    {
	    if (confirm('Clique em OK para imprimir!!!'))
           {
           	window.print();
           }
        else
           {
               window.close();
           }
        window.close();
    }
	
function submitForm() 
{
  window.open('blank.php','popup','width=400,height=300,scrollbars=1,toolbar=no,top=30,left=60');
  document.form.submit();
}	

function esconde() {
  document.getElementById('newpopup').style.visibility="hidden";
}

function setCookie2() {
  document.cookie = "newpop2=1";
}

function CancelRefresh() {
// Cancela a funcao F5
 if (window.event && window.event.keyCode == 116) {
     window.event.keyCode = 8;
    }
// Cancela o BackSpace
 if (window.event && window.event.keyCode == 8) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
    return false;
    }
}
