    var common = '/2/common.php';
    var mouseX;
    var mouseY;
    window.addEvent('domready',function(){
        changeSponzor();
        
    
    
    
    });
    window.addEvent('mousemove',function(event){
        mouseX = event.page.x;
        mouseY = event.page.y;
    });
    
    
    
    function podrocjeImages(el){
        if(el.value == ''){
            $('podrocje').set('html','');
        }
        var ajax = new Request({
              method: 'post',
              url: common+'?action=podrocjeImages',
              onComplete: function(res){
                      if(res.substr(0,10) == "<!--ERR-->"){
                          alert(res.substr(10));
                          $('podrocje').set('html','');
                      }else{
                          $('podrocje').set('html',res);
                      }
              }
        });
        ajax.send('kid='+el.value);
    }
    
    function moveUp(who,mid){
        var ajax = new Request({
              method: 'post',
              url: common+'?action=moveUp'+who,
              onComplete: function(res){
                      if(res.substr(0,10) == "<!--ERR-->"){
                          alert(res.substr(10));
                      }else{
                          window.location = window.location;
                      }
              }
        });
        ajax.send('mid='+mid);
    }
    
    function addObject(who,mid){
        var ajax = new Request({
              method: 'post',
              url: common+'?action=add'+who,
              onComplete: function(res){
                      window.location = window.location;
              }
        });
        ajax.send('mid='+mid);
    }
    
    function saveEditObject(form,who){
        form = $(form);
        var ajax = new Request({
              method: 'post',
              url: common+'?action=saveEdit'+who,
              onComplete: function(res){
                  if(res.substr(0,10) == "<!--ERR-->"){
                      alert(res.substr(10));
                  }else{
                      window.location = window.location;
                  }
              }
        });
        ajax.send(form);
    }
    
    var adminDrag = null;
    var isEdit = false;
    function editObject(tid,who){
        var admin = $('admin');
        var cls = false;
        if(isEdit) cls = closeAdmin();
        if(cls) return;
        //admin.setStyle('top',(mouseY-200));
        admin.set('html','Nalaganje ...');
        admin.style.display = 'block';
        var ajax = new Request({
              method: 'post',
              url: common+'?action=edit'+who,
              onComplete: function(res){
                  if(res.substr(0,10) == "<!--ERR-->"){
                      admin.style.display = 'none';
                      alert(res.substr(10));
                  }else{
                      admin.set('html',res);
                      if($chk($('txt_'+who))) var myMooEditable = $('txt_'+who).mooEditable();
                      if($chk($('t_start'))) new mooTimePicker($('t_start'),{alwaysOn:true,minuteSteps:'0,5,10,15,20,25,30,35,40,45,50,55',hourLabel:'Ura',minsLabel:'Minuta',secsLabel:''});
                      if($chk($('t_end'))) new mooTimePicker($('t_end'),{alwaysOn:true,minuteSteps:'0,5,10,15,20,25,30,35,40,45,50,55',hourLabel:'Ura',minsLabel:'Minuta',secsLabel:''});
                      if($chk($('d_start'))){
                          var dt = new DatePicker('.datep', { pickerClass: 'datepicker_vista' });
                          dt.attach();
                      }

                      
                      adminDrag = new Drag(admin).detach(); 
                      isEdit = true;
                  }
              }
        });
        ajax.send('tid='+tid);
    }
    function closeAdmin(ask){
        var admin = $('admin');
        if(admin.style.display == 'none') return false;
        if(ask == "ask" && !confirm("Želite zapreti administratorsko okno?")) return false;
        admin.style.display = 'none';
        admin.set('html','');
        isEdit = false;
        return true;
    }
    
    function changeSponzor(){
        if(!$chk($('sponzorBanner'))) return;
        var ajax = new Request({
              method: 'post',
              url: common+'?action=sponzorBanner',
              onComplete: function(res){$('sponzorBanner').src = res;}
        });
        ajax.send();
        setTimeout('changeSponzor()',25000);
    }
