﻿//GENERAL FUNCTIONS
function tryParseInt(str, defaultValue) {
    if (defaultValue == null) {
        defaultValue = 0;
    }
    var returnVal = parseInt(str);
    if (returnVal.toString() == "NaN") {
        returnVal = defaultValue;
    }
    return returnVal;
}
function padWithZeros(number, length) {
    var returnVal = number.toString();
    while (returnVal.length < length) {
        returnVal = '0' + returnVal;
    }
    return returnVal;
}
function setCookie(name, value, expireHours) {
    var expirationDateTime = new Date();
    expirationDateTime.setHours(expirationDateTime.getHours() + expireHours, expirationDateTime.getMinutes(), expirationDateTime.getSeconds(), expirationDateTime.getMilliseconds());
    document.cookie = name + "=" + escape(value) + (expireHours != null ? ";expires=" + expirationDateTime.toUTCString() : "");
}
function getCookie(name) {
    var cookieRegEx = new RegExp(name + "=([^;]*)");
    var result = document.cookie.match(cookieRegEx);
    if (result != null) {
        return unescape(RegExp.$1);
    }
    else {
        return null;
    }
}
