
// GOOGLE MAPS ::::::::::::::::::::::::::::::::::::::::::	
		var map;
		var geocoder;
		var address;
		
		function initialize($pesquisa,$endereco,$cidade,$cep) {
		  map      = new GMap2(document.getElementById("mapa"));
		  map.addControl(new GLargeMapControl3D);
		  geocoder = new GClientGeocoder();
		  convertAddress($pesquisa,$endereco,$cidade,$cep);
		  
		  GEvent.addListener(map, "click", getAddress);  
		}
		
		function getAddress(overlay, latlng) {
		  if (latlng != null) {
			address = latlng;
			geocoder.getLocations(latlng, showAddress);
		  }
		}
		
		function convertAddress(address,$endereco,$cidadeUf,$cep) {
		  geocoder.getLatLng(address,function(point) {
			  if (!point) {
				alert(address + " não encontrado!");
			  } else {
				map.setCenter(point, 15);
				var marker = new GMarker(point);
				map.addOverlay(marker);
				marker.openInfoWindowHtml(
				'<p><b>Endere&ccedil;o:</b> ' + $endereco + '<br />' +
				'<p><b>Cidade:</b> ' + $cidadeUf + '</p>' +
				'<p><b>CEP:</b> ' + $cep + '</p>'
				);
			  }
			});
		}
		
		function showAddress(response) {
		  map.clearOverlays();
		  if (!response || response.Status.code != 200) {
			alert("Status Code:" + response.Status.code);
		  } else {
			place = response.Placemark[0];
			point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
			marker = new GMarker(point);
			map.addOverlay(marker);
			// '<b>Latitude:</b>' + place.Point.coordinates[0] + '<br>' +
			// '<b>Longitude:</b>' + place.Point.coordinates[1] + '<br>' +
			// '<b>Address:</b>' + place.address;
			$array    = place.address.split("-");
			$array_   = $array[3].split(",");
			$array__ = $array[4].split(",");
			marker.openInfoWindowHtml(
			   '<p><b>Endere&ccedil;o:</b> ' + $array[0] + '-' + $array[1] + '<br />' +
			   '<p><b>Cidade:</b> ' + $array[2] + '-' + $array_[0] + '</p>' +
			   '<p><b>CEP:</b> ' + $array_[1] + '-' + $array__[0] + '</p>'
				);
		  }
		}	
		
// FIM GOOGLE MAPS :::::::::::::::::::::::::::::::::::::::::		
		
//========================================================
//INCLUSÃO DE ARQUIVOS SWF
//========================================================
//--------------------------------------------------------
//Na página, incluir os arquivos SWF desta maneira:
//<script> 
//EscreveFlash(LARGURA, ALTURA, "arquivo.swf");
//< / script>  (sem os espaços)
//--------------------------------------------------------
function EscreveFlash(piWid, piHei, psSrc, psId)
{
var strSwf;

strSwf = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" id="+psId+" width="+piWid+" height="+piHei+">";
strSwf += "<param name=\"movie\" value=\""+psSrc+"\"' />";
strSwf += "<param name=\"allowScriptAccess\" value=\"sameDomain\" />";
strSwf += "<param name=\"quality\" value=\"high\" />";
strSwf += "<param name=\"wmode\" value=\"transparent\" />";
strSwf += "<embed id="+psId+" name="+psId+" allowScriptAccess=\"sameDomain\" swLiveConnect=\"true\" src=\""+psSrc+"\" quality=\"high\" wmode=\"transparent\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width="+piWid+" height="+piHei+"></embed></object>";

this.document.write(strSwf);
} 
function validaSenha(campo1,campo2){
	if(document.getElementById(campo1).value != document.getElementById(campo2).value){
		document.getElementById(campo1).value="";
		document.getElementById(campo2).value ="";
		document.getElementById(campo1).focus();
		return alert('A senha nao confere!');
	}else{
		return "";
	}
}

// LIMITA a quantidade de caracteres no TEXTAREA
function limit_caractere($e,$obj,$cont,$vlr){
	$vlr2      = $vlr - 1;
	$contador  = document.getElementById($cont);
	$qntd      = $vlr - $obj.value.length; // $qntd recebe o total estipulado de carac. estabelecido por $vlr
	$tecla     = (window.event)?event.keyCode:$e.which;
	
	if ($tecla != 9){
		if($tecla != 0 && $tecla != 8){
			$result = 'Carac. restantes: '+ ($qntd - 1);	
			$contador.value = $result;
			$total = $obj.value;
			$total = $total.substring(0,$vlr2); // reservatorio de dados
			
			if($qntd <= 0){
				$obj.value = '';
				$obj.value = $total;
				$contador.value = 'Carac. restantes: '+ $qntd;
			}			
		}else{
			if($qntd < 250){
			$contador.value = 'Carac. restantes: '+ ($qntd+1);
			}
		}
	}	
} 

// mascara para telefone
function tel(elemento){
var telefone
if (elemento.value.length > 0 )
{
if (elemento.value.length == 1)
{
telefone = elemento.value;
elemento.value = '(' + telefone;
elemento.focus();
}
if (elemento.value.length == 3)
{
telefone = elemento.value;
elemento.value = telefone + ') ';
elemento.focus();
}
}
return 0;
}

//--------------------------------------------------------
// Campo somente numérico
// Colocar onkeypress='return numerico(event)' no campo do formulário
// permite o usuário digitar somente numeros
//--------------------------------------------------------
function numerico($evento) { 
    var $tecla=(window.event)?event.keyCode:$evento.which;
	
	if (($tecla == 0) || ($tecla == 8)){
		return true;
	}
	
    if(($tecla > 47 && $tecla < 58)){
		return true;
	}else{
		return false;	
	}    
} 