function fiyatguncelle() {
 var sel, qua, cs1, cs2, cs3, ca1, ca2, ca3;
 var sum, tax, gsm, gsa, i;
 sum = 0;
 tax = 0;

 for( i = 0; i < nol; i++ ) {
  sel = MM_findObj('product_' + i );
  qua = MM_findObj('quantity_' + i );
  cs1 = MM_findObj('cost1_' + i );
  cs2 = MM_findObj('cost2_' + i );
  cs3 = MM_findObj('cost3_' + i );

  sel = sel.options[ sel.selectedIndex ].value;
  
  if( sel != 0 ) {
   cs1.value = products[sel][0];
   cs2.value = products[sel][1] + ' YTL';
   cs3.value = Math.round(products[sel][1] * qua.value * 100) / 100 + ' YTL';

   sum = sum + products[sel][1] * qua.value;
   tax = tax + products[sel][2] * qua.value;
  } else {
   cs1.value = 0;
   cs2.value = 0;
   cs3.value = 0;
  }
 }

 gsm = Math.round((sum + tax) * 100) / 100;
 sum = Math.round(sum * 100) / 100;
 tax = Math.round(tax * 100) / 100;

 ca1 = MM_findObj('cost_1');
 ca2 = MM_findObj('cost_2');
 ca3 = MM_findObj('cost_3');

 gsa = MM_findObj('total_cost');

 gsa.value = gsm;

 ca1.value = (sum) + ' YTL ';
 ca2.value = (tax) + ' YTL ';
 ca3.value = (gsm) + ' YTL ';
}

function temizle() {
 var sel, qua, cs1, cs2, cs3, ca1, ca2, ca3;

 for( i = 0; i < nol; i++ ) {
  sel = MM_findObj('product_' + i );
  qua = MM_findObj('quantity_' + i );
  cs1 = MM_findObj('cost1_' + i );
  cs2 = MM_findObj('cost2_' + i );
  cs3 = MM_findObj('cost3_' + i );

  sel.selectedIndex = 0;
  qua.valu = "1";
 }

 fiyatguncelle();
}

function taksit() {
 var gsa;

 gsa = MM_findObj('total_cost');

 window.open('index.php?go=' + modid_store + ',4&price=' + gsa.value, '', 'width=500, height=400, scrollbars=yes');
}

function MM_findObj(n, d) {
 var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
  d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
 if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
 for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
 if(!x && d.getElementById) x=d.getElementById(n); return x;
}
