function clickAddPro(proId,index,f_price)
{
    var total_price = parseInt(f_price);
    var listId = proId + ",";
    var checkAll = true;
    $("input[name='addpro_"+index+"']").each(function (i){
									if(this.checked)
                                    {
                                        total_price = total_price + parseInt($(this).val());
                                        listId = listId +$(this).attr("proid") + ",";
                                    }else
                                        checkAll = false;
								});
    listId = listId.substring(0,listId.length-1);
    $("#urladdall_"+index).attr("href","/index.php?mod=cart&task=add&ajax&pid="+listId);
    $("#datht_total_price_"+index).html(formatCurrency(total_price));
    if(checkAll)
    {
      $("#show_promotion_"+index).css("display","block");
      var promotion = parseInt($("#promotion_"+index).val());
      var promotion_price = total_price - (total_price * promotion)/100;
      $("#show_promotion_price_"+index).html(formatCurrency(promotion_price));
    }else{
        $("#show_promotion_"+index).css("display","none");  
    }
}
function displayS2T()
{
    try{
        $("#s2t_contents").html($(".s2t_contents").html());
    }catch(err) {

        }
}
function formatCurrency(num) {
    num = num.toString().replace(/\$|\,/g,'');
    if(isNaN(num))
    num = "0";
    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num*100+0.50000000001);
    num = Math.floor(num/100).toString();
    for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
    num = num.substring(0,num.length-(4*i+3))+'.'+
    num.substring(num.length-(4*i+3));
    return (((sign)?'':'-') + num);
}
function changeSl(pid)
{
    $("#link-add-cart").attr("href","/index.php?mod=cart&task=add&ajax&pid="+pid+"&qty="+$("#sl-product").val());
}
function closePopup()
{
    $("#popup").css("display","none");
}

