﻿// JScript File

function CheckAll(formulario, classe)
{
   	
   var formulario = document.getElementById(formulario);
   
   alert(formulario);
   
   for (var i=0; i<formulario.elements.length; i++)
   {		
		var x = formulario.elements[i];
		
		if(x.className == classe)
		{		
		    if (x.type == "checkbox")
		    {
			    x.checked = !x.checked;
		    }
	    }
    }
}



function exibePainel(painelid, campoid, value)
{
   painel = document.getElementById(painelid);
   campo = document.getElementById(campoid);  
     
   if(campo.value == value)
   {
      painel.className = "";
   }
   else
   {
      painel.className = "Oculto";
   }
}

function checkPainel(painelid, check)
{
   painel = document.getElementById(painelid);
   check = document.getElementById(check);  
     
   if(check.checked)
   {
      painel.className = "";
   }
   else
   {
      painel.className = "Oculto";
   }
}

// --------------------------------
// Popup
// Marcus Vinícius Siqueira
// Autor: Marcus Vinícius Siqueira
// Data: 24/01/2008
// --------------------------------
function popupall(Url,Name,ScrollBars,Resizable)
{
    newWindow = window.open(Url,Name,'toolbar==,location=0,directories=0,menubar=0,scrollbars=1,resizable='+Resizable+',top=0,left=0,width='+screen.availWidth+',height='+screen.availHeight+'');
    if(newWindow)
    {
        newWindow.focus();
        abriu = true
        return false
    }  
};

function openModalAll(pUrl)
{
   return openModal(pUrl, screen.availHeight, screen.availWidth); 
}

function openModal(pUrl, pWidth, pHeight)
{
	if (window.showModalDialog)
	{
		return window.showModalDialog(pUrl, window,
		  "dialogWidth:" + pWidth + "px;dialogHeight:" + pHeight + "px");
	} else
	{
		try {
			netscape.security.PrivilegeManager.enablePrivilege(
			  "UniversalBrowserWrite");
			window.open(pUrl, "wndModal", "width=" + pWidth
			  + ",height=" + pHeight + ",resizable=no,modal=yes");
			return true;
		}
		catch (e)
		{
			popup(pUrl,'');
			return false;
		}
	}
}

function popup(Url,Name, Width, Height)
{
   if(Width == null)
    {
       Width = screen.availWidth;
       Left = 0;
    }
    else
    {
        Left = ((screen.availWidth/2)-(Width/2));
    }

    if(Height == null)
    {
       Height = screen.availHeight;
       Top = 0; 
    }
    else
    {
        Top = ((screen.availHeight/2)-(Height/2));
    }
    
    if(Name == null)
    {
       Name = "PopUp";
    }   
    
    newWindow=window.open(Url,Name,'toolbar==,location=0,directories=0,menubar=0,scrollbars=1,resizable=0,left='+Left+',top='+Top+',width='+Width+',height='+Height+'');
    if(newWindow)
    {
        abriu = true
        return false
    }  
};
//---------------------------------

function ConfirmaExclusao(link, PagCancel)
{
    if(! confirm('Deseja realmente excluir este registro?'))
    {
        link.href = PagCancel;
        return false;
    }
    return true;
}

function ConfirmaCancelamento(link, PagCancel)
{
    if(! confirm('Deseja realmente cancelar esta assinatura?'))
    {
        link.href = PagCancel;
        return false;
    }
    return true;
}
function ConfirmaReativacao(link, PagCancel)
{
    if(! confirm('Deseja realmente reativar esta assinatura?'))
    {
        link.href = PagCancel;
        return false;
    }
    return true;
}

function MsgOk(msg, pagina)
{
    if (msg == "1")
        alert("Inclusão Efetuada com Sucesso");
    else
    if (msg == "2")
        alert("Alteração Efetuada com Sucesso");
    else
    if (msg == "4")
        alert("Exclusão Efetuada com Sucesso");
    
 else
    if (msg == "5")
        alert("Suspensão Efetuada com Sucesso");
    location.href=pagina;    
}

function contador(field,ncaracteres)
{
   var fieldSize =  document.getElementById(field).value.length;
   
   caracteres = document.getElementById(ncaracteres);	
   totalCaracter = fieldSize;
   caracteres.innerHTML = totalCaracter;
}