function createAjaxObj(){
	var httprequest=false
	if (window.XMLHttpRequest){ 
		httprequest=new XMLHttpRequest()
		if (httprequest.overrideMimeType)
			httprequest.overrideMimeType('text/xml')
	}
	else if (window.ActiveXObject){ 
		try {
			httprequest=new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e){
			try {
				httprequest=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){}
		}
	}
	return httprequest
}

var ajaxpack=new Object()
ajaxpack.basedomain="http://"+window.location.hostname
ajaxpack.ajaxobj=createAjaxObj()
ajaxpack.filetype="txt"
ajaxpack.addrandomnumber=0 

ajaxpack.getAjaxRequest=function(url, parameters, callbackfunc, filetype){
	ajaxpack.ajaxobj=createAjaxObj() 
	if (ajaxpack.addrandomnumber==1) 
		var parameters=parameters+"&ajaxcachebust="+new Date().getTime()
	if (this.ajaxobj){
		this.filetype=filetype
		this.ajaxobj.onreadystatechange=callbackfunc
		this.ajaxobj.open('GET', url+"?"+parameters, true)
		this.ajaxobj.send(null)
	}
}

ajaxpack.postAjaxRequest=function(url, parameters, callbackfunc, filetype){
	ajaxpack.ajaxobj=createAjaxObj() 
	if (this.ajaxobj){
		this.filetype=filetype
		this.ajaxobj.onreadystatechange = callbackfunc;
		this.ajaxobj.open('POST', url, true);
		this.ajaxobj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		this.ajaxobj.setRequestHeader("Content-length", parameters.length);
		this.ajaxobj.setRequestHeader("Connection", "close");
		this.ajaxobj.send(parameters);
	}
}
var funcaoRetorno='';
function mostraInv(tmp) {
	if (document.getElementById(tmp).style.display=='none') 
		document.getElementById(tmp).style.display='block';
	else 
		document.getElementById(tmp).style.display='none';
}

function showMsg(msg) {
	try{
		if(msg.length==0) {
			document.getElementById("msgdiv").innerHTML = '';
			document.getElementById("msgdiv").style.display = "none";
		}
		else {
			document.getElementById("msgdiv").innerHTML = '<a href="javascript: showMsg(\'\'); menuLogin(0)" class="fecha" style="float:right; margin-right:10px;"></a>'+msg;
			document.getElementById("msgdiv").style.display = "block";
		}
	} catch(e){}
}
function showSaida(msg) {
	if(msg.length==0) {
		document.getElementById("saidadiv").innerHTML = '';
		document.getElementById("saidadiv").style.display = "none";
	}
	else {
		document.getElementById("saidadiv").innerHTML = msg;
		document.getElementById("saidadiv").style.display = "block";
	}	
}

function nl2br(tmp){
re="\n";
saida=tmp.replace(re,"<br>");
if (tmp.match(re)) nl2br(saida)
return saida;
}
function processGetPost(){
var myajax=ajaxpack.ajaxobj
var myfiletype=ajaxpack.filetype
	if (myajax.readyState == 4){ //if request of file completed
		if (myajax.status==200 || window.location.href.indexOf("http")==-1){ //if request was successful or running script locally
			

			if (myfiletype=="txt"){
				eval(funcaoRetorno + '(myajax.responseText)');
			}
			else {
				eval(funcaoRetorno + '(myajax.responseXML)');
			}
		}
	}
}

function sendData(formname,funcaoRet,formato){
	a=funcaoRet.lastIndexOf("/")+1
	funcaoRetorno=funcaoRet.substring(a)
	showMsg("Aguarde...")
	var formulario = document.forms[formname];
	var saida="";
	for (a=0;a<formulario.length;a++) {
		var type=formulario.elements[a].type.substr(0,4);
		switch (type) {
			case "text":
				saida+=formulario.elements[a].name+"="+encodeURI(formulario.elements[a].value)+ "&"
				break
			case "pass":
				saida+=formulario.elements[a].name+"="+encodeURI(formulario.elements[a].value)+ "&"
				break
			case "hidd":
				saida+=formulario.elements[a].name+"="+encodeURI(formulario.elements[a].value)+ "&"
				break
			case "radi":
				if (formulario.elements[a].checked) saida+=formulario.elements[a].name+"="+encodeURI(formulario.elements[a].value)+ "&"
				break
			case "chec":
				if (formulario.elements[a].checked) saida+=formulario.elements[a].name+"="+encodeURI(formulario.elements[a].value)+ "&"
				break
			case "sele":
				if (formulario.elements[a].value!='') saida+=formulario.elements[a].name+"="+encodeURI(formulario.elements[a].value)+ "&"
				break
			default: 
			break
		}
	}
	saida+="formname="+encodeURI(formulario)
	ajaxpack.postAjaxRequest(funcaoRet+".php", saida, processGetPost, formato)
}
function sendGetData(valor,funcaoRet,formato){
	a=funcaoRet.lastIndexOf("/")+1
	funcaoRetorno=funcaoRet.substring(a)
	showMsg("Aguarde...")
	ajaxpack.getAjaxRequest(funcaoRet+".php", "valor="+valor, processGetPost, formato)
}
function alternaBloco(tmp){
	a=document.getElementById(tmp).style.display;
	if (a=='block') 
		document.getElementById(tmp).style.display='none'; 
	else
		document.getElementById(tmp).style.display='block';
}
function mostraBloco(tmp){
	document.getElementById(tmp).style.display='block';
}
function escondeBloco(tmp){
	document.getElementById(tmp).style.display='none';
}

function mostraDados(tmp){
	window.open(local+'anuncios/mostradados.php?id='+tmp,'dados','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=no,width=900,height=540');
}
function mostraDados2(tmp){
	//alert("mostraDados2 - MUDAR PARA MOSTRADADOS")
	mostraDados(tmp)
	//window.open('anuncios/mostradados.php?id='+tmp,'dados','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=no,width=900,height=540');
}
function mostraAlbum(tmp){
	window.open(local+'albuns/mostra_album.php?id='+tmp,'album','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=850,height=600')
}
function mostraAlbumSenha(tmp){
	window.open(local+'albuns/mostra_album_senha.php?id='+tmp,'album','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=850,height=600')
}
function chatDireto(qual) {
	alert("O chat direto está temporariamente desabilitado.")
	
}