function disableEnterKey(e) {
    var key;
    if (window.event)
        key = window.event.keyCode; //IE
    else
        key = e.which; //firefox     

    return (key != 13);
}

function isdefined(variable) {
    return (typeof (variable) == "undefined") ? false : true;
}

function openfloorplanwindow(strHREF) {
    var width = 600;
    var height = 600;
    var useScroll = true;
    var resizable = true;

    if (typeof (VWFloorplanImageInit) != "undefined") {
        if (VWFloorplanImageInit.hasOwnProperty('width'))
            width = VWFloorplanImageInit.width;
        if (VWFloorplanImageInit.hasOwnProperty('height'))
            height = VWFloorplanImageInit.height;
        if (VWFloorplanImageInit.hasOwnProperty('scrollbars'))
            useScroll = VWFloorplanImageInit.scrollbars;
        if (VWFloorplanImageInit.hasOwnProperty('resizable'))
            resizable = VWFloorplanImageInit.resizable;
    }


    openwindow(strHREF, width, height, useScroll, resizable);
}
// open a centered window
function openwindow(strHREF, w, h, useScrollbar, resizable) {
    var undefined;
    var width;
    var height;

    if (w == undefined) {
        width = 600;
    } else {
        width = w;
    }

    if (h == undefined) {
        height = 400;
    } else {
        height = h;
    }

    var strFeatures;

    if (useScrollbar || (useScrollbar == undefined)) {
        strFeatures = 'height=' + height + ',width=' + width + ',scrollbars';
    } else {
        strFeatures = 'height=' + height + ',width=' + width;
    }

    if (resizable) {
        strFeatures += ',resizable=yes';
    }
    else {
        strFeatures += ',resizable=no';
    }

    if (window.screen) {
        var ah = screen.availHeight - 30;
        var aw = screen.availWidth - 10;

        var xc = (aw - width) / 2;
        var yc = (ah - height) / 2;

        strFeatures += ',left=' + xc + ',screenX=' + xc;
        strFeatures += ',top=' + yc + ',screenY=' + yc;
    }
    //alert(strFeatures);
    window.open(strHREF, 'popup', strFeatures);
}


function showFloorplan(source, floorplanID) {
    showResponse("Overlay/Floorplan.aspx?floorplanid=" + floorplanID, "ov1", source, 'masterModal', false, false, 550, 600, 50);
}

function initFloorplanImages() {
    ShowFloorplanImage($vW('.FlooplanImage:first'));

    $vW('.nextImage').click(NextFloorplanImage);
    $vW('.prevImage').click(PrevFloorplanImage);

    var images = $vW('.FlooplanImage');

    if (images.length < 2) {
        $vW('.navigation').hide();
    }
    if (images.length == 0) {
        $vW('.FlooplanImages').hide();
    }
}

function updateButtions() {
    var shown = $vW('.activeFlooprlanImage');

    if (shown.next().length > 0) {
        $vW('.nextImage').removeAttr("disabled");
    }
    else {
        $vW('.nextImage').attr("disabled", "disabled");
    }

    if (shown.prev().length > 0) {
        $vW('.prevImage').removeAttr("disabled");
    }
    else {
        $vW('.prevImage').attr("disabled", "disabled");
    }
}

function NextFloorplanImage() {
    var shown = $vW('.activeFlooprlanImage');
    shown.hide().removeClass('activeFlooprlanImage');
    var next = shown.next();
    if (next.length == 0) {
        next = $vW('.FloorplanImage:first')
    }
    ShowFloorplanImage(next);
    return false;
}


function PrevFloorplanImage() {
    var shown = $vW('.activeFlooprlanImage');
    shown.hide().removeClass('activeFlooprlanImage');
    var next = shown.prev();
    if (next.length == 0) {
        next = $vW('.FloorplanImage:last');
    }
    ShowFloorplanImage(next);
    return false;
}

function ShowFloorplanImage(i) {
    i.show().addClass('activeFlooprlanImage');
    updateButtions();
}

