function show(hora,idx) {
	var string, cont, horario, aux;
	string="<form id='form1' name='form1' method='post' action='../Gerente_Engine/index.php?acao=adicionar'>";
	string+="<table style='border:1px solid #666;' width='100%' cellpadding='0' cellspacing='0' border='0'>";
	string+="<tr>";
	string+="<td style='line-height:7px;'>&nbsp;</td>";
	string+="</tr>";
	string+="<tr height='17px'>";
	string+="<td width='18%'><span style='margin:7px;'>Título:</span></td>";
	string+="<td><input style='border-bottom:1px solid #666' class='cadastro_campo' type='text' id='titulo' name='titulo'></td>";
	string+="</tr>";
	string+="<tr height='24px'>";
	string+="<td><span style='margin:7px;'>Descrição:</span></td>";
	string+="<td><textarea style='height:70px;' class='cadastro_campo' id='texto' name='texto'></textarea></td>";
	string+="</tr>";
	string+="<tr height='24px'>";
	string+="<td><span style='margin:7px;'>Início:</span></td>";
	string+="<td>";
	string+="<select class='cadastro_campo_peq' id='hora_inicio_h' name='hora_inicio_h'>";
	for (cont=6;cont<=20;cont++) {
		if (hora==cont) aux=1;
		else aux=0;
		cont=""+cont;
		if (cont.length==1) horario="0"+cont;
		else horario=cont;
		if (aux==1) string+="<option value='"+horario+"' selected='selected'>"+horario+"</option>";
		else string+="<option value='"+horario+"'>"+horario+"</option>";
	}
	string+="</select>&nbsp;<b>:</b>&nbsp;<select class='cadastro_campo_peq' id='hora_inicio_m' name='hora_inicio_m'>";
	for (cont=0;cont<=55;cont++) {
		cont=""+cont;
		if (cont.length==1) horario="0"+cont;
		else horario=cont;
		string+="<option value='"+horario+"'>"+horario+"</option>";
		cont=parseInt(cont);
		cont=cont+4;
	}
	string+="</select>";
	string+="</td>";
	string+="</tr>";
	string+="<tr height='24px'>";
	string+="<td><span style='margin:7px;'>Término:</span></td>";
	string+="<td>";
	string+="<select class='cadastro_campo_peq' id='hora_termino_h' name='hora_termino_h'>";
	for (cont=6;cont<=20;cont++) {
		hora=parseInt(hora);
		if ((hora+1)==cont) aux=1;
		else aux=0;
		cont=""+cont;
		if (cont.length==1) horario="0"+cont;
		else horario=cont;
		document.print(horario);
		if (aux==1) string+="<option value='"+horario+"' selected='selected'>"+horario+"</option>";
		else string+="<option value='"+horario+"'>"+horario+"</option>";	
	}
	string+="</select>&nbsp;<b>:</b>&nbsp;<select class='cadastro_campo_peq' id='hora_termino_m' name='hora_termino_m'>";
	for (cont=0;cont<=55;cont++) {
		cont=""+cont;
		if (cont.length==1) horario="0"+cont;
		else horario=cont;
		string+="<option value='"+horario+"'>"+horario+"</option>";
		cont=parseInt(cont);
		cont=cont+4;
	}
	string+="</select>";
	string+="<input type='hidden' name='id' id='id' value='"+idx+"'>";
	string+="</td>";
	string+="</tr>";
	string+="<tr>";
	string+="<td style='line-height:7px;'>&nbsp;</td>";
	string+="</tr>";
	string+="<tr height='30px' style='background-color:#ccc;'>";
	string+="<td><span style='margin:7px;'><input class='cadastro_button' type='button' value='Salvar'></span></td>";
	string+="<td align='right'><span style='margin:7px;font-weight:bold;'>";
	string+="<a style='text-decoration:none;color:#000;' onclick='hide(\""+hora+"\")' href='javascript:void(0)'>Fechar</a>";
	string+="</span></td>";
	string+="</tr>";
	string+="</table>";
	string+="</form>";
	document.getElementById('cadastro').innerHTML=string;
	document.getElementById('cadastro').style.display="block";
}
function hide(hora) {
	document.getElementById('cadastro').innerHTML="";
	document.getElementById('cadastro').style.display="none";
}
function update(hora,id,titulo,texto,hora_inicio,hora_termino) {
	var inicio,termino;
	show(hora,id);
	document.getElementById('titulo').value=titulo;
	document.getElementById('texto').innerHTML=texto;
	inicio=hora_inicio.split(':');
	termino=hora_termino.split(':');
	document.getElementById('hora_inicio_h').value=inicio[0];
	document.getElementById('hora_inicio_m').value=inicio[1];
	document.getElementById('hora_termino_h').value=termino[0];
	document.getElementById('hora_termino_m').value=termino[1];
}