﻿var _startele = null;
var _startDate = "";
var btnNavAvail = null;
var ReadOnly = null;
var WHID=0;

function LoadAvailability(uid, olnk) {
    //only used when loaded upon specific request
    if (!SITE.BUSY) {
        SITE.BUSY = true;
        var _o = GEID("AvailabilityHolder");
        show(_o);
        _o.style.left = findPosX(olnk) + 50 + "px";
        _o.style.top = findPosY(olnk) + "px";
        show(_o);
        ReadOnly = true;
        Wait("workhours_readonly");
        Service.GetAvailability(uid, "", true, renderHours);
    }
}

function showAvailability(uid, btn, startDate, readonly) {
    if (!SITE.BUSY) {
        SITE.BUSY = true;
        _startDate = startDate;
        ReadOnly = readonly;
        Service.GetAvailability(uid, _startDate, readonly, renderHours);
    }
}

function renderHours(o) {
    SITE.BUSY = false;
    if (ReadOnly)
        GEID("workhours_readonly").innerHTML = o;
    else
        GEID("workhours").innerHTML = o;
}
function trover(o) {
    if (o.className == "trquiet")
        o.className = "trquiet chl";
}
function trout(o) {
    o.className = o.className.replace(" chl", "");
}

var csvCost = "";
function CalcPrice() {
    var iPeople=SelectedValue(ddlPeople);
    Service.CreditsTotalGet(BookingTypeID, iPeople,ShowCreditPrice);    
}
function ShowCreditPrice(o) {
    GEID("Cost").innerHTML = o;
}
function book(o, c, w) {
    try {
        obook.className = obook.className.replace(" select", "");
    }
    catch (e) { }

    currenttime = c;
    SetTime();

    WHID = w;
    o.className += " select";
    obook = o;
}

function SetTime() {
    var minutes = SelectedValue(ddlMinutes);
    if (currenttime != "")
        Service.GetTime(currenttime, minutes, ShowTime);
}
function ShowTime(o) {
    GEID("txtBookingTime").value = o;
}
function changetime() {
    var minutes = SelectedValue(ddlMinutes);
    SetTime();
}

