﻿// BinaryChoice - js de comportamentos // 
// Última Atualização :: 04/2008
 
//========================================================================================================
// Janelas Pop-up
// WindowsShow('elemento.ext','150','200','yes')
//========================================================================================================
function WindowShow(elemento,wsize,hsize,scro)
{
if (navigator.appName == "Microsoft Internet Explorer")
{
wsize = parseInt(wsize) + 20;
hsize = parseInt(hsize) + 20;
}
BinaryWindow = window.open(elemento,"WinView","resizable=no,toolbar=no,status=no,menubar=no,scrollbars="+scro+",screenX=20,screenY=20,top=20,left=20,dependent=yes,width="+wsize+",height="+hsize+"")
if(false == BinaryWindow.closed) 
 {
   BinaryWindow.close ();
   BinaryWindow = window.open(elemento,"WinView","resizable=no,toolbar=no,status=no,menubar=no,scrollbars="+scro+",screenX=20,screenY=20,top=20,left=20,dependent=yes,width="+wsize+",height="+hsize+"")
 }
}
//========================================================================================================
// Exibe oculta objetos
// action: 0=exibe | 1=oculta
//========================================================================================================
function showHide(id,action) {
 var obj = document.getElementById(id);
 
 if(action == true) {
  obj.style.display = "inline";
 } if  (action == false){
  obj.style.display = "none";
 }
}

//========================================================================================================
//== Troca a imagem de um item
//== trocaImagem(imagematual,novaimagem)
//========================================================================================================
function trocaImagem(img_name,imgNome){
document[img_name].src=imgNome;
}

//========================================================================================================
// Alterar cor no mouseOver			  																	==
//uso: onmouseover="tdCorClass(this,'tdOver');" onmouseout="tdCorClass(this,'tdNormal');"			    ==
//========================================================================================================

function tdCorClass(Obj,nomeClass){
var CssClass = nomeClass;
Obj.className = CssClass;
}

//uso: onmouseover="tdBgStyle(this,'#F8FDC6');" onmouseout="tdBgStyle(this,'#D1E809');"

function tdBgStyle(Obj,Cor){
var CssStyle = Cor;
Obj.style.backgroundColor = CssStyle;
}

//========================================================================================================
// Adicionar aos Favoritos			  																	==
//uso: addBookmark(url, titulo)																		    ==
//========================================================================================================

function addBookmark(url, titulo)
{
	//Parâmetros: 
	//url: Endereço a ser adicionado
	//titulo: Título que aparecerá nos Favoritos
	if (document.all)
		window.external.AddFavorite(url, titulo)
}

//========================================================================================================
// Switcher							  																	==
//========================================================================================================

function SwitchMenu(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("TreeView").getElementsByTagName("span"); 
		if(el.style.display != "block"){ 
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu") 
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}

//------------------------------ Switchmenu2

function SwitchMenu2(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("masterdiv2").getElementsByTagName("span"); //DynamicDrive.com change
		if(el.style.display != "block"){ //DynamicDrive.com change
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu2") //DynamicDrive.com change
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}

/////////////////////////////////////////////////////////////////////////////////////////////////// AJAX - XMLHTTPRequests.
function createXMLHTTP() 
	{
		var ajax;
		try 
		{
			ajax = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(e) 
		{
			try 
			{
				ajax = new ActiveXObject("Msxml2.XMLHTTP");
				alert(ajax);
			}
			catch(ex) 
			{
				try 
				{
					ajax = new XMLHttpRequest();
				}
				catch(exc) 
				{
					 alert("Este navegador nao suporta recursos de Ajax.");
					 ajax = null;
				}
			}
			return ajax;
		}
	
	
		   var arrSignatures = ["MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0",
							    "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP",
							    "Microsoft.XMLHTTP"];
		   for (var i=0; i < arrSignatures.length; i++) 
		   {
				try 
				{
					var oRequest = new ActiveXObject(arrSignatures[i]);
					return oRequest;
				} 
				catch (oError) 
				{
			    }
		   }
		
			   throw new Error("MSXML nao esta instalado neste sistema.");
	}
	
	
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
