/** ---------------- FUNCAO DE TESTE ---------------------------*/
function testar(){
	alert("Java Script Teste OK!!!");
}

/** ---------------- RELÓGIO ---------------------------*/
var timerID = null;
var timerRunning = false;
function stopclock(){
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false;
}

function startclock(){
    stopclock();
    showtime();
}

function showtime(){
    var now = new Date();
    var hours = now.getHours();
    var minutes = now.getMinutes();
    var seconds = now.getSeconds();
    var timeValue = "" + hours;
    timeValue  += ((minutes < 10) ? ":0" : ":") + minutes;
    timeValue  += ((seconds < 10) ? ":0" : ":") + seconds;    
    if (window.document.getElementById("relogio") != null){
		window.document.getElementById("relogio").innerHTML=""+timeValue;
    	timerID = setTimeout("showtime()",1000);
	    timerRunning = true;
    }else{    	
    	timerRunning = false;
    	return false;
    }
}
/** ---------------- AUX SUBMETER FORMULARIO ---------------------------*/
function validarImagem(){
	//Filtrando arquivo por extensao
	var f = document.formulario;
	var tiposAceitos = "jpeg,jpg,gif,png";
	var ext = f.upImagem.value;		
	ext = ext.substring(ext.length-4,ext.length);		
	ext = ext.toLowerCase();
	var resp = tiposAceitos.search(ext);
	
	if(resp != "-1" && f.upImagem.value != ""){
		f.imagem.value = "Selecionada";
		f.excluirImagem.value = "0"; 
		return true;
	}else{
		if(f.imagemObrigatoria != null && f.imagem == "Sem imagem" && f.upImagem.value == "" ){
			alert("Imagem obrigatoria!");
			return false;
		}else
			if (f.upImagem.value == "")
				return true;
			else{
				alert("Erro: tipo de imagem não suportado!\nUse "+tiposAceitos);
				f.upImagem.value = "";
				f.imagem.value = "Sem imagem";
				return false;
			}
	}
	return false;
			
}
function excluirImage(){
	document.formulario.excluirImagem.value = "1";		
	document.formulario.upImagem.value = "";
	document.formulario.imagem.value = "Excluir imagem";
}

/* ---------- ABRIR POP-UP ---------------- */
var cfg_url = "";
function abrirPopup(idPop){	      
   var largura = 10;
   var altura  =  10;
   var winl = 0;//(screen.width - largura) / 2;
   var wint = 0;//(screen.height - altura) / 2;
   winprops = "height="+ altura +",width="+ largura +",top="+wint+",left="+winl+",resizable=1,location=0, menubar=0, scroubar=1, statusbar=0,toolbar=0";
   //winprops = "height="+ altura +",width="+ largura +"";
   window.open( cfg_url+"/src/popup.php?idPop="+idPop,"janela"+idPop, winprops );   
}
