$(function(){
	$('#frmComentario').submit(function(){
		if($.trim($('#nome').val())==""){
			$('#nome').css({ border: "1px solid red" });	
			alert("Por favor, digite seu nome");
			$('#nome').focus();
			return false;
		}
		else if($.trim($('#email_n').val())==""){
			$('#email_n').css({ border: "1px solid red" });	
			alert("Por favor, digite seu e-mail");
			$('#email_n').focus();
			return false;
		}
		else if($.trim($('#comentario').val())==""){
			$('#comentario').css({ border: "1px solid red" });
			alert("Escreva seu comentário");
			$('#comentario').focus();
			return false;
		}
		
		
	});
	/*=================================================================*/
	//Criar Blog
	$('#ipt_url-blog').keypress(function(event){
		var tecla=(window.event)?event.keyCode:event.which;
		//alert(tecla);
		if((tecla > 47 && tecla < 58)|| (tecla >= 97 && tecla < 122) || tecla==46 || tecla==45 || tecla==95){ 
			return true;
		}else{
			if (tecla != 8){
				return false;
			}else{ 
				return true;
			}
		}

	});
	$('#ipt_nome-blog').keyup(function(event){
			palavra = $.trim($('#ipt_nome-blog').val());
			
			com_acento = 'aoáàãâäéèêëíìîïóòõôöúùûüçÁÀÃÂÄÉÈÊËÍÌÎÏÓÒÕÖÔÚÙÛÜÇ';
			sem_acento = 'aoaaaaaeeeeiiiiooooouuuucAAAAAEEEEIIIIOOOOOUUUUC';
			nova='';
			
			for(i=0;i<palavra.length;i++) {
				if (com_acento.indexOf(palavra.substr(i,1))>=0) {
					nova+=sem_acento.substr(com_acento.indexOf(palavra.substr(i,1)),1);
				}else {
					nova+=palavra.substr(i,1);
				}
			}

			nova = nova.replace(/[^a-zA-Z0-9\.\-\+\_]/g,"");

			$('#ipt_url-blog').val(nova.replace(/[\s]*\s/g,".").toLowerCase());
	});
	/*=======================*/
	$('#frmMeuBlog').submit(function(event){
		var url = $('#ipt_url-blog').val();
		var enviar = 0;
		$.ajax({
			url: "/_exec/ajax/verificaURLBlog",
		  	type: "POST",
			cache: false,
			async: false,
			dataType: "text",
			data:{ 'url' : url},
		  	success: function(response){
				enviar = parseInt(response);
		  	}
		});		
		if(!enviar){
			$('#msg_urlIndisponivel').show();
			$('#ipt_url-blog').focus();
			return false;
			event.preventDefault();
		}
		return false;
	});
	if($("#arquivo").treeview){
		$("#arquivo").treeview({
			toggle: function() {
				
				$(this).find('.collapsable-hitarea').html('&#9660;');
				$(this).find('.expandable-hitarea').html('&#9654;');
			   }
	
		});
	}
});
