// Javascript from Moodle modules
wrs_addEvent(window, 'load', function () {
    wrs_imageAlignFix();
});
/* Image align bug: "align" attribute is not standard, so there are browsers that does not support it. */
function wrs_imageAlignFix() {
    var images = document.getElementsByTagName('img');
	
    for (var i = images.length - 1; i >= 0; --i) {
        if (images[i].className == 'Wirisformula') {
            images[i].style.verticalAlign = (-images[i].height / 2) + 'px';
        }
    }
}
/* Tools */
/**
 * Cross-browser addEventListener/attachEvent function.
 * @param object element Element target
 * @param event event Event
 * @param function func Function to run
 */
function wrs_addEvent(element, event, func) {
    if (element.addEventListener) {
        element.addEventListener(event, func, false);
    }
    else if (element.attachEvent) {
        element.attachEvent('on' + event, func);
    }
}/**
 * JavaScript for checking or unchecking 
 * all the students or all students in a group.
 *
 * @param toggle Check All/None
 * @param start the first checkbox to be changed
 * @param end the last checkbox to be changed
 * return boolean
 **/
function block_quickmail_toggle(toggle, start, end) {
    // Element ID
    var id = 'mailto'+start;

    // iterate through all of the appropriate checkboxes and change their state
    while(document.getElementById(id) && start != end) {
        document.getElementById(id).checked = toggle;
        start++;
        id = 'mailto'+start;
    }

    return false;
}
