﻿/// <reference path="jquery.js"/>  

function init() {
    ajaxMoods();
    ajaxGamercard();
}

function ajaxMoods() {

    $.ajax({
        url: "/external/ajax/MoodsRequest.aspx", cache: false,
        success: function(html) {

            if (html != "error") {
                var array = html.split("<br />");
                var isFirst = true;
                for (var i = 0; i < array.length - 1; i++) {

                    var backgroundColor = "";

                    if (array[i].split(";")[1] <= 7) {
                        backgroundColor = "#99BB99";
                    } else {
                        backgroundColor = "#BB9999";
                    }


                    if (isFirst) {
                        $("#MoodsList").append("<div class='moodsBox'><div style='background-color:" + backgroundColor + ";color:#FFFFFF;padding:0px 0px 1px 5px;font-weight:bold;'>" + array[i].split(";")[1] + "</div><div style='margin:5px;'>" + array[i].split(";")[3] + "</div></div>");
                        isFirst = false;
                    } else {
                        $("#MoodsList").append("<div class='moodsBox'><div style='background-color:" + backgroundColor + ";color:#FFFFFF;padding:0px 0px 1px 5px;font-weight:bold;'>" + array[i].split(";")[1] + "</div><div style='margin:5px;'>" + array[i].split(";")[3] + "</div></div>");
                    }

                }
            } else {
                $("#MoodsList").append("<div class='moodsBox'><div style='background-color:#666666;color:#FFFFFF;padding:0px 0px 1px 5px;font-weight:bold;'>Error</div><div style='margin:5px;'>Connection Problem</div></div>");
            }
        }
    });

}

function ajaxGamercard() {

    $.ajax({
        url: "/external/ajax/GamercardReqeust.aspx",
        success: function(html) {
            $("#eibxGamercard").append(html);
        }
    });

}