function puxaCont(qString,pagina,local) {
	qString 			= (qString)?qString:'rnd=' + Math.random();
	var ajax 			= new sack( pagina );
	ajax.element		= local; 
	ajax.onError		= function(){ this.elementObj.innerHTML = this.response; };
	ajax.onLoading 		= function(){ this.elementObj.innerHTML = "Buscando..." };
	ajax.onLoaded 		= function(){ this.elementObj.innerHTML = this.response; };
	ajax.onInteractive	= function(){ this.elementObj.innerHTML = "Carregando..." }; 
	ajax.onCompletion	= function(){ this.elementObj.innerHTML = this.response; };
	ajax.runAJAX( qString );
}

function abrirPag(estado){

	//if(estado != "")
		puxaCont(0,"detalhes.asp?estado=" + estado,"divRepre-geral");
	//else
	//	alert('Selecione um estado válido!');		
}

function teste(){	
	alert('JG =)');
}

function resetaCampo(campo){
	g = document.news;
	if(g[campo].value == "") g[campo].value = "Digite seu e-mail";
	return false;		
}

function limpaCampo(campo){
	g = document.news;
	if(g[campo].value == g[campo].value) g[campo].value = "";
	return false;	
}

function trocaCor(objeto,xeca){
	if(xeca == 0){
		objeto.style.background = '#f3f3f3';

	}else if(xeca == 1){
		objeto.style.background = '';
	}
}

function limpaCampo(campo){					
	if(campo.value == campo.defaultValue) 	campo.value = "";
	else if(campo.value == "")				campo.value = campo.defaultValue;							
}

/* Validador email: */

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Email Inválido!")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Email Inválido!")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   alert("Email Inválido!")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		   alert("Email Inválido!")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   alert("Email Inválido!")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   alert("Email Inválido!")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		   alert("Email Inválido!")
		    return false
		 }

 		 return true					
	}

function ValidateForm(){
	var emailID=document.news.email
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Digite o endereço de email!")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }

function formataMoeda(valor){
	
	if(valor == "" || valor == null) 
		valor = 0;
	
	valor = valor.toString();
	valor = parseFloat(valor.replace(",",".")).toFixed(2).replace(".",",");
	
	trvl = valor.slice(0,valor.lastIndexOf(","));
	novo_valor = "";

	while(trvl.length > 3){
		qtd_trvl = trvl.length;
		novo_valor = "." + trvl.slice((qtd_trvl-3),(qtd_trvl)) + novo_valor;
		trvl = trvl.slice(0,(trvl.length - 3));
	}
	
	novo_valor = valor.slice(0,trvl.length) + novo_valor + valor.slice(valor.lastIndexOf(","),valor.length);
	
	return "(R$)&nbsp;" + novo_valor;
}

//tool type
