function userReports(displayDiv,cliscript)
{
    this.porociloVoznja   = porociloVoznja;
    this.porociloPostanki = porociloPostanki;
    this.checkDate        = checkDate;
    this.getDateFS        = getDateFS;
    var dispId            = displayDiv;         
    var cspath            = cliscript;
    
    function porociloVoznja(idnaprave,od_datum, do_datum, interval,excel)
    {
        if (checkDate(od_datum,do_datum))
        {
              if (excel == false)
              {
                  $jq('#userMsg').html('....Loading ....');
                  $jq('#'+dispId).html('');
                  $jq.get(cspath,{idnaprave:idnaprave,od_datum:od_datum,do_datum:do_datum,interval:interval,porocilo:'drive',excelf:excel},function(data)
                  {    
                      $jq('#'+dispId).html(data);   
                      $jq('#userMsg').html('');
                  });
              }
              else
              {
                 //window.open(cspath+'?idnaprave='+escape(idnaprave)+'&od_datum='+escape(od_datum)+'&do_datum='+escape(do_datum)+'&interval='+interval+'&porocilo=drive&excelf='+excel,'','width=0,height=0' );
                 document.location = cspath+'?idnaprave='+escape(idnaprave)+'&od_datum='+escape(od_datum)+'&do_datum='+escape(do_datum)+'&interval='+interval+'&porocilo=drive&excelf='+excel;
              }  
        }
    }
    
    function porociloPostanki(idnaprave,od_datum, do_datum, interval,excel)
    {
        if (checkDate(od_datum,do_datum))
        {
          if (excel == false)
          {
                $jq('#userMsg').html('....Loading ....');
                $jq('#'+dispId).html(''); 
                $jq.get(cspath,{idnaprave:idnaprave,od_datum:od_datum,do_datum:do_datum,interval:interval,porocilo:'stops',excelf:excel},function(data)
                {    
                    $jq('#'+dispId).html(data);   
                    $jq('#userMsg').html('');
                });
          }
          else
          {
                 //window.open(cspath+'?idnaprave='+escape(idnaprave)+'&od_datum='+escape(od_datum)+'&do_datum='+escape(do_datum)+'&interval='+interval+'&porocilo=stops&excelf='+excel,'','width=0,height=0' );
                 document.location = cspath+'?idnaprave='+escape(idnaprave)+'&od_datum='+escape(od_datum)+'&do_datum='+escape(do_datum)+'&interval='+interval+'&porocilo=stops&excelf='+excel;
          }
        
        }
    
    }
    
    function checkDate(fdate,tdate)
    {
         var odc = fdate; 
         var doc = tdate;
         if (odc.length == 0){ alert(getMessage('msghistdate1'));return false; }
         if (doc.length == 0){ alert(getMessage('msghistdate2'));return false; }
         if (getDateFS(odc) > getDateFS(doc) ){ alert(getMessage('msghistdate4'));return false; }
         
         var dt = (getDateFS(doc) - getDateFS(odc)) / 1000; 
         
         if (dt  >  (3600*24)){ alert(getMessage('msghistdate3'));return false; }
         
         return true;
    }
      
     function getDateFS(str)
     {
          var d1      = str.split(" ");
          var dpart   = d1[0];
          var tpart   = d1[1]; 
          var dparts  = dpart.split(".");
          var tparts  = tpart.split(":");
          var day     = parseFloat(dparts[0]);
          var month   = parseFloat(dparts[1]) - 1;
          var year    = dparts[2]; 
          var hour    = tparts[0]; 
          var min     = tparts[1];
        
          var dte = new Date(year, month, day);
          dte.setHours(hour,min,0);
          
          return dte;
      }
      

}
