<!--
/*       Copyright (C) Dynamica S.r.l. 2001-2002.

         Le informazioni, il formato e la sintassi di questo modulo
         sono  di proprieta' della  Dynamica S.r.l. che ne conserva
         tutti i diritti ai sensi della corrente normativa Italiana
         sul diritto d'autore.
         La  Dynamica  S.r.l.  non  si  fa carico  di  anomalie  da
         malfunzionamento dei propri programmi dovute a alterazioni
         e/o aggiunte apportate a questo file.

         The information in this file is provided for the exclusive use of
         the licensees of Dynamica s.r.l..  Such users have the
         right to use and  modify this code provided that it is used
         exclusively with Dynamica's products and for purposes authorized
         by the license agreement provided they include this notice and
         the associated copyright notice with any such product.
         The information in this file is provided "AS IS" without warranty.

         Dynamica S.r.l. Milano, 2001-2002.
*/

var reload_virfar=1;

var demone_refresh_inframe = null;
var oldvalrefresh = null;
var ref_orig = null;

/*
   invia_form_inframe()
   formLaunch = form della finestra contenitore 
   timeField = campo tempo restante
   stopField = campo abilitazione/disabilitazione refresh
   frameName = campo nome del frame che fa refresh
   formName = nome della form del frame da inviare
   refreshField = input text che contiene il tempo del refresh 
*/
function invia_form_inframe(formLaunch,timeField,stopField,
                            frameName,formName,refreshField,dove,refreal){
   var timeRefresh=1000;

        
   if(ref_orig==null)
      ref_orig=dove;     
   fcont=document.forms[formLaunch];
   if(fcont.elements[stopField].value!="SI"){
      if(String(fcont.elements[timeField].value)!="start") {
         if(eval(fcont.elements[timeField].value)<=0){
            fcont.elements[timeField].value='start';
            document.getElementById(frameName).src=String(dove);
            }
          }
      if(oldvalrefresh==null){
         dove=ref_orig+'&S_refr_reale='+fcont.elements[refreshField].value;
         oldvalrefresh=eval(fcont.elements[refreshField].value);
         fcont.elements[timeField].value=fcont.elements[refreshField].value;
         }
      if(fcont.elements[timeField].value=='start') 
         fcont.elements[timeField].value=eval(oldvalrefresh*1000);
      else
         fcont.elements[timeField].value=eval((fcont.elements[timeField].value - timeRefresh));
      }
   if(demone_refresh_inframe!=null) {
      clearInterval(demone_refresh_inframe);
      demone_refresh_inframe=null;
      }
   demone_refresh_inframe = setInterval('invia_form_inframe("'+formLaunch+'","'+timeField+'","'+stopField+'","'+frameName+'","'+formName+'","'+refreshField+'","'+dove+'")',timeRefresh);
   }

function invia_form_rotativo(formLaunch,timeField,stopField,
                            frameName,formName,refreshField,dove,camloop,jumpField){
   var timeRefresh=1000;
        

   if(ref_orig==null)
      ref_orig=dove;     
   fcont=document.forms[formLaunch];
   if(eval(fcont.elements[jumpField].value)==1){
       fcont.elements[timeField].value='start';
       fcont.elements[jumpField].value=0;
       }
   if(fcont.elements[stopField].value!="SI"){
      if(String(fcont.elements[timeField].value)!="start") {
         if(eval(fcont.elements[timeField].value)<=0){
            fcont.elements[timeField].value='start';
            codice=fcont.elements['codice'].value;
            _str=String(dove)+"&codice="+codice;
            if(fcont.elements[stopField].value=='LOOP')
               _str+="&loop=1";
            document.getElementById(frameName).src=_str;
            }
          }
      if(oldvalrefresh==null){
         dove=ref_orig+'&S_refr_rotativo='+fcont.elements[refreshField].value;
         oldvalrefresh=eval(fcont.elements[refreshField].value);
         fcont.elements[timeField].value=fcont.elements[refreshField].value;
         }
      if(fcont.elements[timeField].value=='start') 
         fcont.elements[timeField].value=eval(oldvalrefresh*1000);
      else
         fcont.elements[timeField].value=eval((fcont.elements[timeField].value - timeRefresh));
      }
   if(demone_refresh_inframe!=null) {
      clearInterval(demone_refresh_inframe);
      demone_refresh_inframe=null;
      }
   demone_refresh_inframe = setInterval('invia_form_rotativo("'+formLaunch+'","'+timeField+'","'+stopField+'","'+frameName+'","'+formName+'","'+refreshField+'","'+dove+'","'+camloop+'","'+jumpField+'")',timeRefresh);
   }

function HelementInRow(i,v){
   stringa='<input type="hidden" value="'+v+'" name="'+i+'">';
   return(stringa);
   }

function ImgInRow(i,s,a,riga){
   stringa='<img align="middle" id="'+i+'" src="'+s+'" alt="'+a+'">';
   return(stringa);
   }
function ItextInRow(i,v,s,m,change){
   stringa='<input class="ilista1" type="text" value="'+v+'" size="'+s+'" name="'+i+'" id="'+i+'" maxlength="'+m+'" '+(change!=''?'onchange="'+change+'"':'')+'>';
   return(stringa);
   }
function DatePopupInRow(form_name,css,sca){
  switch(css){
   case 'li':
      css_cal='little';
      break;
   case 'me':
      css_cal='medium';
      break;
   case 'la':
      css_cal='large';
      break;
     }

   stringa='&nbsp;&nbsp;<a border="0" href="javascript:show_calendar(\''+form_name+'\',\''+sca+'\',\''+css_cal+'\');" onMouseover="window.status=\'Date Picker\';return true" onMouseout="window.status=\'\';return true;"><img border="0" src="/img/'+css+'ICcalen.gif"></a>';
   return(stringa);
   }

function addrow(riga,css,baco,desc,ean,prezzo,form_name){
   restanti=parent.document.forms[form_name].elements['maxhiddenrow'].value;
   if(restanti==0){
      divlast=parent.xbGetElementById('ultimo');
      divlast_s=new xbStyle(divlast);
      divlast_s.setInnerHTML('ATTENZIONE !!! RAGGIUNTO IL LIMITE MASSIMO !!!');
      G_SID=parent.document.forms[form_name].elements['G_SID'].value;
      parent.document.getElementById('play_frame').src=proxy_js+'play_isound.php?G_SID=' + G_SID + '&suono=ERRORE';
      return true;
      }
   restanti--;
   parent.document.forms[form_name].elements['maxhiddenrow'].value=restanti;
   cp=new Array();
   cps=new Array();
   for(i=0;i<11;i++){
      nome='r'+riga+'c'+i;
      cp[i]=parent.document.getElementById(nome);
      cps[i]=new xbStyle(cp[i]);
      }
   cps[0].setInnerHTML(eval(riga)+1);
   cps[1].setInnerHTML(baco);
   cps[2].setInnerHTML(desc);
   cps[3].setInnerHTML(prezzo);
   cps[4].setInnerHTML('0');
   cps[5].setInnerHTML(ItextInRow('CON_'+riga,0,4,4,'')+HelementInRow('BAC_'+riga,baco)+HelementInRow('EAN_'+riga,ean)+HelementInRow('PRE_'+riga,prezzo));
   cps[6].setInnerHTML(ItextInRow("PEN_"+riga,1,4,4,'cambio_manuale('+riga+')')+HelementInRow("QTA_"+riga,0));
   cps[7].setInnerHTML('<div id=\'spunta_'+riga+'\'>'+ImgInRow('stato-h-'+riga,'/img/'+css+'non-spunta.gif','differenza-'+riga,riga)+'</div>');
   cps[8].setInnerHTML(ItextInRow('BOL_'+riga,'',5,15,'')+HelementInRow('FOR_'+riga,''));
   cps[9].setInnerHTML(ItextInRow('FAT_'+riga,'',5,15,'')+HelementInRow('TIP_'+riga,'')+HelementInRow('DES_'+riga,desc)+HelementInRow('JDES_'+riga,desc));
   cps[10].setInnerHTML(ItextInRow('SCA_'+riga,'',10,10,'')+DatePopupInRow(form_name,css,'SCA_'+riga));
   barcode=parent.document.forms[form_name].elements['virt_barcode'].value;
   parent.document.forms[form_name].elements['virt_barcode'].value=barcode + ',\'' + parseInt(baco,10) + '\'';
   ean13=parent.document.forms[form_name].elements['virt_ean13'].value;
   parent.document.forms[form_name].elements['virt_ean13'].value=ean13 + ',\'' + parseInt(ean,10) + '\'';
   nome='JDES_'+riga;
   descrizione=parent.document.forms[form_name].elements[nome].value;
   nome='PEN_'+riga;
   vpenna=parent.document.forms[form_name].elements[nome].value;
   divlast=parent.xbGetElementById('ultimo');
   divlast_s=new xbStyle(divlast);
   divlast_s.setInnerHTML('ultima lettura: '+descrizione+' (qta. '+vpenna+')');
   }

function dyna_exec(a) {
   b=proxy_js+'baco_frame.php?' + a[0] + document.getElementById(a[1]).value;
   document.getElementById('baco_frame').src=b;
   }

function stampa_frame(gsid,nomefile,nomeframe,nomecampo,titolo,copie) {
   alert('stampa di ' + titolo + ' accodata.');
   x=document.forms['chiudiVendita'].elements[nomecampo];
   p=x[x.selectedIndex].value;
   c=document.forms['chiudiVendita'].elements[copie].value;
   b=proxy_js+'stampa_frame.php?G_SID=' + gsid + '&file=' + nomefile + '&printer=' + p + '&copie=' + c;
   document.getElementById(nomeframe).src=b;
   }
//-->
