
var tophl1ini;
var tophl2ini;
var tophl3ini;

var tamtexto1;
var tamtexto2;
var tamtexto3;
var tamtexto4;
var tamtexto5;
var tamtexto6;
var tamtexto7;
var tamtexto8;
var tamtexto9;

var ultnum;

			
function PosicionaV(obj, top)
{
	obj.style.position = "absolute";
	obj.style.top = top;
}

function TrocaImg(obj, num)
{
	obj.src = "Imagens/baixo.gif";
	
	var tamtexto;
	if( num == 1)
	{
		tamtexto = tamtexto1;
	}
	else if( num == 2)
	{
		tamtexto = tamtexto2;
	}
	else if( num == 3)
	{
		tamtexto = tamtexto3;
	}
	else if( num == 4)
	{
		tamtexto = tamtexto4;
	}
	else if( num == 5)
	{
		tamtexto = tamtexto5;
	}
	else if( num == 6)
	{
		tamtexto = tamtexto6;
	}
	else if( num == 7)
	{
		tamtexto = tamtexto7;
	}
	else if( num == 8)
	{
		tamtexto = tamtexto8;
	}
	else if( num == 9)
	{
		tamtexto = tamtexto9;
	}
	
	
	AddAbre(obj, num, tamtexto);
	
}

function AddAbre(obj, num, tamtexto)
{
	obj.onclick = function()
	{
		abre(num, tamtexto);
	}
}

function abre(numobj, tamtexto)
{
	var topobj;
	var hl;
	hl = document.getElementById("hl" + numobj);
		
	if(hl != null)
	{
		topobj = parseInt(hl.style.top) + 20;
	}
	
	var lb;
	lb = document.getElementById("lb" + numobj);
	
	if(lb != null)
	{
		lb.style.visibility = "visible";
		PosicionaV(lb, topobj);					
	}
	
	var img;
	img = document.getElementById("img" + numobj);
	
	if(img != null)
	{
		img.src = "Imagens/cima.gif";
						
		img.onclick = function()
		{
			esconde();
			TrocaImg(img, numobj, tamtexto);
		}
	}
	
	var imglogo;
	imglogo = document.getElementById("imglogo" + numobj);
	
	if(imglogo != null)
	{
		imglogo.style.visibility = "visible";
		
		var tamlogo;
		tamlogo = parseInt(imglogo.height);
		
		var tamtexto;
		
		if( numobj == 1)
		{
			tamtexto = tamtexto1;
		}
		else if( numobj == 2)
		{
			tamtexto = tamtexto2;
		}
		else if( numobj == 3)
		{
			tamtexto = tamtexto3;
		}
		else if( numobj == 4)
		{
			tamtexto = tamtexto4;
		}
		else if( numobj == 5)
		{
			tamtexto = tamtexto5;
		}
		else if( numobj == 6)
		{
			tamtexto = tamtexto6;
		}
		else if( numobj == 7)
		{
			tamtexto = tamtexto7;
		}
		else if( numobj == 8)
		{
			tamtexto = tamtexto8;
		}
		else if( numobj == 9)
		{
			tamtexto = tamtexto9;
		}
		
		if(tamtexto < tamlogo)
		{
			var dif;
			dif = tamlogo - tamtexto;
			dif = dif / 2;
			
			PosicionaV(imglogo, topobj - dif);
		}
		else if(tamtexto > tamlogo)
		{
			var dif;
			dif = tamtexto - tamlogo;
			dif = dif / 2;
			
			PosicionaV(imglogo, topobj + dif);
		}
		else if(tamtexto == tamlogo)
		{
			PosicionaV(imglogo, topobj);
		}
	}
	
	var i;
	var topi;
	
	for( i = 1; i <10; i++)
	{					
		if(i == (numobj + 1))
		{		
			hl = document.getElementById("hl" + numobj);
			var hlesse;
			hlesse = document.getElementById("hl" + i);
			if(hl != null && hlesse != null)
			{
				topobj = parseInt(hl.style.top) + 20;
				topi = topobj + tamtexto + 20;
			}
			else
			{
				if(ultnum == 1)
				{
					topi = topi + tamtexto1;		
				}
				else if(ultnum == 2)
				{
					topi = topi + tamtexto2;		
				}
				else if(ultnum == 3)
				{
					topi = topi + tamtexto3;		
				}
				else if(ultnum == 4)
				{
					topi = topi + tamtexto4;		
				}
				else if(ultnum == 5)
				{
					topi = topi + tamtexto5;		
				}
				else if(ultnum == 6)
				{
					topi = topi + tamtexto6;		
				}
				else if(ultnum == 7)
				{
					topi = topi + tamtexto7;		
				}
				else if(ultnum == 8)
				{
					topi = topi + tamtexto8;		
				}
				else if(ultnum == 9)
				{
					topi = topi + tamtexto9;		
				}
				
				if(topi < 420)
				{
				    topi = 420;
				}
				
				MudaPnlFooter(topi + 40);
				MudaPnlFundo(topi + 40 + 30 + 40);
				break;
			}	
			
			hli = document.getElementById("hl" + i);
		
			if(hli != null)
			{
				PosicionaV(hli, topi);
				
			}
			
			var imgi;
			imgi = document.getElementById("img" + i);
			
			if(imgi != null)
			{
				PosicionaV(imgi, topi - 3);	
				TrocaImg(imgi, i);
												
			}
			
			var lbi;
			lbi = document.getElementById("lb" + i);
			
			if(lbi != null)
			{
				lbi.style.visibility = "hidden";
				lbi.style.position = "absolute";
				lbi.style.top = -1500;											
			}
			
			var imglogo;
			imglogo = document.getElementById("imglogo" + i);
			
			if(imglogo != null)
			{
				imglogo.style.visibility = "hidden";
				imglogo.style.top = -1500;		
			}
		}
		else if(i >= numobj && i != 1)
		{
			
			hli = document.getElementById("hl" + i);
		
			if(hli != null)
			{
				topi = topi + 30;
				PosicionaV(hli, topi);							
			}
			else 
			{
				//MudaPnlFundo(topi + 300);
				if(topi < 420)
				{
				    topi = 420;
				}
				MudaPnlFooter(topi + 40);
				MudaPnlFundo(topi + 30 + 40 + 40);
				break;
			}
			
			var imgi;
			imgi = document.getElementById("img" + i);
			
			if(imgi != null)
			{
				PosicionaV(imgi, topi - 3);	
				imgi.src = "Imagens/baixo.gif";								
			}
			
			var lbi;
			lbi = document.getElementById("lb" + i);
			
			if(lbi != null)
			{
				PosicionaV(lbi, topi + 20);
				if(i == numobj)
				{
					lbi.style.visibility = "visible";
					
					imglogo = document.getElementById("imglogo" + i);						
					
					if(tamtexto < tamlogo)
					{
						var dif;
						dif = tamlogo - tamtexto;
						dif = dif / 2;
						
						PosicionaV(imglogo, topi + 20 - dif);
					}
					else if(tamtexto > tamlogo)
					{
						var dif;
						dif = tamtexto - tamlogo;
						dif = dif / 2;
						
						PosicionaV(imglogo, topi + 20 + dif);
					}
					else if(tamtexto == tamlogo)
					{
						PosicionaV(imglogo, topi + 20);
					}
				}
				else
				{
					lbi.style.visibility = "hidden";
					lbi.style.position = "absolute";
					lbi.style.top = -1500;
					
					var imglogo;
					imglogo = document.getElementById("imglogo" + i);
					
					if(imglogo != null)
					{
						imglogo.style.visibility = "hidden";
						imglogo.style.top = -1500;		
					}	
				}											
			}
		}
		else if(i < numobj)
		{
			if(topi == null) // i = 1
			{
				var hli;
				hli = document.getElementById("hl" + i);
					
				if(hli != null)
				{
					topi = parseInt(hli.style.top);
				}
				
				var lbi;
				lbi = document.getElementById("lb" + i);
				
				if(lbi != null)
				{
					lbi.style.visibility = "hidden";	
					lbi.style.position = "absolute";
					lbi.style.top = -1500;										
				}
				
				var imglogo;
				imglogo = document.getElementById("imglogo" + i);
				
				if(imglogo != null)
				{
					imglogo.style.visibility = "hidden";
					imglogo.style.top = -1500;		
				}
				
				var imgi;
				imgi = document.getElementById("img" + i);
				
				if(imgi != null)
				{
					TrocaImg(imgi, i);
				}
			}
			else
			{
				topi = topi + 30;
				hli = document.getElementById("hl" + i);
			
				if(hli != null)
				{
					PosicionaV(hli, topi);							
				}
				
				var imgi;
				imgi = document.getElementById("img" + i);
				
				if(imgi != null)
				{
					PosicionaV(imgi, topi - 3);	
					TrocaImg(imgi, i);							
				}
				
				var lbi;
				lbi = document.getElementById("lb" + i);
				
				if(lbi != null)
				{
					lbi.style.visibility = "hidden";
					lbi.style.position = "absolute";
					lbi.style.top = -1500;											
				}
				
				var imglogo;
				imglogo = document.getElementById("imglogo" + i);
				
				if(imglogo != null)
				{
					imglogo.style.visibility = "hidden";
					imglogo.style.top = -1500;		
				}
			}			
		}	
		else 
		{
			if(i == 1)
			{
				var hlx;
				i = i + 1;
				hlx = document.getElementById("hl" + i);
				
				if(hlx == null)
				{
				    var toptoptop = 460;
				    if((topobj + tamtexto + 40) > 460)
				    {
				        toptoptop = topobj + tamtexto + 40;
				    }
					MudaPnlFooter(toptoptop);
					
					if(topobj + tamtexto  + 30 + 40 + 40 < 530)
					{
					    toptoptop = 530;
					}
					else
					{
						toptoptop = topobj + tamtexto  + 30 + 40 + 40;			
					}
					MudaPnlFundo(toptoptop);
					break;
				}
				else
				{
					i = i - 1;
				}
			}
		}	
	}
	
	img.src = "Imagens/cima.gif";
}


function esconde()
{
	var i;
	
	
	// Titulos
	
	var hl1;
	hl1 = document.getElementById("hl1");
		
	if(hl1 != null)
	{
		tophl2ini = parseInt(hl1.style.top);
	}
	
	for( i = 1; i <10; i++)
	{	
		var lbi;
		lbi = document.getElementById("lb" + i);
		
		var imglogo;
		imglogo = document.getElementById("imglogo" + i);
		
		if(imglogo != null)
		{
			imglogo.style.visibility = "hidden";
			imglogo.style.top = -1500;		
		}
		
		if(lbi != null)
		{
			lbi.style.visibility = "hidden";
			lbi.style.position = "absolute";
			lbi.style.top = -1500;												
		}
		else
		{
			
			if(tophl2ini < 460)
			{
				tophl2ini = 460;
			}
			
			
			MudaPnlFooter(tophl2ini );
			MudaPnlFundo(tophl2ini + 30 + 40);
			break;
		}
		
		
		
		if( i > 1)
		{
			var hl;
			hl = document.getElementById("hl" + i);
			
			if(hl != null)
			{				
				PosicionaV(hl, tophl2ini);					
			}
			
			var img;
			img = document.getElementById("img" + i);
				
			if(img != null)
			{
				PosicionaV(img, tophl2ini - 3);					
			}
		}
		tophl2ini = tophl2ini + 30;
	}
}	

function MudaPnlFundo(height)
{

	var pnlFundo;
	pnlFundo = document.getElementById("pnlFundo");
		
	if(pnlFundo != null)
	{	
		pnlFundo.style.display = "block"; 
		pnlFundo.style.height = height;
		pnlFundo.height = height;
		
	}
	
	var pnlFundoMenor;
	pnlFundoMenor = document.getElementById("pnlFundoMenor");
		
	if(pnlFundoMenor != null)
	{				
		pnlFundoMenor.style.display = "block"; 
		pnlFundoMenor.style.height = 100;					
	}							
}	

function MudaPnlFooter(top)
{

	var pnlFooter;
	pnlFooter = document.getElementById("pnlFooter");
		
	if(pnlFooter != null)
	{
		pnlFooter.style.position = "absolute";
		pnlFooter.style.top = top;		
	}
	
}

/***********************************************************************
// Objetivo  :	Aumentar o Zoom de uma imagem
// Premissas :	Nenhuma
// Entradas  :	panel      - nome do objeto que deve ter o zoom aumentado
// Retorno   :	

************************************************************************/

function AumentaZoom(panel)
{
	var divzoom;
	divzoom = document.getElementById(panel);
	
	if(divzoom != null)
	{
		divzoom.style.zoom = parseInt(divzoom.style.zoom) + 1;
	}
}

/***********************************************************************
// Objetivo  :	Diminuir o Zoom de uma imagem
// Premissas :	Nenhuma
// Entradas  :	panel      - nome do objeto que deve ter o zoom diminuido
// Retorno   :	

************************************************************************/

function DiminuiZoom(panel)
{
	var divzoom;
	divzoom = document.getElementById(panel);
	
	if(divzoom != null)
	{
		if(parseInt(divzoom.style.zoom) >= 1)
		{
			divzoom.style.zoom =  parseInt(divzoom.style.zoom) - 1;
		}
	}
}

function trocaimagens(tabstrip) 
{ 
	var imgesquerda; 
	imgesquerda = document.getElementById("TabStrip1_imgtabesquerda" + tabstrip); 

	if(imgesquerda != null) 
	{ 
		imgesquerda.src = "../Imagens/TabStrip/tab_esquerda_ativa.gif"; 
	} 
	
	var tddireita; 
	tddireita = document.getElementById("TabStrip1_tdtabdireita" + tabstrip); 
	
	if(tddireita != null) 
	{ 
		tddireita.background = "../Imagens/TabStrip/tab_direita_ativa.gif"; 
	} 
	
	var lbtab;	 			
	lbtab = document.getElementById("TabStrip1_lbtab" + tabstrip); 
	
	if(lbtab != null) 
	{ 
		lbtab.style.cursor = "hand"; 
		lbtab.style.color = "#336699"; 
	} 
	
	var div;		 		
	div = document.getElementById("TabStrip1_divtab" + tabstrip); 
	
	if(div != null) 
	{ 
		div.style.cursor = "hand"; 
		div.onmouseover = null; 
		div.onmouseout = null; 
	} 
					
	for(i = 1; i < 10; i++) 
	{ 
		if(i != tabstrip)  
		{					
			var div_outra;			
			div_outra = document.getElementById("TabStrip1_divtab" + i); 
		
			if(div_outra != null) 
			{			 

				var index; 
				index = i;	 
										
				div_outra.style.cursor = "hand"; 
					
				div_outra.onmouseover = function() 
				{ 

					var lbtab_outra; 												
					lbtab_outra = document.getElementById("TabStrip1_lbtab" + this.indice_tab); 
					if(lbtab_outra != null) 
					{	 			
	
						lbtab_outra.style.color = "#FFFFFF"; 
					} 
				} 
				
				div_outra.onmouseout = function() 
				{					 			
					var lbtab_outra2;	 											
					lbtab_outra2 = document.getElementById("TabStrip1_lbtab" + this.indice_tab); 
					
					if(lbtab_outra2 != null) 
					{					 		
						lbtab_outra2.style.color = "#336699"; 
					} 
						
				} 
				
				var imgesquerda_outra; 
				imgesquerda_outra = document.getElementById("TabStrip1_imgtabesquerda" + i); 
				
	
				if(imgesquerda_outra != null) 
				{ 
					if(i != 1) 
					{ 
						imgesquerda_outra.src = "../Imagens/TabStrip/tab_esquerda_emfoco.gif"; 
					} 
					else 
					{ 
						imgesquerda_outra.src = "../Imagens/TabStrip/tab_esquerda_primeira_emfoco.gif"; 
					} 
				} 
				
				var tddireita_outra; 
				tddireita_outra = document.getElementById("TabStrip1_tdtabdireita" + i); 
				
				if(tddireita_outra != null) 
				{ 
					tddireita_outra.background = "../Imagens/TabStrip/tab_direita_emfoco.gif"; 
				} 
				

				var lbtab_outra; 
				lbtab_outra = document.getElementById("TabStrip1_lbtab" + i); 
				
				if(lbtab_outra != null) 
				{ 
					lbtab_outra.style.cursor = "hand"; 
					lbtab_outra.color = "#547CA4"; 
				} 
			}	 			
		} 
	} 
} 
			
function some(tabselecionada) 
{ 
	//tabselecionada indice da tab selecionada 
	var tab_selec; 
	tab_selec = document.getElementById("tabselecindex"); 
	
	if(tab_selec != null) 
	{ 
		tab_selec.value = tabselecionada;	 			
	} 
	
	var panel; 
	panel = document.getElementById('PanelTabStrip' + tabselecionada); 
//		alert( document.getElementById('PanelTabStrip' + tabselecionada));	
	if(panel != null) 
	{		
		panel.style.left = "15px"; 
		panel.style.top = "113px"; 
		panel.style.position = "absolute"; 
		panel.style.zIndex = "999999"; 
		panel.style.visibility = "visible"; 	
		panel.style.filter = "none"; 
		
		var nome = "";
		for(var i = 0; i < panel.childNodes.length; i++)
		{
			if(panel.children[i] != null)
			{
				nome = panel.children[i].id;
				if(nome.indexOf("txt") == 0)
				{
					var textbox;
					textbox = document.getElementById(panel.children[i].id);
					
					if(textbox != null)
					{
						if(textbox.disabled == false && textbox.isTextEdit == true)
						{
							textbox.focus();
							break;
						}
						
					}
				}
			}
		}
	} 
	
	for(i = 1; i < 10; i++) 
	{ 
		if(i != tabselecionada) 
		{   
			var outro_panel; 
			outro_panel = document.getElementById('PanelTabStrip' + i); 
//			alert('PanelTabStrip' + i + ' ' + outro_panel); 

			if(outro_panel != null) 
			{ 
				outro_panel.style.left = "15px"; 
				outro_panel.style.top = "113px"; 
				outro_panel.style.position = "absolute"; 
				outro_panel.style.zIndex = "999999"; 
				outro_panel.style.visibility = "hidden"; 
				outro_panel.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=0)"; 
			} 
		} 			
	} 
	trocaimagens(tabselecionada); 
}  



var isDHTML = 0;
var isID = 0;
var isAll = 0;
var isLayers = 0;

if(document.getElementById)
{
	isID = 1;
	isDHTML = 1;
}
else
{
	if(document.all)
	{
		isAll = 1;
		isDHTML = 1;
	}
	else
	{
		browserVersion = parseInt(navigator.appVersion);

		if((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4))
		{
			isLayers = 1;
			isDHTML = 1;
		}
	}
}

function findDOM(objectID, withStyle)
{
	if(withStyle == 1)
	{

		if(isID)
		{

			return document.getElementById(objectID).style;
		}
		else
		{
			if(isAll)
			{

				return (document.all[objectID].style);
			}
			else
			{
				if(isLayers)
				{

					return (document.layers[objectID]);
				}
			}
		}
	}
	else
	{
		if(isID)
		{
			return (document.getElementById(objectID));
		}
		else
		{
			if(isAll)
			{
				return (document.all[objectID]);
			}
			else
			{
				if(isLayers)
				{
					return (document.layers[objectID]);
				}
			}
		}
	}
}

function findLivePageWidth()
{
	if(window.innerWidth != null)
	{
		return window.innerWidth;
	}
	if(document.body.clientWidth != null)
	{
		return document.body.clientWidth;
	}
}




function ExibeToolTip(objectID, domParent)
{
	if(isDHTML)
	{
	
		domStyle = findDOM(objectID,1);
		dom = findDOM(objectID,0);		
		domParentStyle = domParent.style;//findDOM(domParent,1);
		state = domStyle.display;
		

		domStyle.position = "absolute";
			
		if(domStyle.pixelLeft != null)
		{
			domStyle.pixelLeft = domParentStyle.pixelLeft + 30;			
			domStyle.pixelTop = domParentStyle.pixelTop + 20;
		}
		else
		{
			domStyle.left = 100;			
			domStyle.top = 500;
		}			
		
		domStyle.display = "inline";
		
	}
}



function SomeToolTip(objectID)
{
	if(isDHTML)
	{	
		domStyle = findDOM(objectID,1);
		domStyle.display = "none";	
	}
}

function ExibeMsgObrigatorio()
{
	var dlg;
	
	dlg = document.getElementById("dlgmsgobrig");
	
	
	DivSetVisible(true, 'dlgmsgobrig', 'notificacao_iframe');
	DivSetVisible(false, 'msgalerta', 'msgalerta_iframe');
	
	
	if(dlg != null)
	{
		
		for( x = 0; x < 5; x++)
		{
			var msg;
			msg = document.getElementById("msg" + x );
            msg.value = "";
		}
		
		
		
	    for (i=0; i<Page_Validators.length; i++) 
		{
		
			
            if (!Page_Validators[i].isvalid && typeof(Page_Validators[i].errormessage) == "string") 
            {
            
				for( x = 0; x < 5; x++)
				{
					var msg;
					msg = document.getElementById("msg" + x );
					if(msg.value == "")
					{
						msg.value = Page_Validators[i].errormessage ;
						break;
					}                    
				} 
			}         
        }           
	}
}

function FechaMsgObrigatorio()
{
	var dlg;
	dlg = document.getElementById("dlgmsgobrig");
	
	if(dlg != null)
	{
		DivSetVisible(false, 'dlgmsgobrig', 'notificacao_iframe');
		//dd.elements.dlgmsgobrig.hide();
	}
}


/**************************************************************************
função utilizada para exibir o iframe junto com componentes que aparecem na 
tela, para que eles não fiquem abaixo de um dropdownlist.
****************************************************************************/

function DivSetVisible(state, div, iframe) 
{ 

var DivRef = document.getElementById(div); 
var IfrRef = document.getElementById(iframe); 
	
	if(state) 
	{ 
		
		if(DivRef != null)
		{
			DivRef.style.display = "block"; 
		}
		
		
		if(IfrRef != null)
		{
			IfrRef.style.width = DivRef.offsetWidth; 
			IfrRef.style.height = DivRef.offsetHeight; 
			IfrRef.style.top = DivRef.style.top; 
			IfrRef.style.left = DivRef.style.left; 
			IfrRef.style.zIndex = DivRef.style.zIndex - 1;	
			
			IfrRef.style.display = "block"; 
		}	
	} 
	else 
	{ 
		if(DivRef != null)
		{
			DivRef.style.display = "none"; 
		}
		if(IfrRef != null)
		{
			IfrRef.style.display = "none";
		} 
	} 
} 


function DivSetVisibleMsg(state, div, iframe, comp) 
{ 

var DivRef = document.getElementById(div); 
var IfrRef = document.getElementById(iframe); 
var Comp = document.getElementById(comp);
	
	if(state) 
	{ 
		
		if(DivRef != null)
		{
			DivRef.style.display = "block"; 
		}
		
		
		if(IfrRef != null && Comp != null)
		{
			var top_iframe = parseInt(DivRef.style.top.replace("px", "")) + parseInt(Comp.style.top.replace("px", ""));
			var left_iframe = parseInt(DivRef.style.left.replace("px", "")) + parseInt(Comp.style.left.replace("px", ""));
			IfrRef.style.width = DivRef.offsetWidth; 
			IfrRef.style.height = DivRef.offsetHeight; 
			IfrRef.style.top = top_iframe; 
			IfrRef.style.left = left_iframe; 
			IfrRef.style.zIndex = DivRef.style.zIndex - 1;	
			
			IfrRef.style.display = "block"; 
		}	
	} 
	else 
	{ 
		if(DivRef != null)
		{
			DivRef.style.display = "none"; 
		}
		if(IfrRef != null)
		{
			IfrRef.style.display = "none";
		} 
	} 
} 


function DivSetVisibleMenu(state, div, iframe) 
{ 
//var DivRef = document.getElementById('Calendario1_tb_fora'); 
//var IfrRef = document.getElementById('DivShim'); 

var DivRef = document.getElementById(div); 
var IfrRef = document.getElementById(iframe); 
	
	if(state) 
	{ 

		DivRef.style.display = "block"; 
		IfrRef.style.width = 200; 
		IfrRef.style.height = 200; 
		IfrRef.style.top = DivRef.style.top; 
		IfrRef.style.left = DivRef.style.left; 
		IfrRef.style.zIndex = DivRef.style.zIndex - 1;		
		IfrRef.style.display = "block"; 
	
	} 
	else 
	{ 
		if(DivRef != null)
		{
			DivRef.style.display = "none"; 
		}
		if(IfrRef != null)
		{
			IfrRef.style.display = "none";
		} 
	} 
} 



function redictsettimeout(tempo)
{
	window.setTimeout("window.location.href='..\Logoff.aspx'",tempo);
}


function SomenteNumeros()
{
	var lngKey;			// Código ASC da tecla digitada
		
	lngKey = window.event.keyCode;	
		
	if ( ((lngKey <= 47)||(lngKey >= 58)) && (lngKey != 9) ) 
	{
		window.event.keyCode = 0;
		return false;
	}
			
	return true;
	
}


function SomenteNumerosComVirgula()
{
	var lngKey;			// Código ASC da tecla digitada
		
	lngKey = window.event.keyCode;	
		
	if ( ((lngKey <= 47)||(lngKey >= 58)) && (lngKey != 9) && (lngKey != 44) ) 
	{
		window.event.keyCode = 0;
		return false;
	}
			
	return true;
	
}

function SomenteCaracteres()
{
	var lngKey;			// Código ASC da tecla digitada
		
		
	lngKey = window.event.keyCode;	
	
	if(lngKey == 32) //Espaço
	{
		return true;
	}
	else if(lngKey <= 64)
	{
		window.event.keyCode = 0;
		return false;
	}
	else if(lngKey > 64 && lngKey < 91)
	{
		return true;
	}	
	else if(lngKey >= 91 && lngKey <= 96)
	{
		window.event.keyCode = 0;
		return false;
	}
	else if(lngKey > 96 && lngKey < 123)
	{
		return true;
	}
	else if(lngKey >= 123)
	{
		window.event.keyCode = 0;
		return false;
	}	
}
			

function ApenasTeclasPermitidas(strCaracteres)
{
	var lngKey;			// Código ASC da tecla digitada
	var strValor;
				
	lngKey = window.event.keyCode;
	strValor = String.fromCharCode(lngKey);
					
	if ( (strCaracteres.indexOf(strValor) < 0 )&& (lngKey != 9))
	{
		window.event.keyCode = 0;
		return false;
	}
				
	return true;
				
}

function ApenasTeclasValor(strValorAtual)
{
	var lngKey;	//Código ASC da tecla digitada
	var strValor;
	lngKey = window.event.keyCode;	
					
	strValor = String.fromCharCode(lngKey);
				
	if ( (lngKey <= 47||lngKey >= 58) && lngKey != 9 &&  strValor != ',' ) 
	{
		window.event.keyCode = 0;
		return false;					
	}
	else if ( strValor == ',' )
	{				
		if ( strValorAtual.indexOf(',') > -1  )
		{
			window.event.keyCode = 0;
			return false;
		}
				
	}
						
	return true;
				
}

function ApenasDigitos( objText )
{
	return( ApenasContidos( objText, "0123456789" ) );
}

//********************************************************************************
// Objetivo  :	Verifica se o o campo contem apenas os caracteres válidos
// Premissas :	Nenhuma
// Entradas  :	objText - Campo input
//strValidos - Lista de caracteres válidos
// Retorno   :	true ou false
//********************************************************************************
function ApenasContidos( objText, strValidos )
{
	var temp;
	var i;
	var strValor = objText.value;
				
	for ( i=0; i < strValor.length; ++i)
	{
		temp = strValor.substring(i, i+1);				
		if (strValidos.indexOf(temp) < 0)
		{ 
			return(false);
		}
	}
	return(true);
}

//**************************************************************************************************************
// Objetivo  :	Efetua o intercâmbio entre os strings
// Premissas :	Nenhuma
// Entradas  :	strField   = string utilizado
//			    strSearch  = string pesquisado
//			    strReplace = string que se quer substituir
// Retorno   :	true ou false
//**************************************************************************************************************

function Replace(strField, strSearch, strReplace)
{ 
	while (strField.indexOf(strSearch) > -1) 
	strField = strField.replace(strSearch, strReplace); 
	return(strField); 
} 

//**************************************************************************************************************
// Objetivo  :	Formata Data
// Premissas :	Nenhuma
// Entradas  :	objObject      - objeto para formatar a data
// Retorno   :	true ou false
//**************************************************************************************************************

function FormatarData(objObject)
{ 
	var intValue = objObject.value;
				
	intValue = Replace(intValue, '/', '');
				
	if (intValue.length > 2)
	{ 
		intValue = intValue.substring(0,2) + "/" + intValue.substring(2, intValue.length); 
	} 
	if (intValue.length > 5)
	{
		intValue = intValue.substring(0,5) + "/" + intValue.substring(5, intValue.length); 
	} 
	objObject.value = intValue;
}

//**************************************************************************************************************
// Objetivo  :	Formata Mes Ano
// Premissas :	Nenhuma
// Entradas  :	objObject      - objeto para formatar a data
// Retorno   :	true ou false
//**************************************************************************************************************

function FormatarMesAno(objObject)
{ 
	var intValue = objObject.value;
				
	intValue = Replace(intValue, '/', '');
				
	if (intValue.length > 2)
	{ 
		intValue = intValue.substring(0,2) + "/" + intValue.substring(2, intValue.length); 
	} 
	objObject.value = intValue;
}



//**************************************************************************************************************
// Objetivo  :	Formata Decimal 2 casas
// Premissas :	Nenhuma
// Entradas  :	objObject      - objeto para formatar o decimal
// Retorno   :	true ou false
//**************************************************************************************************************

function FormatarDecimal2Casas(objObject)
{ 
	var intValue = objObject.value;
		
		if(intValue.indexOf('0,') == 0)
		{
			intValue = Replace(intValue, '0,', '');	
		}
		intValue = Replace(intValue, ',', '');	
		
	if (intValue.length > 2)
	{ 
		
		intValue = intValue.substring(0,intValue.length - 2) + "," + intValue.substring(intValue.length - 2, intValue.length); 
	} 
	else if (intValue.length <= 2 )
	{
		
		intValue = "0," + intValue; 
	}
	
	objObject.value = intValue;
}

//**************************************************************************************************************
// Objetivo  :	Formata Decimal 4 casas
// Premissas :	Nenhuma
// Entradas  :	objObject      - objeto para formatar o decimal
// Retorno   :	true ou false
//**************************************************************************************************************

function FormatarDecimal4Casas(objObject)
{ 
	var intValue = objObject.value;
				
	if(intValue.indexOf('0,') == 0)
		{
			intValue = Replace(intValue, '0,', '');	
		}
	intValue = Replace(intValue, ',', '');	
				
	if (intValue.length > 4)
	{ 
		intValue = intValue.substring(0,intValue.length - 4) + "," + intValue.substring(intValue.length - 4, intValue.length); 
	} 
	else if (intValue.length <= 4 )
	{
		
		intValue = "0," + intValue; 
	}
	
	objObject.value = intValue;
}


//**************************************************************************************************************
// Objetivo  :	Formata Decimal 6 casas
// Premissas :	Nenhuma
// Entradas  :	objObject      - objeto para formatar o decimal
// Retorno   :	true ou false
//**************************************************************************************************************

function FormatarDecimal6Casas(objObject)
{ 
	var intValue = objObject.value;
				
	if(intValue.indexOf('0,') == 0)
	{
		intValue = Replace(intValue, '0,', '');
	}
	intValue = Replace(intValue, ',', '');	
				
	if (intValue.length > 6)
	{ 
		intValue = intValue.substring(0,intValue.length - 6) + "," + intValue.substring(intValue.length - 6, intValue.length); 
	} 
	else if (intValue.length <= 6 )
	{
		
		intValue = "0," + intValue; 
	}
	
	objObject.value = intValue;
}

//**************************************************************************************************************
// Objetivo  :	Formata Decimais de acordo com parâmetro.
// Premissas :	Nenhuma
// Entradas  :	objObject       - objeto para formatar o decimal
//			 :  objQtdeDecimais - objeto que indica a quantidade de casas decimais
// Retorno   :	true ou false
//**************************************************************************************************************

function FormatarQuantidadeDecimais(objObject, objQtdeDecimais)
{ 
	var intValue        = objObject.value;
	var intQtdeDecimais = objQtdeDecimais; 
				
	intValue = Replace(intValue, '0,', '');
	intValue = Replace(intValue, ',', '');	
    
  	if (intValue.length > intQtdeDecimais)
	{ 
		intValue = intValue.substring(0,intValue.length - intQtdeDecimais) + "," + intValue.substring(intValue.length - intQtdeDecimais, intValue.length); 
	}
    else if (intValue.length <= intQtdeDecimais )
	{
		intValue = "0," + intValue; 
	}
			
	objObject.value = intValue;
}

//**************************************************************************************************************
// Objetivo  :	Formata Porcentagem
// Premissas :	Nenhuma
// Entradas  :	objObject      - objeto para formatar a porcentagem
// Retorno   :	true ou false
//**************************************************************************************************************

function FormatarPorcentagem(objObject)
{ 
	var intValue = objObject.value;

	//intValue = Replace(intValue, ',', '');
	intValue = Replace(intValue, '%', '');

	if (intValue.length > 3 && intValue.indexOf(',') < 1)
	{ 
		intValue = Replace(intValue, ',', '');
		intValue = intValue.substring(0,3) + "," + intValue.substring( 3, intValue.length); 
	} 
	
	intValue = intValue + '%';
	
	objObject.value = intValue;
}

//**************************************************************************************************************
// Objetivo  :	Formata Porcentagem Simples
// Premissas :	Nenhuma
// Entradas  :	objObject      - objeto para formatar a porcentagem
// Retorno   :	true ou false
//**************************************************************************************************************

function FormatarPorcentagemSimples(objObject)
{ 
	var intValue = objObject.value;

	//intValue = Replace(intValue, ',', '');
	intValue = Replace(intValue, '%', '');

	if (intValue.length == 1 )
	{ 
		intValue = intValue + "%";
	} 
	
	objObject.value = intValue;
}

//**************************************************************************************************************
// Objetivo  :	Formata Porcentagem
// Premissas :	Nenhuma
// Entradas  :	objObject      - objeto para formatar a porcentagem
// Retorno   :	true ou false
//**************************************************************************************************************

function Porcentagem(objObject)
{
	var intValue = objObject.value;
	var intInteiro = "";
	var intFinal = ""
	
	//intValue = Replace(intValue, ',', '');
	intValue = Replace(intValue, '%', '');
	
	if(intValue.indexOf(',') > 0)
	{
		intInteiro = intValue.substring(0,intValue.indexOf(',')+ 1);
		intFinal   = intValue.substring(intValue.indexOf(',')+ 1,intValue.length);
		
		if (intFinal.length == 0) 
		{
			intFinal = "0000";
		}
		else if (intFinal.length == 1) 
		{
			intFinal = intFinal + "000";
		}
		else if (intFinal.length == 2) 
		{
			intFinal = intFinal + "00";
		}
		else if (intFinal.length == 3) 
		{
			intFinal = intFinal + "0";
		}
		
		intValue = intInteiro + intFinal; 
		
	}
	else
	{
		intValue = intValue + ",0000"; 
	 
	}
	
	intValue = intValue + '%';
	
	objObject.value = intValue;
}

//**************************************************************************************************************
// Objetivo  :	Formata Porcentagem Seis
// Premissas :	Nenhuma
// Entradas  :	objObject      - objeto para formatar a porcentagem
// Retorno   :	true ou false
//**************************************************************************************************************

function PorcentagemSeis(objObject)
{
	var intValue = objObject.value;
	var intInteiro = "";
	var intFinal = ""
	
	//intValue = Replace(intValue, ',', '');
	intValue = Replace(intValue, '%', '');
	
	if(intValue.indexOf(',') > 0)
	{
		intInteiro = intValue.substring(0,intValue.indexOf(',')+ 1);
		intFinal   = intValue.substring(intValue.indexOf(',')+ 1,intValue.length);
		
		if (intFinal.length == 0) 
		{
			intFinal = "000000";
		}
		else if (intFinal.length == 1) 
		{
			intFinal = intFinal + "00000";
		}
		else if (intFinal.length == 2) 
		{
			intFinal = intFinal + "0000";
		}
		else if (intFinal.length == 3) 
		{
			intFinal = intFinal + "000";
		}
		else if (intFinal.length == 4) 
		{
			intFinal = intFinal + "00";
		}
		else if (intFinal.length == 5) 
		{
			intFinal = intFinal + "0";
		}
		
		intValue = intInteiro + intFinal; 
		
	}
	else
	{
		intValue = intValue + ",000000"; 
	 
	}
	
	intValue = intValue + '%';
	
	objObject.value = intValue;
}

//**************************************************************************************************************
// Objetivo  :	Colocar Porcentagem
// Premissas :	Nenhuma
// Entradas  :	objObject      - objeto para formatar a porcentagem
// Retorno   :	true ou false
//**************************************************************************************************************

//function FormatarDecimal2Casas(objObject)
//{ 
//	var intValue = objObject.value;
				
//	intValue = Replace(intValue, ',', '');
				
//	if (intValue.length > 2)
//	{ 
//		intValue = intValue.substring(0,intValue.length - 2) + "," + intValue.substring(intValue.length - 2, intValue.length); 
//	} 
	
//	objObject.value = intValue;
//}


//**************************************************************************************************************
// Objetivo  :	Validar a data digitada
// Premissas :	Nenhuma
// Entradas  :	objObject      - objeto para formatar a data
// Retorno   :	mensagem ou nada
//**************************************************************************************************************

			
function  ValidarData(objObject, objtooltip)
{
	SomeToolTip(objtooltip);
	var intValue = objObject.value;
	var strData
	var intDia 
	var intMes 
	var intAno 
			    
    if (intValue == null || intValue == "" ) 
	{
			SomeToolTip(objtooltip);				
	}
	else
	{
		FormatarData(objObject);
			    
		strData = Replace(intValue,"/", "");
			    
		intDia = strData.substring( 0, 2);
		intMes = strData.substring( 2, 4);
		intAno = strData.substring( 4, 8);
				
			    
		if ((intDia.lenght  < 1) || (intMes.lenght  < 1) || (intAno.lenght  < 1) )
		{  
			ExibeToolTip(objtooltip,objObject);
			//window.event.srcElement.focus();
		}
		
		else if ((intMes <= 0) || (intMes > 12) || (intDia <= 0) || (intDia > 31))
		{
			ExibeToolTip(objtooltip,objObject);
			//window.event.srcElement.focus();
		}
		else if (intDia > 30 && ((intMes == 4) || (intMes == 6) || (intMes == 9) || (intMes == 11))) 
		{
			ExibeToolTip(objtooltip,objObject);
			//window.event.srcElement.focus();
		}
		else if (intMes == 2 && intDia > 29)
		{
			ExibeToolTip(objtooltip,objObject);
			//window.event.srcElement.focus();
		}
		else if (intAno < 1800)
		{
			ExibeToolTip(objtooltip,objObject);
			//window.event.srcElement.focus();
		}
		else if (intMes == 2 && intDia > 28 && ( intAno%4 !=0 ))
		{
			ExibeToolTip(objtooltip,objObject);
			//window.event.srcElement.focus();
		}		
	}
}



//**************************************************************************************************************
// Objetivo  :	Validar a data digitada -- Se válida, dá post no controle
// Premissas :	Nenhuma
// Entradas  :	objObject      - objeto para formatar a data
// Retorno   :	mensagem ou nada
//**************************************************************************************************************

			
function  ValidarDataPost(objObject, objtooltip)
{
	SomeToolTip(objtooltip);
	var intValue = objObject.value;
	var strData
	var intDia 
	var intMes 
	var intAno 
			    
    if (intValue == null || intValue == "" ) 
	{
			SomeToolTip(objtooltip);				
	}
	else
	{
		FormatarData(objObject);
			    
		strData = Replace(intValue,"/", "");
			    
		intDia = strData.substring( 0, 2);
		intMes = strData.substring( 2, 4);
		intAno = strData.substring( 4, 8);
				
			    
		if ((intDia.lenght  < 1) || (intMes.lenght  < 1) || (intAno.lenght  < 1) )
		{  
			ExibeToolTip(objtooltip,objObject);
			//window.event.srcElement.focus();
		}		
		else if ((intMes <= 0) || (intMes > 12) || (intDia <= 0) || (intDia > 31))
		{
			ExibeToolTip(objtooltip,objObject);
			//window.event.srcElement.focus();
		}
		else if (intDia > 30 && ((intMes == 4) || (intMes == 6) || (intMes == 9) || (intMes == 11))) 
		{
			ExibeToolTip(objtooltip,objObject);
			//window.event.srcElement.focus();
		}
		else if (intMes == 2 && intDia > 29)
		{
			ExibeToolTip(objtooltip,objObject);
			//window.event.srcElement.focus();
		}
		else if (intAno < 1800)
		{
			ExibeToolTip(objtooltip,objObject);
			//window.event.srcElement.focus();
		}
		else if (intMes == 2 && intDia > 28 && ( intAno%4 !=0 ))
		{
			ExibeToolTip(objtooltip,objObject);
			//window.event.srcElement.focus();
		}
		else
		{
			__doPostBack(objObject.id,objObject.id);
		}		
	}
}


//**************************************************************************************************************
// Objetivo  :	Validar o mes e ano digitado
// Premissas :	Nenhuma
// Entradas  :	objObject      - objeto para formatar a data
// Retorno   :	mensagem ou nada
//**************************************************************************************************************

			
function  ValidarMesAno(objObject, objtooltip)
{
	SomeToolTip(objtooltip);
	var intValue = objObject.value;
	var strData
	var intMes 
	var intAno 
			    
    if (intValue == null || intValue == "" ) 
	{
			SomeToolTip(objtooltip);				
	}
	else
	{
		FormatarMesAno(objObject);
			    
		strData = Replace(intValue,"/", "");
			    
		intMes = strData.substring( 0, 2);
		intAno = strData.substring( 2, 6);				
			    
		if ((intMes.lenght  < 1) || (intAno.lenght  < 1) )
		{  
			ExibeToolTip(objtooltip,objObject);
			//window.event.srcElement.focus();
		}
		else if ((intMes <= 0) || (intMes > 12))
		{
			ExibeToolTip(objtooltip,objObject);
			//window.event.srcElement.focus();
		}
		else if (intAno < 1800)
		{
			ExibeToolTip(objtooltip,objObject);
			//window.event.srcElement.focus();
		}
	}
}

//**************************************************************************************************************
// Objetivo  :	Validar o ano digitado
// Premissas :	Nenhuma
// Entradas  :	objObject      
// Retorno   :	mensagem ou nada
//**************************************************************************************************************

			
function  ValidarAno(objObject, objtooltip)
{
	SomeToolTip(objtooltip);
	var intValue = objObject.value;
	var strData
	var intAno 
	
			    
    if (intValue == null || intValue == "" ) 
	{
			SomeToolTip(objtooltip);				
	}
	else
	{
		intAno = Replace(intValue,"/", "");
			    
		if (intAno.lenght  < 1 )
		{  
			ExibeToolTip(objtooltip,objObject);
			//window.event.srcElement.focus();
		}
		else if (intAno < 1800)
		{
			ExibeToolTip(objtooltip,objObject);
			//window.event.srcElement.focus();
		}
	}
}


//**************************************************************************************************************
// Objetivo  :	Validar o mês digitado
// Premissas :	Nenhuma
// Entradas  :	objObject      
// Retorno   :	mensagem ou nada
//**************************************************************************************************************

			
function  ValidarMes(objObject, objtooltip)
{
	SomeToolTip(objtooltip);
	var intValue = objObject.value;
	var strData
	var intMes 
	
			    
    if (intValue == null || intValue == "" ) 
	{
			SomeToolTip(objtooltip);				
	}
	else
	{
		intMes = intValue;			
			    
		if (intMes.lenght  < 1)
		{  
			ExibeToolTip(objtooltip,objObject);
			//window.event.srcElement.focus();
		}
		else if ((intMes <= 0) || (intMes > 12))
		{
			ExibeToolTip(objtooltip,objObject);
			//window.event.srcElement.focus();
		}
	}
}


//**************************************************************************************************************
// Objetivo  :	Validar o dia digitado
// Premissas :	Nenhuma
// Entradas  :	objObject      
// Retorno   :	mensagem ou nada
//**************************************************************************************************************

			
function  ValidarDia(objObject, objtooltip)
{
	SomeToolTip(objtooltip);
	var intValue = objObject.value;
	var strData
	var intDia 
				    
    if (intValue == null || intValue == "" ) 
	{
			SomeToolTip(objtooltip);				
	}
	else
	{
		intDia = intValue;
				
			    
		if (intDia.lenght  < 1)
		{  
			ExibeToolTip(objtooltip,objObject);
			//window.event.srcElement.focus();
		}
		
		else if ((intDia <= 0) || (intDia > 31))
		{
			ExibeToolTip(objtooltip,objObject);
			//window.event.srcElement.focus();
		}
	}
}

//**************************************************************************************************************
// Objetivo  :	Formata Hora
// Premissas :	Nenhuma
// Entradas  :	objObject      - objeto para formatar a hora
// Retorno   :	true ou false
//**************************************************************************************************************

function HoraNormal(objObject)
{ 
	var intValue = objObject.value;
				
	intValue = Replace(intValue, ':', '');
	
	
	if (intValue.length == 3 || intValue.length == 4)
	{ 
		intValue = intValue.substring(0,2) + ":" + intValue.substring(2, intValue.length); 				
	} 
	else if (intValue.length >= 5)
	{
		intValue = intValue.substring(0,2) + ":" + intValue.substring(2, 4) + ":" + intValue.substring(4, intValue.length);
	} 
	
		
	objObject.value = intValue;
}


//**************************************************************************************************************
// Objetivo  :	Validar a hora digitada
// Premissas :	Hora com 2 digitos e minutos com 2 digitos
// Entradas  :	objObject      - objeto para formatar a hora
// Retorno   :	mensagem ou nada
//**************************************************************************************************************

function  ValidarHora(objObject, objtooltip)
{
	SomeToolTip(objtooltip);
	var intValue = objObject.value;
	var strData
	var inthora
	var intmin

			    
    if (intValue == null || intValue == "" ) 
	{
		SomeToolTip(objtooltip);		
	}
	else
	{
		HoraNormal(objObject);
		
		if (intValue.length < 3)
		{
			intValue = intValue + ":00";
		}
					    
		strData = Replace(intValue,":", "");
					    
		inthora = strData.substring( 0, 2);
		intmin = strData.substring( 2, 4);	
					    
		if ((inthora > 24) || (intmin > 60))
		{  
			ExibeToolTip(objtooltip,objObject);
			//window.event.srcElement.focus();
		}
		else
		{
			objObject.value = intValue;
		}
	}
}



//**************************************************************************************************************
// Objetivo  :	Formata Hora
// Premissas :	Nenhuma
// Entradas  :	objObject      - objeto para formatar a hora
// Retorno   :	true ou false
//**************************************************************************************************************

function HoraGrande(objObject)
{ 
	
}


//**************************************************************************************************************
// Objetivo  :	Validar a hora digitada
// Premissas :	Hora com 2 digitos e minutos com 2 digitos
// Entradas  :	objObject      - objeto para formatar a hora
// Retorno   :	mensagem ou nada
//**************************************************************************************************************

function  ValidarHoraGrande(objObject)
{

}

//**************************************************************************************************************
// Objetivo  :	Formata Hora
// Premissas :	Nenhuma
// Entradas  :	objObject      - objeto para formatar a hora
// Retorno   :	true ou false
//**************************************************************************************************************

function HoraSemSeg(objObject)
{ 
		var intValue = objObject.value;
				
	intValue = Replace(intValue, ':', '');
				
	if (intValue.length == 3 || intValue.length == 4)
	{ 
		intValue = intValue.substring(0,2) + ":" + intValue.substring(2, intValue.length); 
	} 
	objObject.value = intValue;
}


//**************************************************************************************************************
// Objetivo  :	Validar a hora digitada
// Premissas :	Hora com 2 digitos e minutos com 2 digitos
// Entradas  :	objObject      - objeto para formatar a hora
// Retorno   :	mensagem ou nada
//**************************************************************************************************************

function  ValidarHoraSemSeg(objObject)
{

}



//**************************************************************************************************************
// Objetivo  :	Formata CPF
// Premissas :	Nenhuma
// Entradas  :	objObject      - objeto para formatar a hora
// Retorno   :	true ou false
//**************************************************************************************************************

function CPF(objObject)
{ 
	var intValue = objObject.value;
	
	if ((window.event.keyCode >= 48 && window.event.keyCode <= 57) || (window.event.keyCode >= 96 && window.event.keyCode <= 105) )
	 {				
		intValue = Replace(intValue, '-', '');
		intValue = Replace(intValue, '.', '');
					
		if (intValue.length >= 3 && intValue.length < 7)
		{ 			
			intValue = intValue.substring(0,3) + "." + intValue.substring(3,intValue.length);
		} 
		else if (intValue.length >= 7 && intValue.length < 11)
		{			
			intValue = intValue.substring(0,3) + "." + intValue.substring(3,6) + "." + intValue.substring(6,intValue.length);
		} 
		else if (intValue.length >= 9)
		{
			intValue = intValue.substring(0,3) + "." + intValue.substring(3,6) + "." + intValue.substring(6,9) + "-"  + intValue.substring(9,intValue.length);
		} 
		
		
		objObject.value = intValue;
	}
}

//**************************************************************************************************************
// Objetivo  :	Formata CPF
// Premissas :	Nenhuma
// Entradas  :	objObject      - objeto para formatar a hora
// Retorno   :	true ou false
//**************************************************************************************************************

function FormataCPF(objObject)
{ 
	var intValue = objObject.value;
	
				
		
		if (intValue.length == 11)
		{
			intValue = Replace(intValue, '-', '');
			intValue = Replace(intValue, '.', '');
		
			intValue = intValue.substring(0,3) + "." + intValue.substring(3,6) + "." + intValue.substring(6,9) + "-"  + intValue.substring(9,intValue.length);
		} 
		
		objObject.value = intValue;
	
}


function ValidarCPF(objObject, objtooltip) 
{

	SomeToolTip(objtooltip);
	var intValue = objObject.value;
	var CheckCpf;
    var NumCpf, lii;
    var i, X, M, n;
        
    if (intValue == null || intValue == "" ) 
	{
		SomeToolTip(objtooltip);		
	}
	else
	{
			intValue = Replace(intValue, '-', '');
			intValue = Replace(intValue, '.', '');
			
			soma = 0;
			
				for (i=0; i < 9; i ++)
				{
					soma += parseInt(intValue.charAt(i)) * (10 - i);
				}

				resto = 11 - (soma % 11);

				if (resto == 10 || resto == 11)
					resto = 0;

				if (resto != parseInt(intValue.charAt(9)))
				{
					ExibeToolTip(objtooltip,objObject);
					//window.event.srcElement.focus();
				}
				
				
				soma = 0;

				for (i = 0; i < 10; i ++)
				{
					soma += parseInt(intValue.charAt(i)) * (11 - i);
				}

				resto = 11 - (soma % 11);

				if (resto == 10 || resto == 11)
				{
					resto = 0;
				}

				if (resto != parseInt(intValue.charAt(10)))
				{
					ExibeToolTip(objtooltip,objObject);
					//window.event.srcElement.focus();
				}

				return true;
	}
}

//************************************************************************************
// Metodo Formatar CNPJ
//--> Formatar nesse estilo: 123456789/1234-12 (123.567.901/1234-12)
//
//************************************************************************************

function CNPJ(objObject)
{ 
	var intValue = objObject.value;
	
	if ((window.event.keyCode >= 48 && window.event.keyCode <= 57) || (window.event.keyCode >= 96 && window.event.keyCode <= 105) )
	 {					
		if (intValue.length == 2)
		{ 
			intValue = intValue.substring(0,2) + ".";
		} 
		else if (intValue.length == 6 )
		{
			intValue = intValue.substring(0,6) + "." ;
		} 
		else if (intValue.length == 10)
		{
			intValue = intValue.substring(0,10) + "/"  + intValue.substring(10,intValue.length);
		} 
		else if (intValue.length == 15)
		{
			intValue = intValue.substring(0,15) + "-"  + intValue.substring(15,intValue.length);
		} 
		objObject.value = intValue;
	}
}

function FormataCNPJ(objObject)
{ 
	var intValue = objObject.value;
	
		if (intValue.length == 14)
		{
			intValue = Replace(intValue, '-', '');
			intValue = Replace(intValue, '.', '');
			intValue = Replace(intValue, '/', '');
		
			intValue = intValue.substring(0,2) + "." + intValue.substring(2,5) + "." + intValue.substring(5,8) + "/"  + intValue.substring(8,12) +  "-" + intValue.substring(12,intValue.length);
		} 
		
		objObject.value = intValue;
	
}


//************************************************************************************
//								Metodo Validar CNPJ
//
//************************************************************************************

function ValidarCNPJ(objObject, objtooltip) 
{
	SomeToolTip(objtooltip);
	var intValue = objObject.value;
	var CheckCpf;
    var NumCpf, lii;
    var i, X, M, n;
    
    if (intValue == null || intValue == "" ) 
	{
		SomeToolTip(objtooltip);		
	}
	else
	{
		var i; 
		intValue = Replace(intValue, ".", ""); 
		intValue = Replace(intValue, "-", ""); 
		intValue = Replace(intValue, "/", "");  
		
		cnpj = intValue;
		
		var c = cnpj.substr(0,12); 
		var dv = cnpj.substr(12,2); 
		
		if (cnpj == "00000000000000") 
		{ 
			return false; 
		} 
		
		var d1 = 0; 
		
		var ms = "543298765432"; 
		
		for (i = 0; i < 12; i++) 
		{ 
			d1 += c.charAt(i)*ms.charAt(i); 
		} 
		
		d1 = (d1 % 11); 
		
		if (d1 == 0 || d1 == 1) 
		{
			d1 = 0; 
		} 
		else 
		{ 
			d1 = 11 - d1; 
		}
		var d1 = 0; 
		
		var ms = "543298765432"; 
		
		for (i = 0; i < 12; i++) 
		{ 		
			d1 += c.charAt(i)*ms.charAt(i); 		
		} 
		
		d1 = (d1 % 11); 
		
		if (d1 == 0 || d1 == 1) 
		{ 
			d1 = 0; 
		} 
		else 
		{ 
			d1 = 11 - d1; 
		} 
		
		var c = c + d1;
		var d2 = 0; 
		var ms = "6543298765432"; 
		
		for (i = 0; i < 13; i++) 
		{ 
			d2 += c.charAt(i)*ms.charAt(i); 
		} 
		d2 = (d2 % 11); 
		
		if (d2 == 0 || d2 == 1) 
		{
			d2 = 0; 
		} 
		else 
		{ 
			d2 = 11 - d2; 
		} 
		
		if (dv.charAt(0) != d1 || dv.charAt(1) != d2) 
		{ 
			ExibeToolTip(objtooltip,objObject);
			//window.event.srcElement.focus();
		}	
				
	}
}



//************************************************************************************
//								Metodo Validar CPF/CNPJ
//
//************************************************************************************


function ValidarCPFCNPJ(objObject, objtooltip)
{

var err = false;

	SomeToolTip(objtooltip);
	var intValue = objObject.value;
	var CheckCpf;
    var NumCpf, lii;
    var i, X, M, n;
    
    if (intValue == null || intValue == "" ) 
	{
		SomeToolTip(objtooltip);		
	}
	else
	{
		
			intValue = Replace(intValue, '-', '');
			intValue = Replace(intValue, '.', '');
			
			soma = 0;
			
				for (i=0; i < 9; i ++)
				{
					soma += parseInt(intValue.charAt(i)) * (10 - i);
				}

				resto = 11 - (soma % 11);

				if (resto == 10 || resto == 11)
					resto = 0;

				if (resto != parseInt(intValue.charAt(9)))
				{
				
					err = true;
					//window.event.srcElement.focus();
				}
				else
				{
			
					FormataCPF(objObject);
				}
				
				soma = 0;

				for (i = 0; i < 10; i ++)
				{
					soma += parseInt(intValue.charAt(i)) * (11 - i);
				}

				resto = 11 - (soma % 11);

				if (resto == 10 || resto == 11)
				{
					resto = 0;
				}

				if (resto != parseInt(intValue.charAt(10)))
				{
				
					err = true;
					//window.event.srcElement.focus();
				}
				else
				{
					FormataCPF(objObject);
				}

				//return true;
		
	}
	
	
	if(err == true )
	{
		if (intValue == null || intValue == "" ) 
		{
			SomeToolTip(objtooltip);		
		}
		else
		{
			var i; 
			intValue = Replace(intValue, ".", ""); 
			intValue = Replace(intValue, "-", ""); 
			intValue = Replace(intValue, "/", "");  
			
			cnpj = intValue;
			
			var c = cnpj.substr(0,12); 
			var dv = cnpj.substr(12,2); 
			
			if (cnpj == "00000000000000") 
			{ 
				return false; 
			} 
			
			var d1 = 0; 
			
			var ms = "543298765432"; 
			
			for (i = 0; i < 12; i++) 
			{ 
				d1 += c.charAt(i)*ms.charAt(i); 
			} 
			
			d1 = (d1 % 11); 
			
			if (d1 == 0 || d1 == 1) 
			{
				d1 = 0; 
			} 
			else 
			{ 
				d1 = 11 - d1; 
			}
			var d1 = 0; 
			
			var ms = "543298765432"; 
			
			for (i = 0; i < 12; i++) 
			{ 		
				d1 += c.charAt(i)*ms.charAt(i); 		
			} 
			
			d1 = (d1 % 11); 
			
			if (d1 == 0 || d1 == 1) 
			{ 
				d1 = 0; 
			} 
			else 
			{ 
				d1 = 11 - d1; 
			} 
			
			var c = c + d1;
			var d2 = 0; 
			var ms = "6543298765432"; 
			
			for (i = 0; i < 13; i++) 
			{ 
				d2 += c.charAt(i)*ms.charAt(i); 
			} 
			d2 = (d2 % 11); 
			
			if (d2 == 0 || d2 == 1) 
			{
				d2 = 0; 
			} 
			else 
			{ 
				d2 = 11 - d2; 
			} 
			
			if (dv.charAt(0) != d1 || dv.charAt(1) != d2) 
			{ 
			
				err = true;
			}	
			else
			{
				err = false;
				FormataCNPJ(objObject);
			}
		}
	}
	
	if(err == true)
	{
		ExibeToolTip(objtooltip,objObject);
		//window.event.srcElement.focus();
		return true;
	}
	else
	{
		return false;
	}
}




//************************************************************************************
// Metodo Formatar Telefone
//--> Formatar nesse estilo: 5555-5555
//
//************************************************************************************

function Telefone(objObject)
{ 
	var intValue = objObject.value;
	
	if ((window.event.keyCode >= 48 && window.event.keyCode <= 57) || (window.event.keyCode >= 96 && window.event.keyCode <= 105) )
	 {					
		if (intValue.length == 4)
		{ 
			intValue = intValue.substring(0,4) + "-";
		}
		objObject.value = intValue;
	}
}

//************************************************************************************
//								Metodo Validar Telefone
//
//************************************************************************************

function ValidarTelefone(objObject, objtooltip)
{
	SomeToolTip(objtooltip);
	
	var intValue = objObject.value;
	intValue = Replace(intValue, '-', '');
	
    if (intValue == null || intValue == "" ) 
	{
		SomeToolTip(objtooltip);		
	}
	else
	{
		if (intValue <=0 )
		{
				ExibeToolTip(objtooltip,objObject);
		}
	}
}



//************************************************************************************
// Metodo Formatar CEP
//--> Formatar nesse estilo: 55555-555
//
//************************************************************************************

function CEP(objObject)
{ 
	var intValue;
	intValue = objObject.value;
	
	if ((window.event.keyCode >= 48 && window.event.keyCode <= 57) || (window.event.keyCode >= 96 && window.event.keyCode <= 105) )
	 {					
		if (intValue.length == 5)
		{ 
			intValue = intValue.substring(0,5) + "-";
		}
		objObject.value = intValue;
	}
}

//************************************************************************************
//								Metodo Validar CEP
//
//************************************************************************************

function ValidarCEP(objObject, objtooltip)
{
	SomeToolTip(objtooltip);
	
	var intValue;
	intValue = objObject.value;
	intValue = Replace(intValue, '-', '');
	
    if (intValue == null || intValue == "" ) 
	{
		SomeToolTip(objtooltip);		
	}
	else
	{
		if (intValue<=0 || intValue>=99999999)
		{
				ExibeToolTip(objtooltip,objObject);
		}
	}
}


//**************************************************************************************************************
// Objetivo  :	Formata Seguradora (XXX-X)
// Premissas :	Nenhuma
// Entradas  :	objObject      - objeto para formatar a porcentagem
// Retorno   :	true ou false
//**************************************************************************************************************

function FormatarSeguradora(objObject)
{ 
	var intValue = objObject.value;

	//intValue = Replace(intValue, ',', '');
	intValue = Replace(intValue, '-', '');

	if (intValue.length > 3 )
	{ 
		intValue = intValue.substring(0,3) + "-" + intValue.substring( 3, intValue.length); 
	} 
	
	objObject.value = intValue;
}
