function onRType()
{
   if ($('#car').attr('checked')) {
      $('#g_car').show();
      
      $('#g_man').hide();
      $('#g_man1').hide();
      $('#g_man2').hide();
      
      $('#g_co').hide();
   }
   else if ($('#man').attr('checked')) {
      $('#g_car').hide();
      $('#g_car1').hide();
      $('#g_car2').hide();
      
      $('#g_man').show();

      $('#g_co').hide();
   }
   else if ($('#company').attr('checked')) {
      $('#g_car').hide();
      $('#g_car1').hide();
      $('#g_car2').hide();
      
      $('#g_man').hide();
      $('#g_man1').hide();
      $('#g_man2').hide();

      $('#g_co').show();
   }
}
function onRTypeSub()
{
   if ($('#car').attr('checked')) {
      if ($('#model').attr('checked')) {
         $('#g_car1').show();
         $('#g_car2').hide();
      }
      else if ($('#plate').attr('checked')) {
         $('#g_car1').hide();
         $('#g_car2').show();
      }
   }
   else if ($('#man').attr('checked')) {
      if ($('#fullname').attr('checked')) {
         $('#g_man1').show();
         $('#g_man2').hide();
      }
      else if ($('#ids').attr('checked')) {
         $('#g_man1').hide();
         $('#g_man2').show();
      }
   }
}
function onType()
{
   if ($('#car').attr('checked')) {
      $('#g_ids').show();
      $('#g_co').show();
      $('#g_bar').show();
      $('#badd').show();
      $('#bsave').show();
      $('#name1').text('Οδηγός');
      $('#name2').text('Συνοδηγός');
      $('#lcar').css('font-weight','bold');
      $('#lman').css('font-weight', 'normal');
   }
   else if ($('#man').attr('checked')) {
      $('#g_ids').hide();
      $('#g_co').show();
      $('#g_bar').show();
      $('#badd').show();
      $('#bsave').show();
      $('#name1').text('Εισερχόμενος #1');
      $('#name2').text('Εισερχόμενος #2');
      $('#lcar').css('font-weight','normal');
      $('#lman').css('font-weight', 'bold');
      revert_input(document.forms[0].CPLATE);      
      revert_input(document.forms[0].CMODEL);
   } 
}
function revert_input(o1)
{
   if (o1.i_datain) {
      $(o1).val( $(o1).attr('title') );
      $(o1).css('color','#c0c0c0');
      o1.i_datain=false;
   }
}
function goAddPers()
{
   var ni = $('[name="FULLNAME[]"]').length+1;
   var trs='<tr>'+
      '<td>Εισερχόμενος #'+ni+'</td>'+
      '<td><input type="text" class="gray" name="FULLNAME[]" maxlength="100" size="50"></td>'+
      '<td><input type="text" class="gray" name="IDS[]" maxlength="30"></td>'+
      '</tr>';
   $('#g_co').append(trs);
   set_some_values();
   $('[name="FULLNAME[]"]').autocomplete({source:'/ishop/secuviewer_json.php?f=fullname', minLength:2});
   $('[name="IDS[]"]').autocomplete({source:'/ishop/secuviewer_json.php?f=ids', minLength:2});      
}
function goAddStep()
{
   var ni = $('[name="STEP[]"]').length;
   var trs='<tr>' +
      '<td>Πάνω από</td>' +
      '<td><input type="text" name="STEP[]" size="5"> λεπτά</td>' +
      '<td>Χρώμα</td>'+
      '<td><input type="text" id="coloriz'+ni+'" name="COLOR[]" value="#123456" READONLY size="8" onclick="set_color('+ni+')"></td>' +
      '</tr>';
   $('#g_sta').append(trs);
}
function goSave()
{
   $('input:text').each( function(){
      if (this.i_datain!=true) {
         $(this).val('');
      }
   } );
   document.forms[0].submit();
}
function goCancel()
{
   location.href=location.pathname+'?FUNCTION=';
}
function goRemove(id)
{
   var f1=document.forms[0];
   f1.RECORDID.value=id;
   f1.FUNCTION.value='7';
   f1.submit();
}
function goResetGrp(id)
{
   var f1=document.forms[0];
   f1.RECORDID.value=id;
   f1.FUNCTION.value='12';
   f1.submit();
}
function goResetSi(id)
{
   var f1=document.forms[0];
   f1.RECORDID.value=id;
   f1.FUNCTION.value='13';
   f1.submit();
}
function set_some_values()
{
   var co=$('[name="FULLNAME[]"]');
   for (var i=0;i<co.length;i++) {
      if ($(co[i]).val()=='') {
         $(co[i]).val('Επίθετο όνομα');
      }
   }
   
   var co=$('[name="IDS[]"]');
   for (var i=0;i<co.length;i++) {
      if ($(co[i]).val()=='') {
         $(co[i]).val('Ταυτότητα');
      }
   }
}
function detailsChanged()
{
   alert('detailsChanged');
   if (!document.forms[0].DETAILS.checked) {
      document.forms[0].DETAILS.checked=true;
      document.forms[0].DETAILS.value="0";
      document.forms[0].submit();
   }
}

$.datepicker.setDefaults({dateFormat: 'dd-mm-yy'});

/*
* jQuery.fn.textLimit( limit, callback );
*
* Add a limit to your textarea and inputfields.
*
* $('.element').textLimit( 100 );
*
* Version 1.0.0
* www.labs.skengdon.com/textLimit
* www.labs.skengdon.com/textLimit/js/textLimit.min.js
*/
;(function($){$.fn.clearTextLimit=function(){return this.each(function(){this.onkeydown=this.onkeyup=null;});};$.fn.textLimit=function(limit,callback){if(typeof callback!=='function')var callback=function(){};return this.each(function(){this.limit=limit;this.callback=callback;this.onkeydown=this.onkeyup=function(){this.value=this.value.substr(0,this.limit);this.reached=this.limit-this.value.length;this.reached=(this.reached==0)?true:false;return this.callback(this.value.length,this.limit,this.reached);}});};})(jQuery);