//************************************************MENU PRINCIPAL
var foo = null; // object	
function doMove() {
	  /*if(foo.style.height != "140px"){
		  foo.style.height = parseInt(foo.style.height)+20+'px';			  
	  } else {*/
	  		//mude link para fechar
			document.getElementById("bt_menu_open").style.display = "none";
			document.getElementById("bt_menu_close").style.display = "block";
			foo.style.height = "140px";
			return false;
	  //}	
	  //setTimeout(doMove,0); // call doMove in 20msec*/
	  
}
function doUnMove() {
	  /*if(foo.style.height != "0px"){
		  foo.style.height = parseInt(foo.style.height)-20+'px';			 
	  }	else {*/
		  //mude link para abrir
		  document.getElementById("bt_menu_open").style.display = "block";
		  document.getElementById("bt_menu_close").style.display = "none";
		  foo.style.height = "0px";
		  return false;
	  //}
	  //setTimeout(doUnMove,0); // call doMove in 20msec*/
	 
}

function init(x) {
	  if(x == "abrir"){
			foo = document.getElementById('MenuNavegacao'); // get the "foo" object
			//foo.style.height = '0px'; // set its initial position to 0px
			doMove(); // start animating	
	  }else{
			foo = document.getElementById('MenuNavegacao'); // get the "foo" object
			//foo.style.height = '140px'; // set its initial position to 0px
			doUnMove(); // start animating	
	  }	  
}
//************************************************OPEN WIN
janela = null;
function openWindow(theURL,winName,features) { //v2.0 */
	if (janela != null)
		{
			if (!janela.closed)
			{
				janela.close();
			}
		}	
  	janela = window.open(theURL,winName,features);
}
//************************************************BÍBLIA ONLINE
var no = /\D{1,}/;
expressao = "";
function livroSelect(myForm) {
   if (!no.test(myForm.lvBiblia.value)) {
    	expressao = "Testamento ou Livro\n"
   }   	
   if (!expressao){
       return true
   }
   else {
        expressao = "Informe:\n\n" + expressao
        alert(expressao)
        expressao=""
        return false
   }
}
//************************************************MOSTRA/ESCONDE - MENUS
function SwitchMenu(obj){
 if(document.getElementById){
 var el = document.getElementById(obj);
 var ar = document.getElementById("cont").getElementsByTagName("DIV");
  if(el.style.display == "none"){
   for (var i=0; i<ar.length; i++){
    ar[i].style.display = "none";
   }
   el.style.display = "block";
  }else{
   el.style.display = "none";
  }
 }
}
function mostra(idTag){
	var x = document.getElementById(idTag);
	x.className = "mostra";
}
function esconde(idTag){
	var x = document.getElementById(idTag);
	x.className = "esconde";
}
/* fim - funcao mostra/esconde */
function mudaCor (objetoReferencia, cor) {
		objetoReferencia.style.background = cor;
}
//***********************************************browser detect
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

//************************************************AJAX


Function.Empty = function( ) { };
function JsAjax( method, type, header ) {
	this.method = method||JsAjax.GET;
	this.type = type||JsAjax.TEXT;
	this.header = header||null;
}
// Submit types.
JsAjax.GET = "GET";
JsAjax.POST = "POST";
JsAjax.HEAD = "HEAD";
// Response Types.
JsAjax.TEXT = "text";
JsAjax.XML = "xml";
var _ms_XMLHttpRequest_ActiveX = "";
//Create the Request.
JsAjax.CreateHttpRequest = function() {
	
	var self = this;
	//alert(BrowserDetect.browser);
	//alert(BrowserDetect.version);
	//alert(BrowserDetect.OS);	
	
    // check the dom to see if this is IE or not
    if (window.XMLHttpRequest && !(BrowserDetect.browser == "Explorer" && BrowserDetect.version == "7")) {		
	// Not IE
        //self.AJAX = new XMLHttpRequest();
		try{return new XMLHttpRequest();}catch(exception){}		
		throw new Error("Browser não possui suporte ao Ajax.");		
    } else {	
	// Hello IE!
        // Instantiate the latest MS ActiveX Objects
        if (_ms_XMLHttpRequest_ActiveX) {            
			//self.AJAX = new ActiveXObject(_ms_XMLHttpRequest_ActiveX);			
			try{return new ActiveXObject(_ms_XMLHttpRequest_ActiveX);}catch(exception){}			
			throw new Error("Browser não possui suporte ao Ajax.");
        } else {			
	    // loops through the various versions of XMLHTTP to ensure we're using the latest
	    var versions = ["Msxml2.XMLHTTP.7.0", "Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP",
                        "Microsoft.XMLHTTP"];

            for (var i = 0; i < versions.length ; i++) {               
				/*try {
		    // try to create the object
		    // if it doesn't work, we'll try again
		    // if it does work, we'll save a reference to the proper one to speed up future instantiations
                    self.AJAX = new ActiveXObject(versions[i]);

                    if (self.AJAX) {
                        _ms_XMLHttpRequest_ActiveX = versions[i];
                        break;
                    }
                }
                catch (objException) {
                // trap; try next one
                } ;*/
				try{return new ActiveXObject(versions[i]);				
					_ms_XMLHttpRequest_ActiveX = versions[i];
					 break;
				}catch (objException) {
                // trap; try next one
                }
            }

            ;
        }
    }
	
	/*
	try{return new XMLHttpRequest();}catch(exception){}
	try{return new ActiveXObject("Msxml2.XMLHTTP" );}catch(exception){}
	try{return new ActiveXObject("Microsoft.XMLHTTP");}catch(exception){}
	throw new Error("Browser não possui suporte ao Ajax.");
	*/
}

/** Event's */
JsAjax.prototype.onSend = Function.Empty;
JsAjax.prototype.onUninitialized = Function.Empty;
JsAjax.prototype.onLoading = Function.Empty;
JsAjax.prototype.onLoaded = Function.Empty;
JsAjax.prototype.onComplete = Function.Empty;
JsAjax.prototype.onInteractive = Function.Empty;
JsAjax.prototype.onReadText = Function.Empty;
JsAjax.prototype.onReadXml = Function.Empty;
JsAjax.prototype.onError = function( strError ) { alert( strError ); }

/** Method's */
JsAjax.prototype.send = function( strUrl, objHeader, strContent ) {
	try {
		var handle = this;
		var request = JsAjax.CreateHttpRequest( );
		request.onreadystatechange = function( ) {
			switch ( request.readyState ) {
				case 0 : //uninitialized
					handle.onUninitialized( );
					break;
				case 1 : //loading
					handle.onLoading( );
					break;
				case 2 : //loaded
					handle.onLoaded( );
					break;
				case 3 : //interactive
					handle.onInteractive( );
					break;
				case 4 : //complete
					handle.onComplete( );
					if ( handle.type == JsAjax.XML && (request.status == 0 || request.status == 200) ) {
						handle.onReadXml( request.responseXml );
					} else if ( request.status == 0 || request.status == 200 ) {
						handle.onReadText( request.responseText );
					} else {
						handle.onError( "(" + request.status + ") Ajax request error." );
					}
					break;
			};
		}
		request.open( handle.method , strUrl, true );// Ajax (Async) -> true
		// Utiliza atributos de Header.
		if( typeof objHeader == "object" ) {
			for( var header in objHeader ) {
				request.setRequestHeader( header, objHeader[header] );
			}
		}
		handle.onSend( );
		request.send( strContent||false );
	} catch( exception ) {
		handle.onError( "AjaxError: " + exception.message );
	}
}
function fCarregaLista(url, idDestination, hide, show){
		var carregaLista = new JsAjax( );			
		carregaLista.divContent = document.getElementById(idDestination);
		carregaLista.onSend = function( ) {
			this.divContent.innerHTML = "<span class='ajaxLoadIco'><img src='layouts/images/ajax_load_snake.gif'> carregando...</span>";
			//this.divContent.innerHTML = "<span class='ajaxLoadIco'><img src='layouts/images/ajax_load_snake.gif'> Aguarde...</span>";
		}
		carregaLista.onComplete = function( ) {
			this.divContent.innerHTML = "<span class='ajaxLoadIco'><img src='layouts/images/ajax_load_snake.gif'> concluindo...</span>";
			//this.divContent.innerHTML = "<span class='ajaxLoadIco'><img src='layouts/images/ajax_load_snake.gif'> Processando...</span>";
			if(hide != ""){			
				hideById(hide);			
			}
			if(show != ""){			
				showById(show);			
			}
		}
		carregaLista.onError = function( strText ) {
			this.divContent.innerHTML = "<span class='ajaxLoadIco'><img src='layouts/images/ajax_load_snake.gif'> Desculpe, erro ao processar ação!</span>";
			
			if(hide != ""){			
				hideById(hide);			
			}
			if(show != ""){			
				showById(show);			
			}
			
		}
		carregaLista.onReadText = function( strText ) { // pode ser onReadXml
			this.divContent.innerHTML = strText;
		}
		carregaLista.send(url);
		carregaLista = null;		
		
}
function setLiAndLink( idUl,classNoSelected,classSelected,liSelect,url,idDestination, hide, show ){		
		if(hide != ""){			
			hideById(hide);			
		}
		if(show != ""){			
			showById(show);			
		}
		url = url + "&amp;tab=" + classSelected;
		var ullist=document.getElementById(idUl).getElementsByTagName("li");
		for (var i=0; i<ullist.length; i++)
		ullist[i].className=classNoSelected;	
		
		ullist[liSelect - 1].className=classSelected;
		fCarregaLista(url, idDestination, show, hide);
}
//************************************************
function hideById(id){		
			document.getElementById(id).style.display = "none";			
}
function showById(id){		
			document.getElementById(id).style.display = "block";			
}

//************************************************
//************************************************
startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
  this.className+=" aba";
  this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
  this.className=this.className.replace(" aba", "");
   }
   }
  }
 }
}
window.onload=startList;

//swap image
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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_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_findObj(n, d) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

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];}
}
//-->
//resource
function getPreviousFeaturedResource()
{
	FeaturedResources[FeaturedResource_rowid].style.display = "none";
	if(--FeaturedResource_rowid < 0)
	{
	  FeaturedResource_rowid = FeaturedResources.length-1;
	}
	FeaturedResources[FeaturedResource_rowid].style.display = "block";
}
function getNextFeaturedResource()
	{
	FeaturedResources[FeaturedResource_rowid].style.display = "none";
	FeaturedResource_rowid = ++FeaturedResource_rowid % FeaturedResources.length;
	FeaturedResources[FeaturedResource_rowid].style.display = "block";
}


// Event Listener
function addLoadListener(fn)
{
	if (typeof window.addEventListener != 'undefined')
	{
		window.addEventListener('load', fn, false);
	}
	else if (typeof document.addEventListener != 'undefined')
	{
		document.addEventListener('load', fn, false);
	}
	else if (typeof window.attachEvent != 'undefined')
	{
		window.attachEvent('onload', fn);
	}
	else
	{
		return false;
	}
	
	return true;
};




function attachEventListener(target, eventType, functionRef, capture)
{
    if (typeof target.addEventListener != "undefined")
    {
        target.addEventListener(eventType, functionRef, capture);
    }
    else if (typeof target.attachEvent != "undefined")
    {
        target.attachEvent("on" + eventType, functionRef);
    }
    else
    {
        return false;
    }

    return true;
};

// Resolution
checkBrowserWidth();

attachEventListener(window, "resize", checkBrowserWidth, false);

function checkBrowserWidth()
{
	var theWidth = getBrowserWidth();
	
	if (theWidth == 0)
	{
		var resolutionCookie = document.cookie.match(/(^|;)tmib_res_layout[^;]*(;|$)/);

		if (resolutionCookie != null)
		{
			setStylesheet(unescape(resolutionCookie[0].split("=")[1]));
		}
		
		addLoadListener(checkBrowserWidth);
		
		return false;
	}

	if (theWidth > 800)
	{
		setStylesheet("1024 x 768");
		document.cookie = "tmib_res_layout=" + escape("1024 x 768");
	}
	else
	{
		setStylesheet("");
		document.cookie = "tmib_res_layout=";
	}
	
	return true;
};




function getBrowserWidth()
{
	if (window.innerWidth)
	{
		return window.innerWidth;
	}
	else if (document.documentElement && document.documentElement.clientWidth != 0)
	{
		return document.documentElement.clientWidth;
	}
	else if (document.body)
	{
		return document.body.clientWidth;
	}
	
	return 0;
};




function setStylesheet(styleTitle)
{
	var currTag;

	if (document.getElementsByTagName)
	{
		for (var i = 0; (currTag = document.getElementsByTagName("link")[i]); i++)
		{
			if (currTag.getAttribute("rel").indexOf("style") != -1 && currTag.getAttribute("title"))
			{
				currTag.disabled = true;

				if(currTag.getAttribute("title") == styleTitle)
				{
					currTag.disabled = false;
				}
			}
		}
	}
	
	return true;
};

// Dropdown Menu
<!--//--><![CDATA[//><!--
startList = function() {
if (document.all&&document.getElementById) {
topMenuRoot = document.getElementById("topMenu");
for (x=0; x<topMenuRoot.childNodes.length; x++) {
node = topMenuRoot.childNodes[x];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
}
node.onmouseout=function() {
this.className=this.className.replace(" over", "");
}
}
}
}
}

if (window.attachEvent)
window.attachEvent("onload", startList)
else
window.onload=startList;

//--><!]]>