// definint tamanys lletra

t10=10*stp+stp_factor;
t11=11*stp+stp_factor;
t12=12*stp+stp_factor;
t13=13*stp+stp_factor;
t15=15*stp+stp_factor;

////////////////////////////////////////////////////////////////////////////////
/////  ofertes_2.js   :  funcions estructura botiga     ////////////////////////
////////////////////////////////////////////////////////////////////////////////

var c_productes_nom=new Array();            // aquestes declaracions no funciones si
var c_productes_imatge=new Array();         // pertanyen a un altre script !!  ??
var c_productes_imatge_a=new Array();         // pertanyen a un altre script !!  ??
var c_productes_descripcio=new Array();
var c_productes_preu=new Array();
var c_productes_index=new Array();
var c_productes_afegits=new Array();        // rep info només a nivell de jscript
var c_productes_stock=new Array();        // rep info només a nivell de jscript

for (n=0;n<arts_pag;n++)
{
c_productes_nom[n]=eval('c_productes_nom'+n);
c_productes_imatge[n]=eval('c_productes_imatge'+n);
c_productes_imatge_a[n]=eval('c_productes_imatge_a'+n);
c_productes_descripcio[n]=eval('c_productes_descripcio'+n);
c_productes_preu[n]=eval('c_productes_preu'+n);
c_productes_index[n]=eval('c_productes_index'+n);
c_productes_stock[n]=eval('c_productes_stock'+n);
}

//-------------pas variables de php a jscript:----


var productes_nom=new Array()
var productes_imatge=new Array()
var productes_imatge_a=new Array()
var productes_descripcio=new Array()
var productes_preu=new Array()
var productes_stock=new Array()


for (i=0;i<num_productes;i++)
{
    productes_nom[i]=eval('productes_nom'+i)
    productes_imatge[i]=eval('productes_imatge'+i)
    productes_imatge_a[i]=eval('productes_imatge_a'+i)
    productes_descripcio[i]=eval('productes_descripcio'+i)
    productes_preu[i]=eval('productes_preu'+i)
    productes_stock[i]=eval('productes_stock'+i)
}


//--------------------------------------------------
function descripcio_in(ident2)
{
    c_imatge=eval('c_productes_imatge['+ident2+']');
if(c_imatge!='taller_fotos/blanc.jpeg' )
{
    cadena_descripcio=c_productes_descripcio[ident2];
    recerca='<br>';
    posicio=cadena_descripcio.indexOf(recerca);
    descripcio=c_productes_descripcio[ident2].substr(0,50);
    descripcio=descripcio.replace(/<br>/ig,"&nbsp;&nbsp;");
    document.getElementById('darticle').innerHTML='<p class=\'text_tarticle\' style=\' font-size:'+t13+'; color:#000000;\'><b>'+c_productes_nom[ident2]+'<b></p>';
    document.getElementById('ddescripcio').innerHTML='<p class=\'text_tdescripcio\' style=\'background-color:'+web_c['w_fons']+'; font-size:'+t12+'; color:'+web_c['w_marc']+';\'><br>&nbsp;&nbsp;&nbsp;&nbsp;'+descripcio+' ...<br>&nbsp;</p>';
}

return;
}

//--------------------------------------------------
function descripcio_out()
{
if(c_imatge!='taller_fotos/blanc.jpeg')
{
    document.getElementById('ddescripcio').innerHTML='<hr width=\'1\' size=\'1\'></hr>';
    document.getElementById('darticle').innerHTML='';
}

return;
}

//--------------------------------------------------
function si_cursor(ident)
{
    c_imatge=eval('c_productes_imatge['+ident+']');
if(c_imatge=='taller_fotos/blanc.jpeg')
{
    eval("document.getElementById('id01"+ident+"').style.cursor='default';");
}
else
{
    eval("document.getElementById('id01"+ident+"').style.cursor='pointer';");
}

return;
}

//--------------------------------------------------
function nova_pagina(pagina,pags_cataleg,elements)
{

if(mode_seccio=='article' && pagina!=1)
{

    np='';
    np=np+"<table >";
    np=np+"    <tr>";
    np=np+"        <td >";
    np=np+"        <img id='im_article_principal'  src='"+productes_imatge_a[0]+"' width='"+foto_gran*0.8*swp+"' height='"+foto_gran*0.8*swp+"'>";
    np=np+"        </td>";
    np=np+"    </tr>";
    np=np+"</table>";
    document.getElementById('d_article_principal').innerHTML=np;
}
else if(mode_seccio=='article' && pagina==1)
{
    np='';
    np=np+"<table onMouseover='si_cursor(0);descripcio_in(0);'  onMouseout='descripcio_out();' onClick='mostrar(0);'>";
    np=np+"    <tr>";
    np=np+"        <td >";
    np=np+"        <img id='im_article_principal' src='"+productes_imatge_a[0]+"' width='"+foto_gran*0.8*swp+"' height='"+foto_gran*0.8*swp+"'>";
    np=np+"        </td>";
    np=np+"    </tr>";
    np=np+"</table>";
    document.getElementById('d_article_principal').innerHTML=np;
}
for(i=1;i<=pags_cataleg;i++)
{
    if(i==pagina)
    {
        document.getElementById('pag'+i).style.textDecoration='underline';
    }
    else
    {
        document.getElementById('pag'+i).style.textDecoration='none';
    }
}

index_element_menor=(pagina-1)*arts_pag;    //arts_pag ==> declarada a botiga.php
if(pagina!=pags_cataleg)
{
    index_element_major=index_element_menor+arts_pag-1;
    elements_pagina=arts_pag;
}
else
{
    index_element_major=elements-1;
    elements_pagina=elements-(pagina-1)*arts_pag;
}

//i: index elements
//j: index casella

j=0
for (i=index_element_menor;i<=index_element_major;i++)
{

   eval ("document.getElementById('id01"+j+"').src='"+productes_imatge[i]+"'");
   c_productes_nom[j]=productes_nom[i];
   c_productes_imatge[j]=productes_imatge[i];
   c_productes_imatge_a[j]=productes_imatge_a[i];
   c_productes_descripcio[j]=productes_descripcio[i];
   c_productes_preu[j]=productes_preu[i];
   c_productes_index[j]=i;
   c_productes_afegits[j]=0;
   c_productes_stock[j]=productes_stock[i];
   document.getElementById('num'+j).value=num[i];

j++
}
// elements sense contingut:        //ok

for (i=j;i<arts_pag;i++)
{
   eval ("document.getElementById('id01"+i+"').src='taller_fotos/blanc.jpeg'");         //ok
   c_productes_nom[i]="ubicació inexistent";
   c_productes_imatge[i]='taller_fotos/blanc.jpeg';
   c_productes_imatge_a[i]='';
   c_productes_index[i]='';
   c_productes_afegits[i]=0;
   c_productes_preu[i]='';
   c_productes_descripcio[i]="";
   c_productes_stock[i]=0;
    si_cursor(i);
j++
}
return
}

//--------------------------------------------------
function esborrar_seleccio()
{
for (i=0;i<num_productes;i++)
{
num[i]=0;
}
total=0;

for (i=0;i<num_anterior.length;i++)
{
num_anterior[i]=0;
}

num_anterior=0;
total_anterior=0;

tancar_totes();
return;
}

//--------------------------------------------------

var sw=screen.width
var sh=screen.height

element_mostrat=0;
//--------------------------------------------------
function mostrar(i)
{
element_mostrat=i;
search='?'+(new Date()).getTime();
if ((c_productes_nom[i]!='ubicació inexistent') && (c_productes_imatge[i]!='taller_fotos/blanc.jpeg'))
{
   document.getElementById('darticle').style.innerHTML='&nbsp;';
   document.getElementById('ddescripcio').style.innerHTML='&nbsp;';


document.getElementById('tm1').innerHTML=c_productes_nom[i];
document.getElementById('im_mostrar').src=c_productes_imatge[i]+search;

    
    if(mode_seccio!='article' && c_productes_preu[i]!=0) //mode_seccio='article':si preu no és 0, mostrar:
    {
        document.getElementById('tm5').innerHTML=c_productes_preu[i]+'&nbsp;&euro;&nbsp;&nbsp;&nbsp;(&nbsp;&nbsp;I.V.A incl.&nbsp;&nbsp;)';
        document.getElementById('tm5').style.visibility='inherit';
        document.getElementById('tm4').style.visibility='inherit';
        document.getElementById('i_afegir').style.visibility='inherit';
    }
    else  if(mode_seccio=='article' && productes_nom[0]==c_productes_nom[i]) //mode_seccio='seccio':
    {
        document.getElementById('tm5').innerHTML=c_productes_preu[i]+'&nbsp;&euro;&nbsp;&nbsp;&nbsp;(&nbsp;&nbsp;I.V.A incl.&nbsp;&nbsp;)';
        document.getElementById('tm5').style.visibility='inherit';
        document.getElementById('tm4').style.visibility='inherit';
        document.getElementById('i_afegir').style.visibility='inherit';
    }
    else  if(mode_seccio=='article' && productes_nom[0]!=c_productes_nom[i]) //mode_seccio='seccio':
    {
        document.getElementById('tm5').innerHTML=productes_preu[0]+'&nbsp;&euro;&nbsp;&nbsp;&nbsp;(&nbsp;&nbsp;I.V.A incl.&nbsp;&nbsp;)';
        document.getElementById('tm5').style.visibility='inherit';
        document.getElementById('tm4').style.visibility='inherit';
        document.getElementById('i_afegir').style.visibility='hidden';
    }
    else
    {
        document.getElementById('i_afegir').style.visibility='hidden';
    }

        
document.getElementById('tm6').innerHTML=c_productes_descripcio[i];

document.getElementById('im_mostrar').width=foto_petita*swp;
document.getElementById('taula_principal').style.visibility='hidden';
document.getElementById('d_article_principal').style.visibility='hidden';
document.getElementById('t_detalls').style.visibility='hidden';
document.getElementById('im_article_principal').style.visibility='hidden';

document.getElementById('t_mostrar').style.zIndex=10;
document.getElementById('t_mostrar').style.visibility='inherit';

}
return;
}

//--------------------------------------------------
function ampliar()
{
search='?'+(new Date()).getTime();

document.getElementById('im_ampliar').src=c_productes_imatge_a[element_mostrat]+search;

document.getElementById('taula_principal').style.visibility='hidden';
document.getElementById('d_article_principal').style.visibility='hidden';
document.getElementById('t_detalls').style.visibility='hidden';
document.getElementById('im_article_principal').style.visibility='hidden';

document.getElementById('t_mostrar').style.zIndex=0;
document.getElementById('t_mostrar').style.visibility='hidden';
document.getElementById('t_ampliar').style.zIndex=10;
document.getElementById('t_ampliar').style.visibility='inherit';

return;
}

//--------------------------------------------------

var total=0

//elements afegits:.............................................................

var num=new Array();
var index=0;
for (i=0;i<num_productes;i++)
{
num[i]=0;
}

//--------------------------------------------------
function afegir()
{
    if(bloquejar_comandes=='no')
    {
        index=c_productes_index[element_mostrat];
        num[index]++;
        //eval("document.getElementById('f"+k+"').num"+k+".value="+num[index]+";");
        //document.getElementById('i_unitats').value=num[index];
    }
    else
    {
        alert(text_cat[27]);
    }
return;
}
//--------------------------------------------------

function f_pnemonic_activar()
{
    f_pnemonic_num();
    id_pnemonic=setInterval('f_pnemonic_num()',1000);
return;
}

function f_pnemonic_num()
{

    pnemonic_num=0;
    for (i=0;i<num_anterior.length;i++)
    {
        if (num_anterior[i]!=0)
        {
            pnemonic_num=pnemonic_num+num_anterior[i];
        }
    }

    for (i=0;i<=num.length-1;i++)
    {
        if (num[i]!=0)
        {
            pnemonic_num=pnemonic_num+num[i];
        }
    }

    if(pnemonic_num!=0)
    {
        e="     <table bgcolor='"+web_c['w_fons']+"'><tr><td bgcolor='#dddddd'>";
        e=e+"   <p class='PPNEMONIC' style=' font-size:"+t12+";color:"+web_c['w_fons']+";'>";
        e=e+"   "+text_cat[16]+": <strong>"+pnemonic_num+"</strong> "+text_cat[17]+"</p></td></tr></table>";
        document.getElementById('d_pnemonic').innerHTML=e;
        document.getElementById('d_pnemonic').style.visibility='inherit';
    }
    else
    {
        document.getElementById('d_pnemonic').style.visibility='hidden';
    }
return;
}

function test_us_pasw()
{
    h_usuari=document.getElementById('i_nom').value;
    h_password=document.getElementById('i_password').value;

    document.getElementById('usuari_botiga').value=h_usuari;
    document.getElementById('password_botiga').value=h_password;

    existeix_usuari2=document.getElementById('usuari_botiga').value;
    existeix_password2=document.getElementById('password_botiga').value;
    
// valors totals per d'unitats seleccionades en seccions anteriors i en l'última secció

total_num=0;
total_num_anterior=0;

for (i=0;i<num_productes;i++)
{
total_num=total_num+num[i];
}
for (i=0;i<num_anterior.length;i++)
{
total_num_anterior=total_num_anterior+num_anterior[i];
}
////////////////////////////////////////////////////////////////////////////////

    if( existeix_usuari2=='' || existeix_password2=='' )
    {
        document.getElementById('palerta_us_pasw').innerHTML="&nbsp;<br>"+text_cat[20]+"<a href='' class='aqui' style='background-color:"+web_c['w_fons']+"; color:"+web_c['w_marc']+"; font-size:"+t12+";' onClick='tancar_totes();registrarse();return false;'>"+text_cat[21]+"</a>"+text_cat[22]+"<br>&nbsp";
        document.getElementById('palerta_us_pasw').style.visibility='inherit';
        return false;
    }
    else if(total_num==0 && total_num_anterior==0)
    {
        document.getElementById('palerta_us_pasw').innerHTML=text_cat[23];
        document.getElementById('palerta_us_pasw').style.visibility='inherit';
        return false;
    }
    else
    {
        document.getElementById('palerta_us_pasw').innerHTML='';
        document.getElementById('palerta_us_pasw').style.visibility='hidden';
caqp='';
for (i=0;i<num.length;i++)
{
    if (num[i]!=0)
    {
        caqp=caqp+productes_nom[i]+'prop'+num[i]+'prop'+productes_preu[i]+'prop'+productes_imatge_a[i]+'art';
    }
}

for (i=0;i<num_anterior.length;i++)
{
    if (productes_quantitat_anterior[i]!=0)
    {
        caqp=caqp+productes_nom_anterior[i]+'prop'+productes_quantitat_anterior[i]+'prop'+productes_preu_anterior[i]+'prop'+productes_imatge_a_anterior[i]+'art';
    }
}
        document.getElementById('ec_arts_quan_preu').value=caqp;
        document.getElementById('enviar_comanda').submit();
    }
return true;
}

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
total_anterior=0;

    productes_nom_anterior=new Array();
    productes_quantitat_anterior=new Array();
    productes_preu_anterior=new Array();
    productes_imatge_a_anterior=new Array();

    productes_nom_anterior[0]='';
    productes_quantitat_anterior[0]=0;
    productes_preu_anterior[0]=0;
    productes_imatge_a_anterior[0]='';

for (i=0;i<num_anterior.length;i++)
{

    productes_nom_anterior[i]=eval("matriu_arts_quan_preu"+i+"['article'];");
    productes_quantitat_anterior[i]=eval("matriu_arts_quan_preu"+i+"['quantitat'];");
    productes_preu_anterior[i]=eval("matriu_arts_quan_preu"+i+"['preu'];");
    productes_imatge_a_anterior[i]=eval("matriu_arts_quan_preu"+i+"['imatge_a'];");
}

//reagrupar articles de les seccions anteriors i articles de la secció actual

for (i=0;i<num.length;i++)
{
    for (j=0;j<num_anterior.length;j++)
    {
        if(productes_nom[i]==productes_nom_anterior[j])
        {
            num[i]=num[i]+num_anterior[j];
            num_anterior[j]=0;
            productes_quantitat_anterior[j]=0;
        }
    }
}










total=0;
total_anterior=0;

function veure_comanda()
{

document.getElementById('t_ampliar').style.visibility='hidden';
document.getElementById('t_mostrar').style.visibility='hidden';
document.getElementById('taula_principal').style.visibility='hidden';
document.getElementById('d_article_principal').style.visibility='hidden';
document.getElementById('t_detalls').style.visibility='hidden';
document.getElementById('im_article_principal').style.visibility='hidden';
document.getElementById('t_pagines').style.visibility='hidden';

total=0;
total_anterior=0;

//..............................................................................

        to=0*swp;
        le=212*swp;

        wtaula=756*swp;
        htaula_articles=sh/2;


h_usuari=document.getElementById('i_nom').value;
h_password=document.getElementById('i_password').value;
document.getElementById('usuari_botiga').value=h_usuari;
document.getElementById('password_botiga').value=h_password;

//quants tipus de producte hi ha a la comanda:

tipus=''
for (i=0;i<num_productes;i++)
{
    if (num[i]!=0){tipus=tipus+i+','}
}
document.getElementById('tipus').value=tipus;


// articles seleccionats en aquesta seccio:
c5='';

c5=c5+"                                <table align='center' width='100%' bgcolor='"+web_c['w_fons']+"'>";
c5=c5+"                                    <tr align='center' height='50'>";

c5=c5+"                                        <th width='25%' align='center' bgcolor='"+web_c['w_fons']+"'>";
c5=c5+"                                        </th>";

c5=c5+"                                        <th width='1'  bgcolor='"+web_c['w_marc']+"'>";
c5=c5+"                                        </th>";

c5=c5+"                                        <th width='25%' align='center' bgcolor='"+web_c['w_fons']+"'>";
c5=c5+"                                        <p  id='p12'  class='PCAMP_COMANDA2' style='color:"+web_c['w_marc']+"; font-size:"+t12+"px;;'>"+text_cat[24]+":</p>";
c5=c5+"                                        </th>";

c5=c5+"                                        <th width='1' bgcolor='"+web_c['w_marc']+"'>";
c5=c5+"                                        </th>";

c5=c5+"                                        <th width='25%' align='center' bgcolor='"+web_c['w_fons']+"'>";
c5=c5+"                                        <p  id='p13'  class='PCAMP_COMANDA2' style='color:"+web_c['w_marc']+"; font-size:"+t12+"px;'>"+text_cat[25]+":</p>";
c5=c5+"                                        </th>";

c5=c5+"                                        <th width='1'bgcolor='"+web_c['w_marc']+"'>";
c5=c5+"                                        </th>";

c5=c5+"                                        <th width='25%' align='center' bgcolor='"+web_c['w_fons']+"'>";
c5=c5+"                                        <p  id='p14'  class='PCAMP_COMANDA2' style='color:"+web_c['w_marc']+"; font-size:"+t12+"px;px;'>"+text_cat[26]+":</p>";
c5=c5+"                                        </th>";
c5=c5+"                                    </tr>";

c5=c5+"                                    <tr >";
c5=c5+"                                        <td >";
c5=c5+"                                        </td>";

c5=c5+"                                        <td width='1'>";
c5=c5+"                                        </td>";

c5=c5+"                                        <td height='1' bgcolor='"+web_c['w_marc']+"'>";
c5=c5+"                                        </td>";

c5=c5+"                                        <td width='1'>";
c5=c5+"                                        </td>";

c5=c5+"                                        <td height='1' bgcolor='"+web_c['w_marc']+"'>";
c5=c5+"                                        </td>";

c5=c5+"                                        <td width='1'>";
c5=c5+"                                        </td>";

c5=c5+"                                        <td height='1' bgcolor='"+web_c['w_marc']+"'>";
c5=c5+"                                        </td>";
c5=c5+"                                    </tr>";





for (i=0;i<num.length;i++)
{
    if (num[i]!=0)
    {
c5=c5+"                             <tr >";
c5=c5+"                                <td align='center' bgcolor='"+web_c['w_fons']+"'>";
c5=c5+"                                <img src='"+productes_imatge_a[i]+"' border='0' width='60' height='60'>";
c5=c5+"                                </td>";
c5=c5+"                                <td  bgcolor='"+web_c['w_marc']+"'>";
c5=c5+"                                </td>";
c5=c5+"                                <td  align='center'  bgcolor='"+web_c['w_fons']+"'>";
c5=c5+"                                <input type='text' style=' font-size:"+t12+"px;' name='article"+i+"' readonly size='10' value='"+productes_nom[i]+"'>";
c5=c5+"                                </td>";
c5=c5+"                                <td bgcolor='"+web_c['w_marc']+"'>";
c5=c5+"                                </td>";
c5=c5+"                                <td  align='center' bgcolor='"+web_c['w_fons']+"'>";
c5=c5+"                                <input type='text' style=' font-size:"+t12+"px;' name='quantitat"+i+"' readonly  size='10' value='"+num[i]+"'>";
c5=c5+"                                </td>";
c5=c5+"                                <td bgcolor='"+web_c['w_marc']+"'>";
c5=c5+"                                </td>";
c5=c5+"                                <td align='center' bgcolor='"+web_c['w_fons']+"'>";
c5=c5+"                                <p style='color:"+web_c['w_marc']+"; font-size:"+t12+"px;'>";
c5=c5+"                                <input type='text' style=' font-size:"+t12+"px;' name='preu"+i+"' readonly  size='10' value='"+productes_preu[i]+"'>&nbsp;&nbsp;&euro;";
c5=c5+"                                </p></td>";
c5=c5+"                             </tr>";
c5=c5+"                             <tr >";
c5=c5+"                                 <td >";
c5=c5+"                                 </td>";
c5=c5+"                                 <td width='1'>";
c5=c5+"                                 </td>";
c5=c5+"                                 <td height='1' bgcolor='"+web_c['w_marc']+"'>";
c5=c5+"                                 </td>";
c5=c5+"                                 <td width='1'>";
c5=c5+"                                 </td>";
c5=c5+"                                 <td height='1' bgcolor='"+web_c['w_marc']+"'>";
c5=c5+"                                 </td>";
c5=c5+"                                 <td width='1'>";
c5=c5+"                                 </td>";
c5=c5+"                                 <td height='1' bgcolor='"+web_c['w_marc']+"'>";
c5=c5+"                                 </td>";
c5=c5+"                             </tr>";

        total=total+num[i]*productes_preu[i]
    }
}


// articles procedents de seccions anteriors:
num_anterior_length=num_anterior.length;
if(num_anterior_length==undefined){num_anterior_length=0;}
c5=c5+"                             <tr>";
c5=c5+"                                <td>";
c5=c5+"                                <input type='hidden' name='num_anterior' value='"+num_anterior_length+"'>";
c5=c5+"                                </td>";
c5=c5+"                             </tr>";
for (i=0;i<num_anterior.length;i++)
{
    if (num_anterior[i]!=0)
    {
c5=c5+"                             <tr >";
c5=c5+"                                <td align='center' bgcolor='"+web_c['w_fons']+"'>";
c5=c5+"                                <img src='"+productes_imatge_a_anterior[i]+"' border='0' width='60' height='60'>";
c5=c5+"                                </td>";
c5=c5+"                                <td  bgcolor='"+web_c['w_marc']+"'>";
c5=c5+"                                </td>";
c5=c5+"                                <td  align='center'  bgcolor='"+web_c['w_fons']+"'>";
c5=c5+"                                <input type='text' style=' font-size:"+t12+"px;' name='article_anterior"+i+"' readonly size='10' value='"+productes_nom_anterior[i]+"'>";
c5=c5+"                                </td>";
c5=c5+"                                <td bgcolor='"+web_c['w_marc']+"'>";
c5=c5+"                                </td>";
c5=c5+"                                <td  align='center' bgcolor='"+web_c['w_fons']+"'>";
c5=c5+"                                <input type='text' style=' font-size:"+t12+"px;' name='quantitat_anterior"+i+"' readonly  size='10' value='"+productes_quantitat_anterior[i]+"'>";
c5=c5+"                                </td>";
c5=c5+"                                <td bgcolor='"+web_c['w_marc']+"'>";

c5=c5+"                                </td>";
c5=c5+"                                <td align='center' bgcolor='"+web_c['w_fons']+"'>";
c5=c5+"                                <p style='color:"+web_c['w_marc']+"; font-size:"+t12+"px;'>";
c5=c5+"                                <input type='text' style=' font-size:"+t12+"px;' name='preu_anterior"+i+"' readonly  size='10' value='"+productes_preu_anterior[i]+"'>&nbsp;&nbsp;&euro;";
c5=c5+"                                </p></td>";
c5=c5+"                             </tr>";

c5=c5+"                             <tr >";
c5=c5+"                                 <td >";
c5=c5+"                                 </td>";
c5=c5+"                                 <td width='1'>";
c5=c5+"                                 </td>";
c5=c5+"                                 <td height='1' bgcolor='"+web_c['w_marc']+"'>";
c5=c5+"                                 </td>";
c5=c5+"                                 <td width='1'>";
c5=c5+"                                 </td>";
c5=c5+"                                 <td height='1' bgcolor='"+web_c['w_marc']+"'>";
c5=c5+"                                 </td>";
c5=c5+"                                 <td width='1'>";
c5=c5+"                                 </td>";
c5=c5+"                                 <td height='1' bgcolor='"+web_c['w_marc']+"'>";
c5=c5+"                                 </td>";
c5=c5+"                             </tr>";
        total_anterior=total_anterior+productes_quantitat_anterior[i]*productes_preu_anterior[i];
    }
}
        total=total + total_anterior;

c5=c5+"                                    <tr >";
c5=c5+"                                        <td>";
c5=c5+"                                        </td>";

c5=c5+"                                        <td>";
c5=c5+"                                        </td>";

c5=c5+"                                        <td>";
c5=c5+"                                        </td>";

c5=c5+"                                        <td>";
c5=c5+"                                        </td>";

c5=c5+"                                        <td>";
c5=c5+"                                        </td>";

c5=c5+"                                        <td>";
c5=c5+"                                        </td>";

c5=c5+"                                        <td>";
c5=c5+"                                        <table width='150' valign='top'>";
c5=c5+"                                            <tr  bgcolor='"+web_c['w_fons']+"'>";
c5=c5+"                                                <td width='50%' >";
c5=c5+"                                                <p  id='p15'  class='PCAMP_COMANDA3' style='color:"+web_c['w_marc']+"; font-size:"+t12+";'>total:</p>";
c5=c5+"                                                </td>";

c5=c5+"                                                <td width='50%'>";
c5=c5+"                                                <p  id='p16'  style='color:"+web_c['w_marc']+"; font-size:10px;'>";
c5=c5+"                                                <input  id='p17'  type='text'  style='font-size:"+t12+";' name='total'  size='10' readonly value='"+total+"'>&nbsp;&nbsp;&euro;";
c5=c5+"                                                </p>";
c5=c5+"                                                </td>";
c5=c5+"                                            </tr>";
c5=c5+"                                        </table>";
c5=c5+"                                        </td>";
c5=c5+"                                    </tr>";
c5=c5+"                               </table>";



document.getElementById('d_articles_veure_comanda').innerHTML=c5;
document.getElementById('t_veure_comanda').style.visibility='inherit';
return false;
}



function registrarse()
{
        h_taula=sh*0.66;
        wobj=700*swp;
        hobj=h_taula;
        to=120*swp;
        le=225*swp;

objA="<table height='"+h_taula+"'><tr  ><td valign='top'>";
objB="<object id='o_x' type='text/html' data='form_usuaris_botiga.php' width='"+wobj+"' height='"+hobj+"'>";
objC="</object></td><td valign='top'><input type='button'  class='ITANCAR' style='font-size:"+t12+";'  id='i_tancar' onClick='tancar_totes();' value='&nbsp;x&nbsp;'></td></tr></table>";

//document.getElementById('t_alerta_us_pasw').style.visibility='hidden';
document.getElementById('finestra_obj').innerHTML=objA+objB+objC;
document.getElementById('finestra_obj').style.top=to;
document.getElementById('finestra_obj').style.left=le;


document.getElementById('taula_principal').style.visibility='hidden';
document.getElementById('d_article_principal').style.visibility='hidden';
document.getElementById('t_detalls').style.visibility='hidden';
document.getElementById('im_article_principal').style.visibility='hidden';


document.getElementById('finestra_obj').style.left=le;

document.getElementById('finestra_obj').style.visibility='inherit';

return false;
}



function com_comprar()
{
document.getElementById('t_pagines').style.visibility='hidden';
document.getElementById('taula_principal').style.visibility='hidden';
document.getElementById('d_article_principal').style.visibility='hidden';
document.getElementById('t_detalls').style.visibility='hidden';
document.getElementById('im_article_principal').style.visibility='hidden';

document.getElementById('t_com_comprar2').style.visibility='inherit';
return;
}
function condicions()
{
        h_taula=sh*0.62;
        wobj=700*swp;
        hobj=h_taula;
        to=120*swp;
        le=225*swp;


objA="<table height='"+h_taula+"' ><tr ><td valign='top' >";
objB="<object  id='o_x' type='text/html' data='condicions.php' width='"+wobj+"' height='"+hobj+"'>";
objC="</object></td><td valign='top'><input type='button'  class='ITANCAR' style='font-size:"+t12+";'  id='i_tancar' onClick='tancar_totes();' value='&nbsp;x&nbsp;'><td></tr></table>";

//document.getElementById('t_alerta_us_pasw').style.visibility='hidden';
document.getElementById('finestra_obj').innerHTML=objA+objB+objC;
document.getElementById('finestra_obj').style.top=to;
document.getElementById('finestra_obj').style.left=le;

document.getElementById('taula_principal').style.visibility='hidden';
document.getElementById('d_article_principal').style.visibility='hidden';
document.getElementById('t_detalls').style.visibility='hidden';
document.getElementById('im_article_principal').style.visibility='hidden';

document.getElementById('finestra_obj').style.visibility='inherit';

return false;
}

//--------------------------------------------------
function tancar_totes()
{

document.getElementById('t_veure_comanda').style.visibility='hidden';
document.getElementById('t_mostrar').style.visibility='hidden';
document.getElementById('t_mostrar').style.zIndex=0;

document.getElementById('finestra_obj').style.visibility='hidden';
document.getElementById('t_com_comprar2').style.visibility='hidden';

document.getElementById('taula_principal').style.visibility='inherit';
document.getElementById('d_article_principal').style.visibility='inherit';
document.getElementById('t_detalls').style.visibility='inherit';
document.getElementById('im_article_principal').style.visibility='inherit';
document.getElementById('t_pagines').style.visibility='inherit';
total=0;
//document.getElementById('finestra_obj').innerHTML='';
//document.getElementById('t_alerta_us_pasw').style.visibility='hidden';
return;
}

//--------------------------------------------------
function tancar_ampliacio()
{
document.getElementById('t_ampliar').style.visibility='hidden';
document.getElementById('t_ampliar').style.zIndex=0;
document.getElementById('t_mostrar').style.zIndex=10;
document.getElementById('t_mostrar').style.visibility='inherit';

return;
}


//--------------------------------------------------
function carregar_seccio(seccio_seleccionada)
{
//passant variables de productes seleccionats;
document.getElementById('r_usuari_botiga').value=document.getElementById('i_nom').value;
document.getElementById('r_password_botiga').value=document.getElementById('i_password').value;

caqp='';
for (i=0;i<num.length;i++)
{
    if (num[i]!=0)
    {
        caqp=caqp+productes_nom[i]+'prop'+num[i]+'prop'+productes_preu[i]+'prop'+productes_imatge_a[i]+'art';
    }
}

for (i=0;i<num_anterior.length;i++)
{
    if (productes_quantitat_anterior[i]!=0)
    {
        caqp=caqp+productes_nom_anterior[i]+'prop'+productes_quantitat_anterior[i]+'prop'+productes_preu_anterior[i]+'prop'+productes_imatge_a_anterior[i]+'art';
    }
}
document.getElementById('r_arts_quan_preu').value=caqp;
document.getElementById('sel_seccio').value=seccio_seleccionada;

document.getElementById('f_seleccionar_seccio').submit();
return;
}


