// cart
function ToRial(str) {
	str = String(str);
	str = str.replace(/\,/g, "");
	var objRegex = new RegExp("(-?[0-9]+)([0-9]{3})");
	while (objRegex.test(str)) {
		str = str.replace(objRegex, "$1,$2")
	}
	return str
};

function Total_Price(count,price,id) {
  document.getElementById(id).innerHTML = ToRial(price * count);
}
function product_sizing_coloring(sizing=null,coloring=null,id='',def_color=null,def_size=null) {
  if(coloring) {
      const coloring_elem = document.getElementById('coloring'+id);
      const colors = coloring.split('-');
      for(let i =0;i<colors.length;i++) {
          let html = '<option'+(def_color?(colors[i]==def_color?' selected':''):'')+'>'+ colors[i] +'</option>';
          coloring_elem.insertAdjacentHTML('beforeend', html);
      }
  }
  if(sizing) {
      const sizing_elem = document.getElementById('sizing'+id);
      const sizes = sizing.split('-');
      for(let i =0;i<sizes.length;i++) {
          let html = '<option'+(def_size?(sizes[i]==def_size?' selected':''):'')+'>'+ sizes[i] +'</option>';
          sizing_elem.insertAdjacentHTML('beforeend', html);
      }
  }
}