﻿function closeModalPopup(modalPopupName) {

    var modalPopup = $find(modalPopupName);
    if (modalPopup == null) {
        return;
    }
    modalPopup.hide();
}

function switchImage(imgId, imgUrl) {
    if (document.getElementById(imgId) != null) {
        document.getElementById(imgId).src = imgUrl;
    }
}



function toggleMenu(id, show) {
    document.getElementById(id).style.display = show ? 'block' : 'none';
}


function toggleBackgroundColor(divId, checkboxId) {
    if (document.getElementById(checkboxId).checked) {
        //make border colored (selected)
        document.getElementById(divId).style.border = 'dashed 1px #f00';
    }
    else {
        //make it go (not selected)
        document.getElementById(divId).style.border = "none";
    }
}

function PopupHelp(url, h, w, l, t) {
    newwindow = window.open(url, 'name', 'height=' + h + ',width=' + w + ',left=' + l + ',top=' + t + ',resizable=yes,scrollbars=no,toolbar=no,status=yes');
    if (window.focus) { newwindow.focus(); }
}
// unobtrusive JavaScript for "Print This!" links
// http://perishablepress.com/press/2009/02/01/unobtrusive-javascript-for-print-this-links/

function printClick() {
    if (!document.getElementById) return false;
    if (!document.getElementById("print_this")) return false;
    var link = document.getElementById("print_this");
    link.onclick = function() {
        if (window.opera) { alert("Print this page"); }
        window.print();
        return false;
    }
    link.onkeypress = link.onclick;
}

// onload function 

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}
addLoadEvent(printClick);
addLoadEvent(propertyPartnersStyling);

//Shawn Olson & http://www.shawnolson.net
function checkUncheckAll(theElement) {
    var theForm = theElement.form, z = 0;
    for (z = 0; z < theForm.length; z++) {
        if (theForm[z].type == 'checkbox' && theForm[z].name != 'checkall') {
            theForm[z].checked = theElement.checked;
        }
    }
}

function propertyPartnersStyling() {
    var parentDiv = document.getElementById('PropertyPartners');
    if (parentDiv != null) {
        var divs = parentDiv.getElementsByTagName("div");
        for (var i = 0; i < divs.length; i++) {
            var images = new Array();
            images = divs[i].getElementsByTagName("img");
            if (images[0].src.match(/filler1x1\.gif/)) {
                images[0].style.margin = "0px";
                divs[i].style.display = "none";
            }

        }
    }
}
