﻿/// <reference path="../jquery-1.4.1-vsdoc.js" />

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;
        //$("select[id$='DDL_CurrentLevel']")[0].selectedIndex = count - 2;
    }
}

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);
                    //$("#currencyMark").text(princeInfo.CurrencyMark);
                    $("#Amount").text(princeInfo.Amount);
                    $("#Times").text(princeInfo.Days);
                    $("#VipAmount").text(princeInfo.VipAmount);
                }
            }
        }
    )
}

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();
        //        var sign = text.substring(0, 1);
        //        var amount = text.substring(1, text.length);
        AText = $(this);
        AjaxMethodPL.ToCurrentCurrency("USD", amount, function (result) {
            $(this).text(result);
        }
            );
    });
}
