﻿function limitChars(textArea, limit, infodiv) {
    var text = $(textArea).val();
    var textlength = text.length;

    if(textlength >= limit) {
        $('#' + infodiv).html('0');
        $(textArea).val(text.substr(0, limit));
        return false;
    } else {
        $('#' + infodiv).html((limit - textlength));
        return true;
    }
}

function CheckAll(divClass) {
    $('div.' + divClass + ' input[@type=\'checkbox\']').each(function() {
        if ($(this).is(':checked'))
            $(this).removeAttr('checked');
        else
            $(this).attr('checked', 'checked');
    });
}

function ShowConfirm() {
    return confirm("You have unpaid items, would you like to continue and lose your unpaid for items?")
}

function moveMeToTop() {
    $(document).ready(function() {
        $('.moveMeToTop').each(function(i) {
            $('body form').before(this);
        });
    });
}

function RedirectAfterTimeout(secTimeout, url) {
    document.write("<meta http-equiv='Refresh' content='" + secTimeout + "; URL=" + url + "' />");
}