// ************************************************************
// LOADING NOTIFY METHODS
// ************************************************************

var loadingNotifyDiv = null;
var loadingCount = 0;

// Creates loading notify div
function CreateLoading()
{
	text = "Carregando...";
	if(!loadingNotifyDiv)
	{
		
		// Creates a div
		loadingNotifyDiv = document.createElement("div");
		loadingNotifyDiv.className = "loadingNotify"; //class that contains div style
		loadingNotifyDiv.style.position = "Absolute";
		PositionLoading();

		document.body.appendChild(loadingNotifyDiv);
		
		window.onscroll = PositionLoading;
	}
	
	// Increments the loading count
	loadingCount++;

	// Updates the text	
	loadingNotifyDiv.innerHTML = text;
}

function DestroyLoading()
{
	loadingCount--;
	if(loadingCount==0)
	{
		// Destroys the div and resets the parameters
		document.body.removeChild(loadingNotifyDiv);
		loadingNotifyDiv = null;
		loadingNotifyTimer = -1;
		
		window.onscroll = null;
	}
}

function PositionLoading()
{
	if(loadingNotifyDiv)
	{
		// Gets the scrolled top of the page
		var scrollTop = document.all ? document.body.scrollTop: window.pageYOffset;
		loadingNotifyDiv.style.top = scrollTop + "px";
		loadingNotifyDiv.style.left =  "870px";
	}
}

function fnSubmitAction(form,action,idContent)
    {		
		form.idContent.value = idContent;
		form.selectActionTodo.value = action;
		form.listAction.value = 1;
		form.submit();    
    }   
    
	function fnSubmit(form,action)
	{				
		form.listAction.value = action;			
		form.submit();
	}
	
	function MascaraData(data, event){
	var tecla = event.keyCode
    nav = navigator.appName
    // if(nav == "Microsoft Internet Explorer")
    // {
    //   tecla = window.event.keyCode;
    // }
	if(tecla != '8' && tecla != '46')
	{
		verdata = '';
		verdata = verdata + data.value;
		if (verdata.length == 2){
			verdata = verdata + '/';
			data.value=verdata;
		}
		if (verdata.length == 5){
			verdata = verdata + '/';
			data.value=verdata;         
		}
	}
}


function ValidaData(ele)
{
    erro='nao';
	if (ele.value=='' || ele.value==' ')
	{
       alert ('Campo deve ser preenchido!');
       ele.focus();
       erro='sim';
	   return
	}
	else
	{
		data=ele.value
		var partes = data.split('/');
		var Ano = partes[2];
		var Mes = partes[1];
		var Dia = partes[0];


		var Data1 = (Ano+Mes+Dia);
		if (isNaN(Data1))
		{
			alert ('Data incorreta!');
			ele.focus();
			erro='sim';
			return
		}
		if (Ano < 1500)
		{
			alert ('Data incorreta!');
			ele.focus();
			erro='sim';
			return
		}
		Data1 = new Date(Ano, Mes - 1, Dia);
		if (Mes < 1 || Mes > 12)
		{
			alert ('Data incorreta!');
			ele.focus();
			erro='sim';
			return
		}
		if (Dia < 1 || Dia > 31)
		{
			alert ('Data incorreta!');
			ele.focus();
			erro='sim';
			return
		}
		if (Dia > 30 || (Dia > 28 && Mes==02))
		{
			D = Data1.getDate();
			if (D<Dia)
			{
				alert ('Data incorreta!');
				ele.focus();
				erro='sim';
				return
			}
		}
	}
}
