//General
/* general */
if (document.all) {
    var agt = navigator.userAgent.toLowerCase();
    ie  = true; moz = false; op = false;
    if (agt.indexOf("opera") != -1) { op = true; ie = false; moz = false; }
} else {
    ie = false; op = false; moz = true;
}

if (moz) {
    emulateEventHandlers(["click", "mousemove", "keypress", "keyup", "keydown", "mouseover", "mouseout", "mouseup", "mousedown", "focus", "load"]);
}

function emulateEventHandlers(eventNames) {
    for (var i = 0; i < eventNames.length; i++) {
        document.addEventListener(eventNames[i], function (e) {window.event = e;}, true);
    }
}

function attachObjEvent(obj, sEvent, sFunction) {
    if (moz) {
        obj.addEventListener(sEvent, sFunction, false);
    } else {
        obj.attachEvent("on" + sEvent, sFunction);
    }
}

function cancelEvent(objEvent) {
    objEvent.cancelBubble = true;
    objEvent.returnValue = false;

    return false;
}

//Esborrar texte cercador on focus
function clear_search_text() {
    $("#query").val("");
}

//Used in bottom left
function printButton() {
    document.write('<a href="javascript:window.print();" class="print" rel="nofollow">Imprimir</a>')
}

//lightbox
$(this).ready(function() { 
    $('a[@rel*=lightbox]').lightbox({
        overlayOpacity:             0.5,
		fileLoadingImage :          'libs/jquery/jquery.lightbox/images/loading.gif',
		fileBottomNavCloseImage :   'libs/jquery/jquery.lightbox/images/closelabel.gif'
    });
});

//Reservations
function setRoom(intId, e) {
    $("#room").val(intId);
    return cancelEvent(e);
}

function setTime(strIni, strEnd, e) {
    $("#timeIni").val(strIni);
    $("#timeEnd").val(strEnd);
    return cancelEvent(e);
}

function setDate(strDay, strMonth, strYear, e) {
    $("#day").val(strDay);
    $("#month").val(strMonth);
    $("#year").val(strYear);
    return cancelEvent(e);
}

//Events
function showEvents(iDay) {
    $("#events_" + iDay).slideDown(400);
}

function hideEvents(iDay) {
    $("#events_" + iDay).slideUp(300);
}