// Creates a pop-up window for the Preferences page
function adWin(psUrl)
{
	var oPrefWindow;
	oPrefWindow = window.open(psUrl,"popAdWindow","top=0,left=0,width=" + (screen.width-11) + ",height=" + (screen.height-55));
	oPrefWindow.focus();
}

// Creates a pop-up window for the Preferences page
function prefWin()
{
	var sURL = "../Preferences/Preferences.aspx";
	var oPrefWindow;
	oPrefWindow = window.open(sURL,"popPrefWindow","scrollbars=1," + createWinPos(735,440));
}

function mlsPopup(psURL)
{
 	var oMLSWindow;
	oMLSWindow = window.open(psURL,"popupWin", "scrollbars=1,resizable=1,"+createWinPos(800,600));

}

function mlsTestmonialPopup(psURL)
{
 	var oMLSWindow;
	oMLSWindow = window.open(psURL,"popupWin", "scrollbars=1,resizable=0,"+createWinPos(632,600));

}
// Pops open site map window
function siteMapWin(psServerName)
{
	var oSiteMapWindow;
	var sSiteMapLink;
	
	if (psServerName == null)
	{
		psServerName = "";
	}
	
	sSiteMapLink = psServerName + "/sitemap/";
	oSiteMapWindow = window.open(sSiteMapLink,"sitemapWindow","scrollbars=1,width=350,height=500,top=0,left=0,screenX=0,screenY=0");
}


//Sets a timeout for banner ad change
var iAdTimeout = null;
function AutoRefreshAdFrame(piInterval)
{
	var sQueryString = "";
	var sAdFrameSrc = document.getElementById("AdFrame").src;
	
	if (iAdTimeout != null)
	{
		top.window.clearTimeout(iAdTimeout);
	}
	
	if (sAdFrameSrc.length > 9 && sAdFrameSrc.substring(sAdFrameSrc.length-9).toLowerCase() == "&portal=1")
	{
		sQueryString = "?portal=1";
	}
	
	iAdTimeout = top.window.setTimeout("document.getElementById(\"AdFrame\").src = this.GetURLPrefix() + \"Common/BannerAd/BannerAd.aspx" + sQueryString + "\";", piInterval);
}

function GetURLPrefix()
{
	var sDirectory = (location.pathname.substring(0,14).toLowerCase() == "/costarpublic/" ? "/CoStarPublic/" : "/");
	
	return sDirectory;
}

//Clears the banner ad timeout when the default page changes
function ClearSetTimeOut()
{
	if(iAdTimeout != null)
	{
		top.window.clearTimeout(iAdTimeout);
	}
}


// Creates a pop-up window for advisory selection
function popupAdvisoryWin(psURL)
{
	var oWindow = window.open(psURL,"popAdvisoryWin", createWinPos(350,235));
}
