﻿var currentServerID;
function MM_swapImgRestore(){ //v3.0
    var i, x, a = document.MM_sr;
    for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) 
        x.src = x.oSrc;
}

function MM_preloadImages(){ //v3.0
    var d = document;
    if (d.images) {
        if (!d.MM_p) 
            d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments;
        for (i = 0; i < a.length; i++) 
            if (a[i].indexOf("#") != 0) {
                d.MM_p[j] = new Image;
                d.MM_p[j++].src = a[i];
            }
    }
}

function MM_findObj(n, d){ //v4.01
    var p, i, x;
    if (!d) 
        d = document;
    if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document;
        n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) 
        x = d.all[n];
    for (i = 0; !x && i < d.forms.length; i++) 
        x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) 
        x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) 
        x = d.getElementById(n);
    return x;
}

function MM_swapImage(){ //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments;
    document.MM_sr = new Array;
    for (i = 0; i < (a.length - 2); i += 3) 
        if ((x = MM_findObj(a[i])) != null) {
            document.MM_sr[j++] = x;
            if (!x.oSrc) 
                x.oSrc = x.src;
            x.src = a[i + 2];
        }
}

function removeOption(selectId){
    var objSelect = document.getElementById(selectId);
    if (objSelect.options.length > 0) {
        objSelect.options.length = 0;
    }
}

function addOption(selectId, txt, val){
    var objSelect = document.getElementById(selectId);
    var objOption = new Option(txt, val);
    objSelect.options.add(objOption);
}

function TabbedPanels(layerId){
    var obj = document.getElementById(layerId);
    obj.style.backgroundImage = './images/index_06_1.jpg';
    switch (layerId) {
        case 'ItemCategories':
            document.getElementById('Profession').style.backgroundImage = './images/index_06_3.jpg';
            break;
        case 'Profession':
            document.getElementById('ItemCategories').style.backgroundImage = './images/index_06_3.jpg';
            break;
    }
}

function usedCode(itemPrice, coupon, discount){
    if (Number(discount) > 5) {
        discount = 5;
    }
    if ((itemPrice * 0.05 - coupon) > 0) {
        var getPrice = Math.round(((Number(itemPrice) - Number(coupon)) * ((100 - Number(discount)) / 100)) * 100) / 100
    }
    else {
        var getPrice = Math.round(((Number(itemPrice) - (Number(itemPrice) * 0.05)) * ((100 - Number(discount)) / 100)) * 100) / 100
    }
    return getPrice;
}

function usedTureCode(itemPrice, coupon, discount){
	if (Number(discount) >= 10) {
        discount = 10;
    }
    if ((itemPrice * 0.05 - coupon) > 0) {
        var getPrice = Math.round(((Number(itemPrice) - Number(coupon)) * ((100 - Number(discount)) / 100)) * 100) / 100
    }
    else {
        var getPrice = Math.round(((Number(itemPrice) - (Number(itemPrice) * 0.05)) * ((100 - Number(discount)) / 100)) * 100) / 100
    }
    return getPrice;
}

function useCode(key){
    if (key != '')
	{        
		var cartName = document.getElementById("cart").value;
        YouthyAjax.CheckDiscountCode(gameName, key, cartName, CallBack);
    }
    else 
	{
        document.getElementById('getDiscountMsg').className = 'textfieldRequiredState';
    }
	function CallBack(response)
	{
		if(response != null && response.value != null && response.value != 0)
		{
			var discountValue = response.value;
			var frm = document.getElementById('checkBuyForm');
			var orgPrice = Number(document.getElementById('orgPrice').value);
			var price = Number(document.getElementById('promotionPrice').value);
			var CashCoupor="0";
			try
			{
			CashCoupor=Number(document.getElementById('inCashCoupor').value);
			}
			catch(ex)
			{
			alert('1');
			}
			//var CashCouporReturn=Number(document.getElementById('showTotal').value);
			var Probability="0";
			try
			{
			Probability=Number(document.getElementById('hidProbability').value);
			}
			catch(ex)
			{
			
			}
			
			try
			{
			document.getElementById('showTotal').innerHTML = (price - discountValue-CashCoupor).toFixed(2);
			}
			catch(ex)
			{		
			}
			try
			{
			document.getElementById('showDiscount').innerHTML = (orgPrice - price + discountValue).toFixed(2);
			}
			catch(ex)
			{		
			}
			try
			{
			document.getElementById('spanCashCouporReturn').innerHTML = ((price - discountValue-CashCoupor)*Probability).toFixed(2);
			}
			catch(ex)
			{
			}
			document.getElementById('showDiscountDiv').style.display = 'block';

		}
		else 
		{
			document.getElementById('discountCode').value = "";
			document.getElementById('discountCode').readonly = false;
			alert('Invalid Code.');
		}
	}
}

function useCode1(key)
{
    if (key != '')
	{
		var cartName = document.getElementById("cart").value;
        YouthyAjax.CheckDiscountCode(gameName, key, cartName, CallBack);
    }
    else 
	{
        document.getElementById('getDiscountMsg').className = 'textfieldRequiredState';
    }
	function CallBack(response)
	{
		if(response != null && response.value != null && response.value != 0)
		{
			var discountValue = response.value;
			var frm = document.getElementById('checkBuyForm');
			var orgPrice = Number(document.getElementById('orgPrice').value);
			var price = Number(document.getElementById('promotionPrice').value);
			document.getElementById('showTotal').innerHTML = (price - discountValue).toFixed(2);
			document.getElementById('showDiscount').innerHTML = (orgPrice - price + discountValue).toFixed(2);
			document.getElementById('showDiscountDiv').style.display = 'block';
		}
		else 
		{
			document.getElementById('discountCode').value = "";
			document.getElementById('discountCode').readonly = true;
			alert('Invalid Code.');
		}
	}
}
function listCountry(gameId, targetId){
    var res = Ajax.call("./?op=jsonFunction&action=listCountry", 'gameId=' + gameId, false, 'POST', 'JSON', false);
    removeOption(targetId);
    addOption(targetId, 'Game\'s Server', '');
    for (var v in res) {
        addOption(targetId, res[v].countryName, res[v].countryId);
    }
}

function listServer(gameId, countryId){
    var res = Ajax.call("./?op=jsonFunction&action=listServer", 'gameId=' + gameId + '&countryId=' + countryId, false, 'POST', 'JSON', false);
    removeOption('serverName');
    addOption('serverName', '-Select Realm-', '');
    for (var v in res) {
        addOption('serverName', res[v].serverName, res[v].serverName);
    }
}

function listFaction(gameId){
    var res = Ajax.call("./?op=jsonFunction&action=listFaction", 'gameId=' + gameId, false, 'POST', 'JSON', false);
    removeOption('factionName');
    addOption('factionName', '-Select Faction-', '');
    for (var v in res) {
        addOption('factionName', res[v].factionName, res[v].factionName);
    }
}

function listClass(gameId){
    var res = Ajax.call("./?op=jsonFunction&action=listClass", 'gameId=' + gameId, false, 'POST', 'JSON', false);
    removeOption('classId');
    addOption('classId', 'Choose Class', '');
    for (var v in res) {
        addOption('classId', res[v].className, res[v].classId);
    }
}

function showHiddenTalant(getOption){
    switch (getOption) {
        case 'hidden':
            document.getElementById('talantId').style.display = 'none';
            document.getElementById('talantId').disabled = true;
            break;
        case 'display':
            document.getElementById('talantId').style.display = 'block';
            document.getElementById('talantId').disabled = false;
            break;
    }
}

function listTalant(gameId, className){
    if (gameId == 1) {
        showHiddenTalant('display');
        var res = Ajax.call("./?op=jsonFunction&action=listTalant", 'gameId=' + gameId + '&classId=' + className, false, 'POST', 'JSON', false);
        removeOption('talantId');
        addOption('talantId', 'Choose Talant', 0);
        for (var v in res) {
            addOption('talantId', res[v].talantName, res[v].talantId);
        }
    }
    else {
        showHiddenTalant('hidden');
    }
}

function listSlot(gameId){
    var res = Ajax.call("./?op=jsonFunction&action=listSlot", 'gameId=' + gameId, false, 'POST', 'JSON', false);
    removeOption('slotId');
    addOption('slotId', 'Choose Slot', '');
    for (var v in res) {
        addOption('slotId', res[v].slotName, res[v].slotId);
    }
}

function MM_effectAppearFade(targetElement, duration, from, to, toggle){
    Spry.Effect.DoFade(targetElement, {
        duration: duration,
        from: from,
        to: to,
        toggle: toggle
    });
    Spry.Effect.DoBlind(targetElement, {
        duration: duration,
        from: from,
        to: to,
        toggle: toggle
    });
    switch (targetElement) {
        case 'Hot_1':
            Spry.Effect.DoFade('Hot_2', {
                duration: duration,
                from: 0,
                to: 0,
                toggle: false
            });
            Spry.Effect.DoFade('Hot_3', {
                duration: duration,
                from: 0,
                to: 0,
                toggle: false
            });
            Spry.Effect.DoFade('Hot_4', {
                duration: duration,
                from: 0,
                to: 0,
                toggle: false
            });
            Spry.Effect.DoBlind('Hot_2', {
                duration: duration,
                from: 0,
                to: 0,
                toggle: toggle
            });
            Spry.Effect.DoBlind('Hot_3', {
                duration: duration,
                from: 0,
                to: 0,
                toggle: toggle
            });
            Spry.Effect.DoBlind('Hot_4', {
                duration: duration,
                from: 0,
                to: 0,
                toggle: toggle
            });
            break;
        case 'Hot_2':
            Spry.Effect.DoFade('Hot_1', {
                duration: duration,
                from: 0,
                to: 0,
                toggle: toggle
            });
            Spry.Effect.DoFade('Hot_3', {
                duration: duration,
                from: 0,
                to: 0,
                toggle: toggle
            });
            Spry.Effect.DoFade('Hot_4', {
                duration: duration,
                from: 0,
                to: 0,
                toggle: toggle
            });
            Spry.Effect.DoBlind('Hot_1', {
                duration: duration,
                from: 0,
                to: 0,
                toggle: toggle
            });
            Spry.Effect.DoBlind('Hot_3', {
                duration: duration,
                from: 0,
                to: 0,
                toggle: toggle
            });
            Spry.Effect.DoBlind('Hot_4', {
                duration: duration,
                from: 0,
                to: 0,
                toggle: toggle
            });
            break;
        case 'Hot_3':
            Spry.Effect.DoFade('Hot_2', {
                duration: duration,
                from: 0,
                to: 0,
                toggle: toggle
            });
            Spry.Effect.DoFade('Hot_1', {
                duration: duration,
                from: 0,
                to: 0,
                toggle: toggle
            });
            Spry.Effect.DoFade('Hot_4', {
                duration: duration,
                from: 0,
                to: 0,
                toggle: toggle
            });
            Spry.Effect.DoBlind('Hot_2', {
                duration: duration,
                from: 0,
                to: 0,
                toggle: toggle
            });
            Spry.Effect.DoBlind('Hot_1', {
                duration: duration,
                from: 0,
                to: 0,
                toggle: toggle
            });
            Spry.Effect.DoBlind('Hot_4', {
                duration: duration,
                from: 0,
                to: 0,
                toggle: toggle
            });
            break;
        case 'Hot_4':
            Spry.Effect.DoFade('Hot_2', {
                duration: duration,
                from: 0,
                to: 0,
                toggle: toggle
            });
            Spry.Effect.DoFade('Hot_3', {
                duration: duration,
                from: 0,
                to: 0,
                toggle: toggle
            });
            Spry.Effect.DoFade('Hot_1', {
                duration: duration,
                from: 0,
                to: 0,
                toggle: toggle
            });
            Spry.Effect.DoBlind('Hot_2', {
                duration: duration,
                from: 0,
                to: 0,
                toggle: toggle
            });
            Spry.Effect.DoBlind('Hot_3', {
                duration: duration,
                from: 0,
                to: 0,
                toggle: toggle
            });
            Spry.Effect.DoBlind('Hot_1', {
                duration: duration,
                from: 0,
                to: 0,
                toggle: toggle
            });
            break;
    }
}

function hotBuy(tagetId){
    var nod = document.getElementById(tagetId);
    nod.className = (nod.className == 'orange') ? 'orange3' : 'orange';
}

function creatCartList(TableID, moneyCode){
    if (!document.getElementById(TableID)) {
        var oBody = document.getElementById('myCartContent');
        var cartTable = '<table id="shoppinCartList" width="100%" border="0" cellspacing="0" cellpadding="0">';
        cartTable += '<tr align="center">';
        cartTable += '<td width="200">Name</td>';
		cartTable += '<td>Lvl</td>';
        cartTable += '<td>Picture</td>';
		cartTable += '<td>Price</td>';
        cartTable += '<td>Delivery</td>';
        cartTable += '<td>Quantity</td>';
        cartTable += '<td>&nbsp;</td>';
        cartTable += '</tr>';
        cartTable += '<tr align="center">';
        cartTable += '<td>&nbsp;</td>';
		cartTable += '<td>&nbsp;</td>';
		cartTable += '<td>&nbsp;</td>';
        cartTable += '<td align="right">Total:</td>';
        cartTable += '<td align="left">' + moneyCode + '&nbsp;<span id="cartTotalPrice"></span></td>';
        cartTable += '<td colspan="4"><a href="checkBuy.html" onclick="Main(\'Buy_CheckOut\');"><img src="./Public/images/checkOut.gif" border="0" /></a></td>';
        cartTable += '</tr>';
        cartTable += '</table>';
        oBody.innerHTML = cartTable;
    }
}

function addToCart(TableID, itemId, selectRow, singlePrice, singleQuantity, moneyCode, gameId, countryId){
	var cartName = document.getElementById("cart") ? document.getElementById("cart").value : "Cart"; 
    AjaxCommon.SaveItemToShoppingCart(itemId, singleQuantity, currentServerID, cartName, CallBack);
	function CallBack(response)
	{
		if(response != null && response.value != null && response.value == true)
		{
			LoadShoppingCart(cartName);
		}
		else
		{
			alert("Error!");
		}
	}
}

function removeItem(TableID, thisRowIndex, itemId, cartName){
	if(confirm("Are you sure remove this item from your shoppingcart!"))
	{
		var result = AjaxCommon.RemoveItemFromShoppingCart(itemId, cartName, CallBack);
	}
	function CallBack(response)
	{
		if(response != null && response.value != null && response.value == true)
		{
			LoadShoppingCart(cartName);
		}
		else
		{
			alert("Error!");
		}
	}
}

function LoadShoppingCart(cartName)
{
	if(document.getElementById("drpItemServer") != null)
	{
        currentServerID = document.getElementById("drpItemServer").value;
	}
    var cartHtml = "";
    var itemHtmlTemplate = "<tr><td>$ItemName$<font color=\"#ffff00\">$ItemQuantity$</font></td><td>$ItemLevel$</td><td><img height=\"40\" width=\"40\" border=\"0\" style=\"cursor: pointer;\" src=\"Public/images/INV/$ItemPic$\"/></td><td>< $ItemTime$Hr</td><td><font size=\"2\">$MoneyHtmlCode$ $SumPrice$</font></td><td><input type=\"button\" onclick=\"subtractOne($ItemIndex$,'$MoneyCode$','$ItemID$');saveCart($ItemIndex$,'$ItemID$', '$CartName$');\" value=\"-\" id=\"button\" name=\"button\" style=\"cursor: pointer;\"/> <input type=\"text\" readonly=\"\" value=\"$Quantity$\" size=\"2\" class=\"inputtext\" name=\"itemQuantity\" id=\"itemQuantity_$ItemIndex$\"/> <input type=\"button\" onclick=\"addOne($ItemIndex$,'$',$ItemID$);saveCart($ItemIndex$,$ItemID$,'$CartName$');\" value=\"+\" id=\"button\" name=\"button\" style=\"cursor: pointer;\"/></td><td><img border=\"0\" onclick=\"removeItem('shoppinCartList',$ItemIndex$,'$ItemID$','$CartName$');Main('Buy_Remove');\" style=\"cursor: pointer;\" title=\"Remove\" src=\"./Public/images/remove.jpg\"/><input type=\"hidden\" value=\"33.99\" id=\"singlePrice_$ItemIndex$\" name=\"singlePrice\"/><input type=\"hidden\" value=\"1\" id=\"singleQuantity_$ItemIndex$\" name=\"singleQuantity\"/></td></tr>";
	var itemHtml = "";
	var sumPrice = 0;
	var sumQuantity = 0;
	AjaxCommon.LoadShoppingCart(cartName, CallBack);
	function CallBack(response)
	{
		if(response != null && response.value != null)
		{
		    var itemIndex = 1;
		    var tbCart = response.value;
			for(var i = 0; i < tbCart.Rows.length; i ++)
			{
			    var tempItemHtml = itemHtmlTemplate;
				tempItemHtml = tempItemHtml.replace(/\$CartName\$/g, cartName);
				tempItemHtml = tempItemHtml.replace(/\$ItemID\$/g, tbCart.Rows[i]["ItemID"]);
				tempItemHtml = tempItemHtml.replace(/\$ItemName\$/g, tbCart.Rows[i]["NewItemName"]);
				tempItemHtml = tempItemHtml.replace(/\$ItemQuantity\$/g, tbCart.Rows[i]["ItemQuantity"] != 0 ? "× " + tbCart.Rows[i]["ItemQuantity"] : "");
				tempItemHtml = tempItemHtml.replace(/\$ItemTime\$/g, tbCart.Rows[i]["ItemDelivery"]);
				tempItemHtml = tempItemHtml.replace(/\$ItemPrice\$/g, tbCart.Rows[i]["ItemPrice"]);
				tempItemHtml = tempItemHtml.replace(/\$SumPrice\$/g, tbCart.Rows[i]["SumPrice"]);
				tempItemHtml = tempItemHtml.replace(/\$ItemLevel\$/g, tbCart.Rows[i]["MinLevel"] == "0" ? "1" : tbCart.Rows[i]["MinLevel"]);
				tempItemHtml = tempItemHtml.replace(/\$ItemPic\$/g, tbCart.Rows[i]["ItemImage"]);
				tempItemHtml = tempItemHtml.replace(/\$Quantity\$/g, tbCart.Rows[i]["Quantity"]);
				tempItemHtml = tempItemHtml.replace(/\$MoneyHtmlCode\$/g, tbCart.Rows[i]["MoneyCode"]);
				tempItemHtml = tempItemHtml.replace(/\$ItemIndex\$/g, itemIndex);
				itemHtml += tempItemHtml;
				sumQuantity += parseInt(tbCart.Rows[i]["Quantity"]);
				sumPrice += parseFloat(tbCart.Rows[i]["SumPrice"]);
				itemIndex ++;
			}
		}
		if(itemHtml != "")
		{
			var promotionPrice = sumPrice;
			var vipPrice = AjaxCommon.GetVipPrice(sumQuantity, sumPrice).value.toFixed(2);
			if(cartName == "PromotionCart")
			{
				promotionPrice = AjaxCommon.GetPromotionPrice(sumQuantity, sumPrice).value.toFixed(2);
			}
			sumPrice = parseFloat(parseFloat(sumPrice).toFixed(2));
			promotionPrice = parseFloat(promotionPrice) + parseFloat(vipPrice) - parseFloat(sumPrice);
			promotionPrice = parseFloat(promotionPrice).toFixed(2);
		    cartHtml = "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" id=\"shoppinCartList\"><tbody><tr align=\"center\"><td width=\"200\">Name</td><td>Lvl</td><td>Picture</td><td>Delivery</td><td>Price</td><td>Quantity</td><td> </td></tr>" + itemHtml + "<tr align=\"center\"><td> </td><td align=\"right\" colspan=\"2\">Total:</td><td align=\"left\" colspan=\"2\">" + tbCart.Rows[0]["MoneyCode"] + " <span id=\"cartTotalPrice\">" + (promotionPrice != sumPrice && promotionPrice != 0 ? "<del>" + sumPrice.toFixed(2) + "</del> &nbsp;" + promotionPrice : sumPrice.toFixed(2)) + "</span></td><td colspan=\"4\"><a onclick=\"Main('Buy_CheckOut');document.getElementById('cartform').submit();\" style=\"cursor:pointer;\"><img border=\"0\" src=\"./Public/images/checkOut.gif\"/></a></td></tr></tbody></table>";
		    document.getElementById("myCartContent").innerHTML = cartHtml;
		}
		else
		{
		    document.getElementById("myCartContent").innerHTML = "<img src=\"Public/images/cart.jpg\" border=\"0\" /><strong><font style=\"color:#FFF\">THERE IS NOTHING IN YOUR SHOPPING TROLLEY ATM</font></strong><img src=\"Public/images/end.jpg\" border=\"0\" />";
		}
	}
}

function addOne(id, moneyCode){
    var quantity = document.getElementById('itemQuantity_' + id);
    var targetValue = Number(quantity.value) + 1;
    quantity.value = targetValue;
}

function subtractOne(id, moneyCode){
    var quantity = document.getElementById('itemQuantity_' + id);
    var targetValue = Number(quantity.value);
    if (targetValue > 1) {
        quantity.value = targetValue - 1;
    }
}

function saveCart(id, itemId, cartName){
    var quantity = document.getElementById('itemQuantity_' + id).value;
	if(currentServerID == "")
	{
		currentServerID = 0;
	}
    var result = AjaxCommon.SaveItemToShoppingCart(itemId, quantity, currentServerID, cartName, CallBack);
	function CallBack(response)
	{
		if(response == null || response.value == null)
		{
			alert("Error!");
		}
		else
		{
			LoadShoppingCart(cartName);
		}
	}
}

function totalPrice(){
    var cartTotalPrice = document.getElementById('cartTotalPrice');
    var shoppinCartLength = Number(document.getElementById('shoppinCartList').rows.length);
    var getTotalPrice = 0;
    for (var i = 1; i < (shoppinCartLength - 1); i++) {
        var singlePrice = Number(document.getElementById('singlePrice_' + i).value);
        var quantity = Number(document.getElementById('itemQuantity_' + i).value);
        getTotalPrice += Math.round(singlePrice * quantity * 100) / 100;
    }
    cartTotalPrice.innerHTML = Math.round(getTotalPrice * 100) / 100;
}

function GameSelect(gameid)
{
    AjaxCommon.GetServerList(gameid, CallBack);
	function CallBack(response)
	{
	   var drpServer = document.getElementById("drpItemServer");
	   drpServer.options.length = 1;
	   for(var i = 0; i < response.value.Rows.length; i ++)
	   {
	       drpServer.options.add(new Option(response.value.Rows[i]["ServarName"], response.value.Rows[i]["ServerID"]));
	   }
	}
}

function SearchGameSelect(gameid, target)
{
    AjaxCommon.GetServerList(gameid, CallBack);
	function CallBack(response)
	{
	   var drpServer = document.getElementById(target);
	   drpServer.options.length = 1;
	   for(var i = 0; i < response.value.Rows.length; i ++)
	   {
	       drpServer.options.add(new Option(response.value.Rows[i]["ServarName"], response.value.Rows[i]["ServerID"]));
	   }
	   GetCharacterClassList(gameid);
	   GetCharacterSlot(gameid);
	}
}

function GetCharacterClassList(gameid)
{
    AjaxCommon.GetCharacterClassList(gameid, CallBack);
	function CallBack(response)
	{
	   var drpCharacterClass = document.getElementById("drpCharacterClass");
	   drpCharacterClass.options.length = 1;
	   for(var i = 0; i < response.value.Rows.length; i ++)
	   {
	       drpCharacterClass.options.add(new Option(response.value.Rows[i]["ClassName"], response.value.Rows[i]["ClassID"]));
	   }
	}
}

function GetCharacterTalant(classid)
{
    AjaxCommon.GetCharacterTalantList(classid, CallBack);
	function CallBack(response)
	{
	   var drpCharacterTalant = document.getElementById("drpCharacterTalant");
	   drpCharacterTalant.options.length = 1;
	   for(var i = 0; i < response.value.Rows.length; i ++)
	   {
	       drpCharacterTalant.options.add(new Option(response.value.Rows[i]["TalantName"], response.value.Rows[i]["TalantID"]));
	   }
	}
}

function GetCharacterSlot(gameid)
{
    AjaxCommon.GetCharacterSlotList(gameid, CallBack);
	function CallBack(response)
	{
	   var drpCharacterSlot = document.getElementById("drpCharacterSlot");
	   drpCharacterSlot.options.length = 1;
	   for(var i = 0; i < response.value.Rows.length; i ++)
	   {
	       drpCharacterSlot.options.add(new Option(response.value.Rows[i]["SlotName"], response.value.Rows[i]["SlotID"]));
	   }
	}
}