
	//'######################################################################
	//'#  Função: Setafunc Javascript funcoes em java
	//'#  Criado: Gustavo - 21/07/2006
	//'#  Ultima Atualizacao:
	//'######################################################################
	
//	objects = document.getElementsByTagName("object");
	
//	for (var i = 0; i < objects.length; i++)
	
//	{
	
//	objects[i].outerHTML = objects[i].outerHTML;
	
//	}	
	
	//#### funcoes grid	#### 
	//--- variaveis globais grid
	var VGridCount = 0;

//### inicio funcao validacao dos campos #### 
	var VImagePath = "imagens/";
	var VImgValErro = VImagePath +"BotCancel.gif";
	var VImgValOK	 = VImagePath +"BotPost.gif";
	
	function newLine2br(targetStr) {
			var rn, r, n;
			rn = /\r\n/g;
			r = /\r/g;
			n = /\n/g;
			targetStr = targetStr.replace(rn, "<br>");
			targetStr = targetStr.replace(r, "<br>");
			targetStr = targetStr.replace(n, "<br>");
			return targetStr;
	}	

	//--- valida campo
	function ValidaCampo(PObj, PRegExp, PLinha)
	{		
		if (PObj.value != "")
		{
			if (PObj.id == "CPF")
			{
				if (isCpf(PObj.value)==false)
				{
					document.images[PLinha].width = 16;
					document.images[PLinha].height = 16;			
					document.images[PLinha].src = VImgValErro;					
					return ""
				}
			}		
			if (PObj.id == "CNPJ")
			{
				if (isCnpj(PObj.value)==false)
				{
					document.images[PLinha].width = 16;
					document.images[PLinha].height = 16;			
					document.images[PLinha].src = VImgValErro;					
					return ""
				}
			}		
			if (PObj.id == "CNPJCPF")
			{
				if (isCpfCnpj(PObj.value)==false)
				{
					document.images[PLinha].width = 16;
					document.images[PLinha].height = 16;			
					document.images[PLinha].src = VImgValErro;					
					return ""
				}
			}	
			if (PObj.id == "CPFCNPJ")
			{
				if (isCpfCnpj(PObj.value)==false)
				{
					document.images[PLinha].width = 16;
					document.images[PLinha].height = 16;			
					document.images[PLinha].src = VImgValErro;					
					return ""
				}
			}				
			var VRegExp = new RegExp (PRegExp);			
			var VOK = VRegExp.exec(PObj.value);			
			if (!VOK)
			{
				document.images[PLinha].width = 16;
				document.images[PLinha].height = 16;			
				document.images[PLinha].src = VImgValErro;
			}
			else
			{
				document.images[PLinha].width = 16;
				document.images[PLinha].height = 16;			
				document.images[PLinha].src = VImgValOK;		
			}		
		}
		else
		{
			document.images[PLinha].width = 16;
			document.images[PLinha].height = 16;			
			document.images[PLinha].src = VImgValOK;				
		}
	}			
	
	//--- valida form inteiro
	function ValidaForm(PForm, PCampo, PRegExp, PMsg, PLinha, PTipo, PLookup)
	{
		var VOk = true;
		var VCampo = PCampo.split("|");
		var VLinha = PLinha.split("|");
		var VTipo = PTipo.split("|");		
		var VRegExp = PRegExp.split("|");		
		var VMsg = PMsg.split("|");
		var VStr1 = "<td>";
		var VHTML = "";
		VErroCount = 0;
		for(var VInt1=0;VInt1 < VCampo.length;VInt1++)
		{ 
			if (TrimJS(document.getElementById(VCampo[VInt1]).value) == "")
			{ 			
				if (VTipo[VInt1] == "2" || VTipo[VInt1] == "3")
				{			
					VStr1 = VStr1 + '<b>' + VMsg[VInt1] + "</b> - Informação obrigatória." + "<br>";
					document.images[VLinha[VInt1]].width = 16;
					document.images[VLinha[VInt1]].height = 16;						
					document.images[VLinha[VInt1]].src = VImgValErro;									
					//document.getElementById(VCampo[VInt1]).focus();
					VOk = false;				
					VErroCount = VErroCount + 1;
				}
			}
			else
			{
				VObjRegExp = new RegExp (VRegExp[VInt1]);
				var VErro = VObjRegExp.exec(document.getElementById(VCampo[VInt1]).value);
				if (!VErro)			
				{
					VStr1 = VStr1 + VMsg[VInt1] + " - Informação incorreta." + "<br>";						
					document.images[VLinha[VInt1]].width = 16;
					document.images[VLinha[VInt1]].height = 16;						
					document.images[VLinha[VInt1]].src = VImgValErro;
					//document.getElementById(VCampo[VInt1]).focus();
					VOk = false;
					VErroCount = VErroCount + 1;
				}
				else
				{
					if (document.getElementById(VCampo[VInt1]).id == "CPFCNPJ")
					{
						if (isCpfCnpj(document.getElementById(VCampo[VInt1]).value)==false)
						{
							VStr1 = VStr1 + VMsg[VInt1] + " - Informação incorreta." + "<br>";													
							document.images[VLinha[VInt1]].width = 16;
							document.images[VLinha[VInt1]].height = 16;						
							document.images[VLinha[VInt1]].src = VImgValErro;
							//document.getElementById(VCampo[VInt1]).focus();
							VOk = false;
							VErroCount = VErroCount + 1;
						}
					}	
					if (document.getElementById(VCampo[VInt1]).id == "CNPJCPF")
					{
						if (isCpfCnpj(document.getElementById(VCampo[VInt1]).value)==false)
						{
							VStr1 = VStr1 + VMsg[VInt1] + " - Informação incorreta." + "<br>";													
							document.images[VLinha[VInt1]].width = 16;
							document.images[VLinha[VInt1]].height = 16;						
							document.images[VLinha[VInt1]].src = VImgValErro;
							//document.getElementById(VCampo[VInt1]).focus();
							VOk = false;
							VErroCount = VErroCount + 1;
						}
					}			
					if (document.getElementById(VCampo[VInt1]).id == "CNPJ")
					{
						if (isCnpj(document.getElementById(VCampo[VInt1]).value)==false)
						{
							VStr1 = VStr1 + VMsg[VInt1] + " - Informação incorreta." + "<br>";													
							document.images[VLinha[VInt1]].width = 16;
							document.images[VLinha[VInt1]].height = 16;						
							document.images[VLinha[VInt1]].src = VImgValErro;
							//document.getElementById(VCampo[VInt1]).focus();
							VOk = false;
							VErroCount = VErroCount + 1;
						}
					}	
					if (document.getElementById(VCampo[VInt1]).id == "CPF")
					{
						if (isCpf(document.getElementById(VCampo[VInt1]).value)==false)
						{
							VStr1 = VStr1 + VMsg[VInt1] + " - Informação incorreta." + "<br>";													
							document.images[VLinha[VInt1]].width = 16;
							document.images[VLinha[VInt1]].height = 16;						
							document.images[VLinha[VInt1]].src = VImgValErro;
							//document.getElementById(VCampo[VInt1]).focus();
							VOk = false;
							VErroCount = VErroCount + 1;
						}
					}						
				}
				if (PLookup != "" && VTipo[VInt1] == "3")
				{
					PegaLookup(PLookup, VMsg[VInt1], VLinha[VInt1]);
				}
			}
		}
		VStr1 = VStr1 + "</td>";
		if(VOk)
		{
			VGravaOK = true
		}
		else
		{
			VGravaOK = false
		}
	}	
	
	//--- valida form inteiro
	function ValidaForm3(PForm, PCampo, PRegExp, PMsg, PLinha, PTipo, PLookup)
	{
		var VOk = true;
		var VCampo = PCampo.split("|");
		var VLinha = PLinha.split("|");
		var VTipo = PTipo.split("|");		
		var VRegExp = PRegExp.split("|");		
		var VMsg = PMsg.split("|");
		var VStr1 = "<td>";
		var VHTML = "";
		var VCampoForm = "";
		VErroCount = 0;
//		PForm = document.getElementById('formVisa')
		for(var VInt1=0;VInt1 < VCampo.length;VInt1++)
		{ 
			VCampoForm = VCampo[VInt1]
			if (TrimJS(PForm[VCampoForm].value) == "")
			{ 			
				if (VTipo[VInt1] == "2" || VTipo[VInt1] == "3")
				{			
					VStr1 = VStr1 + '<b>' + VMsg[VInt1] + "</b> - Informação obrigatória." + "<br>";
					document.images[VLinha[VInt1]].width = 16;
					document.images[VLinha[VInt1]].height = 16;						
					document.images[VLinha[VInt1]].src = VImgValErro;									
					VOk = false;				
					VErroCount = VErroCount + 1;
				}
			}
			else
			{
				VObjRegExp = new RegExp (VRegExp[VInt1]);
				var VErro = VObjRegExp.exec(PForm[VCampoForm].value);
				if (!VErro)			
				{
					VStr1 = VStr1 + VMsg[VInt1] + " - Informação incorreta." + "<br>";						
					document.images[VLinha[VInt1]].width = 16;
					document.images[VLinha[VInt1]].height = 16;						
					document.images[VLinha[VInt1]].src = VImgValErro;
					VOk = false;
					VErroCount = VErroCount + 1;
				}
				else
				{
					if (PForm[VCampoForm].id == "CPFCNPJ")
					{
						if (isCpfCnpj(PForm[VCampoForm].value)==false)
						{
							VStr1 = VStr1 + VMsg[VInt1] + " - Informação incorreta." + "<br>";													
							document.images[VLinha[VInt1]].width = 16;
							document.images[VLinha[VInt1]].height = 16;						
							document.images[VLinha[VInt1]].src = VImgValErro;
							VOk = false;
							VErroCount = VErroCount + 1;
						}
					}	
					if (PForm[VCampoForm].id == "CNPJCPF")
					{
						if (isCpfCnpj(PForm[VCampoForm].value)==false)
						{
							VStr1 = VStr1 + VMsg[VInt1] + " - Informação incorreta." + "<br>";													
							document.images[VLinha[VInt1]].width = 16;
							document.images[VLinha[VInt1]].height = 16;						
							document.images[VLinha[VInt1]].src = VImgValErro;
							VOk = false;
							VErroCount = VErroCount + 1;
						}
					}			
					if (PForm[VCampoForm].id == "CNPJ")
					{
						if (isCnpj(PForm[VCampoForm].value)==false)
						{
							VStr1 = VStr1 + VMsg[VInt1] + " - Informação incorreta." + "<br>";													
							document.images[VLinha[VInt1]].width = 16;
							document.images[VLinha[VInt1]].height = 16;						
							document.images[VLinha[VInt1]].src = VImgValErro;
							VOk = false;
							VErroCount = VErroCount + 1;
						}
					}	
					if (PForm[VCampoForm].id == "CPF")
					{
						if (isCpf(PForm[VCampoForm].value)==false)
						{
							VStr1 = VStr1 + VMsg[VInt1] + " - Informação incorreta." + "<br>";													
							document.images[VLinha[VInt1]].width = 16;
							document.images[VLinha[VInt1]].height = 16;						
							document.images[VLinha[VInt1]].src = VImgValErro;
							VOk = false;
							VErroCount = VErroCount + 1;
						}
					}						
				}
				if (PLookup != "" && VTipo[VInt1] == "3")
				{
					PegaLookup(PLookup, VMsg[VInt1], VLinha[VInt1]);
				}
			}
		}
		VStr1 = VStr1 + "</td>";
		if(VOk)
		{
			VGravaOK = true
		}
		else
		{
			VGravaOK = false
		}
	}		
	
	//--- valida form inteiro
	function ValidaForm2(PForm, PCampo, PRegExp, PMsg, PLinha, PTipo, PLookup)
	{
		var VOk = true;
		var VCampo = PCampo.split("|");
		var VLinha = PLinha.split("|");
		var VTipo = PTipo.split("|");		
		var VRegExp = PRegExp.split("|");		
		var VMsg = PMsg.split("|");
		var VStr1 = "";
		VErroCount = 0;
		for(var VInt1=0;VInt1 < VCampo.length;VInt1++)
		{
			if (TrimJS(document.getElementById(VCampo[VInt1]).value) == "")
			{ 			
				if (VTipo[VInt1] == "2" || VTipo[VInt1] == "3")
				{			
					document.images[VLinha[VInt1]].width = 16;
					document.images[VLinha[VInt1]].height = 16;						
					document.images[VLinha[VInt1]].src = VImgValErro;				
					//document.getElementById(VCampo[VInt1]).focus();
					VOk = false;				
					VErroCount = VErroCount + 1;
				}
			}
			else
			{
				VObjRegExp = new RegExp (VRegExp[VInt1]);
				var VErro = VObjRegExp.exec(document.getElementById(VCampo[VInt1]).value);
				if (!VErro)			
				{
					document.images[VLinha[VInt1]].width = 16;
					document.images[VLinha[VInt1]].height = 16;
					document.images[VLinha[VInt1]].src = VImgValErro;
					//document.getElementById(VCampo[VInt1]).focus();
					VOk = false;
					VErroCount = VErroCount + 1;
				}
				if (PLookup != "" && VTipo[VInt1] == "3")
				{
					PegaLookup(PLookup, VMsg[VInt1], VLinha[VInt1]);
				}
			}
		}
		if(VOk)
		{
			VGravaOK = true
		}
		else
		{
			VGravaOK = false
		}
	}		
	
	//### fim funcoes validacao	#### 
	
	function SackLoad()
	{
		var VStr1 = VerBrowser()
		if (VStr1 == "1")
		{
		document.documentElement.style.cursor = "wait";
		}
		else
		{
			document.body.style.cursor = "wait";		
		}
	}
	
	function SackLoaded()
	{
		var VStr1 = VerBrowser()
		if (VStr1 == "1")
		{
		document.documentElement.style.cursor = "auto";
		}
		else
		{
			document.body.style.cursor = "auto";		
		}
	}			
	
	//--- retorna qual browser esta em uso
	function VerBrowser()
	{
		var VStr1 = "";		
		if (navigator.appName=='Mozilla Firefox')
		{
			VStr1 = "1";
		}	
		if (navigator.appName=='Microsoft Internet Explorer')
		{
			VStr1 = "2";
		}		
		if (navigator.appName=='Netscape')
		{
			VStr1 = "3";
		}
		if (navigator.appName=='Opera')
		{
			VStr1 = "4";
		}				
		return VStr1
	}	
	
	//--- pega resolucao
	function PegaResolucao(PObjeto)
	{		
		var VResolucao = screen.width+"x"+screen.height;
		var VScreen = 0
		if (!PObjeto)
		{
			if (screen.width == 1024)
			{			
				VScreen = screen.width - 50;
				return VScreen
			}
			if (screen.width == 800)
			{			
				VScreen = screen.width - 50;
				return VScreen
			}		
			if (screen.width > 1024)
			{			
				VScreen = 1004;
				return VScreen
			}	
			if (screen.width < 800)
			{			
				VScreen = 780;
				return VScreen
			}	
		}
		else
		{
			if (PObjeto == "TecladoVert")
			{
				if (screen.width == 1024)
				{			
					VScreen = 0
					return VScreen
				}
				if (screen.width == 800)
				{			
					VScreen = 100
					return VScreen
				}		
				if (screen.width > 1024)
				{			
					VScreen = 0
					return VScreen
				}	
				if (screen.width < 800 )
				{			
					VScreen = 0
					return VScreen
				}			
			}			
			else
			{
			if (PObjeto == "TecladoHor")
			{
				if (screen.width == 1024)
				{			
					VScreen = 20
					return VScreen
				}
				if (screen.width == 800)
				{			
					VScreen = 20
					return VScreen
				}		
				if (screen.width > 1024)
				{			
					VScreen = 0
					return VScreen
				}	
				if (screen.width < 800 )
				{			
					VScreen = 0
					return VScreen
				}			
			}				
			else
			{
				if (PObjeto == tbResolucao)
				{
					if (screen.width == 1024)
					{			
						PObjeto.width = screen.width - 20;
					}
					if (screen.width == 800)
					{			
						PObjeto.width = screen.width - 21;
					}		
					if (screen.width > 1024)
					{			
						PObjeto.width = 1004;
					}	
					if (screen.width < 800 )
					{			
						PObjeto.width = 780 - 21;
					}			
				}						
			}
		}
	}
	}	
	
	function TrimJS(sString)
	{
		if (sString == undefined)
		{
			return ""
		}
		while (sString.substring(0,1) == ' ')
		{
		sString = sString.substring(1, sString.length);
		}
		while (sString.substring(sString.length-1, sString.length) == ' ')
		{
		sString = sString.substring(0,sString.length-1);
		}
		return sString;
	}	
	
	function ReplaceJS(PStr,PCar1,PCar2)
	{
		var VStr1 = PStr
		var VStr2 = "'"
		if (VStr1 == "")
		{
			return
		}
		if (VStr1 == " ")
		{
			return
		}		
		if (!VStr1)
		{
			return
		}		
		for(var i=0; i<VStr1.length;i++)
		{
			VStr1 = VStr1.replace(PCar1,PCar2)			
		}	
		return VStr1
	}		
	
	//--- abre janela
	function AbreJanela(PLink, PTitulo, PAltura, PLargura)
	{
		var VAltura = (screen.height-PAltura)/2;
		var VLargura =(screen.width-PLargura)/2;
		popup=window.open(PLink,PTitulo,"top="+VAltura+",left="+VLargura+",height="+PAltura+",width="+PLargura+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no");
		//windowopen(PTitulo,PLink,10,10,VLargura,VAltura)		
		popup.focus();
		return false;
	}	
	
	//--- abre janela
	function AbreJanelaAvisoDispCar(PLink, PTitulo, PAltura, PLargura)
	{
		var VAltura = (screen.height-300)/2;
		var VLargura =(screen.width-500)/2;
		popup=window.open(PLink,PTitulo,"top="+VAltura+",left="+VLargura+",height="+300+",width="+500+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no");
		popup.focus();
		return false;
	}		
	
		//--- abre janela
	function AbreJanela2(PLink, PTitulo, PAltura, PLargura)
	{
		var VAltura = (screen.height-PAltura)/2;
		var VLargura =(screen.width-PLargura)/2;
		popup=window.open(PLink,PTitulo,"top="+VAltura+",left="+VLargura+",height="+PAltura+",width="+PLargura+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no");
		popup.focus();
		return false;
	}		
	
	function openPopUp(PUrl, PName, PParam) {
		window.open(PUrl, PName, PParam)
	}
	
		//--- abre janela
	function AbreJanela5(PLink, PTitulo, PAltura, PLargura)
	{
		var VAltura = (screen.height-PAltura)/2;
		var VLargura =(screen.width-PLargura)/2;
		popup=window.open(PLink,PTitulo,"top="+VAltura+",left="+VLargura+",height="+PAltura+",width="+PLargura+",resizable=no");
		popup.focus();
		return false;
	}	
	
	function AbreSimulacaoAymore(PValor)
	{
		AbreJanela5('../dotstore/loja/SimulacaoAymore.asp?PParam1='+PValor+'&PParam2=', 'Aymore', '500', '630')
	}
	
	function AbreSimulacaoFinan(PValor, PCod)
	{
		popup=window.open('../dotstore/loja/SimulacaoFinan.asp?PParam1='+PValor+'&PParam2='+PCod,'Financiamento',"top="+300+",left="+350+",height="+300+",width="+350+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no");
		popup.focus();		
	}	
	
	function TrocaIdioma(PIdioma, PPTBR, PENG, PESP)
	{
		if (PIdioma == "PTBR")
		{
				return PPTBR
		}
		if (PIdioma == "ENG")
		{
				return PENG
		}		
		if (PIdioma == "ESP")
		{
				return PESP
		}				
	}
	
	function checkdisabled(el) {
		if (VerBrowser() == '2')
		{
		 if (el.options[el.selectedIndex].disabled) {
				el.options.value = el.options[el.selectedIndex+1].value;
				el.onchange()
		 }
		}
	}
	
	function hidedisabledoptions() {
		if (document.all && !window.opera)
		{
		if (VerBrowser() == '2')
		{			
	    selects = document.getElementsByTagName("select");
  	  for (var i=0;i<selects.length;i++)
			{
				for (var j = 0; j < selects[i].options.length; j++)
				{
					 if (selects[i].options[j].disabled)
							selects[i].options[j].style.backgroundColor = 'lightgrey';
				}
			}
		 }
		}
	}	
	
	//--- somente numeros
	function ChkNumero(PStr)
	{
		var VKeyCode = PStr.keyCode ? PStr.keyCode : PStr.which ? PStr.which : PStr.charCode;
		if ((VKeyCode<48 && VKeyCode != 8 && VKeyCode != 46 && VKeyCode != 9 && VKeyCode != 13 )||(VKeyCode>57))
		{
			if (VerBrowser() == "2")//i.e.
			{
				PStr.returnValue = false;
				return false
			}
			else
			{
				var VNewEvent = document.createEvent("KeyEvents")
				VNewEvent.initKeyEvent("keypress", true, true, document.defaultView, PStr.ctrlKey, PStr.altKey, PStr.shiftKey, PStr.metaKey, 0, Doit())
				PStr.preventDefault()
				//PStr.target.dispatchEvent(newEvent)
			}
		}	
	}	
	
	//--- funcao de retorno para checagem de caracteres
	function Doit()
	{
	}
		
	//funcao formata currency
	function LimparMoeda(valor, validos) 
	{
		var result = "";
		var aux;
		for (var i=0; i < valor.length; i++) {
		aux = validos.indexOf(valor.substring(i, i+1));
		if (aux>=0) { result += aux; } } return result; 
	}
	
	//funcao formata currency
	function LimparPeso(valor, validos) 
	{
		var result = "";
		var aux;
		for (var i=0; i < valor.length; i++) {
		aux = validos.indexOf(valor.substring(i, i+1));
		if (aux>=0) { result += aux; } } return result; 
	}	
	
	//funcao formata currency
	function FormataPeso(campo,tammax,teclapres) 
	{
		var tecla = teclapres.keyCode;
		vr = LimparPeso(campo.value,"0123456789");
		tam = vr.length;
		if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }
		if (tecla == 8 )
		{ tam = tam - 1 ; }
		if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 )
		{ dec=2
		if ( tam <= dec )
		{ campo.value = vr ; }
		if ( (tam > dec) && (tam <= 5) ){
		campo.value = vr.substr( 0, tam - 2 ) + "," + vr.substr( tam - dec, tam ) ; }
		if ( (tam >= 6) && (tam <= 8) ){
		campo.value = vr.substr( 0, tam - 5 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; }
		if ( (tam >= 9) && (tam <= 11) ){
		campo.value = vr.substr( 0, tam - 8 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; }
		if ( (tam >= 12) && (tam <= 14) ){
		campo.value = vr.substr( 0, tam - 11 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; }
		if ( (tam >= 15) && (tam <= 17) ){
		campo.value = vr.substr( 0, tam - 14 ) + "." + vr.substr( tam - 14, 3 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - 2, tam ) ;} } 
	}	
	
	//funcao formata data	
	function FormataPeso2( data, ptecla )
	{
   var VTecla = ptecla.keyCode;
  	var tam = data.value.length;
		if (((VTecla) >= 44 ) && ((VTecla) <= 57 )|| VTecla >= 96 && VTecla <= 105)
		{ VTecla;
		if ( ( tam == 2 ) || ( tam == 5 ) )
		{ 
		if (data.value.indexOf(".")<=0)
			{
				data.value = data.value + "."; 
			}
		}
		}
		else
		{ VTecla = 0; }
	}			

	//funcao formata currency
	function FormataMoeda(campo,tammax,teclapres) 
	{
		var tecla = teclapres.keyCode;
		vr = LimparMoeda(campo.value,"0123456789");
		tam = vr.length;
		if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }
		if (tecla == 8 )
		{ tam = tam - 1 ; }
		if (tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 )
		{ dec=2
		if ( tam <= dec )
		{ campo.value = vr ; }
		if ( (tam > dec) && (tam <= 5) ){
		campo.value = vr.substr( 0, tam - 2 ) + "," + vr.substr( tam - dec, tam ) ; }
		if ( (tam >= 6) && (tam <= 8) ){
		campo.value = vr.substr( 0, tam - 5 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; }
		if ( (tam >= 9) && (tam <= 11) ){
		campo.value = vr.substr( 0, tam - 8 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; }
		if ( (tam >= 12) && (tam <= 14) ){
		campo.value = vr.substr( 0, tam - 11 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; }
		if ( (tam >= 15) && (tam <= 17) ){
		campo.value = vr.substr( 0, tam - 14 ) + "." + vr.substr( tam - 14, 3 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - 2, tam ) ;} } 
	}
	
	//funcao formata data	
	function FormataData( data, ptecla )
	{
   var VTecla;
   if (ptecla.keyCode) VTecla = ptecla.keyCode;
   else if (ptecla.which) VTecla = ptecla.which; // Netscape 4.?
	 
		var tam = data.value.length;
		if (((VTecla) >= 44 ) && ((VTecla) <= 57 )|| VTecla >= 96 && VTecla <= 105)
		{ VTecla;
		if ( ( tam == 2 ) || ( tam == 5 ) )
		{ data.value = data.value + "/"; }
		}
		else
		{ VTecla = 0; }
	}	
	
	//funcao formata data	
	function FormataHora( data, ptecla )
	{
   var VTecla;
   if (ptecla.keyCode) VTecla = ptecla.keyCode;
   else if (ptecla.which) VTecla = ptecla.which; // Netscape 4.?
	 
		var tam = data.value.length;
		if (((VTecla) >= 44 ) && ((VTecla) <= 57 )|| VTecla >= 96 && VTecla <= 105)
		{ VTecla;
		if ( ( tam == 2 ) || ( tam == 5 ) )
		{ data.value = data.value + ":"; }
		}
		else
		{ VTecla = 0; }
	}		
	
	//funcao formata cnpj	
	function FormataCNPJ(campo,tammax,teclapres)
	{
		var tecla = teclapres.keyCode;
		var vr = campo.value;
		vr = vr.replace( "-", "" );
		vr = vr.replace( "/", "" );
		vr = vr.replace( ".", "" );
		vr = vr.replace( ".", "" );
		tam = vr.length;
		if (tam < tammax && tecla != 13){ tam = vr.length + 1 ; }
		if (tecla == 13 ){ tam = tam - 1 ; }
		if ( tecla == 13 || (tecla >= 48 && tecla <= 57) || (tecla >= 96 && tecla <= 105) ){
		if ( tam <= 2 ){
		campo.value = vr ; }
		tam = tam - 1;
		if ( (tam > 2) && (tam <= 5) ){
		campo.value = vr.substr( 0, tam - 2 ) + '-' + vr.substr( tam - 2, tam ) ; }
		if ( (tam >= 6) && (tam <= 8) ){
		campo.value = vr.substr( 0, tam - 6 ) + '/' + vr.substr( tam - 6, 4 ) + '-' + vr.substr( tam - 2, tam ) ; }
		if ( (tam >= 9) && (tam <= 11) ){
		campo.value = vr.substr( 0, tam - 9 ) + '.' + vr.substr( tam - 9, 3 ) + '/' + vr.substr( tam - 6, 4 ) + '-' + vr.substr( tam - 2, tam ) ; }
		if ( (tam >= 12) && (tam <= 14) ){
		campo.value = vr.substr( 0, tam - 12 ) + '.' + vr.substr( tam - 12, 3 ) + '.' + vr.substr( tam - 9, 3 ) + '/' + vr.substr( tam - 6, 4 ) + '-' + vr.substr( tam - 2, tam ) ; }
	} }			
	
	function FormataCpf(Campo,ptecla)
	{
		var tam = Campo.value.length;
		var vtecla
  	if (ptecla.keyCode) vtecla = ptecla.keyCode;
	  else if (ptecla.which) vtecla = ptecla.which; // Netscape 4.?		
		if (((vtecla) >= 48 ) && ((vtecla) <= 57 ))
		{
		if ((tam == 3 ) || (tam == 7))
		{
		Campo.value = Campo.value + ".";
		}
		
		if ((tam == 11 ))
		{
		Campo.value = Campo.value + "-";
		}
		}
		else
		{
		}
	}	
	
	function FormataRG(Campo,ptecla)
	{
		var tam = Campo.value.length;
		var vtecla
  	if (ptecla.keyCode) vtecla = ptecla.keyCode;
	  else if (ptecla.which) vtecla = ptecla.which; // Netscape 4.?		
		if (((vtecla) >= 48 ) && ((vtecla) <= 57 )|| ((vtecla) == 120 ))
		{
		if ((tam == 2 ) || (tam == 6))
		{
		Campo.value = Campo.value + ".";
		}
		
		if ((tam == 10 ))
		{
		Campo.value = Campo.value + "-";
		}
		}
		else
		{
		}
	}		
	
	function AlteraQtdeCarrinho(PCampo, PTipo)
	{
		var qtde
		if (document.getElementById(PCampo)!=undefined)
		{
			qtde = document.getElementById(PCampo).value;
			//validando se eh numerico
			if (qtde != (qtde/1) ) {
				qtde = 0;
			}
			if 	(PTipo == 0){	  //Aumentando quantidade do carrinho
				qtde++;
			}else if( PTipo == 1){ //Diminunido quantidade do carrinho
				qtde--;
			}	
			if (qtde > 99){
				qtde--;
			}else if(qtde <= 0){
				qtde = 1;
			}
			document.getElementById(PCampo).value = qtde;
		}
		else
		{
			if (PCampo!=undefined)
			{
				qtde = PCampo.value;
				//validando se eh numerico
				if (qtde != (qtde/1) ) {
					qtde = 0;
				}
				if 	(PTipo == 0){	  //Aumentando quantidade do carrinho
					qtde++;
				}else if( PTipo == 1){ //Diminunido quantidade do carrinho
					qtde--;
				}	
				if (qtde > 99){
					qtde--;
				}else if(qtde <= 0){
					qtde = 1;
				}
				PCampo.value = qtde;
			}			
		}
	}
	
	function LojaAdicionaCarrinho(PCod, PQtde, PCaminho)
	{
		if(PCaminho=='' || PCaminho==null || PCaminho==undefined)
		{
			PCaminho = "../dotstore/loja/"
		}
		PCaminho = "/dotstore/loja/"
		var VIndex = VAjaxObjects.length;
		VAjaxObjects[VIndex] = new sack();
		VAjaxObjects[VIndex].onLoading = function(){ SackLoad(); };
		VAjaxObjects[VIndex].onLoaded = function(){ SackLoaded(); };	
		VAjaxObjects[VIndex].onCompletion = function(){ RetLojaAdicionaCarrinho(VIndex); };
		VAjaxObjects[VIndex].requestFile = PCaminho+"CarrinhoMan.asp?Act=LojaAdicionaCarrinho&ProdutoID="+PCod+"&Qtde="+PQtde
		VAjaxObjects[VIndex].runAJAX();					
		function RetLojaAdicionaCarrinho(PIndex)
		{
			eval(VAjaxObjects[PIndex].response);				
		}
	}
	
	function SetaTitulo(PValor)
	{
		document.title = PValor
	}
	
	function AbreJanelaFEDEX(PCod, PID)
	{
		var VIndex = VAjaxObjects.length;
		VAjaxObjects[VIndex] = new sack();
		VAjaxObjects[VIndex].onLoading = function(){ SackLoad(); };
		VAjaxObjects[VIndex].onLoaded = function(){ SackLoaded(); };	
		VAjaxObjects[VIndex].onCompletion = function(){ RetAbreJanelaFEDEX(VIndex); };
		VAjaxObjects[VIndex].requestFile = '../dotstore/Inc/RetornoLoja.asp?Param1=5&Param2=LocalFedex'
		VAjaxObjects[VIndex].runAJAX();					
		function RetAbreJanelaFEDEX(PIndex)
		{
			var formObj = document.forms['form'];	
			eval(VAjaxObjects[PIndex].response);
			var VStr1 = VSplitGetVal.split("!");
			var VCount = parseInt(VStr1[0])
			var VStr2 = VStr1[1].split("~");
			var VInt1 = 0;
			var VStr3 = "";
			var VStr4 = "";
			var VStr5 = "";
			for(var VInt1=0;VInt1 < VCount;VInt1++)
			{							
				VStr3 = VStr2[VInt1].split("|")
				if (VStr3[0] == PCod)
				{
					VStr5 = "selected='selected'";
				}
				else
				{
					VStr5 = "";
				}
				VStr4 = VStr4 + "<option value='"+ VStr3[0] +"'" + VStr5 + ">"+ VStr3[1] +"</option>"
			}
			var VHTML = "<select name='LocalFedex' id='LocalFedex' class='FCampos' size='5' style='width:150px;border-color:#FF0000; border-width:2;'>";	
			VHTML = VHTML + "<option value='' selected='selected'></option>"+ VStr4
			VHTML = VHTML + "</select>";
			if (document.getElementById("TbFedex")!=undefined){document.getElementById("TbFedex").innerHTML = VHTML};	 
			if (document.getElementById('LocalFedex')!=undefined){GravaFedex(document.getElementById('LocalFedex').value, PID)};		
			if (document.getElementById('LocalFedex')!=undefined){document.getElementById("LocalFedex").onchange = function(){ GravaFedex(document.getElementById('LocalFedex').value, PID); } ;}	
		}
	}
	
	function GravaFedex(PCod, PID)
	{
		var VIndex = VAjaxObjects.length;
		VAjaxObjects[VIndex] = new sack();
		VAjaxObjects[VIndex].onLoading = function(){ SackLoad(); };
		VAjaxObjects[VIndex].onLoaded = function(){ SackLoaded(); };	
		VAjaxObjects[VIndex].onCompletion = function(){ RetGravaFedex(VIndex); };
		VAjaxObjects[VIndex].requestFile = '../dotstore/loja/CalcFedex.asp?Param1=1&Param2='+PCod+'&PFrete='+PID
		VAjaxObjects[VIndex].runAJAX();		
		function RetGravaFedex(PIndex)
		{
			eval(VAjaxObjects[PIndex].response);		
		}
	}

	function AbreJaneDispProdS(PLink)
	{
		AbreJanela(PLink, "AvisoDisp", 300, 500)
	}
	
	//div
	var VScriptIncSub = false	
	function AbreJanelaDivPop(PURL, PAltura, PLargura, PScroll, PURLLoading)
	{
		if(VScriptIncSub==false)
		{
			var headID = document.getElementsByTagName("head")[0];         
			var newScript = document.createElement('link');			
			newScript.type = 'text/css';
			newScript.rel = 'stylesheet';			
			newScript.href = 'http://www.dotstore2.com.br/dotstore/inc/submodal.css';								
			headID.appendChild(newScript);		
			var newScript = document.createElement('script');						
			newScript.type = 'text/javascript';
			newScript.src = 'http://www.dotstore2.com.br/dotstore/inc/submodal.js';
			headID.appendChild(newScript);	
			VScriptIncSub = true;
			window.setTimeout("IniciaPopDiv('"+PURL+"', "+PAltura+", "+PLargura+", "+PScroll+", '"+PURLLoading+"');", 600);					
		}		
		else
		{
			IniciaPopDiv(PURL, PAltura, PLargura, PScroll, PURLLoading);
		}
	}
	
	function IniciaPopDiv(PURL, PAltura, PLargura, PScroll, PURLLoading)
	{
		initPopUpJanela(PScroll, PURLLoading);
		showPopWinJanela(PURL,PAltura, PLargura, false, 'Janela',PURLLoading);	
		addEventJanela(window, "resize", centerPopWinJanela);
		window.onscroll = centerPopWinJanela;			
	}	