
function dropFile(btn){
	if(document.getElementById) {
		tr = btn;
		while (tr.tagName != 'TR') tr = tr.parentNode;
		tr.parentNode.removeChild(tr);
		checkForLast();
	}
}
function addFile(btn){
	if(document.getElementById) {
		tr = btn;
		while (tr.tagName != 'TR') tr = tr.parentNode;
		var idSuffix = Math.round(Math.random()*1000);
		var newTr = tr.parentNode.insertBefore(tr.cloneNode(true),tr.nextSibling);
		thisChilds = newTr.getElementsByTagName('td');
		for (var i = 0; i < thisChilds.length; i++){
			if (thisChilds[i].className == 'header') thisChilds[i].innerHTML = '';
			if (thisChilds[i].className == 'files') thisChilds[i].innerHTML = '<input size="32" name="foto[]" class="wideFile" type="file" value = "">';
		}
		checkForLast();
	}
}
function checkForLast(){
	btns = document.getElementsByName('drop');
	for (i = 0; i < btns.length; i++){
		btns[i].disabled = (btns.length == 1) ? true : false;
	}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function check_date(field){
var checkstr = "0123456789";
var DateField = field;
var Datevalue = "";
var DateTemp = "";
var seperator = "/";
var day;
var month;
var year;
var leap = 0;
var err = 0;
var i;
   err = 0;
   DateValue = DateField.value;
   /* Deleta todos os caracteres exceto de 0 a 9. */
   for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
	     DateTemp = DateTemp + DateValue.substr(i,1);
	  }
   }
   DateValue = DateTemp;
   
   if (DateValue.length == 6) {
      DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
   if (DateValue.length != 8) {
      err = 19;}
   
   year = DateValue.substr(4,4);
   if (year == 0) {
      err = 20;
   }
   
   month = DateValue.substr(2,2);
   if ((month < 1) || (month > 12)) {
      err = 21;
   }
   
   day = DateValue.substr(0,2);
   if (day < 1) {
     err = 22;
   }
  
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
      err = 23;
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
      err = 24;
   }
   
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = 25;
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = 26;
   }
   
   if ((day == 0) && (month == 0) && (year == 00)) {
      err = 0; day = ""; month = ""; year = ""; seperator = "";
   }

   if (err == 0) {
      DateField.value = day + seperator + month + seperator + year;
   }
   
   else {
      alert("Data inválida");
      DateField.value = ""
   }
}

function formatar(src, mask)
{
var i = src.value.length;
var saida = mask.substring(0,1);
var texto = mask.substring(i)
if (texto.substring(0,1) != saida)
{
src.value += texto.substring(0,1);
}
}

function abrirFoto(Arquivo){
	URL='popup_galeria.php?arquivo='+Arquivo;
	j=window.open(URL,'Galeria','menubar=no,scrollbars=no,resizable=no,width=0,height=0');
}
function abrirFoto2(Arquivo){
	URL='../popup_galeria.php?arquivo='+Arquivo;
	j=window.open(URL,'Galeria','menubar=no,scrollbars=no,resizable=no,width=0,height=0');
}
function showHideMenu(menu){
	
	if (document.getElementById(menu).style.display == 'none') {
		document.getElementById(menu).style.display = '';
		
	}else{
		document.getElementById(menu).style.display = 'none';
	}
}
// ALERTA DE EXCLUSÃO DE REGISTRO
function excluir(conteudo){
	if(confirm("Tem certeza que deseja apagar este(a) "+conteudo+"?")){
			return true;
	}else{
			return false;
	}		
}

