﻿function checkCustomPL() {
    startLevel = $.trim($("select[id$='DDL_CurrentLevel'] option:selected").text());
    endLevel = $.trim($("select[id$='DDL_DesiredLevel'] option:selected").text());
    var count = $("select[id$='DDL_DesiredLevel']")[0].length;
    if (parseInt(startLevel) < 1 || parseInt(startLevel) >= parseInt(endLevel)) {
        $("select[id$='DDL_DesiredLevel']")[0].selectedIndex = count - parseInt(startLevel) - 1;
    }
}
function RoleChange() {
    checkCustomPL();
    AjaxMethodPL.GetRolePriceInfo
    (
        parseInt($("input[id$='hdServiceConfigID']").val()),
        parseInt($("select[id$='DDL_CurrentLevel'] option:selected").text()),
        parseInt($("select[id$='DDL_DesiredLevel'] option:selected").text()),
        function(result) {
            if (null == result.error) {
                if (result.value != null) {
                    var princeInfo = eval(result.value);
                    $("span[mark='currencyMark']").text(princeInfo.CurrencyMark);
                    $("input[id$='tt_price']").val(princeInfo.Amount);
                    $("input[id$='tt_time']").val(princeInfo.Days);
                }
            }
        }
    )
}

function Add() {
    var ServiceConfigID = parseInt($("input[id$='hdServiceConfigID']").val());
    var CurrentLevelID = parseInt($("select[id$='DDL_CurrentLevel'] option:selected").val());
    var DesiredLevelID = parseInt($("select[id$='DDL_DesiredLevel'] option:selected").val());
    if (0 == CurrentLevelID || 0 == DesiredLevelID) {
        alert("Please select the service");
        return;
    }
    AjaxMethodPL.AddRoleOrder
    (
        ServiceConfigID,
        parseInt($("select[id$='DDL_CurrentLevel'] option:selected").text()),
        parseInt($("select[id$='DDL_DesiredLevel'] option:selected").text()),
        function(result) {
            //函数在common文件里
            AddTemp_CallBack(result);
        }
    )
}
var AText;
function KK() {
    $("span[name='price']").each(function() {
        var amount = $(this).text();
        AText = $(this);
        AjaxMethodPL.ToCurrentCurrency("USD", amount, function(result) {
            $(this).text(result);
        }
            );
    });
}