function logar()
{

	if(document.form_login.usuario.value == '')
	{
		window.alert('Informe o seu login');
		document.form_login.usuario.focus();
	}else if(document.form_login.senha.value == '')
	{
		window.alert('Informe sua senha');
		document.form_login.senha.focus();
	}else
	{
		document.form_login.submit();
	}
	
}

function enviarEmail()
{
	if(document.form_senha.login.value == '')
	{
		window.alert('Informe o seu login');
		document.form_senha.login.focus();
	}else if(document.form_senha.email.value == '')
	{
		window.alert('Informe seu e-mail');
		document.form_senha.email.focus();
	}else
	{
		document.form_senha.submit();
	}

}

function atualizar()
{
	if(document.form_config.login.value == '')
	{
		alert('Informe seu login');
		document.form_config.login.focus();
	}
	else if(document.form_config.senha.value == '')
	{
		alert('Informe sua senha');
		document.form_config.senha.focus();
	}
	else if(document.form_config.novaSenha.value == '')
	{
		alert('Escolha uma nova senha');
		document.form_config.novaSenha.focus();
	}
	else if(document.form_config.novaSenha2.value == '')
	{
		alert('Confirme sua nova senha');
		document.form_config.novaSenha2.focus();
	}
	else if(document.form_config.email.value == '')
	{
		alert('Informe seu e-mail');
		document.form_config.email.focus();
	}
	else if(document.form_config.novaSenha.value != document.form_config.novaSenha2.value)
	{
		alert('Confirme a nova senha corretamente');
		document.form_config.novaSenha2.focus();
	}
	else
	{
		document.form_config.submit();
	}

}

function janelaEnviarSenha(){
document.getElementById('CB_NotImgContent').innerHTML="<div id=\"divEmail\" ><form name=\"form_senha\" method=\"post\" action=\"administrador/sistema/enviar_senha.php\"><input type=\"text\" name=\"login\" id=\"usuarioSenha\" maxlength=\"50\" class=\"input\"><input type=\"text\" name=\"email\" id=\"emailSenha\" maxlength=\"50\" class=\"input\"><input type=\"button\" value=\"\" id=\"botaoSenha\" class=\"input\" onClick=\"enviarEmail();\"></form></div>";

}

function janelaLogin(){
document.getElementById('CB_NotImgContent').innerHTML="<div id=\"divSenhaPopup\"><form name=\"form_login\" method=\"post\" action=\"administrador/sistema/validar_login.php\"><input type=\"text\" name=\"usuario\" id=\"usuarioLoginPopup\" maxlength=\"50\" class=\"input\"><input type=\"password\" name=\"senha\" id=\"senhaLoginPopup\" maxlength=\"50\" class=\"input\"><input type=\"button\" value=\"\" id=\"botaoLogarPopup\" class=\"input\" onClick=\"logar();\"></form><a href=\"javascript:janelaEnviarSenha()\" class=\"esqueceuSenha\" ></a></div>";
}

function janelaConfig(){
document.getElementById('CB_NotImgContent').innerHTML="<div id=\"divConfigPopup\"><form name=\"form_config\" method=\"post\" action=\"sistema/enviar_atualizacao_cadastro.php\"><input type=\"text\" name=\"login\" id=\"loginPopup\" maxlength=\"50\" class=\"input\"><input name=\"email\" type=\"text\" id=\"emailPopup\" class=\"input\" maxlength=\"50\"><input type=\"password\" name=\"senha\" id=\"senhaPopup\" maxlength=\"50\" class=\"input\"><input type=\"password\" name=\"novaSenha\" id=\"novaSenhaPopup\" maxlength=\"50\" class=\"input\"><input type=\"password\" name=\"novaSenha2\" id=\"novaSenha2Popup\" maxlength=\"50\" class=\"input\"><input type=\"button\" value=\"\" id=\"botaoAtualizarPopup\" class=\"input\" onClick=\"atualizar();\"></form></div>";

document.getElementById("loginPopup").value = usuarioLogin;
document.getElementById("emailPopup").value = usuarioEmail;


}

function reticencias(id){
	var tam = document.getElementById(id).offsetHeight;
	
	if(tam > 20){
		var text = document.getElementById(id).innerHTML;
	
		var textVisible = text.substr(0,100)+" ...";
		
		document.getElementById(id).innerHTML = textVisible;

		var i = 99;
		while(tam > 20){
			textVisible = text.substr(0,i)+" ...";
			document.getElementById(id).innerHTML = textVisible;
			tam = document.getElementById(id).offsetHeight;
			i--;
		}
	}
}

function reticenciasTexto(id){
	var tam = document.getElementById(id).offsetHeight;
	
	if(tam > 58){
		var text = document.getElementById(id).innerHTML;
		
		var textVisible = text.substr(0,200)+"...(continue lendo)";
		
		document.getElementById(id).innerHTML = textVisible;

		var i = 199;
		while(tam > 58){
			
			textVisible = text.substr(0,i)+"...(continue lendo)";
			document.getElementById(id).innerHTML = textVisible;
			tam = document.getElementById(id).offsetHeight;
			i--;
		}
	}
}

function reticenciasNoticia(id){
	var tam = document.getElementById(id).offsetHeight;
	
	if(tam > 20){
		var text = document.getElementById(id).innerHTML;
	
		var textVisible = text.substr(0,100)+"...(continue lendo)";
		
		document.getElementById(id).innerHTML = textVisible;

		var i = 99;
		while(tam > 20){
			textVisible = text.substr(0,i)+"...(continue lendo)";
			document.getElementById(id).innerHTML = textVisible;
			tam = document.getElementById(id).offsetHeight;
			i--;
		}
	}
}

function reticenciasPedido(id){
	var tam = document.getElementById(id).offsetTop+document.getElementById(id).offsetHeight;
	var textoP = document.getElementById(id).innerHTML;

	if(tam > 313){
		var text = document.getElementById(id).innerHTML;
	
		var textVisible = text.substr(0,textoP.length)+"...(continue lendo)";
		
		document.getElementById(id).innerHTML = textVisible;
		
		var i = textoP.length - 1;
		while(tam > 313){
			textVisible = text.substr(0,i)+"...(continue lendo)";
			document.getElementById(id).innerHTML = textVisible;
			tam = document.getElementById(id).offsetTop+document.getElementById(id).offsetHeight;
			i--;
		}
	}
}
