﻿// JScript File

function navigateMLS(destinationUrl, destinationUrlOptions) {
    if(mlsAvailable) {  //mlsAvailable set by headerfooter.master
        var url = "/proxy.aspx?sys=MLS";
        if (destinationUrl != null && destinationUrl != '') {
        	url += "&d=" + destinationUrl;
        	if (destinationUrlOptions != undefined) {        	    
        		url += "&opt=" + destinationUrlOptions;
			}
		}
		goTo(url);
    }
    else {
        //alert("MLS is unavailable");
        var x = window.showModalDialog("/UnavailableSystem.aspx?s=MLS",null,"dialogWidth: 356px; dialogHeight: 270px; center: true; status: true; scroll: false;");
    }
}

function navigatePR(destinationUrl) {
    if(prAvailable) { //prAvailable set by headerfooter.master
        var url = "/proxy.aspx?sys=REALTYRECORDS"
        if (destinationUrl != null && destinationUrl != '') {
            url += "&d=" + destinationUrl;
        }
        goTo(url);
    }
    else {
        //alert("MLS is unavailable");
        var x = window.showModalDialog("/UnavailableSystem.aspx?s=PR",null,"dialogWidth: 356px; dialogHeight: 270px; center: true; status: true; scroll: false;");
    }
}

function navigateBT() {
    if(btAvailable) { //btAvailable set by headerfooter.master
        var url = "/proxy.aspx?sys=MyAccount"
        window.open(url);
    }
    else {
        //alert("MLS is unavailable");
        var x = window.showModalDialog("/UnavailableSystem.aspx?s=BT",null,"dialogWidth: 356px; dialogHeight: 270px; center: true; status: true; scroll: false;");
    }
}


function goTo(url) {
    //We can't use a simple window.location because there apparently is a bug with IE
    //which does not setup the http_refferer. So, simulate a click on an anchor tag.
    //How sad this is.
    
    var a = document.getElementById("lnkJunk");
    a.href = url;
    if (a.click != null) {
        a.click();
    } else {
        window.location = url;
    }
    return;
   
}