﻿var moving = false;
var offX = 0;
var offY = 0;

function setMailWindowPos(e) {
    if (!moving) return;
    if (!e) e = window.event;

    var elem = document.getElementById('mailWindow');
    elem.style.left = e.clientX - offX + 'px';
    elem.style.top = e.clientY - offY + 'px';
}

function lockMailWindow(e) {
    var elem = document.getElementById('mailWindow');
    offX = e.clientX - elem.offsetLeft;
    offY = e.clientY - elem.offsetTop;

    moving = true;
    document.onmousemove = setMailWindowPos;
    document.onmouseup = unlockMailWindow;
}

function unlockMailWindow() {
    moving = false;
    document.onmousemove = null;
    document.onmouseup = null;
}

function buildMailWindow()
{
    var posx = 300;
    var posy = 100;
    var elem = document.getElementById('mailWindow');
    elem.style.display = 'block';
    elem.style.left = posx + 'px';
    elem.style.top = posy + 'px';

    window.frames["mailFrame"].location = 'http://www.apartmentsapart.com/IndexFrame.aspx?pageid=5892&l=1&domainid=1';
    if (window.opera)
        document.getElementById("mailFrame").height = '278px';

}

function hideMailWindow() {
    document.getElementById('mailWindow').style.display = 'none';
    window.frames["mailFrame"].location = 'about:blank';
}

function printUs(){    
    if (navigator.appName == 'Microsoft Internet Explorer' && !window.XMLHttpRequest)
    {
        window.print();
        return false;
    }
    else 
        window.print();
}
function bookmarkUs() {
    if (window.sidebar) // firefox
        window.sidebar.addPanel(document.title, document.URL, "");
    else if (document.all)// ie
        window.external.AddFavorite(document.URL, document.title);
}
function saveAsPage() {
    document.execCommand('SaveAs');
}
function showButtons() {   
        if (window.sidebar) {
            document.getElementById('bookmark').style.display = 'block';
        }
        if (window.opera) {
            document.getElementById('print').style.display = 'block';
            document.getElementById('mail').style.display = 'block'; 
        }        
        if (navigator.appName == 'Microsoft Internet Explorer') {
            document.getElementById('bookmark').style.display = 'block';
            document.getElementById('save').style.display = 'block';
        }
}
