function submitForm(){
	//document.getElementsByName("event")[0].value = evento;
	//document.getElementById(formulario).submit();
	//alert(document.forms[0]);
	document.forms[0].submit();
}

function abreEsqueciMinhaSenha(cpfCnpj, codCid) {
	window.open('resetaSenha.jsp?cpfcnpj=' + cpfCnpj + '&codcid=' + codCid,'caduser','width=775,height=345,resizable=no, scrollbars=no, dependent=no');
}

function getCookieVal(offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1) {
		endstr = document.cookie.length;
	}
	return decodeURIComponent(document.cookie.substring(offset, endstr));
}

function GetCookie(name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) {
			return getCookieVal(j);
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) {
			break;
		}
	}
	return null;
}

function SetCookie(name,value,expires,path,domain,secure) {
	document.cookie = name + "=" + encodeURIComponent(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
}

function DeleteCookie(name,path,domain) {
	if (GetCookie(name)) {
		document.cookie = name + "=" +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

function dataValida(pObj) {	
	objValue = pObj.value;
	if (objValue == '') 
		return false;
	month30	 = '04060911';

	if(objValue == '')
		return false;

	if(objValue.length != 10)
		return false;

	iDay	= parseInt(objValue.substring(0,2),10);
	iMonth	= parseInt(objValue.substring(3,5),10);
	iYear	= parseInt(objValue.substring(6,10),10);

	if(iYear < 1900 || iYear > 2100)
		return false;

	if(iMonth < 1 || iMonth > 12)
		return false;

	if(iDay < 1 || iDay > 31)
		return false;

	if(iMonth == 2) {
		iBi = iYear % 4;

		if(iBi == 0) {
			if(iDay > 29)
				return false;

			return true;
		}

		if(iDay > 28)
		    return false;
	}

	if(iMonth.length != 2)
		iMonth = '0' + iMonth;

	if(month30.indexOf(iMonth) > 0)
		if(iDay > 30)
		    return false;

	return true;
}

function fechaWindowGlobal() {
    var url = window.opener.location.href;
    if (url.indexOf('?') != -1) {
    	url = url.substring(0, url.indexOf('?'));
     	window.opener.location.href = url;
    } else {
      	window.opener.location.reload();
    }
    window.close();
}

var daysOfWeek = ["Domingo", "Segunda-Feira", "Terça-Feira", "Quarta-Feira", "Quinta-Feira", "Sexta-Feira", "Sábado"];
var months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"];

function diaMesAno() {
	mydate = new Date();
	myday = mydate.getDay();
	mymonth = mydate.getMonth();
	myweekday= mydate.getDate();
	weekday= myweekday; 
	myyear = mydate.getYear();
	
	day = daysOfWeek[myday];
	month = months[mymonth];
	return day + ", " + myweekday + " de "+ month + " de " + myyear;
}