function Contador(field,MaxLength) {
	obj = document.getElementById('descricao');
	if (MaxLength !=0) {
		if (obj.value.length > MaxLength)  {
			obj.value = obj.value.substring(0, MaxLength);
			alert ("Número de caracteres excedidos! O limite máximo é de 300 caracteres.");
		}
	}
	
	document.artigo_form.contador.value = 300 - obj.value.length;
} 
   
function confirma(cod,url){
	if(confirm('Tem certeza que deseja remover este item?')){
		window.location.href=url+'?act=deletar&cod='+cod;
	}
}

function concluir(cod,target){
	if(confirm('Ao clicar em Concluir '+target+' ele não podera ser mais editado, você tem certeza que deseja prosseguir?')){
		window.location.href='editar_'+target+'?act=f799d8c1294e7af0f5f21b336d924df6&cod='+cod;
	}
}

function AddCampo(id){
	el = document.getElementById(id);
	el.innerHTML += '<label><input type="file" name="img[]" id="campos" class="text"/></label>';
}

function validaCadastro(){
	if(document.cadastro.usuario.value=="")
	{
		alert( "O campo Usuário obrigatório!" );
		document.cadastro.usuario.focus();
		return false;
	}
	
	if((document.cadastro.senha.value=="") || (document.cadastro.senha_confirma.value==""))
	{
		alert( "Os campos Senha e Confirmar Senha são obrigatórios!" );
		document.cadastro.senha.focus();
		return false;
	}
	
	if(document.cadastro.nome.value=="")
	{
		alert( "O campo Nome é obrigatório!" );
		document.cadastro.nome.focus();
		return false;
	}
	
	if((document.cadastro.email.value=="") || (document.cadastro.email_confirma.value==""))
	{
		alert( "Os campos E-mail e Confirmar E-mail são obrigatórios!" );
		document.cadastro.email.focus();
		return false;
	}
		
	return true;	
}

function addFav(url, title){
    if (window.sidebar) window.sidebar.addPanel(title, url,"");
    else if(window.opera && window.print){
        var mbm = document.createElement('a');
        mbm.setAttribute('rel','sidebar');
        mbm.setAttribute('href',url);
        mbm.setAttribute('title',title);
        mbm.click();
    }
    else if(document.all){window.external.AddFavorite(url, title);}
}

$(function() {

  $("a.bookmark").click(function(e) {
        if ($.browser.opera == false) {
                e.preventDefault();
                var url = this.href;  
                var title = this.title;
               
                if ($.browser.mozilla == true) {
                        window.sidebar.addPanel(title, url, '');
                        return false;
                } else if($.browser.msie == true) {  
                        window.external.AddFavorite( url, title);
                        return false;
                } else {
                        var o = $('a.bookmark').offset();
                        alert('Use as teclas CTRL + D para adicionar aos favoritos.');
                }
        }
  });

});
