// ABRIR POP-UP
function abre_pop(pagina,nome,larg,altu,rolagem) {
	window.open(pagina,nome,"resizable=no,toolbar=no,status=no,menubar=no,scrollbars="+rolagem+",width="+larg+",height="+altu)
}

// TROCA COR 
function troca_cor(dequem,qualcor) {
	document.getElementById(dequem).style.backgroundColor=qualcor;
}

//APARECE MENU FUTUANTE
function menus(acao,quem){
	document.getElementById(quem).style.visibility=acao;
}

// MUDA IMAGEM
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

var mac = (navigator.appVersion.indexOf("Mac") != -1) ? true : false;
var ie = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var fire = (navigator.userAgent.toLowerCase().indexOf("firefox") != -1) ? true : false;

if(mac && ie) document.write ('<style>.sc{padding-right:15px;}body{overflow:hidden;}</style>');

var oldo = '';

function getOffsetTop(element, deep) {
	return getOffsetProperty(element, 'Top', deep);
}

function getOffsetLeft(element, deep) {
	return getOffsetProperty(element, 'Left', deep);
}

function getOffsetProperty(element, property, deep) {
   var offsetValue = 0;
   offsetProperty = 'offset' + property;
   
   do {
      offsetValue += element[offsetProperty];
      element = element.offsetParent;
   } while (deep == true && element != document.body && element != null);
   return offsetValue;
}

function showC(o,texto) {
	if(!fire && !mac) {
		if(o) document.getElementById('comd').style.pixelTop = getOffsetTop(o,1) + 26;
		else document.getElementById('comd').style.pixelTop = getOffsetTop(oldo,1) + 26;
		if(o) document.getElementById('comd').style.pixelLeft = getOffsetLeft(o,1) - 35;
		else document.getElementById('comd').style.pixelLeft = getOffsetLeft(oldo,1) - 35;
		document.getElementById('comd').style.display='block';
		document.getElementById('c_texto2').innerHTML = "<em>"+texto+"</em>";
		oldo = o;
	}
}

function hideC() {
	if(!fire && !mac) {
	document.getElementById('comd').style.display='none';
	}
}

mouseover=true;

function coordinates() {
	if (!moveMe) {return}
	if (event.srcElement.id=="moveMe")	{
		mouseover=true;
		pleft=document.getElementById('moveMe').style.pixelLeft;
		ptop=document.getElementById('moveMe').style.pixelTop;
		xcoor=event.clientX;
		ycoor=event.clientY;
		document.onmousemove=moveImage;
		if (pleft==0 && ptop==0) {
			pleft=460;
			ptop=50;
		}
	}
}

function moveImage() {
	if (mouseover&&event.button==1)	{
		document.getElementById('moveMe').style.pixelLeft=pleft+event.clientX-xcoor;
		document.getElementById('moveMe').style.pixelTop=ptop+event.clientY-ycoor;
		document.getElementById('moveMe2').style.pixelLeft=pleft+event.clientX-xcoor;
		document.getElementById('moveMe2').style.pixelTop=ptop+event.clientY-ycoor;
		return false;
	}
}

function mouseup() {mouseover=false}

function escreve(texto,foto) {
	document.getElementById('nome').innerHTML = texto;
	var a_foto;
	a_foto = foto;
	document.arquivo.src = a_foto;
}

function escreve_link(texto,foto,id_foto) {
	document.getElementById('nome').innerHTML = texto;
	var a_foto;
	a_foto = foto;
	document.arquivo.src = a_foto;
	document.getElementById('envie').href = "amigo.asp?id_evento_foto="+id_foto;
	document.getElementById('m_vitrine').href = "vitrine.asp?id_evento_foto="+id_foto;
}

function escreve_espaco(texto,foto) {
	document.getElementById('nome_espaco').innerHTML = texto;
	var a_foto;
	a_foto = foto;
	document.arquivo.src = a_foto;
}

function escreve_link_espaco(texto,foto,id_foto) {
	document.getElementById('nome_espaco').innerHTML = texto;
	var a_foto;
	a_foto = foto;
	document.arquivo.src = a_foto;
	document.getElementById('envie').href = "amigo.asp?id_evento_foto="+id_foto;
	document.getElementById('m_vitrine').href = "vitrine.asp?id_evento_foto="+id_foto;
}


// FECHA DHTML
function fecha_dhtml(quem) {
	document.getElementById(quem).style.visibility = "hidden";
}

//Interface genérica para acesso ao conector remoto.
function createXMLHttpRequest() {
	
   try{ return new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){}
   try{ return new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){}
   try{ return new XMLHttpRequest(); }catch(e){}
   alert("XMLHttpRequest not supported");
   return null;
}

var xmlhttp = createXMLHttpRequest();

// CARREGA XML
function loadXMLDoc(url,funcao) {
	
	if (window.XMLHttpxmlhttpuest) {
	    xmlhttp = new XMLHttpxmlhttpuest();
	} else if (window.ActiveXObject) {
	    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange = funcao;
	xmlhttp.open("GET", url, true);
	xmlhttp.send(null);
}


function pub_forum() {
	if (xmlhttp.readyState==4)  {
	  // if "OK"
	  if (xmlhttp.status==200)  {

		var txt = xmlhttp.responseText;
		var xml = xmlhttp.responseXML;
		var node = xml.getElementsByTagName("publicidade");

		for (i=0;i<node.length;i++) {
			//alert("a-"+node[i].nodeName);
			for (a=0;a<node[i].childNodes.length;a++) {
				//alert("b-"+node[i].childNodes[a].nodeName);
				//alert(node[i].childNodes[a].attributes.length)
				//alert(node[i].childNodes[a].getAttribute("tipo"))
				//alert(node[i].childNodes[a].firstChild.data);
				if (node[i].childNodes[a].getAttribute("posicao") == "topo") {
					document.getElementById('topo_72890').innerHTML=node[i].childNodes[a].firstChild.data;
					document.getElementById('topo_72890').style.height = node[i].childNodes[a].getAttribute("altura");
					if (eval(node[i].childNodes[a].getAttribute("altura")) == 60 )	{
						document.getElementById('topo_72890').style.top = 21;
						document.getElementById('topo_72890').style.paddingTop = 6;
						document.getElementById('topo_72890').style.paddingBottom = 6;
					}
				}
				/*
				if (node[i].childNodes[a].getAttribute("posicao") == "top_frase") {
					document.getElementById('bn_top_frase').innerHTML=node[i].childNodes[a].firstChild.data;
				}
				if (node[i].childNodes[a].getAttribute("posicao") == "dir_patrocinio") {
					document.getElementById('dir_patrocinio').innerHTML=node[i].childNodes[a].firstChild.data;
				}
				if (node[i].childNodes[a].getAttribute("posicao") == "dir_empe") {
					document.getElementById('dir_empe').innerHTML=node[i].childNodes[a].firstChild.data;
				}
				*/
				if (node[i].childNodes[a].getAttribute("posicao") == "rod_esq") {
					document.getElementById('ban_h_dir1').innerHTML=node[i].childNodes[a].firstChild.data;
				}
				if (node[i].childNodes[a].getAttribute("posicao") == "rod_meio") {
					document.getElementById('ban_h_dir2').innerHTML=node[i].childNodes[a].firstChild.data;
				}
				if (node[i].childNodes[a].getAttribute("posicao") == "rod_dir") {
					document.getElementById('ban_h_dir3').innerHTML=node[i].childNodes[a].firstChild.data;
				}
				if (node[i].childNodes[a].getAttribute("posicao") == "lat_esq") {
					document.getElementById('ban_dir1').innerHTML=node[i].childNodes[a].firstChild.data;
				}
				if (node[i].childNodes[a].getAttribute("posicao") == "lat_meio") {
					document.getElementById('ban_dir2').innerHTML=node[i].childNodes[a].firstChild.data;
				}
				if (node[i].childNodes[a].getAttribute("posicao") == "lat_dir") {
					document.getElementById('ban_dir3').innerHTML=node[i].childNodes[a].firstChild.data;
				}
				if (node[i].childNodes[a].getAttribute("posicao") == "lat_baixo") {
					document.getElementById('ban_dir4').innerHTML=node[i].childNodes[a].firstChild.data;
				}
				/*
				if (node[i].childNodes[a].getAttribute("posicao") == "rod_meio") {
					document.getElementById('img02').innerHTML=node[i].childNodes[a].firstChild.data;
					document.getElementById('an02').innerHTML=node[i].childNodes[a].getAttribute("msg1");
					document.getElementById('n_prc02').innerHTML=node[i].childNodes[a].getAttribute("msg2");
					document.getElementById('lnk_02').href=node[i].childNodes[a].getAttribute("link");
				}
				if (node[i].childNodes[a].getAttribute("posicao") == "rod_dir") {
					document.getElementById('img03').innerHTML=node[i].childNodes[a].firstChild.data;
					document.getElementById('an03').innerHTML=node[i].childNodes[a].getAttribute("msg1");
					document.getElementById('n_prc03').innerHTML=node[i].childNodes[a].getAttribute("msg2");
					document.getElementById('lnk_03').href=node[i].childNodes[a].getAttribute("link");
				}
				if (node[i].childNodes[a].getAttribute("posicao") == "dhtml") {
					document.getElementById('dhtml').innerHTML=node[i].childNodes[a].firstChild.data;
				}
				if (node[i].childNodes[a].getAttribute("posicao") == "popup") {
					link_mod = node[i].childNodes[a].firstChild.data.replace(/&/gi,"|||")
					link_mod = link_mod.replace(/#/gi,"||")
					abre_a_foto(node[i].childNodes[a].getAttribute("local")+"pop_pub.asp?dados="+link_mod,"pop_publicidade","no",node[i].childNodes[a].getAttribute("largura"),node[i].childNodes[a].getAttribute("altura")) 
				}
				*/
			}
		}
		//alert(xmlhttp.responseText);
		//alert(node.childNodes.attributes.item(0).text);
	  }
	  else  {
		  alert("Problemas no carregamento da página\nMensagem: ' " + xmlhttp.statusText + " '\nInforme a mensagem aos moderadores do fórum.")
	  }
	}
}

