// JavaScript Document
<!--
var SiteEndereco = "http://wiffy.no-ip.org:8080/Minamel/";
function AJAX(Url,Div,Met){
	var req = null; 
	var setDiv = Div;
	document.getElementById(setDiv).innerHTML = "<div style=\"text-align:center\"><img src=\""+SiteEndereco+"templates/inicial/imagens/carregando2.gif\"/></div>";
	
	//para funcinoar no MOZILLA	
	if(window.XMLHttpRequest){
		req = new XMLHttpRequest();
		if (req.overrideMimeType){
			req.overrideMimeType('text/xml');
		}
	}
	//para funcionar no IE
	else if (window.ActiveXObject) {
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e)	{
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	req.onreadystatechange = function(){
		document.getElementById(setDiv).innerHTML = "<div style=\"text-align:center\"><img src=\""+SiteEndereco+"templates/inicial/imagens/carregando2.gif\"/></div>";
		if(req.readyState == 4){//Request foi aceito
			if(req.status == 200){//encontrou dados
				document.getElementById(setDiv).innerHTML = req.responseText;
			}else{ //Não encotra os dados
				document.getElementById(setDiv).innerHTML = "Erro: status do código retornado" + req.status + " " + req.statusText;
			}	
		} 
	};
	req.open("GET", Url, true);
	req.send(null);
}
function carrega_img(PAG,IMG,WIDTH,HEIGHT){
	abre('dpopup',WIDTH,HEIGHT);
	AJAX(PAG+IMG, "pop_img");
	return false;
} 
function atualiza(UF,ID){	
	AJAX("cidades.php?ID="+UF,ID);
}
function busca_end(PAG,CEP, ID){
	AJAX(PAG+"?cep="+CEP, ID);
}
function doDestacaTexto(Texto, termoBusca){
	
	/*******************************************************************/
	// CASO QUEIRA MODIFICAR O ESTILO DA MARCAÇÃO ALTERE ESSAS VARIÁVEIS
	/*******************************************************************/
	inicioTag = "<font class='destaque_busca'>";
	fimTag = "</font>";
	
	var novoTexto = "";
	var i = -1;
	var lcTermoBusca = termoBusca.toLowerCase();
	var lcTexto 	 = Texto.toLowerCase();
	
	while (Texto.length > 0){
		i = lcTexto.indexOf(lcTermoBusca, i+1);
		if (i < 0){
			novoTexto += Texto;
			Texto = "";
		}else{
			if (Texto.lastIndexOf(">", i) >= Texto.lastIndexOf("<", i)){
				if (lcTexto.lastIndexOf("/script>", i) >= lcTexto.lastIndexOf("<script", i)){
					
					novoTexto += Texto.substring(0, i) + inicioTag + Texto.substr(i, termoBusca.length) + fimTag;
	  				Texto = Texto.substr(i + termoBusca.length);
					lcTexto = Texto.toLowerCase();
	  				i = -1;
				}
			}
		}
	}
	return novoTexto;
}

function destaca_texto(textoBusca, textoObj, frase){
	if(textoBusca != ''){
		if (frase){
			arrayBusca=[textoBusca];
		}else{
			arrayBusca = textoBusca.split(" ");
		}
		var areaObj = document.getElementById(textoObj);
		var Texto = areaObj.innerHTML;		
		
		for (var i = 0; i < arrayBusca.length; i++){
			Texto = doDestacaTexto(Texto, arrayBusca[i]);
		}
		areaObj.innerHTML = Texto;
		return true;
	}
}
/* FUNÇÕES DO POPUP */
function fecha(x){
	var tam = document.getElementById(x);
	tam.style.display = "none";
	 return false;
}
/* movimento da janela "popup"*/
var ie=document.all;
var nn6=document.getElementById&&!document.all;
var isdrag=false;
var mousex,mousey;
var dobj;

function abre(D,X,Y){
	var setDiv 	= D;
	var	res		= screen.width;
	var pos = (res - X)/2
	
	var tam = document.getElementById(setDiv);
	tam.style.width 	= X+"px";
	tam.style.height 	= Y+"px";
	tam.style.left 		= pos+"px";
	tam.style.display 	= "block";
	
}

function movemouse(e){
	if (isdrag){		
		dobj.style.left = nn6 ? tx + e.clientX - mousex+"px" : tx + event.clientX - mousex+"px";
    	dobj.style.top  = nn6 ? ty + e.clientY - mousey+"px" : ty + event.clientY - mousey+"px";
		return false;
	}
}

function selectmouse(e){
	
	var fobj       = nn6 ? e.target : event.srcElement;
	var topelement = nn6 ? "html" : "body";
	/*
	while (fobj.tagName != toplement && fobj.className != "cpopup"){
		fobj = nn6 ? fobj.parentNode : fobj.parentElement;
		
	}
	*/
	//alert(fobj.className);
	if (fobj.className=="cpopup"){
		isdrag = true;
		dobj = fobj;		
		tx = parseInt(dobj.style.left+0+"px");
		ty = parseInt(dobj.style.top+0+"px");
		mousex = nn6 ? e.clientX : event.clientX;
		mousey = nn6 ? e.clientY : event.clientY;
		document.onmousemove=movemouse;
		return false;
	}
}

document.onmousedown=selectmouse;
document.onmouseup=new Function("isdrag=false");
function submenu_on(ID){
	var tam = document.getElementById(ID);
	tam.style.display = "block";
	return false;
}
function submenu_off(ID){
	var tam = document.getElementById(ID);
	tam.style.display = "none";
	return false;
}
<!-- comentários -->
function validar_campos(){
	
	if($('nome').value == ""){
		$('mensagem').innerHTML = "Quem é você? (informe o nome)<br />";
		$('msg_erro').hide();
		$('msg_erro').appear({duration: 0.3});
		document.contato.nome.focus();
		return false;
	}else if($('email').value == ""){
		$('mensagem').innerHTML = "Informe um e-mail e fique tranquilo(a) que não faremos nenhum SPAM!<br />";
		$('msg_erro').hide();
		$('msg_erro').appear({duration: 0.3});
		document.contato.email.focus();
		return false;
	}else if($('msg').value == ""){
		$('mensagem').innerHTML = "Deixe seu comentário...<br />";
		$('msg_erro').hide();
		$('msg_erro').appear({duration: 0.3});
		document.contato.msg.focus();
		return false;
	}
	return true;
}
function mostraDiv(ID){
	var id = document.getElementById(ID);
	if(id.style.display == "none"){
		$(ID).appear({duration: 0.3});
	}else{
		$(ID).hide();
	}
	return true;
}
function newsletter(ID,TXT){
	var id = document.getElementById(ID);
	if(id.value == TXT){
		id.value = "";
	}else if(id.value == ""){
		id.value = TXT;
	}
	return true;
}
-->
