/*
  // Altere a linha abaixo com a URL da sua imagem da neve.
  var snowsrc="img/flocosnatal.gif"
  // Altere a linha abaixo com o número da qtd de neves que aparecerá juntas.
  var no = 30;

  var ns4up = (document.layers) ? 1 : 0;  // browser sniffer
  var ie4up = (document.all) ? 1 : 0;
  var ns6up = (document.getElementById&&!document.all) ? 1 : 0;

  var dx, xp, yp;    // coordinate and position variables
  var am, stx, sty;  // amplitude and step variables
  var i, doc_width = 760, doc_height = 600;
  
  if (ns4up||ns6up) {
    doc_width = self.innerWidth;
    doc_height = self.innerHeight;
  } else if (ie4up) {
    doc_width = 760;
    doc_height = 600;
  }

  dx = new Array();
  xp = new Array();
  yp = new Array();
  am = new Array();
  stx = new Array();
  sty = new Array();
  
  for (i = 0; i < no; ++ i) {  
    dx[i] = 0;                        // set coordinate variables
    xp[i] = Math.random()*(doc_width-50);  // set position variables
    yp[i] = Math.random()*doc_height;
    am[i] = Math.random()*20;         // set amplitude variables
    stx[i] = 0.02 + Math.random()/10; // set step variables
    sty[i] = 0.7 + Math.random();     // set step variables
    if (ns4up) {                      // set layers
      if (i == 0) {
        document.write("<div name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><img src='"+snowsrc+"' border=\"0\"></layer>");
      } else {
        document.write("<layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><img src='"+snowsrc+"' border=\"0\"></layer>");
      }
    } else if (ie4up||ns6up) {
      if (i == 0) {
        document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><img src='"+snowsrc+"' border=\"0\"></div>");
      } else {
        document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><img src='"+snowsrc+"' border=\"0\"></div>");
      }
    }
  }
  
  function snowNS() {  // Netscape main animation function
    for (i = 0; i < no; ++ i) {  // iterate for every dot
      yp[i] += sty[i];
      if (yp[i] > doc_height-50) {
        xp[i] = Math.random()*(doc_width-am[i]-30);
        yp[i] = 0;
        stx[i] = 0.02 + Math.random()/10;
        sty[i] = 0.7 + Math.random();
        doc_width = 760;
        doc_height = 600;
      }
      dx[i] += stx[i];
      document.layers["dot"+i].top = yp[i];
      document.layers["dot"+i].left = xp[i] + am[i]*Math.sin(dx[i]);
    }
    setTimeout("snowNS()", 10);
  }

  function snowIE_NS6() {  // IE and NS6 main animation function
    for (i = 0; i < no; ++ i) {  // iterate for every dot
      yp[i] += sty[i];
      if (yp[i] > doc_height-50) {
        xp[i] = Math.random()*(doc_width-am[i]-30);
        yp[i] = 0;
        stx[i] = 0.02 + Math.random();
        sty[i] = 0.7 + Math.random()*10;
        doc_width = ns6up?window.innerWidth : 760;
        doc_height = ns6up?window.innerHeight : 600;
      }
      dx[i] += stx[i];
      if (ie4up){
      document.all["dot"+i].style.pixelTop = yp[i];
      document.all["dot"+i].style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]);
      }
      else if (ns6up){
      document.getElementById("dot"+i).style.top=yp[i];
      document.getElementById("dot"+i).style.left=xp[i] + am[i]*Math.sin(dx[i]);
      }   
    }
    setTimeout("snowIE_NS6()", 200);
  }

  if (ns4up) {
    snowNS();
  } else if (ie4up||ns6up) {
    snowIE_NS6();
  }

*/
function MM_openBrWindow(theURL,winName,features)
 {
  window.open(theURL,winName,features);
 }
function btmsglogin(){
  alert("Para inserir recardo voce precisa esta logado. \nCaso voce não tenha cadastro va no menu cadastro.");
}
 function Validapesquisa() {
    var RB_PESQUISA = document.frm_procura.rb_pesquisa.value;

    if (RB_PESQUISA == '' )
	 {
      alert('Selecione o tipo de procura.');
	  document.frm_procura.txt_pesquisa.focus();
	  return false;
	 }

	 else
	  {
		return true;
	 }
}
// JavaScript Document
function efeitomenu(efeito,onoff){
	if(onoff=="on"){
		efeito.style.backgroundColor="#fdfdfd"; 
		efeito.style.textDecoration ="underline";
	}else if(onoff=="off"){
		efeito.style.backgroundColor="#f7f7f7";
		efeito.style.textDecoration="none";
	}
}

function efeitomenu(efeito,onoff){
	if(onoff=="on"){
		efeito.style.backgroundColor="#fdfdfd"; 
		efeito.style.textDecoration ="underline";
	}else if(onoff=="off"){
		efeito.style.backgroundColor="#f7f7f7";
		efeito.style.textDecoration="none";
	}
}

function carregarOpcao(link_url, id_elemento)
	{
        	var objXMLHttpRequest = false;
			
        	if (window.XMLHttpRequest) {
        	
        		objXMLHttpRequest = new XMLHttpRequest();
        	} else if (window.ActiveXObject) {
        	
        		objXMLHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
        	}
		if (objXMLHttpRequest) {
			var obj = document.getElementById(id_elemento);
	
			objXMLHttpRequest.open("POST", link_url);			

			objXMLHttpRequest.onreadystatechange = 
			        function()
				{
				if (objXMLHttpRequest.readyState == 1) {
				    // Cria o efeito de loading
						exibirBgBody();
			   	        loading(true);	
			       } // if->readyState->1
				  if (objXMLHttpRequest.readyState == 4 && objXMLHttpRequest.status == 200) 
				  {
				  	loading(false);
                    removerDivs();
					obj.innerHTML = objXMLHttpRequest.responseText;
		            objXMLHttpRequest.destroy;
	 	            objXMLHttpRequest.free;
					
				  }
			}
		objXMLHttpRequest.send(null);
		}		
	}

function removerDivs() {
	var bgBody = gE('bgBody');
	var boxCad = gE('boxCad');
	bgBody.parentNode.removeChild(bgBody);
	if (boxCad) { // Por que ao clicar X (para deletar um registro) cria-se somente o encobridor e não o boxCad	
		boxCad.parentNode.removeChild(boxCad);
	}
}

function exibirBgBody() {
	// Seleciona a tag body. item(0) por que só existe uma tag body
	var tagBody = gEs('body').item(0);
	// Pega os tamanhos atuais da página, como largura, altura, ...
	var sizesPage = getPageSize();
	// Vamos criar uma tag div
	var bgBody = document.createElement('div');
	// Setar o atributo ID a div criada
	bgBody.setAttribute('id','bgBody');
	// Essa div terá o tamanho exato da página
	bgBody.style.height = arrayPageSize[1] + 'px';
	// Essa div terá a largura exata da página
	bgBody.style.width = arrayPageSize[0] + 'px';
	// Evita criar a div novamente
	if (!gE('bgBody')) {
		tagBody.insertBefore(bgBody, tagBody.firstChild);
	}	
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 

}

// Utilizado para evitar de digitar: document.getElementById toda hora, tornando o processo mais prático
function gE(ID) {
	return document.getElementById(ID);
}

// Utilizado para evitar de digitar: document.getElementsByTagName toda hora, tornando o processo mais prático
function gEs(tag) {
	return document.getElementsByTagName(tag);
}

// Utilizado para criar o efeito de loading
function loading(opt) {
	if (opt == true) {
		// A tag que receberá a img de loading
		var refer = document.getElementById('bgBody');
		// O tamanho da referida tag
		var referHeight = refer.offsetHeight;
		// Dizemos que os elementos dentro dela será alinhado ao centro
		refer.style.textAlign = 'center';
		// Criamos uma imagem, img.
		var img = document.createElement('img');
		// Informamos o caminho da img
		img.setAttribute('src','img/imgLoading.gif');
		// Setamos um atributo ID na img criada
		img.setAttribute('id','loading');
		// Definimos seu tamanho
		img.setAttribute('width','126');
		// Dizemos que o margin-top será a metada do tamanho da div
		img.style.marginTop = (referHeight /2) + 'px';
		// Evita que seja criada duas ou mais img de loading
		if (!document.getElementById('loading')) {
			// Insere a img na tag informada na variável refere
			refer.insertBefore(img, refer.firstChild);
		}
	} else if (opt == false) {
		// Referenciamos a img de login através de seu ID
		var imgLoading = document.getElementById('loading');
		// Removemos a img de loading
		if (imgLoading) {
			imgLoading.parentNode.removeChild(imgLoading);
		}
	}
}
function carregarmeio(link_url, id_elemento)
	{
        	var objXMLHttpRequest = false;
			
        	if (window.XMLHttpRequest) {
        	
        		objXMLHttpRequest = new XMLHttpRequest();
        	} else if (window.ActiveXObject) {
        	
        		objXMLHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
        	}
		if (objXMLHttpRequest) {
			var obj = document.getElementById(id_elemento);
	
			objXMLHttpRequest.open("POST", link_url);			

			objXMLHttpRequest.onreadystatechange = 
			        function()
				{
				if (objXMLHttpRequest.readyState == 1) {
				    // Cria o efeito de loading
						//exibirBgBody();
			   	        loading(true);	
			       } // if->readyState->1
				  if (objXMLHttpRequest.readyState == 4 && objXMLHttpRequest.status == 200) 
				  {
				  	loading(false);
                     //
					obj.innerHTML = objXMLHttpRequest.responseText;
		            objXMLHttpRequest.destroy;
	 	            objXMLHttpRequest.free;
					
				  }
			}
		objXMLHttpRequest.send(null);
		}		
	}

// Cria a div denominada como boxCad, a qual conterá o formulário de cadastro
function boxCad() {
	// Cria um 'container' que comportará o formulário de cadastro.
	var objBody = gEs('body').item(0);
	var sizesPage = getPageSize();
	var boxCad = document.createElement('div');
	boxCad.setAttribute('id','boxCad');
	var wPage = arrayPageSize[0]; // Largura total da página
	var hPage = arrayPageSize[1]; // tamanho total da página
	/*boxCad.style.width = (wPage / 2) + 'px'; // metade da largura da página*/
	boxCad.style.height = (wPage / 2) + 'px'; // metada da altura da página
	boxCad.style.marginTop = -(wPage / 4) + 'px'; // 1 quarto da largura
	//boxCad.style.marginLeft = -(wPage / 4) + 'px'; // 1 quarto da altura
	objBody.insertBefore(boxCad, objBody.lastChild);
}

function MostraFoto(evento,foto){
		exibirBgBody();
		boxCad();
		carregarmeio('mostrafoto.php?evento='+evento+'&foto='+foto,'boxCad');
 } 
function MostraNoticias(idnot,foto){
		exibirBgBody();
		boxCad();
		carregarmeio('mostranoticia.php?id='+idnot,'boxCad');
 } 
 
 