function criaXMLHttp() {
	if (typeof XMLHttpRequest != "undefined") {
          return new XMLHttpRequest();
	} else if (window.ActiveXObject){
		var versoes = ["MSXML2.XMLHttp.5.0",
			"MSXML2.XMLHttp.4.0", "MSXML2.XMLHttp.3.0",
			"MSXML2.XMLHttp", "Microsoft.XMLHttp"
			];
	    for (var i = 0; i < versoes.length; i++) {
			try {
			return new ActiveXObject(versoes[i]);
			} catch (e) {}
		}//for
	}//else
	throw new Error("Seu browser nao suporta AJAX");
}

// mostra e esconde COMENTARIOS do blog (tipo o 'toogle' jquery)
$show_hide_armaz = '';
function toogle($obj){
		if($show_hide_armaz.indexOf($obj) != -1 ){			
			var $array_armaz = $show_hide_armaz.split(" ");
			$show_hide_armaz = '';
			
			for($i=0;$i<=($array_armaz.length - 1);$i++){
				
				if($array_armaz[$i] == $obj){
					$("#"+$array_armaz[$i]).slideUp();					
				}else{
					$show_hide_armaz += $array_armaz[$i]+' ';	
				}					
			}			
		
		}else{			
			$("#"+$obj).slideDown();			
			if($show_hide_armaz.indexOf($obj) == -1){
				$show_hide_armaz += $obj+' ';
			}
		}	
}		

// 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);
			}
		}
	}	
} 

//--------------------------------------------------------
//Formatação e validação de número de telefone
//Colocar onKeyUp="tel(this)" no campo do formulário
//Formatar o campo com 16 caracteres
//Mesclar esta função com a função com a formatação de
//campo somente numérico
//--------------------------------------------------------
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;	
	}    
} 

// Criado por Cedilha Comunicação e Design (www.cedilha.com.br)
//-------------------------------------------------------------------------------------------


//Integração Twitter
getTwitters(
	'arquilondrina',{
	id: 'arquilondrina',
	count: 3,
	enableLinks: true,
	ignoreReplies: true,
	clearContents: true,
	lang: 'pt-br',
	template: '<span class="prefixo"><a href="http://twitter.com/%user_screen_name%/">%user_name%</a></span><br /><span class="texto">%text%</span>'
});






// 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>Telefone:</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 :::::::::::::::::::::::::::::::::::::::::
