String.prototype.trim = function() { return this.replace(/^\s*|\s(?=\s)|\s*$/g, ""); }

function confirmSpDel(table, id, file) {
    if(confirm('Usunąć `'+file+'`?')) {
      document.location.href = 'admin.php?go=delete&table='+table+'&id='+id+'&file='+file+'';
    }
}

function confirmImgDel(table, id, file) {
    if(confirm('Usunąć `'+file+'`?')) {
      document.location.href = 'admin.php?go=deleteImg&table='+table+'&id='+id+'&file='+file+'';
    }
}

function confirmDel(table, id) {
    if(confirm('Usunąć?')) {
      document.location.href = 'admin.php?go=delete&table='+table+'&id='+id+'';
    }
}

function confirmEventDel(table, id) {
    if(confirm('Usunąć wydarzenie?')) {
      document.location.href = 'admin.php?go=delete_event&table='+table+'&id='+id+'';
    }
}

function checkTitle(form){
  if(!form.title.value.trim()){ alert("Pole tytuł jest puste"); form.title.select(); form.title.focus(); return false; }
}

function confirmCatDel(table, id) {
    if(confirm('Usunąć kategorię?')) {
    
        advAJAX.get({
            url : "inc/checkGaleryCat.php?id="+id,
            onSuccess : function(obj) { 
                if(obj.responseText=='notEmpty'){ alert("Nie możesz usunąć kategorii. Znajdują się w niej zdjęcia."); return false; }
                if(obj.responseText=='OK'){ document.location.href = 'admin.php?go=delete&table='+table+'&id='+id+''; }
            } 
        });    

    }
}

function ismaxlength(obj){
  var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
  if (obj.getAttribute && obj.value.length>mlength)
  obj.value=obj.value.substring(0,mlength)
}

