jQuery.noConflict();

// Timetible transposed matrix
var days = jQuery("td.th_normal[valign]")
var time = jQuery("td.th_normal[width=125]")
var classes = jQuery("td.entry_other, td.entry_interest, td.entry_null")
var temp = "";

for (var i = 0; i < 5; i++) {
    temp = time.get(i).innerHTML;
    time.get(i).innerHTML = days.get(i).innerHTML;
    days.get(i).innerHTML = temp;
}

for (var i = 1; i < 5; i++) {
    for (var j = 0; j < i; j++) {
        temp = classes.get(i*5+j).innerHTML;
        classes.get(i*5+j).innerHTML = classes.get(j*5+i).innerHTML;
        classes.get(j*5+i).innerHTML = temp;
        temp = classes.get(i*5+j).className;
        classes.get(i*5+j).className = classes.get(j*5+i).className;
        classes.get(j*5+i).className = temp;
    }
}

// Old groups
if (location.href == "https://student.iimc.kyoto-u.ac.jp/iwproxy/KULASIS/student/la/entry/zenki") {
    var classes = jQuery("td.entry_interest")
    var links = classes.find("a#id_a_1172_0");
    for (var i = 0; i < links.size(); i++) {
        var url = links.get(i).getAttribute("href");
        if (url.indexOf("/iwproxy/KULASIS/student/la/support/top?") == 0) {
            jQuery.ajax({
                url: url,
                context: classes.get(i),
            }).done(function(data, textStatus, jqXHR) {
                var c = jQuery(this).html().split("<br>");
                c[3] = c[3] + " (" + jQuery(data).find("td.odd_normal").get(5).innerHTML.replace(/^\s+/, "") + ")";
                jQuery(this).html(c.join("<br>"));
            });
        }
    }
}

