﻿function getAddonInfo(pId) {
    ret = GoLondonService.GetAddonDescription(pId, getAddonOnSuccess, getAddonOnFail, null);
    return false;
}
function getAddonOnSuccess(args) {
    $('addon_text').innerHTML = args;
    $('addon_info').appear();
}
function getAddonOnFail() {
    $('addon_text').innerHTML = 'Ingen tilleggsinformasjon';
    $('addon_info').appear();
}
function addzero(value) {
    while (value.length < 2) value = String("0") + value;
    return value;
}
function checkName() {
    if ($('newlocation').style.display != 'none') {
        if ($('ctl00_ContentPlaceHolder1_txtNewLocation').value == '') {
            alert('Du må fylle ut navn');
            return false;
        }
    }
}

function checkDateOrder(frm, ci_day, ci_month_year, co_day, co_month_year) {
    if (document.getElementById) {
        var frm = document.getElementById(frm);
        // create date object from checkin values
        // set date to 12:00 to avoid problems with one
        // date being wintertime and the other summertime
        var checkin_day = document.getElementById('b_checkin_day');
        var checkin_month = document.getElementById('b_checkin_month');
        var checkout_day = document.getElementById('b_checkout_day');
        var checkout_month = document.getElementById('b_checkout_month');

        var my = checkin_month.value.split("-");
        var ci = new Date(my[0], my[1] - 1, checkin_day.value, 12, 0, 0, 0);

        // create date object from checkout values
        my = checkout_month.value.split("-");
        var co = new Date(my[0], my[1] - 1, checkout_day.value, 12, 0, 0, 0);

        // if checkin date is at or after checkout date,
        // add a day full of milliseconds, and set the
        // selectbox values for checkout date to new value
        if (ci >= co) {
            co.setTime(ci.getTime() + 1000 * 60 * 60 * 24);
            checkout_day.value = co.getDate();
            var com = co.getMonth() + 1;
            checkout_month.value = co.getFullYear() + "-" + com;
        }
    }
}