/*
function validate_date(field){
  var danes = new Date() ;
  var month;
  var day;
  var year;
  var isvalid;
  var comps;
  var len , tmp ;

  if ( field.value.replace(/ +/, '') == '' )
  { field.value = '' ;
    return true;
  };

  comps = field.value.split( /\D/g ) ;
  len = comps.length ;

  day   = danes.getDate() ;
  month = danes.getMonth()+1 ;
  year  = danes.getFullYear() ;

  tmp = parseInt(comps[0],10) ;
  if ( !isNaN(tmp) ) day = tmp ;
  tmp = parseInt(comps[1],10) ;
  if ( !isNaN(tmp) ) month = tmp ;
  tmp = parseInt(comps[2],10) ;
  if ( !isNaN(tmp) ) year = tmp ;

  if (year < 50)
    year += 2000;
  else if (year < 100)
    year += 1900;

  if ( month >= 1 && month <= 12 && day >= 1 && day <= 31 && year > 1900 && year < 2100 )
  {
    field.value = getdatestring(new Date(year, month - 1, day));
    isvalid = true;
  }
  else
  {
    alert("Pogrešno unesen datum !");
    isvalid = false;
  };
  if ( ! isvalid )
  {
    window.focus();
    field.focus();
    field.select();
  }
  return isvalid;
}
*/
function getdatestring(d)
{ return d.getDate() + "." + (d.getMonth()+1) + "." + d.getFullYear() ; }


function f_Gumb( field, vrednost )
{
    field.form.gumb.value = vrednost ;
    field.form.submit();
}

function TestPoslji(maska){

  maska.napaka = false;

  for( var noElement=0; noElement < maska.elements.length;  noElement++ ){
    var f = maska.elements[noElement] ;

    if ( f.onblur ) f.onblur();
  };

  if ( maska.napaka )
   {
     alert('Pravilno unesite sva polja ... ' );
     return false;
   }
  else
   { return true;}
}

function TestEmpty( f, f_Ref ) {
  var v, p  ;

  if ( f_Ref == null ) f_Ref = f.name+'_t' ;

  p =  document.getElementById( f_Ref );

  if ( p == null ) return true;

  v = f.value;
  v = v.replace(/ +/, '');

  if ( v == '' ) {
   p.className = 'errorprompt';
   f.form.napaka = true;
   }
  else p.className = ''  ;

  return true
}


function f_SetValue( f, v ) {
  var  p  ;

  p =  document.getElementById( f );  

  if ( p == null ) return false;

  p.value = v;

  return true;
}

 

//----------------------------------------------------------------------------------

function f_p_ddMenu_setField(i_selection,mn) {
  field=eval(w_Document+'.'+this.Menus[mn].id)
  field.value=i_selection
}

function f_p_ddMenu_showMenu(mn) {
  this.w_opened=window.open(
       this.Menus[mn].src,
       'w_c_ddMenu',
       'status=no,dependent=yes,'+
       w_Height+'='+this.Menus[mn].height+','+
       w_Width+'='+this.Menus[mn].width+','+
       w_Top+'='+this.Menus[mn].top+','+
       w_Left+'='+this.Menus[mn].left+','+
       w_resize+'=yes,scrollbars=yes');
  this.menuNumber=mn
}

function f_p_ddMenu_Item() {
  this.src    = ''
  this.id     = ''
  this.top    = 0
  this.left   = 0
  this.width  = 100
  this.height = 100
}

function f_p_ddMenu_addItem(src,id,top,left,width,height) {
  this.length++
  this.Menus[this.length]        = new f_p_ddMenu_Item()
  this.Menus[this.length].src    = src
  this.Menus[this.length].id     = id
  this.Menus[this.length].top    = top
  this.Menus[this.length].left   = left
  this.Menus[this.length].width  = width
  this.Menus[this.length].height = height
  return this.length
}

function f_p_ddMenu_Main() {
  this.showMenu = f_p_ddMenu_showMenu
  this.setField = f_p_ddMenu_setField
  this.addItem  = f_p_ddMenu_addItem
  this.w_opened = null
  this.length   = -1
  this.Menus    = new Array()
  this.menuNumber = -1
}

//----------------------------------------------------------------------------------

function f_c_ddMenu_onBlur()
{
  if (!this.selected) {window.focus()}
}

function f_c_ddMenu_onFocus()
{
}

function f_c_ddMenu_onSelect(i_selection) {
  window.opener.ddMenu.parent.setField(i_selection,window.opener.ddMenu.parent.menuNumber)
  window.close()
}

function f_c_ddMenu_Main() {
  this.onFocus    = f_c_ddMenu_onFocus
  this.onBlur     = f_c_ddMenu_onBlur
  this.onSelect   = f_c_ddMenu_onSelect
}

//----------------------------------------------------------------------------------

function f_ddMenu(){
  this.parent = new f_p_ddMenu_Main()
  this.child  = new f_c_ddMenu_Main()
}

//----------------------------------------------------------------------------------

var ddMenu = new f_ddMenu()

