function maximizar()
{
	window.moveTo(0,0);
	if (document.all) {
		top.window.resizeTo(screen.availWidth,screen.availHeight);
	}
	else if (document.layers||document.getElementById) {
		if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
			top.window.outerHeight = screen.availHeight;
			top.window.outerWidth = screen.availWidth;
		}
	}
}

function openfoto( foto, dirFoto, altura, largura, desc )
{
	if (altura>largura)
	{
		largura += 15;
	}
	abrir = 'visualizarfoto.php?strDirFotos='+dirFoto+'&id_foto='+foto+'&desc='+desc;

	tipo = 'width='+largura+', height='+altura+', scrollbars=yes';
	var foto_ = window.open( abrir, 'JANELA_FOTO', tipo );
	foto_.focus();
}

function openurl(url)
{
	window.open(url,'PROCURAR','width=800, height=300, top=10, left=10, scrollbars=yes')
}

function retorna(form, campo, valor)
{
	window.opener.document.getElementById(campo).value=valor;
	campo = campo + "_";
	window.opener.document.getElementById(campo).value=valor;
	window.close();
}
function formataMonetario(campo, e)
{
	if( typeof window.event != "undefined" )
	{
		if (window.event.keyCode != 44 && window.event.keyCode != 46 )
		{
			var valor = campo.value;

			valor = valor.replace(",","");
			valor = valor.replace(" ","");
			valor = valor.split(".").join("");
			valor = valor.split(",").join("");

			for(var i=0; i<valor.length; i++)
			{

				if(valor.substr(i,1) != 0)
				{
					valor = valor.substr(i);


					break;
				}
			}
			if (valor.length < 3  )
			{
				if(valor.length == 2 && valor != 00)
				{
					campo.value = "0,"+valor;
				}else
				{
					campo.value = "";
				}
				if (valor.length == 1 )
				campo.value = "0,0"+valor;
				if(valor.length == 0)
				{
					campo.value = "";
				}
			}else
			{
				var centavos = valor.substr(valor.length-2,2);
				var resto = valor.substr(0,valor.length-2);
				valor = "";
				var count = 0;
				for( var i=resto.length; i>0; i--)
				{
					count++;
					if(count % 3 == 1 && count >1)
					{
						valor = resto.substr(i-1,1)+"."+valor;
					}else
					{
						valor = resto.substr(i-1,1)+valor;
					}

				}
				campo.value = valor+","+centavos;
			}

		}
	}
	else
	{

		if (e.which != 46 && e.which != 44 )
		{
			var valor = campo.value;

			valor = valor.replace(",","");
			valor = valor.replace(" ","");
			valor = valor.split(".").join("");
			valor = valor.split(",").join("");

			for(var i=0; i<valor.length; i++)
			{

				if(valor[i] != 0)
				{
					valor = valor.substr(i);
					break;
				}
			}
			if (valor.length < 3  )
			{
				if(valor.length == 2 && valor != 00)
				{
					campo.value = "0,"+valor;
				}else
				{
					campo.value = "";
				}

				if (valor.length == 1 )
				campo.value = "0,0"+valor;
				if(valor.length == 0)
				{
					campo.value ="";
				}
			}else
			{
				var centavos = valor.substr(valor.length-2,2);
				var resto = valor.substr(0,valor.length-2);
				valor = "";
				var count = 0;
				for( var i=resto.length; i>0; i--)
				{
					count++;
					if(count % 3 == 1 && count >1)
					{
						valor = resto.substr(i-1,1)+"."+valor;
					}else
					{
						valor = resto.substr(i-1,1)+valor;
					}

				}
				campo.value = valor+","+centavos;
			}

		}
	}


}