﻿// JScript File
 
var prc; // = document.getElementById("ctl00_lblCartTotal");  
var newTypeInfoSet;
var priceUpdated = new Array();
var priceIndex = 0;
var priceUpdatedPostback = new Array();
var priceIndexPostback = 0;
var maxcpriceNum = 20;
var maxgcpriceNum = 200;
var maxRowNum = 10;
var defaultRate = 1;

function ResetPrice(type) {

    //MC.ENET.CurrencyService.SetCurrencyType(type, defaultTypeInfo.Type, onSuccess, onError); return false;
    var parameters = "{'type':'" + type + "','defaultType':'" + defaultTypeInfo.Type + "'}";
    $.ajax({
        type: "POST",
        url: getBaseURL() + 'MCWebServices/CurrencyService.asmx/SetCurrencyType',
        data: parameters,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (result) {
            //alert(result.d);
            onSuccess(result.d);
        },
        error: function (xhr, status, error) {
            //alert(xhr.statusText);
        }
    });

    return false;  
} 
 function setpriceUpdatedDdl()
{
     var tmp = document.getElementById("ddlistcomp");
     if (tmp) {
         for (var i = 0; i < tmp.length; i++) {
             tmp.options[i].innerHTML = findPricePart(tmp.options[i].text);

         }
     }
}
function setpriceUpdated() {
    addpriceUpdated("ctl00_lblCartTotal");
    addpriceUpdated("ewebprice");
    addpriceUpdated("retailprice");
    addpriceUpdated("percsaving");
    addpriceUpdated("webprice");
    addpriceUpdated("surchrg");
    addpriceUpdated("exclvatprice");
    addpriceUpdated("inclvatprice");
    addpriceUpdated("exclvatsurchrg");
    addpriceUpdated("inclvatsurchrg");
    addpriceUpdated("rebateprice");
    addpriceUpdated("priceoverride");
    addpriceUpdated("pricematch");
    addpriceUpdated("clubprice");
    addpriceUpdated("clubpercsaving");
    addpriceUpdated("addph");
    addpriceUpdatedSet("multipricing");
    addpriceUpdatedSet("ekitprice");
    addpriceUpdatedSet("ekitpricesurchrg");
    addpriceUpdatedSet("ekitpriceexclvat");
    addpriceUpdatedSet("ekitpriceinclvat");
    addpriceUpdatedSet("ekitpriceexclvatsurchrg");
    addpriceUpdatedSet("ekitpriceinclvatsurchrg");
    addpriceUpdated("custpriceperchar");
    addpriceUpdated("custprice");
    
    addpriceUpdatedSet("cretailprice"); 
    addpriceUpdatedSet("cpercsaving");
    addpriceUpdatedSet("cwebprice");
    addpriceUpdatedSet("csurchrg");
    addpriceUpdatedSet("cexclvatprice");
    addpriceUpdatedSet("cinclvatprice");
    addpriceUpdatedSet("cexclvatsurchrg");
    addpriceUpdatedSet("cinclvatsurchrg");
    addpriceUpdatedSet("crebateprice");
    addpriceUpdatedSet("cpriceoverride");
    addpriceUpdatedSet("cpricematch");
    addpriceUpdatedSet("cclubprice");
    addpriceUpdatedSet("cclubpercsaving");
    addpriceUpdatedSet("caddph");
    addpriceUpdatedSet1("cmultipricing");
    
    addgridpriceUpdatedSet("gcretailprice"); 
    addgridpriceUpdatedSet("gcpercsaving");
    addgridpriceUpdatedSet("gcwebprice");
    addgridpriceUpdatedSet("gcsurchrg");
    addgridpriceUpdatedSet("gcexclvatprice");
    addgridpriceUpdatedSet("gcinclvatprice");
    addgridpriceUpdatedSet("gcexclvatsurchrg");
    addgridpriceUpdatedSet("gcinclvatsurchrg");
    addgridpriceUpdatedSet("gcrebateprice");
    addgridpriceUpdatedSet("gcpriceoverride");
    addgridpriceUpdatedSet("gcpricematch");
    addgridpriceUpdatedSet("gcclubprice");
    addgridpriceUpdatedSet("gcclubpercsaving");
    addgridpriceUpdatedSet("gcaddph");
    addgridpriceUpdatedSet1("gcmultipricing");
    
    addpriceUpdatedSet1("gwebprice");
    addpriceUpdatedSet1("gsurchrg");
    addpriceUpdatedSet1("ginclvatprice");
    addpriceUpdatedSet1("gexclvatprice");
    addpriceUpdatedSet1("ginclvatsurchrg");
    addpriceUpdatedSet1("gexclvatsurchrg");
    addpriceUpdatedSet1("grebateprice");
    addpriceUpdatedSet1("gclubprice");
    
    addpriceUpdatedSet1("rwebprice");
    addpriceUpdatedSet1("rsurchrg");
    addpriceUpdatedSet1("rwebpricemax");
    addpriceUpdatedSet1("rexclvatprice");
    addpriceUpdatedSet1("rinclvatprice");
    addpriceUpdatedSet1("rexclvatsurchrg");
    addpriceUpdatedSet1("rinclvatsurchrg");
    addpriceUpdatedSet1("rrebateprice");
    addpriceUpdatedSet1("rrebatepricemax");
    addpriceUpdatedSet1("rclubprice");
    addpriceUpdatedSet1("rpwebprice");
    addpriceUpdatedSet1("rpsurchrg");
    addpriceUpdatedSet1("rpwebpricemax");
    addpriceUpdatedSet1("rpexclvatprice");
    addpriceUpdatedSet1("rpinclvatprice");
    addpriceUpdatedSet1("rpexclvatsurchrg");
    addpriceUpdatedSet1("rpinclvatsurchrg");
    addpriceUpdatedSet1("rprebateprice");
    addpriceUpdatedSet1("rprebatepricemax");
    addpriceUpdatedSet1("rpclubprice");
    
    addpriceUpdatedSet1("twebprice");
    addpriceUpdatedSet1("tsurchrg");
    addpriceUpdatedSet1("twebpricemax");
    addpriceUpdatedSet1("texclvatprice");
    addpriceUpdatedSet1("tinclvatprice");
    addpriceUpdatedSet1("texclvatsurchrg");
    addpriceUpdatedSet1("tinclvatsurchrg");
    addpriceUpdatedSet1("trebateprice");
    addpriceUpdatedSet1("trebatepricemax");
    addpriceUpdatedSet1("tclubprice");
    addpriceUpdatedSet1("tpwebprice");
    addpriceUpdatedSet1("tpsurchrg");
    addpriceUpdatedSet1("tpwebpricemax");
    addpriceUpdatedSet1("tpexclvatprice");
    addpriceUpdatedSet1("tpinclvatprice");
    addpriceUpdatedSet1("tpexclvatsurchrg");
    addpriceUpdatedSet1("tpinclvatsurchrg");
    addpriceUpdatedSet1("tprebateprice");
    addpriceUpdatedSet1("tprebatepricemax");
    addpriceUpdatedSet1("tpclubprice");
    
    
}
function addpriceUpdatedSet1(priceid)
{
    var tmp;
    for(var i=1; i<maxcpriceNum; i++)
    {
        for(var j=0; j<maxRowNum; j++)
        {
            tmp = document.getElementById(priceid + j.toString() + "-" + i.toString());
            if (tmp)
            {
                priceUpdated[priceIndex] = tmp.id;
                priceIndex++;
            }
        }
    }

}
function addgridpriceUpdatedSet1(priceid)
{
    var tmp;
    for(var i=1; i<maxgcpriceNum; i++)
    {
        for(var j=0; j<maxRowNum; j++)
        {
            tmp = document.getElementById(priceid + j.toString() + "-" + i.toString());

            if (tmp)
            {
                priceUpdated[priceIndex] = tmp.id;
                priceIndex++;
            }
        }
    }

}

function addpriceUpdatedSet(priceid)
{
    var tmp;
    for(var i=1; i<maxcpriceNum; i++)
    {
        tmp = document.getElementById(priceid + i.toString());
        if (tmp)
        {
            priceUpdated[priceIndex] = priceid + i.toString();
            priceIndex++;
        }
    }

}
function addgridpriceUpdatedSet(priceid)
{
    var tmp;
    for(var i=1; i<maxgcpriceNum; i++)
    {
        tmp = document.getElementById(priceid + i.toString());
        if (tmp)
        {
            priceUpdated[priceIndex] = priceid + i.toString();
            priceIndex++;
        }
    }

}
function addpriceUpdated(priceid)
{
    var tmp = document.getElementById(priceid);

    if (tmp)
    {
        priceUpdated[priceIndex] = priceid;
        priceIndex++;
    }

}  
function findPricePart(word) {
     var tmp = word;
     var ndx = word.indexOf("$");
     if (ndx > -1) {
         tmp = word.substr(ndx, word.length - ndx);
         var str = tmp.split(/\s/g);
         tmp = getInitPrice(str[0]);
         tmp = word.replace(str[0], tmp);
     }

     return tmp;
 }
 
function getInitPriceMultipricing(price)
{
    var tmp = (((price.toLowerCase().replace("<br>", " <br>")).replace("</br>", " </br>")).replace("<br />", " <br />")).replace("<br/>", " <br/>");
    return getInitPriceSaving(tmp);
}
function getInitPriceSaving(price) {
  var tmp = price.split(/\s/);
  var newprice= "";
  for (var i = 0; i < tmp.length; i++) {
    if (tmp[i].indexOf("$")>-1)
    {
        newprice += " " + getInitPrice(tmp[i]);
    }
    else
    {
        newprice += " " + tmp[i];
    }   
  }
  return newprice;
}

function getInitPriceByRate(price)
{
    price = price.replace(/,/g, "");
    
    price = (price * defaultRate/defaultTypeInfo.Rate).toFixed(2).toString();
    
    var  tmp = price.split(".");
    if (tmp[0].length>3)
    {
        price = tmp[0].substr(0, tmp[0].length-3) + "," + tmp[0].substr(tmp[0].length-3, 3);
        var tmp1 = "00";
        if (tmp.length > 1)
            tmp1 = tmp[1];
        price += "." + tmp1;
    }
    return price;
}
function getPriceNumber(price) {

    if (price.indexOf("$") > -1)
        price = price.replace("$", "");
    if (price.indexOf("€") > -1)
        price = price.replace("€", "");
    if (price.indexOf("£") > -1)
        price = price.replace("£", "");
    return price;
}
function getInitPrice(price) {
     var formatPrice;
     var negative = false;
     price = getPriceNumber(price);
     if (price.indexOf("-") > -1)
     {
         price = price.replace("-", "");
         negative = true;
     }
         
     price = getInitPriceByRate(price);
     var tmp = price.toString().split(".");
     var tmp1 = "00";
     if (tmp.length > 1)
         tmp1 = tmp[1];
     if (defaultTypeInfo.DecimalSeparator == "~")
         defaultTypeInfo.DecimalSeparator = ",";
     if (defaultTypeInfo.ThousandSeparator=="~")
            defaultTypeInfo.ThousandSeparator = ",";
     var tmp2;
     if (tmp[0].indexOf(",")>0)
     {
        tmp2 = tmp[0].replace(",", defaultTypeInfo.ThousandSeparator);
     }
     else
     {
        if (tmp[0].length>3)
        { 
            tmp2 = tmp[0].substr(0, tmp[0].length-3) + defaultTypeInfo.ThousandSeparator + tmp[0].substr(tmp[0].length-3);
        }
        else
            tmp2 =tmp[0];
     }
     
     //formatPrice = tmp2 + defaultTypeInfo.DecimalSeparator + tmp1;
     if(negative)
         formatPrice = '-' + tmp2 + defaultTypeInfo.DecimalSeparator + tmp1;
     else
         formatPrice = tmp2 + defaultTypeInfo.DecimalSeparator + tmp1;
     
     if (defaultTypeInfo.SymbolPrefix == true) {
         formatPrice =  defaultTypeInfo.Symbol + formatPrice;
     }
     else {
         formatPrice = formatPrice + defaultTypeInfo.Symbol;
     }
     return formatPrice;
 }
function setInitPrice()
{
    currencydisplay = true;
    setpriceUpdated();

    if (priceUpdated.length>0)
    {
    
        for(var i=0; i< priceUpdated.length; i++)
        {
            var priceid = document.getElementById(priceUpdated[i]);

            if (priceid.id.indexOf("ctl00_lblCartTotal") != -1 || priceid.id.indexOf("saving") != -1 || priceid.id.indexOf("ekitprice") != -1 || priceid.id.indexOf("addph") != -1 || priceid.id.indexOf("custpriceperchar") != -1)
            {
                priceid.innerHTML = getInitPriceSaving(priceid.innerHTML);
            }
            else if (priceid.id.indexOf("multipricing") != -1)
            {
                priceid.innerHTML = getInitPriceMultipricing(priceid.innerHTML);
            }
            else if (priceid.id.indexOf("priceoverride") != -1) 
            {
                priceid.value = removeHTMLEntities(getInitPrice("0"));
            }
            else
            {  
                priceid.innerHTML = getInitPriceSaving(priceid.innerHTML);
            }
        }
    }
    //addpriceupdatedoncart();
    setpriceUpdatedDdl();
}

function addpriceupdatedoncart() {
    $('[class^="DC"]').each(function () {

        if ($(this).find("label").html() != null && $(this).find("label").html() != "undefined") {            
            if ($(this).find("label").html().indexOf(defaultTypeInfo.Symbol) > -1)
            $(this).find("label").html($(this).text()); // = getUpdatedPriceSaving($(this).find("Label").html(), result);
        }
        else {
            priceUpdated[priceIndex] = $(this).text();
            priceIndex++;
        }
    });
}

function addpriceupdatedoncart(result) {
    var p;
    if (result != null && result != undefined)
        p = jQuery.extend(true, {}, result);
        
    var i=0;
    $('[class^="DC"]').each(function () {
        if ($(this).find("label").html() != null && $(this).find("label").html() != "undefined") {
            
            if ($(this).find("label").html().indexOf(defaultTypeInfo.Symbol) > -1) {
                $(this).find("label").html(getUpdatedPriceSaving($(this).text(), p)); // = getUpdatedPriceSaving($(this).find("Label").html(), result);
            }
        }
        else {    
            if ($(this).attr("class") == "EzPayBig" || $(this).html().indexOf(defaultTypeInfo.Symbol) > -1) {
                $(this).html(getUpdatedPriceSaving($(this).text(), p));
            }
        }
    });

}


function onSuccess(result)//return culture
{
    setpriceUpdated();
    if (result != "undefined") {
        newTypeInfoSet = result.split("^");
        prc = document.getElementById("ctl00_lblCartTotal");
        if (prc) {
            prc.innerHTML = getUpdatedPriceSaving(prc.innerHTML, result);
        }

        prc = document.getElementById("ctl00_lblFreeShpMsg");
        if (prc)
            prc.innerHTML = getUpdatedPriceSaving(prc.innerHTML, result);
        prc = document.getElementById("ctl00_ContentPlaceHolder1_cart_lblshipfee");
        if (prc)
            prc.innerHTML = getUpdatedPriceSaving(prc.innerHTML, result);
        
        prc = document.getElementById("ctl00_lblEasyPayTag");
        if (prc)
            prc.innerHTML = getUpdatedPriceSaving(prc.innerHTML, result);


        prc = document.getElementById("ctl00_ContentPlaceHolder1_cart_lblsubtot"); //'ctl00_ContentPlaceHolder1_cart_lblsubtot'
        if (prc) {
            prc.innerHTML = getUpdatedPriceSaving(prc.innerHTML, result);
        }
        prc = document.getElementById("ctl00_ContentPlaceHolder1_cart_lbldiscount"); //'ctl00_ContentPlaceHolder1_cart_lbldiscount'
        if (prc) {
            prc.innerHTML = getUpdatedPriceSaving(prc.innerHTML, result);
        }
        prc = document.getElementById("ctl00_ContentPlaceHolder1_cart_lbltotal"); //'ctl00_ContentPlaceHolder1_cart_lbltotal'
        if (prc) {
            prc.innerHTML = getUpdatedPriceSaving(prc.innerHTML, result);
        }
        prc = document.getElementById("webprice"); //'ctl00_ContentPlaceHolder1_cart_lbltotal'
        if (prc) {
            prc.innerHTML = getUpdatedPriceSaving(prc.innerHTML, result);
        }
        prc = document.getElementById("ctl00_ContentPlaceHolder1_cart_lblShippingChrg"); //'ctl00_ContentPlaceHolder1_cart_lbltotal'
        if (prc && prc.innerHTML.indexOf("Free") < 0) {
        
            prc.innerHTML = getUpdatedPriceSaving(prc.innerHTML, result);
        }
        
        addpriceupdatedoncart(result);

        defaultTypeInfo.Type = newTypeInfoSet[5];  
        defaultTypeInfo.Symbol = newTypeInfoSet[0];   
        defaultTypeInfo.SymbolPrefix = newTypeInfoSet[1]; 
        if (defaultTypeInfo.SymbolPrefix=="True")
            defaultTypeInfo.SymbolPrefix = true;
        else
            defaultTypeInfo.SymbolPrefix = false;        
        defaultTypeInfo.DecimalSeparator = newTypeInfoSet[2];  
        defaultTypeInfo.ThousandSeparator = newTypeInfoSet[3];  
        defaultTypeInfo.Rate = newTypeInfoSet[4];
    } 
}
function onError(error) {
    //alert(error.get_message());
}
function isNumberKey(evt)
{
    var charCode = (evt.which) ? evt.which : event.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57))
		return false;    
    return true;
}

function isNumberKeyQty(evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;
    if (charCode == 13) {
        var update = '';
        var lineno = '';
        $("input[name='txtQty']").each(function () {

            lineno = $(this).attr("id").substring($(this).attr("id").indexOf('-', 0) + 1);
            update += lineno + "-" + $(this).val() + "-" + ($("#chkdelete-" + lineno).val() == 1 ? 'True' : 'False') + ";";
        });

        $("#ctl00_ContentPlaceHolder1_cart_hdnUpdQty").val('');
        $("#ctl00_ContentPlaceHolder1_cart_hdnUpdQty").val(update);
        $("#ctl00_ContentPlaceHolder1_cart_hdncartneedupd").val('true');
        $("#ctl00_ContentPlaceHolder1_btnUpdateBot").click(); return true;
    }

    return true;
}

function removeHTMLEntities(inputString)
{
    var div = document.createElement('div');
    div.innerHTML = inputString;
    return div.innerHTML;
}


function getUpdatedPriceSaving(price, r) {

    var result;
    if (r != null && r != "undefined")
        result = jQuery.extend(true, {}, r);
    
    var pattern = /\d+/i;
    var pattern1 = /-/i;
    var tmp = price.split(/\s/);
    var newprice = "";

    defaultTypeInfo.Symbol = removeHTMLEntities(defaultTypeInfo.Symbol);
    if (tmp[0].indexOf(defaultTypeInfo.Symbol) > -1) {
        for (var i = 0; i < tmp.length; i++) {
            if (i == 0) {
                if (tmp[i].indexOf(defaultTypeInfo.Symbol) > -1)
                    newprice += tmp[i];
                    else
                        newprice += " " + tmp[i];
            }
            else if ((tmp[i - 1].search(pattern) > -1 && tmp[i - 1].search(pattern1) == -1) || (tmp[i].search(pattern) > -1 && tmp[i].search(pattern1) == -1 && tmp[i - 1].indexOf(defaultTypeInfo.Symbol) > -1)) {
                newprice += tmp[i];
            }
            else {
                newprice += " " + tmp[i];
            }
        }
    }
    if (tmp.length == 2 && tmp[1].indexOf(defaultTypeInfo.Symbol) > -1)
        newprice = tmp[1] + " " + tmp[0];
    tmp = newprice.split(/\s/);
    
    newprice = "";
    var t = "";
    var b = false;
    if (tmp.length == 2 && (tmp[0] == defaultTypeInfo.Symbol)) {
        t = tmp[0] + "" + tmp[1];
        newprice += " " + getUpdatedPrice(t, result);
    }
    else if (tmp.length == 2 && ( tmp[1] == defaultTypeInfo.Symbol)) {
        t = tmp[1] + "" + tmp[0];
        newprice += " " + getUpdatedPrice(t, result);
    }
    else {
        for (var i = 0; i < tmp.length; i++) {
            if (tmp[i] == defaultTypeInfo.Symbol) {
                b = true;
                break;
            }
            if (tmp[i].indexOf(defaultTypeInfo.Symbol) > -1) {
                newprice += " " + getUpdatedPrice(tmp[i], result);
            }
            else {
                newprice += " " + tmp[i];
            }
        }
    }
        
    return newprice;
}
function getUpdatedPrice(orig, result) {

        if (result == undefined)
            return "";

        var tt = defaultTypeInfo.Symbol;
        if (tt == orig && defaultTypeInfo.Type != 1)
             return "";
        var negative = false;
        
        if (orig.indexOf("-") > -1)
        {
             orig = orig.replace("-", "");
             negative = true;
        }
        
        var update = orig;

        var symbolLength = tt.length;

        if (tt.substring(2, 0) == "&#") {
            symbolLength = 1;
        }

        if (orig.indexOf(defaultTypeInfo.Symbol) == 0) {
            orig = orig.substr(symbolLength, orig.length);
        }
        else {
            orig = orig.substr(0, orig.length - symbolLength);
        }

        if (orig != "0" && orig != "") 
        {
            if (defaultTypeInfo.DecimalSeparator == "~")
                defaultTypeInfo.DecimalSeparator = ",";

            var updateset = orig.split(defaultTypeInfo.DecimalSeparator);
            if (defaultTypeInfo.ThousandSeparator == "~")
                defaultTypeInfo.ThousandSeparator = ",";

            if (updateset[0].indexOf(defaultTypeInfo.ThousandSeparator) > -1)
                updateset[0] = updateset[0].replace(defaultTypeInfo.ThousandSeparator, "");

            update = updateset[0] + "." + updateset[1];
        }
        else
            update = "0";
        
        var asFloat = defaultTypeInfo.Rate;

        if (update != null && update.length > 1) {
            if (update.indexOf(defaultTypeInfo.Symbol) > -1)
                update = update.replace(defaultTypeInfo.Symbol, "");
        }
        
        update = (update * asFloat/newTypeInfoSet[4]).toFixed(2);
        
        updateset = update.split(".");
        if (updateset[0].length > 3)
        {
            updateset[0] = updateset[0].substr(0, updateset[0].length -3) +   newTypeInfoSet[3] + updateset[0].substr(updateset[0].length -3, 3);
        }
        
        update =  updateset[0] +  newTypeInfoSet[2] + updateset[1];
            
        if (newTypeInfoSet[1]=='True')
        {
           update = newTypeInfoSet[0] +  update;
        }
        else
        {
           update = update + newTypeInfoSet[0];
       }
        
        if (negative)
            update = '-' + update;
        
        return update;
    }      

function setPostBackPrice()
{
    if (!currencydisplay)
       return;

    priceUpdatedPostback = new Array();
    priceIndexPostback = 0;

    addpriceUpdatedPostback("retailprice");
    addpriceUpdatedPostback("percsaving");
    addpriceUpdatedPostback("webprice");
    addpriceUpdatedPostback("surchrg");
    addpriceUpdatedPostback("exclvatprice");
    addpriceUpdatedPostback("inclvatprice");
    addpriceUpdatedPostback("exclvatsurchrg");
    addpriceUpdatedPostback("inclvatsurchrg");
    addpriceUpdatedPostback("rebateprice");
    addpriceUpdatedPostback("priceoverride");
    addpriceUpdatedPostback("pricematch");
    addpriceUpdatedPostback("clubprice");
    addpriceUpdatedPostback("clubpercsaving");
    addpriceUpdatedPostback("addph");
    addpriceUpdatedSetPostback("multipricing");
    
    if (priceUpdatedPostback.length>0)
    {
    
        for(var i=0; i< priceUpdatedPostback.length; i++)
        {
            var priceid = document.getElementById(priceUpdatedPostback[i]);
         
            if (priceid.id.indexOf("saving") != -1 || priceid.id.indexOf("addph") != -1)
            {
                priceid.innerHTML = getInitPriceSaving(priceid.innerHTML);
            }
            else if (priceid.id.indexOf("multipricing") != -1)
            {
                priceid.innerHTML = getInitPriceMultipricing(priceid.innerHTML);
            }
            else if (priceid.id.indexOf("priceoverride") != -1) 
            {
                priceid.value = removeHTMLEntities(getInitPrice("0"));
            }
            else
            {  
                priceid.innerHTML = getInitPrice(priceid.innerHTML);
            }
        }  
    }
}

function addpriceUpdatedSetPostback(priceid)
{
    var tmp;
    for(var i=1; i<maxcpriceNum; i++)
    {
        tmp = document.getElementById(priceid + i.toString());
        if (tmp)
        {
            priceUpdatedPostback[priceIndexPostback] = priceid + i.toString();
            priceIndexPostback++;
        }
        else
        {
            break;
        }
    }

}
function addpriceUpdatedPostback(priceid)
{
    var tmp = document.getElementById(priceid);
    if (tmp)
    {
        priceUpdatedPostback[priceIndexPostback] = priceid;
        priceIndexPostback++;
    }

}


