var enPlayer = { "FloorPlan": 1, "ShowImg": 2, "AlbumExterior": 3, "AlbumInterior": 4 };

function HideImg() {

    if (document.getElementById('VFPT_ShowImg')) {
	if (typeof vpHide == 'function') vpHide(0, enPlayer.ShowImg);
        document.getElementById('VFPT_ShowImg_Img').style.visibility = 'hidden';
        document.getElementById('VFPT_ShowImg').style.visibility = 'hidden';
    }
}

function ShowImg(i, bCheckResize, lId) {
    if (!document.getElementById('VFPT_ShowImg') || !document.getElementById('VFPT_ShowImg_Img') || !document.getElementById('vcSI0')) return;
    if (bCheckResize == 1 && document.getElementById("bLargeImage")) if (document.getElementById("bLargeImage").value == 1) return;

    var bXY = document.getElementById('VFPT_ShowImg').style.visibility == 'visible' ? false : true;
    document.getElementById('VFPT_ShowImg').style.visibility = 'visible';
    document.getElementById('VFPT_ShowImg_Img').style.visibility = aImg[i].bVideo ? 'hidden' : 'visible';
    var sDesc = aImg[i].sDescription;
    if (sDesc != '') sDesc = "<hr class=Album>" + sDesc

    document.getElementById("VFPT_ShowImg_Label").innerHTML = aImg[i].sLabel;
    document.getElementById("VFPT_ShowImg_Desc").innerHTML = sDesc;

    if (aImg[i].bVideo) {
        vpPauseAll();
        vpPlay(0, enPlayer.ShowImg, aImg[i].sSrc, aImg[i].bMute)
        document.getElementById('vcSI0').style.left = ((document.getElementById('VFPT_ShowImg').offsetWidth - document.getElementById('vcSI0').offsetWidth) / 2) - 6; // center the player in the div
    }
    else {
        var sSrc = aImg[i].sSrc.replace('/Image/', '/Image/High/');
        if (typeof vpHide == 'function') vpHide(0, enPlayer.ShowImg);
        document.getElementById('VFPT_ShowImg_Img').src = sSrc;
    }

    if (bXY) {
        document.getElementById('VFPT_ShowImg').style.left = document.body.scrollLeft;
        document.getElementById('VFPT_ShowImg').style.top = document.body.scrollTop;
    }
}

function MouseOver(lFloorPlanIndex, lIndex) {
    if (lIndex == 0) return;
    if (aImg[lIndex].bVideo)
        vpPlay(lFloorPlanIndex, enPlayer.FloorPlan, aImg[lIndex].sSrc, aImg[lIndex].bMute);
    else {
        if (typeof vpHide == 'function') vpHide(lFloorPlanIndex, enPlayer.FloorPlan);
        var sImgSrc = aImg[lIndex].sSrc;
        if (document.getElementById("bLargeImage")) if (document.getElementById("bLargeImage").value == 1) sImgSrc = sImgSrc.replace("/Image/", "/Image/High/");
        //if (sImgSrc != '' && document.getElementById('VFPT_FP_Image' + String(lFloorPlanIndex))) document.getElementById('VFPT_FP_Image' + String(lFloorPlanIndex)).src = sImgSrc;
	if (document.getElementById('VFPT_FP_Image' + String(lFloorPlanIndex))) {
		document.getElementById('VFPT_FP_Image' + String(lFloorPlanIndex)).style.visibility = sImgSrc == '' ? 'hidden' : 'visible';
		document.getElementById('VFPT_FP_Image' + String(lFloorPlanIndex)).src = sImgSrc;
	}
    }
    if (document.getElementById('VFPT_FP_Label' + String(lFloorPlanIndex))) document.getElementById('VFPT_FP_Label' + String(lFloorPlanIndex)).innerHTML = aImg[lIndex].sLabel;
    if (document.getElementById('VFPT_FP_Description' + String(lFloorPlanIndex))) document.getElementById('VFPT_FP_Description' + String(lFloorPlanIndex)).innerHTML = aImg[lIndex].sDescription;
    if (document.getElementById('VFPT_Instructions')) document.getElementById('VFPT_Instructions').style.visibility = 'hidden';
}
function MouseOut() {
    document.body.style.cursor = 'default';
}

function tblGetRowCount(sTableId) {
    if (!document.getElementById(sTableId)) return;
    return document.getElementById(sTableId).rows.length;
}
function tblGetRow(sTableId, lRow) {
    lRow -= 1;
    if (!document.getElementById(sTableId).rows[lRow]) return;
    return document.getElementById(sTableId).rows[lRow]
}
function tblGetRowCells(sTableId, lRow) {
    var Row = tblGetRow(sTableId, lRow);
    if (!Row) return;
    if (!Row.cells) return;
    return Row.cells
}
function tblCellCount(sTableId, lRow) {
    var Row = tblGetRow(sTableId, lRow);
    if (!Row) return;
    if (!Row.cells) return;
    return (Row.cells.length);
}
function tblGetCell(sTableId, lRow, lColumn) {
    lColumn -= 1;
    var RowCells = tblGetRowCells(sTableId, lRow);
    if (!RowCells) return;
    if (!RowCells[lColumn]) return;
    return RowCells[lColumn];
}
function tblColSpan(sTableId, lRow, lColumn, lColSpan) {
    var Cell = tblGetCell(sTableId, lRow, lColumn);
    if (!Cell) return;
    Cell.colSpan = lColSpan
}
function tblInsertRow(sTableId, lRow) {
    if (!document.getElementById(sTableId)) return;
    document.getElementById(sTableId).insertRow(--lRow);
}
function tblDeleteRow(sTableId, lRow) {
    var Row = tblGetRow(sTableId, lRow);
    if (!Row) return;
    document.getElementById(sTableId).deleteRow(--lRow);
}
function tblInsertCell(sTableId, lRow, lColumn, sId, sClass, lColSpan, sInnerHtml) {
    if (document.getElementById(sId)) return;
    lColumn -= 1;
    var Row = tblGetRow(sTableId, lRow);
    if (!Row) return;
    var Cell = Row.insertCell(lColumn);
    Cell.id = sId;
    Cell.className = sClass;
    Cell.colSpan = lColSpan;
    Cell.innerHTML = sInnerHtml;
    return Cell;
}
function tblDeleteCell(sTableId, lRow, lColumn) {
    lColumn -= 1;
    var Row = tblGetRow(sTableId, lRow);
    if (!Row) return;
    if (lColumn >= 1 && lColumn <= tblCellCount('VFPT_TBL', 3)) Row.deleteCell(lColumn)
}

