	//////// CONSTANTS ////////

    ATTRIBUTE_CLASS = "class";
    ATTRIBUTE_ID = "id";
    ATTRIBUTE_STLYE = "style";
    CLASS_TABLE_MAINBODY = "MainBody";
    CLASS_TABLE_MAIN = "tblMain";
    CLASS_WORKSPACE = "WorkspaceBGNoScroll";
    CLASS_MAGICWRAPPER = "MagicBodyWrapper";
    CSS_FULLHEIGHT = "100%";
    CSS_FULLWIDTH = "100%";
    CSS_OVERFLOW_VISIBLE = "visible";
    EMPTY_STRING = "";
    ID_BUTTON_REFRESH = "refreshButton"
    ID_DIV_BODY = "divBody";
    ID_DIV_WORKSPACE = "WorkspaceBGNoScroll";
    ID_TABLE_FIXED = "tblFixedLayout";
    JS_REFRESHDISPLAY = "RefreshDisplayForPrint()";
    SELECTOR_BODY = "body";
    SELECTOR_CLASS = ".";
    SELECTOR_ID = "#";
	 
	
	//////// VARIABLES ////////
	
	var mgSessionNumber;
	var bShowingTime;
	var st_image;
		var f = new Array();
	var f2 = new Array();
	var FiltersEnabled = 1 // if you're not going to use transitions or filters in any of the tips set this to 0
	var nIncrement;
	var bSortAsSelected;
	var bState = true;
	var bQYState = true;
	var bQNState = true;
	var strCartSectionType;
	var strProspectSectionLabel;
	var intProspectTotalListings;
	var strCartLabel;
	var mgCartCount;
	var numProspectRID;
	var mgAppName;
	var useMapBook;
	var checkboxFilter ='';
	var divTag;
	var iScrollPos = 0;
	var mgIsRealtor;
	var showFilter = 0;
	var strPropertyType_Code;// = new Array();
	var mgSetTab;
	var bShowingTime;
	var st_image;
	var nIncrement;
	var bSortAsSelected;
	var strCartSectionType;
	var strProspectSectionLabel;
	var intProspectTotalListings;
	var strCartLabel;
	var mgUseMapBook;
	var mgSelectStatus;
	var showFilter;
	var mgRealtorEmtpy;
	var mgIsRealtor;
	var mgSetTab;
	var mgNotArchiveOrNotSearch;
	var mgNotArchive;
	var mgHasExports;
	var mgNotArchive;
	var mgListingCart;
	var mgShowStatisticsButton;
	var mgIsPublic;
	var mgShowSubdivision;
	var mgSubdivisionLabel;
	var mgRapMLSImages;
	var mgAppname;
	var mgProspectNum;
	var mgBMTypeMemberNumber;
	
	// SBI# 16700, MM, 5/19/10
	var mgBRTypeOfficeNumber;
	var mgIsIDXFranchise;
	
	var mgSearchTypeP;
	var mgAgentOrOfficeNumber;
	var mgDisplayType;
	var mgAgentName;
	var mgAgentNumber;
	var sPTOptionsString;
	var mgStatusFromDate;
	var mgStatusThruDate;
	var mgWithChecked;
	var mgWithoutChecked;
	var mgPicturesChecked;
	var mgVMChecked;
	var mgShowOpenHouses;
	var mgOpenHousesChecked;
	var mgOpenHousesLabel;
	var mgShowTours;
	var mgToursChecked;
	var mgToursLabel;
	var mgShowAttachments;
	var mgAttachedDocsChecked;
	var mgShowCaravans;
	var mgCaravansChecked;
	var mgCaravansLabel;
	var mgShowTuesdayTours;
	var mgTuesdayToursChecked;
	var mgTuesdayToursLabel;
	var mgShowPrivacySetting;
	var mgPrivacySettingMLSChecked;
	var mgPrivacySettingPrivateChecked;
	var mgPrivacySettingBothChecked;
	var mgPrivacySettingLabel;
	var mgPublicClientLabel;
	var mgGroupCodeSelected;
	var mgShowProspectInfo;
	var mgProspectName;
	var mgMergeEmail;
	var mgEmailTo;
	var mgEmailCc;
	var mgMergeStreetAddress;
	var mgStreetAddress;
	var mgMergeCity;
	var mgCityStateZip;
	var mgMergeContactPhone;
	var mgContactPhone;
	var sProspectSearchesHTML;
	var mgRowClassR1;
	var searchName;

	var mgLongitude;
	var mgLatitude;

	var rapMap = null;
	var rapPin = null;

	//////// EVENTS ////////

    $(function() {
	    mgLongitude = "-117.369988";
	    mgLatitude = "34.4853809";
	    rapMap = GetMap(15, false);
	    $("#divScreenCover").animate({ opacity: 0 });
	    $("#divMapContainer").animate({ opacity: 0 });
	    $("#divFadeLoad").animate({ opacity: 1 });
    });


	//////// METHODS ////////
	function reAlign()
	{ }

	function PrintMagicDisplay() 
	{
	    InitializeDisplayForPrint();
	    window.print();
	    setTimeout(JS_REFRESHDISPLAY, 1000);
	}

	function RefreshDisplayForPrint() 
	{
	    document.getElementById(ID_BUTTON_REFRESH).click();
	}

	function InitializeDisplayForPrint() {
        RemoveAttributesForPrint(SELECTOR_CLASS + CLASS_TABLE_MAINBODY);
        RemoveAttributesForPrint(SELECTOR_ID + ID_DIV_WORKSPACE);
        RemoveAttributesForPrint(SELECTOR_CLASS + CLASS_WORKSPACE);
        RemoveAttributesForPrint(SELECTOR_CLASS + CLASS_TABLE_MAIN);
        RemoveAttributesForPrint(SELECTOR_ID + ID_TABLE_FIXED);
        RemoveAttributesForPrint(SELECTOR_ID + ID_DIV_BODY);
        RemoveAttributesForPrint(SELECTOR_BODY);
        RemoveAttributesForPrint(SELECTOR_CLASS + CLASS_MAGICWRAPPER);
	}

	function RemoveAttributesForPrint(selector) {
	    $(selector).attr(ATTRIBUTE_STLYE, EMPTY_STRING).attr(ATTRIBUTE_CLASS, EMPTY_STRING).attr(ATTRIBUTE_ID, EMPTY_STRING).css({ height: CSS_FULLHEIGHT, width: CSS_FULLWIDTH, overflow: CSS_OVERFLOW_VISIBLE });
	}

	function SetFixedHeaderMagic() {
	    var content = EMPTY_STRING;  //$('.MagicTableBody').html();
	    var tableWidth = 0;

	    //content = $('.MagicTableBody')[parent.iSelectedTabIndex].html();	    
//	        function() {
//	            content = $(this).html();
//	        }
	    //	    );

	    $('.MagicTableBody').each(
	    function(index) {
	        if (index == parent.iSelectedTabIndex) {
	            content = $(this).html();
	        }
	    }
	    );

	    $('.MagicDivBody').each(
	    function(index) {
	        if (index == parent.iSelectedTabIndex) {
	            tableWidth = $(this).width();
	        }
	    }
	    );

	    $('.MagicTableWrapper').each(
	    function(index) {
	        if (index == parent.iSelectedTabIndex) {
	            $(this).html('<TABLE width="100%" cellspacing="0" cellpadding="0" style="border-right:1px solid #9D9DA1;border-bottom:1px solid #9D9DA1;border-left:1px outset white; border-top:1px outset white; border-collapse:separate;" id="tblBody" class="MagicTableBody">' + content + '</table>');
	            $(this).width(tableWidth - 17);
	        }
	    }
	    );
	    
	    //$('.MagicTableWrapper').html('<TABLE width="100%" cellspacing="0" cellpadding="0" style="border-right:1px solid #9D9DA1;border-bottom:1px solid #9D9DA1;border-left:1px outset white; border-top:1px outset white; border-collapse:separate;" id="tblBody">' + content + '</table>');
	    //$('.MagicTableWrapper').width(tableWidth - 17);	
	}
	
//Window load event handler
function loadWindow() {

    var ua = navigator.userAgent.toLowerCase();
    isFirefox = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1 && ua.indexOf('firefox') != -1);
    isSafari = ua.indexOf('safari') != -1;
    
    if(!isSafari)
    {
        sizeContentIframe();
        //SetFixedHeaderMagic();   
    }
    else{
        if (document.getElementById('WorkspaceBGSH')) {
	            document.getElementById('WorkspaceBGSH').className = "WorkspacePublicBGSafari";
	        }
	        SetSafariDisplay();
    }
}

//When the document is ready attach event handlers to the window.
$(function() {
    var ua = navigator.userAgent.toLowerCase();
    isFirefox = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1 && ua.indexOf('firefox') != -1);
    isSafari = ua.indexOf('safari') != -1;

    $(window).load(loadWindow);
    $(window).resize(ResizeWindow);
});

function ResizeWindow() 
{
    ShowMap(false, '', mgLatitude, mgLongitude);

    if (isSafari) {
        SetSafariDisplay();
    }
    else if (getIsMOZ()) {
        setFireFoxDisplay();
    }
    else {
        sizeContentIframe();
    }
}

function setFireFoxDisplay() {
    sizeContentIframe();
    resizeTabs(); 
}

function sizeContentOffset(offset) 
{
    var height = window.innerHeight; //Firefox
    if (document.body.clientHeight) {
        height = document.body.clientHeight; //IE
    }

    var titletext = "";
    var HeightOffset = 0;

    if (ObjectExists(parent) && ObjectExists(parent.document.getElementById("pageTitle"))) 
    {
        titletext = parent.document.getElementById("pageTitle").innerHTML
    }

    if (titletext.indexOf("View/Revise") == -1) {

        HeightOffset = 97;
    }
    else {
        HeightOffset = 238;
    }

    $('#divBody').removeAttr("height");
    $('.MagicDivBody').removeAttr("height");

    $('#divBody').height(parseInt(height) - (HeightOffset + offset));
    $('.MagicDivBody').height(parseInt(height) - (HeightOffset + offset));
}

//Sets the height of the main content iframe to fill the window.
function sizeContentIframe() {
    var height = window.innerHeight; //Firefox
   // var width = window.innerWidth; //Firefox
    if (document.body.clientHeight) {
        height = document.body.clientHeight; //IE
        width = document.body.clientWidth;
    }

    var titletext = "";

    if (ObjectExists(parent) && ObjectExists(parent.document.getElementById("pageTitle"))) {
        titletext = parent.document.getElementById("pageTitle").innerHTML
    }
    var isOfficeListings = (titletext.indexOf("Office Listings") != -1);

    if (!getIsIE()) {
        titletext = "";
        var HeightOffset = 0;
        if (ObjectExists(parent) && ObjectExists(parent.document.getElementById("pageTitle"))) {
            titletext = parent.document.getElementById("pageTitle").innerHTML
        }

        if (titletext.indexOf("View/Revise") == -1) {

            HeightOffset = 97;            
        }
        else {
            HeightOffset = 238;
        }    
    
        $('.WorkspaceBGNoScroll').height(parseInt(height - 80));
        $('.WorkspaceBG').height(parseInt(height - 60));
        $('#divBody').height(parseInt(height) - HeightOffset);

        //Fix for vertical scrollbar issue for magic custom displays added this classname - "divBodyClassName" to all tags with "divBody" as ID
        if (!getIsIE()) {
            $('.divBodyClassName').height(parseInt(height) - HeightOffset);
            if (isOfficeListings) {
                //$('#Main_Body').width(parseInt(width));
            }
        }
        
        $('.MagicBodyWrapper').height(parseInt(height) - HeightOffset);        
        $('.MagicDivBody').height(parseInt(height) - HeightOffset);
        $('.divBodyOpenHouse').height(parseInt(height) - 80);

        
        
        try{
            if(strPropertyType_Code.length > 1)
            {
                $('#tdTabTable').css("position", "relative");
                $('#tdTabTable').css("top", "-1px");        
            }
        }
        catch(e)
        {
            //strPropertyType_Code does not exist
        }
    }
    //SetFixedHeaderMagic();
}

function SetSafariDisplay() {

    var isReviseListing = false;
    var isMarketWatch = false;
    var isOpenHouse = false;
    var isAgentsListings = false;
    var isOfficeListings = false;
    var isHotSheet = false;
    var isReverseProspecting = false;
    var titletext = "";
    var HeightOffset = 0;
    if (parent) {
        titletext = parent.document.getElementById("pageTitle").innerHTML
    }
    isMarketWatch = (titletext.indexOf("Market Watch") != -1);
    isOpenHouse = (titletext.indexOf("Open House") != -1);
    isAgentsListings = (titletext.indexOf("Agent's Listings") != -1);
    isOfficeListings = (titletext.indexOf("Office Listings") != -1);
    isHotSheet = (titletext.indexOf("Hotsheet Search") != -1);

    HeightOffset = 198;

    $('.MainBody').attr("style", "height:100%");

    if (titletext.indexOf("View/Revise") == -1 && !isOpenHouse) {
        isReviseListing = false;
    }
    else {
        isReviseListing = true;
       
        
    }
    if (!isReviseListing && !isMarketWatch && !isAgentsListings && !isOfficeListings && !isHotSheet) {
        $('.WorkspacePublicBGSafari').css("overflow", "auto");
        
    }
    else {
        $('.MagicBodyWrapper').css("overflow", "auto");
        $('#MLSPageHeaderID').css("overflow", "hidden");

        if (isOfficeListings) {
            $('.WorkspacePublicBGSafari').attr("style", "overflow:hidden;height:100%;");
        }
    }

	if (isHotSheet || isMarketWatch) {
            $('#divBody').height(parseInt(window.innerHeight - 100));
            $('#MLSPageHeaderID').css("overflow", "hidden");
        }
	else if(isReviseListing)
	{
	    $('#divBody').height(parseInt(window.innerHeight - 230));
		
	}


    var height = window.innerHeight; //Firefox
    if (document.body.clientHeight) {
        height = document.body.clientHeight - 45; //IE
    }
    if (isReviseListing || isHotSheet) {
        $('.MagicBodyWrapper').height(parseInt(height - HeightOffset));
        
        if (!IsLowerResolution()) {
            $('.WorkspacePublicBGSafari').height(parseInt(height));
        }
        else {
            $('.WorkspacePublicBGSafari').height(parseInt(height - 45));
        }
    }
    else if (isMarketWatch || isOfficeListings) {
        $('.MagicBodyWrapper').height(parseInt(height - 70));
        $('.WorkspacePublicBGSafari').height(parseInt(height - 70));
    }
    else {
        $('.WorkspacePublicBGSafari').height(parseInt(height - 100));
        $('.MagicBodyWrapper').height(parseInt(height - 45));

    }
    
    $('.MagicDivBody').height(parseInt(height) - HeightOffset);
    $('.divBodyOpenHouse').height(parseInt(height) - 80);
}
var loaded = false;
function InitForm() {

    if (!loaded) {
            loaded = true;
            //Preload Options Pane Images
            MM_preloadImages(sRapMLSImages + 'opclosedout.gif', sRapMLSImages + 'opclosedover.gif', sRapMLSImages + 'opopenedout.gif', sRapMLSImages + 'opopenedover.gif');
            divTag = document.getElementById('divBody') ? "divBody" : "WorkspaceBGSH";
            // Magic Tag IF_REALTOR = Agent>0 AND Not Empty RIDs
            if (mgIsRealtor) {
                // Init Options Pane to Open/Closed
                openCloseOptions(0, 1);
                // Realign Fixed Header Width
                if (document.getElementById('ExpandableModule_' + strPropertyType_Code[0])) {
                    width = 0; height = 0;

                    /*if (getIsIE()) {
                    reAlign(); //XBrowser : Not working for Firefox so removing this for !IE
                    }*/
                } // Resize Fixed Header Header

                if (document.readyState != 'complete') {
                    //document.attachEvent("onreadystatechange",isBackButton())
                    mlsAttachEvent(document, "load", isBackButton, null);
                }

                if (bSortAsSelected) { updateSortAsSelected(document.InputForm.Sort_As_Selected) };

                updateSortDirection('A');
                updateSortDirection('B');
                updateSortDirection('C');

                //initCheckBoxCounter();
                // Checked updated in Magic-Footer  
                if (iCheckedTotal == checkBoxTotal) {
                    bState = false;
                    updateCheckUncheckAll()
                }

                updateCounter();
                document.getElementById('showCheckUncheckAll').innerHTML = document.getElementById('Check1').title;

                // get the already checked selections
                var f = document.InputForm.elements;
                setSortOptions(f, bSortAsSelected);
                if (mgSetTab) {
                    // Needed for Tabs not generated in Magic - Hotsheet/Non Fixed Header
                    setActiveTab(strActiveProperty);
                    setCheckBoxPT();
                }
                else {
                    // If Tabs initialized in Magic, set Active PT DIV Display
                    setActiveTab(strActiveProperty); // Now also needed for back button logic
                    setPTTableDisplay();
                }

                if (document.getElementById('TipLayer')) { applyCssFilter() }

                if (checkBoxTotal == 0) {
                    bShowingTime = false;
                }
                if (bShowingTime) initShowingTime();
                if (document.InputForm.IsHotsheet && document.InputForm.IsHotsheet.value == 'yes') updateHotsheetCounters();

                insertFooter(); // Insert Footer for each PT
                // ------ Added to fix the  ITG # 259303 and 265334. Deepak R  Date:5-Dec-2006	--------
                getSavedCheckedChecklist();
                // ------ Added to fix the  ITG # 259303 and 265334. Deepak R  Date:5-Dec-2006	--------
            }


            if (mgSelectStatus) {
                // Inserts Revise Filters in Fixed Header Table
                //if (!getIsWK()) {
                    insertReviseModule(0);
                //}
            }



            if (mgIsPublic) {
                document.body.scroll = 'no'
            }

            //Restore Scroll to search result after returning from Listing Detail except for public
            //Not needed as it is now called from setActiveTab

            // For Displays - Loading is turned off here instead of PageFooter
            if (document.getElementById('Loading')) document.getElementById('Loading').style.display = "none";
            if (document.getElementById('Loaded')) document.getElementById('Loaded').style.visibility = "visible";
        }
	} // End InitForm()
	
//-- ITG#274389. To fix public access property search javascript error 
	function initShowingTime()
	{
		//Do nothing
	}
	
	function updateCheckedCount()
	{
	if(parent.iCheckBoxCounter > 0)
		{
			iCheckedTotal = parent.iCheckBoxCounter;
		}
	}

	function restoreScroll()
	{
		if(parent.arrPTScroll)
		{
			iScrollPos = parent.arrPTScroll[parent.iSelectedTabIndex];
		}
		else
		{
			iScrollPos = parent.document.getElementById('hdnDivScrollValue').value;
		}
		if(parent.iSelectedTabIndex && divTag == 'divBody' && document.getElementsByName('divBody').length > 1)
			{
				document.getElementsByName('divBody')[parent.iSelectedTabIndex].scrollTop = iScrollPos;
			}
		else if(document.getElementById(divTag))
		{
			document.getElementById(divTag).scrollTop = iScrollPos;
		}
	}
//ITG # 255580 --- This function initialize the Property Type Array for storing the scroll positions.	
	function setArrPTScroll()
	{		
		setStrActiveProperty(document.InputForm.Active_Tab.value);		
		if(!parent.arrPTScroll)
		{
			parent.arrPTScroll = new Array(strPropertyType_Code.length);
			for (i = 0; i < parent.arrPTScroll.length; i++)
			{		
					parent.arrPTScroll[i] = 0;
			}
		}
		saveScroll();
	}
	function saveScroll()
	{
		var iPosition = 0;
		if(parent.arrPTScroll)
		{
			if(divTag == 'divBody' && document.getElementsByName('divBody').length > 1)
				{
					iPosition = document.getElementsByName('divBody')[parent.iSelectedTabIndex].scrollTop;
				}
			else if(document.getElementById(divTag))
			{
				iPosition = document.getElementById(divTag).scrollTop;
			}
		}
		if(parent.arrPTScroll)
		{
			parent.arrPTScroll[parent.iSelectedTabIndex] = iPosition;
		}
		else
		{
			parent.document.getElementById('hdnDivScrollValue').value = iPosition;
		}

	}

	function updateHotsheetCounters() // Add in the counters next to each Property Type on Hotsheet
	{
		if(document.InputForm.PTypeCounter)
		{
			var objElements = document.forms["InputForm"].elements;
			var aPTypeStringValues = new Array(); 
			var aSectionStringValues = new Array(); 
			var strToken = '|';
			var pTypeIndex = 0;
			var sectionIndex = 0;
			var propertyType = '';
			var propertyTypeValue = 0;
			var sectionType = '';
			var SectionValue = 0;

			aSectionStringValues = objElements['SectionCounter'].value.split(strToken);

			if(aSectionStringValues != null && aSectionStringValues !='')//The current string has a value
			{
				for(sectionIndex in aSectionStringValues)// Loop trough array
				{
					// Every second value will hold the Property Type.  Format = Section|Counter|Section|Counter
					if(sectionIndex % 2 == 0)
					{
						sectionType = aSectionStringValues[sectionIndex];
					}
					if(sectionIndex % 2 != 0)
					{
						sectionValue = aSectionStringValues[sectionIndex];
					
						// update merge form with values..
						document.getElementById('sectionCounter_' + sectionType).innerHTML = '(' + sectionValue + ')';
						//Reset variables
						sectionType = '';
						sectionValue = 0;
					}
				}
			}
		}
	}
	
	function additionalInfo(Listing,Address,City,Price,ListOffice,ListAgent,Phone,SoldDate,MapCoord,subdivision,aAmenitiesDescriptions,aAmenitiesValues)
{
	WindowStyle = ["white","black","#0040A8","#FFFFFF","","","","","Arial","Arial","left","sticky","1","1",400,250,5,0,-20,-100,46,.2,0,"simple","#aaaaaa"]
//                     0      1        2         3      4  5  6  7    8       9       10     11     12  13 14  15 16 17 18  19  20 21 22  23       24  
//                                                                                                         14-width      18,19-x and y pos
	var sRowClass = new Array();
	sRowClass[0] = '<TR class="bgLightBlueBarsBlackText"><TD>'
	sRowClass[1] = '<TR class="bgWhiteBarsBlackText"><TD>'

	var WindowText = new Array();
	WindowText[0] = " &nbsp;&nbsp;Additional Information"
	if(MapCoord !='')
	{
		WindowText[1] = "<TABLE cellpadding=8 cellspacing=10 width=100%> <TR><TD>"+
		" <TABLE width=100% cellpadding=3>"+
			sRowClass[0] +"<B>Listing #</B></TD><TD>"+Listing+"</TD></TR>"+
			sRowClass[1] +"<B>Address</B></TD><TD>"+Address+"</TD></TR>"+
			sRowClass[0] +"<B>City</B></TD><TD>"+City+"</TD></TR>"+
			sRowClass[1] +"<B>Price</B></TD><TD>"+Price+"</TD></TR>"+
			sRowClass[0] +"<B>List Office</B></TD><TD>"+ListOffice+"</TD></TR>"+
			sRowClass[1] +"<B>List Agent</B></TD><TD>"+ListAgent+"</TD></TR>"+
			sRowClass[0] +"<B>Preferred Phone</B></TD><TD>"+Phone+"</TD></TR>"+
			sRowClass[1] +"<B>Map Coord.</B></TD><TD>"+MapCoord+"</TD></TR>"+
			sRowClass[0] +"<B>Sold Date</B></TD><TD>"+SoldDate+"</TD></TR>"
			+
			sRowClass[1] +"<B>Subdivision</B></TD><TD>"+subdivision+"</TD></TR>"
						}
	else
	{
		WindowText[1] = "<TABLE cellpadding=8 cellspacing=10 width=100%> <TR><TD>"+
		" <TABLE width=100% cellpadding=3>"+
			sRowClass[0] +"<B>Listing #</B></TD><TD>"+Listing+"</TD></TR>"+
			sRowClass[1] +"<B>Address</B></TD><TD>"+Address+"</TD></TR>"+
			sRowClass[0] +"<B>City</B></TD><TD>"+City+"</TD></TR>"+
			sRowClass[1] +"<B>Price</B></TD><TD>"+Price+"</TD></TR>"+
			sRowClass[0] +"<B>List Office</B></TD><TD>"+ListOffice+"</TD></TR>"+
			sRowClass[1] +"<B>List Agent</B></TD><TD>"+ListAgent+"</TD></TR>"+
			sRowClass[0] +"<B>Preferred Phone</B></TD><TD>"+Phone+"</TD></TR>"+
			sRowClass[1] +"<B>Sold Date</B></TD><TD>"+SoldDate+"</TD></TR>"+
			sRowClass[0] +"<B>Subdivision</B></TD><TD>"+subdivision+"</TD></TR>"
						}

	if (aAmenitiesDescriptions[0])
		{
			var i=0;
			while (i < aAmenitiesDescriptions.length)
			{
				// modify sRowClass[x + i % 2]  to 0+ or 1- depending on whether the Standard Rows are even or odd
				WindowText[1] = WindowText[1] + sRowClass[0 + i % 2] +"<B>"+aAmenitiesDescriptions[i]+"</B></TD><TD>"+aAmenitiesValues[i]+"</TD></TR>";
				i = i+1;
			}
		}

	WindowText[1] = WindowText[1] + "</TABLE> </TD></TR></TABLE>"
		stm(WindowText,WindowStyle)
}

	function validateValue(sortBox,checkBoxName)
	{
		if (sortBox.value.search(/[^0-9]/) != -1)
			{
				alert('Invalid number');
				return false
			}
			if (parseInt(sortBox.value,10) > nMaxValue)
				{nMaxValue = parseInt(sortBox.value,10)}
			if (!document.InputForm.elements[checkBoxName].checked)
				{
					document.InputForm.elements[checkBoxName].checked = true;
					updateCounter(document.InputForm.elements[checkBoxName],sortBox.name)
				}
	}

	function checkEnabled(sortBox)
	{
		if (!bSortAsSelected)
			{
				sortBox.blur()
			}
	}

	function updateSortAsSelected(checkBox)
	{
	    nMaxValue = 0;

	    var f;
	    if (getIsIE()) {
	        f = document.InputForm.elements;
	    } else {
	        f = document.InputForm;
	    }
		
		//var SortSelected=document.styleSheets[document.styleSheets.length-1].rules[0];
	    bSortAsSelected = checkBox.checked;
		
		if (f.elements['N1'])
		{
		    setSortAsSelectedStyleSheet(bSortAsSelected);
		    
			for(var i = 1; i <= checkBoxTotal; i++)
			{
				if (bSortAsSelected)
				{
					EnableSortAsSelectedRefresh(true);
					if(f.elements['CB'+i].checked)
					{
						//f.elements['N'+i].disabled = false;
						nMaxValue = nMaxValue +nIncrement;
						f.elements['N'+i].value = nMaxValue;
					}
					else
					{
						//f.elements['N'+i].disabled = true;
						f.elements['N'+i].value = '';
					}
				}
				else
				{
					EnableSortAsSelectedRefresh(false);
				}
			}
			setSortOptions(f,checkBox.checked)
		}
    }

    function setSortAsSelectedStyleSheet(bSortAsSelected) {
        if (bSortAsSelected) {

            if (getIsIE()) {

                document.styleSheets[document.styleSheets.length - 1].addRule(".SortSelected", "display:block; width:45px;");
            }
            else {
                //Delete the Rule if it exists already
                var sortSelectedRule = document.styleSheets[document.styleSheets.length - 1].cssRules.length;
                if (document.styleSheets[document.styleSheets.length - 1].cssRules[0].selectorText == ".SortSelected" || document.styleSheets[document.styleSheets.length - 1].cssRules[0].selectorText == ".sortselected") {
                    document.styleSheets[document.styleSheets.length - 1].deleteRule(0);
                }

                //add the new rule again
                document.styleSheets[document.styleSheets.length - 1].insertRule(".SortSelected{display:block; width:100%;}", 0);
                $(".RememberSortSelected").removeClass("SortSelected");
            }
        }
        else {
            if (getIsIE()) {

                document.styleSheets[document.styleSheets.length - 1].addRule(".SortSelected", "display:none;");
            }
            else {
                $(".RememberSortSelected").addClass("SortSelected");
                //Delete the Rule if it exists already
                var sortSelectedRule = document.styleSheets[document.styleSheets.length - 1].cssRules.length;
                if (document.styleSheets[document.styleSheets.length - 1].cssRules[0].selectorText == ".SortSelected" || document.styleSheets[document.styleSheets.length - 1].cssRules[0].selectorText == ".sortselected") {
                    document.styleSheets[document.styleSheets.length - 1].deleteRule(0);
                }

                document.styleSheets[document.styleSheets.length - 1].insertRule(".SortSelected{display:none;}", 0);
            }
        }
    }

	function EnableSortAsSelectedRefresh(bEnable)
	{
		var imgSortAsSelected = document.getElementById('SortAsSelectedImage');
		if (imgSortAsSelected != null)
		{
			if (bEnable)
			{
				imgSortAsSelected.src = mgRapMLSImages + 'sort_on.gif';
			}
			else
			{
				imgSortAsSelected.src = mgRapMLSImages + 'sort_off.gif';
			}
		}
	}

	function updateSortDirection(sABC)
	{
		// Set Offset for Index: B and C sort have an extra Blank value
		sABC == 'A' ? iOffSet= 0 : iOffSet = 1;
		if (document.InputForm.Sort_Dir_Defaults.value.substr(document.InputForm.elements['Sort_'+sABC].selectedIndex-iOffSet, 1) == 'D')
			{iDir = 1}
		else
			{iDir = 0}
		document.InputForm.elements['Sort_Dir_'+sABC][iDir].checked = true;
		document.InputForm.elements['Sort_Dir_'+sABC][1-iDir].checked = false;
		// update Hidden Fields for GETPARAM
		document.InputForm.elements['Sort_'+sABC+'_H'].value = document.InputForm.elements['Sort_'+sABC].value
	}

	function setSortOptions(f,checkBoxValue)
	{
		f.Sort_A.disabled = checkBoxValue;
		f.Sort_B.disabled = checkBoxValue;
		f.Sort_C.disabled = checkBoxValue;
		f.Sort_Dir_A[0].disabled = checkBoxValue;
		f.Sort_Dir_A[1].disabled = checkBoxValue;
		f.Sort_Dir_B[0].disabled = checkBoxValue;
		f.Sort_Dir_B[1].disabled = checkBoxValue;
		f.Sort_Dir_C[0].disabled = checkBoxValue;
		f.Sort_Dir_C[1].disabled = checkBoxValue;

		f.Sort_As_Selected.checked = checkBoxValue;
		document.getElementById('SortAsSelectedLink').disabled = (bSortAsSelected ? 'false':'true')
		document.getElementById('SortAsSelectedImage').src = sRapMLSImages+(bSortAsSelected? 'sort_on.gif':'sort_off.gif')
	}

	function setPTTableDisplay()
	{

		if (isBackButton()) // see MLSSearchResultsFootUpdateTags.htm
		{
			setStrActiveProperty(parent.strSelectedTab);
		}
		for (intPropertyIndex in strPropertyType_Code)
		{
			if (strPropertyType_Code[intPropertyIndex] == strActiveProperty)
				{
					document.getElementById('PT_TABLE_'+strPropertyType_Code[intPropertyIndex]).style.display = "";
				}
			else
				{
							document.getElementById('PT_TABLE_'+strPropertyType_Code[intPropertyIndex]).style.display = "none";
				}
		}
	}

	function setStrActiveProperty (sVal)
	{
		strActiveProperty = sVal;
		parent.strSelectedTab = sVal;
		document.InputForm.Active_Tab.value = sVal;
		parent.iSelectedTabIndex = getActivePTIndex();
	}

	function ReviseCriteriaButton(iUseMagic)
	{
		if (iUseMagic == 1)
		{
		/*ITG # 257707 RV 01/08/07
		  Sending mgSearchTypeP as a parameter to MLSSearch */
		location.href = "/scripts/mgrqispi.dll?APPNAME=" + mgAppName + "&PRGNAME=MLSSearch&ARGUMENTS=-N" + mgSessionNumber + ",-N" + mgProspectNum + ",-A" + mgSearchTypeP + ",-AY,-N" + mgBMTypeMemberNumber;
		}
		else
		{
		DoASPSearch(0, mgSearchRidP, mgSearchTypeP, '', sMLS,mgSessionNumber ,2, 1)
		}
		return true;
	}
	function reviseCriteria()
	{
		history.go(-1)
	}
	function insertFooter()
	{
		if (document.getElementById('TableFooter_'+strPropertyType_Code[0]))
		{
			for (i in strPropertyType_Code)
			{
					document.getElementById('TableFooter_'+strPropertyType_Code[i]).innerHTML = document.getElementById('footer').innerHTML
			}
		}
	}

	function ReviseStatusButton()
	{
		if (document.InputForm.Property_Status.value == '-') {alert('Invalid status');return false}
		{
			var includeValue ='';
			// ITG #416947, BTs
			var privacySettingValue =''; 
			var objPrivacySettingArray = document.InputForm.Privacy_Setting;

			if(document.InputForm.Include[0].checked) {includeValue = 'with'}
			if(document.InputForm.Include[1].checked) {includeValue = 'without'}
			
			// ITG #416947, BTs
			if (objPrivacySettingArray != null && objPrivacySettingArray.length > 2)
			{
				if(objPrivacySettingArray[0].checked) 
				{
					privacySettingValue = 'M';
				}
				
				if(objPrivacySettingArray[1].checked) 
				{
					privacySettingValue = 'P';
				}
				
				if(objPrivacySettingArray[2].checked) 
				{
					privacySettingValue = 'B';
				}
			}
			
			concatenateCheckboxes();
			location.href = "/scripts/mgrqispi.dll?APPNAME=" + mgAppName + "&PRGNAME=MLSAgentOfficeListings&ARGUMENTS=-N" + mgSessionNumber 
				+ ",-N" + mgAgentOrOfficeNumber 
				+ ",-A" + mgDisplayType 
				+ ",-A" + document.InputForm.Property_Status.value
				+ "&AgentName=" + mgAgentName 
				+ "&AgentNumber=" + mgAgentNumber 
				+ "&Status_From_Date=" + document.InputForm.Status_From_Date.value
				+ "&Status_Thru_Date=" +document.InputForm.Status_Thru_Date.value
				+ "&CheckboxFilter=" + checkboxFilter
				+ "&Include=" + includeValue //last 2 parameters adds on the functionality to view/revise listings as other agent
				+ "&Privacy_Setting=" + privacySettingValue // ITG #416947, BT, 11/30/07 - Private Listings Enhancement
		}

		return true;
	}
	function insertReviseModule(index)
	{
		//if (document.getElementById('ExpandableModule_'+strPropertyType_Code[0]))
		{
			for (i in strPropertyType_Code)
			{
				if (i == index)
				{
					sTempExpandHTML = '<table CELLSPACING="0" CELLPADDING="0" BORDER="0" WIDTH="100%" CLASS="PodBorder">'
						+'<tr >'
							+'<td CLASS="PodBorder ExpandibleHeader" NOWRAP>'
								+ '<div ID="Statuses" STYLE="cursor:hand" onClick="ShowHideTab(\'Statuses\');"><img SRC="' + mgRapMLSImages + 'minus_s.gif" WIDTH="9" HEIGHT="9" ID="FT_Statuses" STYLE="cursor:hand">&nbsp;Filters</div>'
							+'</td>'
						+'</tr>'
						+'<tr >'
							+'<td STYLE="padding:1px" COLSPAN="2">'
								+'<div ID="DIV_Statuses" STYLE="display:">'
									+'<table WIDTH="60%" ALIGN="center" BORDER="0">'
										+'<tr>'
											+'<td CLASS="sNavyTextB">Status to Display</td>'
											+'<td CLASS="sNavyTextB">From Date</td>'
											+'<td CLASS="sNavyTextB">Thru Date</td>'
											// ITG #416947, BTs
											if(mgShowPrivacySetting)
											{	sTempExpandHTML +=
											  '<td CLASS="sNavyTextB">' + mgPrivacySettingLabel + '</td>'
											}

									        var fromDate = '<img class="CalendarBindImage" ALIGN="top" BORDER="0" SRC="' + mgRapMLSImages + 'popCalendar.gif" STYLE="position: relative; cursor: hand " TITLE="View Calendar" onClick="CalFrame.getCalendarFor(this.parentNode.childNodes[0])"> ';
									        var toDate = '<img class="CalendarBindImage" ALIGN="top" BORDER="0" SRC="' + mgRapMLSImages + 'popCalendar.gif" STYLE="position: relative; cursor: hand " TITLE="View Calendar" onClick="CalFrame.getCalendarFor(this.parentNode.childNodes[0])"> ';
									        
											sTempExpandHTML +=
											 '<td></td>'
										+'</tr>'
										+'<tr>'
											+'<td CLASS="mBlackTextB" NOWRAP >'
												+'<select id="Property_Status" NAME="Property_Status" onChange="updateStatusFromDate(this)">'
													+ sPTOptionsString
												+'</select>'
											+'</td>'
											+'<td NOWRAP>'
												+ '<input class="CalendarBind" TYPE="text" SIZE="8" id="Status_From_Date" NAME="Status_From_Date" MAXLENGTH="8" VALUE="' + mgStatusFromDate + '" STYLE="position: relative">&nbsp;'
											    + fromDate
												+ '</td>'
											+'<td NOWRAP>'
												+ '<input class="CalendarBind" TYPE="text" SIZE="8" id="Status_Thru_Date" NAME="Status_Thru_Date" MAXLENGTH="8" VALUE="' + mgStatusThruDate + '" STYLE="position: relative">&nbsp;'												
												+ toDate
												+ '</td>';
											
											// ITG #416947, BTs
											if(mgShowPrivacySetting)
											{	sTempExpandHTML +=
												 '<td CLASS="sBlackTextB">'
													+'<input TYPE="radio" NAME="Privacy_Setting" VALUE="M" ' + mgPrivacySettingMLSChecked + '>MLS&nbsp;'
													+'<input TYPE="radio" NAME="Privacy_Setting" VALUE="P" ' + mgPrivacySettingPrivateChecked + '>Private&nbsp;'
													+'<input TYPE="radio" NAME="Privacy_Setting" VALUE="B" ' + mgPrivacySettingBothChecked + '>Both&nbsp;'
												+'</td>'
											}
											
											sTempExpandHTML +=
											'<td>'
												+'<input CLASS="WorkspaceButton" onMouseOver="this.className=\'WorkspaceButtonHover\'" onMouseOut="this.className=\'WorkspaceButton\'" TYPE="button" VALUE="Search" onClick="SetTarget(); ReviseStatusButton()">'
											+'</td>'
										+'</tr>'
										+'<tr>'
											+'<td COLSPAN="4" CLASS="sNavyTextB">Include only listings <input TYPE="radio" NAME="Include" VALUE="with" ' + mgWithChecked + '>with&nbsp; <input TYPE="radio" NAME="Include" VALUE="without" ' + mgWithoutChecked + '>without the criteria below </td>'
										+'</tr>'
										+'<tr>'
											+'<td COLSPAN="4" NOWRAP CLASS="sBlackText"> '
												+'<input TYPE="checkbox" NAME="Pictures" ' + mgPicturesChecked + '>Pictures&nbsp;&nbsp; <input TYPE="checkbox" NAME="Virtual_Media" ' + mgVMChecked + '>Virtual Media&nbsp;&nbsp;';
											if(mgShowOpenHouses) sTempExpandHTML += '<input TYPE="checkbox" NAME="Open_Houses" ' + mgOpenHousesChecked + '>' + mgOpenHousesLabel + '&nbsp;&nbsp;';
											if(mgShowTours) sTempExpandHTML += '<input TYPE="checkbox" NAME="Tours" ' + mgToursChecked + '>' + mgToursLabel + '&nbsp;&nbsp;';
											if(mgShowAttachments) sTempExpandHTML += '<input TYPE="checkbox" NAME="Attach_Docs" ' + mgAttachedDocsChecked + '>Attached Documents&nbsp;&nbsp;';
											if(mgShowCaravans) sTempExpandHTML += '<input TYPE="checkbox" NAME="Caravans" ' + mgCaravansChecked + '>' + mgCaravansLabel;
											//ITG #281495, BT, 06/06/07 - SF Tuesday Tour
											if(mgShowTuesdayTours) sTempExpandHTML += '<input TYPE="checkbox" NAME="Tuesday_Tours" ' + mgTuesdayToursChecked + '>' + mgTuesdayToursLabel;

										sTempExpandHTML += '</td>'
										+'</tr>'
									+'</table>'
								+'</div>'
							+'</td>'
						+'</tr>'
					+'</table>'
					+'<br>'
					+'<table BORDER="0" WIDTH="100%" CELLSPACING="0" CELLPADDING="0">'
					+'<tr HEIGHT="20">';
					// Quattro Enhancement (ITG#270093), BT, 02/09/07
					/*
					if(mgRealtorEmtpy) sTempExpandHTML += ''; //+'<TD align="center" width="60%" class="mBlackTextB"><FONT class="mRedTextB" id="RecordsFound">0</FONT><SPAN class="mBlackTextB">&nbsp;<FONT id="RecordsType">Listing</FONT>(s) found.&nbsp;</SPAN>'
					if(! mgRealtorEmtpy) sTempExpandHTML += '<td CLASS="sBlueTextB" ALIGN="left" NOWRAP><img SRC="' + mgRapMLSImages + 'trianglenote.gif">&nbsp;&nbsp;&nbsp;Click <img SRC="' + mgRapMLSImages + 'revise.gif" BORDER="0"> to revise the corresponding listing';
					*/

					if(! mgRealtorEmtpy && ! mgIsSRDX) 
					{
						sTempExpandHTML += '<td CLASS="sBlueTextB" ALIGN="left" NOWRAP><img SRC="' + mgRapMLSImages + 'trianglenote.gif">&nbsp;&nbsp;&nbsp;Click <img SRC="' + mgRapMLSImages + 'revise.gif" BORDER="0"> to revise the corresponding listing';
					}
					else
					{
						sTempExpandHTML += ''; //+'<TD align="center" width="60%" class="mBlackTextB"><FONT class="mRedTextB" id="RecordsFound">0</FONT><SPAN class="mBlackTextB">&nbsp;<FONT id="RecordsType">Listing</FONT>(s) found.&nbsp;</SPAN>'
					}
					// End of Quattro Enhancement (ITG#270093)


					sTempExpandHTML += '</td>'
						+'</tr>'
					+'</table>';
					document.getElementById('ExpandableModule_'+strPropertyType_Code[index]).innerHTML = sTempExpandHTML;
				}// check if index matches
				else
				{
					document.getElementById('ExpandableModule_'+strPropertyType_Code[i]).innerHTML = "";
				}
			}// for loop ends
		}

		//SBI #13682, BTs, 03/10/10 - bind new calendar control
		RemoveLegacyCalendar();
		BindCalendar(sRapMLSImages)
    }
	
	function resetHitCounter(nHitCounterOption,sHitCounterMLNumber,sMLSOrigin)
	{
		// Option 3=Agent 4=Public
		sHitCounterLabel = nHitCounterOption == 3 ? 'Agent Hits' : mgPublicClientLabel;
		if (confirm('Are you sure you want to reset your ' + sHitCounterLabel + ' counter to 0?'))
		{
			var myHeight = 150;
			var myWidth = 350;
			var myTop = (window.screen.height - myHeight ) / 2;
			var myLeft = (window.screen.width - myWidth ) / 2;
			document.InputForm.Hit_Counter_ML_Number.value = sHitCounterMLNumber;
			document.InputForm.Hit_Counter_Option.value = nHitCounterOption;
			document.InputForm.Hit_Counter_MLS_Origin.value = sMLSOrigin
			var winURL = '/scripts/mls/MLSResetHitCounterSubmit.htm';
			var sResetHitCounter = window.open(winURL , 'resetHitCounter', 'menubar=no,toolbar=no,resizable=no,directories=no,scrollbars=no,status=no,width='+myWidth+',height='+myHeight+',left=' + myLeft + ',top=' + myTop)
		}
	}

	function UpdateHitCounter(nHitounterOption,sHitCounterMLNumber)
	{
		sHitCounterFontID = nHitounterOption == 3 ? 'AgentHit' : 'PublicHit'
		document.getElementById(sHitCounterFontID +sHitCounterMLNumber).innerHTML = 0;
	}


	function concatenateCheckboxes()
	{
		checkboxFilter =''; // Reset variable
		if (document.InputForm.Pictures)
		{
			if(document.InputForm.Pictures.checked){checkboxFilter = 'P'} else{checkboxFilter}
		}
		if (document.InputForm.Virtual_Media)
		{
			if(document.InputForm.Virtual_Media.checked) {checkboxFilter += 'V'} else{checkboxFilter}
		}
		if (document.InputForm.Open_Houses)
		{
			if(document.InputForm.Open_Houses.checked) {checkboxFilter += 'O'} else{checkboxFilter}
		}
		if (document.InputForm.Tours)
		{
			if(document.InputForm.Tours.checked) {checkboxFilter += 'T'} else{checkboxFilter}
		}
		if (document.InputForm.Attach_Docs)
		{
			if(document.InputForm.Attach_Docs.checked) {checkboxFilter += 'E'} else{checkboxFilter}
		}
		if (document.InputForm.Caravans)
		{
			if(document.InputForm.Caravans.checked) {checkboxFilter += 'C'} else{checkboxFilter}
		}
		//ITG #281495, BT, 06/06/07 - SF Tuesday Tour
		if (document.InputForm.Tuesday_Tours)
		{
			if(document.InputForm.Tuesday_Tours.checked) {checkboxFilter += 'S'} else{checkboxFilter}
		}
	}

	function updateStatusFromDate(objCbox) {

	        var objElements = document.forms["InputForm"].elements;
	        var selectedValue = "";
            
	        if (document.getElementById("Property_Status")) 
	        {
	            selectedValue = $('select#' + "Property_Status" + ' option:selected').attr("name");
	            if (selectedValue == "")
	            {   
	                document.getElementById("Status_From_Date").value = "";
	            }
	            else 
	            {
	                document.getElementById("Status_From_Date").value = selectedValue;
	            }
	        }

	}

	/** Begin Virtual Media **/
	/* 
	* SBI# 16700, MM, 5/19/10 - Added parameters that provide the additional information
	* the virtual media program needs in order to correctly determine whether or not the
	* virtual tour link should show for a paticular listing('MLNumber') for a specific
	* search type('mgSearchTypeP') and for the client facing status of the current context
	* ('bIsClientFacing')
	*/
	function openVirtualMediaWindow(MLNumber,sMLSOrigin,bIsClientFacing,nLONumber)
	{
		var myWidth = 800;
		var myHeight = 600;
		var myTop = 75;
		var myLeft = 100;
		var url;
		
		url = '/scripts/mgrqispi.dll?APPNAME=' + mgAppName + '&PRGNAME=MLSVirtualMedia&ARGUMENTS=-N' + mgSessionNumber + ',-N' + MLNumber + ',-N3&MLSOrigin='+sMLSOrigin;

        if (bIsClientFacing)
        {
            url += "&IsClientFacing=Y";
        } // if (bIsClientFacing)

        // Add parameters for the agent idx search
        if (mgSearchTypeP == 'BM')
        {
            url += "&IDXMemberNumber=" + mgBMTypeMemberNumber;
            url += "&AgentOfficeComparison=M";
        } // if (mgSearchTypeP == 'BM')
        else if (mgSearchTypeP == 'BR')
        {
            if (mgIsIDXFranchise)
            {
                url += "&IsIDXFranchise=Y";
                url += "&IDXFranchiseOfficeNum=" + nLONumber;
            } // if (mgIsIDXFranchise)
        
            // Add parameters for the office idx search
            url += "&IDXOfficeNumber=" + mgBRTypeOfficeNumber;
            url += "&AgentOfficeComparison=O";
        } // else if (mgSearchTypeP == 'BR')

		//window.open changed to add scrollbar per Bret
		var openVirtualMediaWindow = window.open (url, 'mediaWin', 'menubar=no,toolbar=no,resizable=yes,directories=no,scrollbars=yes,status=no,width='+myWidth+',height='+myHeight+',left=' + myLeft + ',top=' + myTop)
		return true;
	}
    /** End Virtual Media **/

	function addToCart()
	{
	    document.InputForm.CheckedRidList.value = fnBuildCBString(checkBoxTotal);

	    MlsPageButtons["Cart"].SetText('Processing...');
	    MlsPageButtons["Cart"].SetDisable(true);

	    //RNI 100604-000054, BTs, 06/10/2010 - Changed the flow of the AddToListingCart process so that it is within the application (iframe) rather than in a pop-up window
	    AddHiddenIframeDocument('iframe_add_to_cart', MagicDomain + '/scripts/mls/MLSAddToListingCart.htm');
	}

	function UpdateCartQuantity(cartTotal,cartAdded)
	{
		//document.getElementById('cartQuantity').innerHTML = cartTotal;
		document.VCRForm.Listing_Cart_Count.value = cartTotal;
		alert (cartAdded + ' listing(s) added to ' + strCartLabel + '. \n\n  Total in ' + strCartLabel + ': '+document.VCRForm.Listing_Cart_Count.value );
		if(MlsPageButtons["Cart"] != null)
		{
		    MlsPageButtons["Cart"].SetText('Add to ' + strCartLabel + ' (' + cartTotal + ')');
		    MlsPageButtons["Cart"].SetDisable(false);
		}
	}

	function CheckProspect()
	{
		if (document.InputForm.Prospect_Number.selectedIndex == 0)
			{
				alert ("You have not selected a valid prospect.");
				return false
			}
		return OneChecked()
	}
	
	function moveToProspectCartSection(ProspectCartSection)
	{
		document.InputForm.CheckedRidList.value = fnBuildCBString(checkBoxTotal);
		document.InputForm.Prospect_Cart_Section_Target.value = ProspectCartSection;
		var myHeight=150; var myWidth=350; var myTop=(window.screen.height-myHeight)/2; var myLeft=(window.screen.width-myWidth)/2;
		var winURL = MagicDomain +'/scripts/mls/MLSAddToProspectCart.htm';
		var smoveToProspectCartSection = window.open(winURL , 'addToProspectCart', 'menubar=no,toolbar=no,resizable=no,directories=no,scrollbars=no,status=no,width='+myWidth+',height='+myHeight+',left=' + myLeft + ',top=' + myTop)
	}

	function saveListingsToProspectCart()
	{
		document.InputForm.CheckedRidList.value = fnBuildCBString(checkBoxTotal);
		document.InputForm.Prospect_Cart_Section_Target.value = "B";
		document.InputForm.Add_to_Saved_Prospect_Cart.value = "yes";
		var myHeight=150; var myWidth=350; var myTop=(window.screen.height-myHeight)/2; var myLeft=(window.screen.width-myWidth)/2;
		var winURL = MagicDomain +'/scripts/mls/MLSAddToProspectCart.htm';
		var sSaveToProspectCartSection = window.open(winURL , 'addToProspectCart', 'menubar=no,toolbar=no,resizable=no,directories=no,scrollbars=no,status=no,width='+myWidth+',height='+myHeight+',left=' + myLeft + ',top=' + myTop)
	}

	function UpdateCartProspectSection(nSectionA,nSectionB,nSectionC,sNewSection,sProspectName)
	{
		//alert("UpdateCartProspectSection("+nSectionA+'/'+nSectionB+'/'+nSectionC+'/'+sNewSection)
		alert ('Listing(s) added to Prospect ' + strCartLabel + '. \n\nTotal saved for '+sProspectName+': '+nSectionB)
	}


	// Property Links
	function ReviseListing(nMLNumber,sMLSOrigin)
	{
		// sMLSOrigin - we don't need to pass this parameter, since we're not modifying a listing in quattro.
		document.location.href ='/scripts/mgrqispi.dll?APPNAME=' + mgAppName + '&PRGNAME=MLSModifyListing&ARGUMENTS=-N' + mgSessionNumber + ',-N'+nMLNumber+',-N1';
	}
	
	function ViewPrimaryPicture(nPictureWidth,sPictureFilename)
	{
		var myWidth = nPictureWidth + 40
		var myHeight = myWidth * .75
		var myTop = (window.screen.height - myHeight)/2
		var myLeft = (window.screen.width - myWidth)/2
		var oPictureWindow=window.open(sPictureFilename, 'newWin', 'menubar=no,toolbar=no,resizable=no,directories=no,scrollbars=no,status=no,height=' + myHeight + ',width=' + myWidth + ',left=' + myLeft + ',top=' + myTop);oPictureWindow.focus();
	}

	function ViewAllPictures(nMLNumber,sSearchType,sMLSOrigin)
	{
		//document.location.href = sMagicPath+'MLSPictureDescriptions&ARGUMENTS=-N' + mgSessionNumber + ',-N'+nMLNumber+',-A'+sSearchType+',-N0,-ARR'
		var myTop = 0 //(window.screen.height - 310)/2;
		var myLeft = 0 //(window.screen.width - 600)/2;
		var objPrinterFriendlyWindow = window.open (sMagicPath+'MLSPictureDescriptions&ARGUMENTS=-N' + mgSessionNumber + ',-N'+nMLNumber+',-A'+sSearchType+',-N0,-N,-ARR'+',-LFalse,-N,-A'+ sMLSOrigin, 'newWin', 'menubar=no,toolbar=no,resizable=yes,directories=no,scrollbars=no,status=no,width=685,height=600,left=' + myLeft + ',top=' + myTop);
	}

	function ViewHistory(nMemberNumber,sMLS,sAssociation,nOfficeNumber,nMain_OfficeNumber,nWorkingOffice,sAPN,sCOUNTY,nMLNumber,sArchive,sMLSOrigin)
	{
		var myWidth = 850;
		var myHeight = 500;
		var myTop = 45;
		var myLeft = 65;
		var width = 500;
		var url = sMagicPath+'MLSReportPropertyHistory&ARGUMENTS=-N' + mgSessionNumber + ',-A,-AR,-AR,-N0,-A,-A,-A,-LFalse,-N0,-N'+nMemberNumber+',-A'+sMLS+',-A'+sAssociation+',-N'+nOfficeNumber+',-N'+nMain_OfficeNumber+',-N'+nWorkingOffice+',-N0,-A1,-A'+sAPN+',-A'+sCOUNTY+',-N'+nMLNumber+',-A'+sArchive+'&MLS_Origin='+sMLSOrigin;
		
		openLookUpWinWHLT(url, myWidth, myHeight,myLeft,myTop)

		//openLookUpWinWHLT('/scripts/mgrqispi.dll?APPNAME=MLSReportPropertyHistory&ARGUMENTS=-N' + mgSessionNumber + ',-A,-AR,-AR,-N0,-A,-A,-A,-LFalse,-N0,-N'+nMemberNumber+',-A'+sMLS+',-A'+sAssociation+',-N'+nOfficeNumber+',-N'+nMain_OfficeNumber+',-N'+nWorkingOffice+',-N0,-A1,-A'+sAPN+',-A'+sCOUNTY+',-N'+nMLNumber+',-A'+sArchive, 'mediaWin', 'fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=yes,directories=no,location=no',800,600,100,75)
		//alert('/scripts/mgrqispi.dll?APPNAME=MLSReportPropertyHistory&ARGUMENTS=-N' + mgSessionNumber + ',-A,-AR,-AR,-N0,-A,-A,-A,-LFalse,-N0,-N'+nMemberNumber+',-A'+sMLS+',-A'+sAssociation+',-N'+nOfficeNumber+',-N'+nMain_OfficeNumber+',-N'+nWorkingOffice+',-N0,-A1,-A'+sAPN+',-A'+sCOUNTY+',-N'+nMLNumber+',-A'+sArchive, 'mediaWin', 'fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=yes,directories=no,location=no')
		
		//document.location.href = sMagicPath+'MLSReportPropertyHistory&ARGUMENTS=-N' + mgSessionNumber + ',-A,-AR,-AR,-N0,-A,-A,-A,-LFalse,-N0,-N'+nMemberNumber+',-A'+sMLS+',-A'+sAssociation+',-N'+nOfficeNumber+',-N'+nMain_OfficeNumber+',-N'+nWorkingOffice+',-N0,-A1,-A'+sAPN+',-A'+sCOUNTY+',-N'+nMLNumber+',-A'+sArchive;
	}

	function ViewTaxURL(sAPN,nFIPSCode)
	{
		var myWidth = 850;
		var myHeight = 500;
		var myTop = 45;
		var myLeft = 65;
		var width = 500;
		var url = sMagicPath+'MLSTaxDetail&ARGUMENTS=-A'+sAPN+',-N' + mgSessionNumber + '+,-LFalse,-N'+nFIPSCode;

		openLookUpWinWHLT(url, myWidth, myHeight,myLeft,myTop)
//		document.location.href = sMagicPath+'MLSTaxDetail&ARGUMENTS=-A'+sAPN+',-N' + mgSessionNumber + '+,-LFalse,-N'+nFIPSCode
	}

	function ViewDisclosure(nMLNumber,sMLSOrigin)
	{
		document.location.href = sMagicPath+ 'MLSDisclosureForm&ARGUMENTS=-N' + mgSessionNumber + ',-N'+nMLNumber+',-AV&MLS_Origin='+sMLSOrigin;
	}

	function ViewAgent(nMemberNumber,sOpenNewWindow)
	{
		var myWidth = 750;
		var myHeight = 500;
		var myTop = 75;
		var myLeft = 100;

		if(sOpenNewWindow =='Y')
		{
			//var openViewAgent = window.open (sMagicPath+'MLSListingAgentDetail&ARGUMENTS=-N'+nMemberNumber+',-N' + mgSessionNumber + '', 'mediaWin', 'menubar=no,toolbar=yes,resizable=yes,directories=no,scrollbars=no,status=no,width='+myWidth+',height='+myHeight+',left=' + myLeft + ',top=' + myTop)
			openLookUpWinWHLT('/scripts/mgrqispi.dll?APPNAME=' + mgAppName + '&PRGNAME=MLSListingAgentDetail&ARGUMENTS=-N'+nMemberNumber+',-N' + mgSessionNumber + '', myWidth, myHeight, myLeft, myTop);
		}
		else
		{
			document.location.href = sMagicPath+'MLSListingAgentDetail&ARGUMENTS=-N'+nMemberNumber+',-N' + mgSessionNumber + ''
		}
	}

	function ViewOffice(nOfficeNumber,sOpenNewWindow)
	{
		var myWidth = 750;
		var myHeight = 500;
		var myTop = 75;
		var myLeft = 100;

		if(sOpenNewWindow =='Y')
		{
			//window.open (sMagicPath+'MLSOfficeInformationPublic&ARGUMENTS=-N'+nOfficeNumber+',-N' + mgSessionNumber + '','newWin','menubar=no,toolbar=no,resizable=yes,directories=no,scrollbars=no,status=no')
			openLookUpWinWHLT('/scripts/mgrqispi.dll?APPNAME=' + mgAppName + '&PRGNAME=MLSOfficeInformationPublic&ARGUMENTS=-N'+nOfficeNumber+',-N' + mgSessionNumber + '', myWidth, myHeight, myLeft, myTop);
		}
		else
		{
			document.location.href = sMagicPath+'MLSOfficeInformationPublic&ARGUMENTS=-N'+nOfficeNumber+',-N' + mgSessionNumber + '';
		}
	}

	function ClearCheckBox(cbx)
	{
		if(cbx.name.substring(0,2) == "QY")
		{
			if(InputForm.elements["QN" + cbx.name.substring(2)] != null)
			{
				InputForm.elements["QN" + cbx.name.substring(2)].checked = false;
			}
		}
		if(cbx.name.substring(0,2) == "QN")
		{
			if(InputForm.elements["QY" + cbx.name.substring(2)] != null)
			{
				InputForm.elements["QY" + cbx.name.substring(2)].checked = false;
			}
		}
		return true;
	}

	function toggleCheckBoxes(namePrefix)
	{
		var f = document.InputForm.elements;
		var bState = namePrefix == 'QY' ? bQYState : bQNState;
		var otherPrefix = namePrefix == 'QY' ? 'QN' : 'QY';
		for(i = 0; i < f.length; i++)
		{
			if(f[i].type == "checkbox" &&
			f[i].name.substring(0,2) == namePrefix)
			{
				f[i].checked = bState;
				if (strCartSectionType == 'A')
				{
					var otherBox = f[otherPrefix+f[i].name.substring(2,f[i].name.length)];
					if (bState) otherBox.checked = false;
				}
			}
		}
		if(bState)
		{
			if (strCartSectionType == 'A')
			{
				otherPrefix == 'QY' ? bQYState = true : bQNState = true;
			}
		}
		namePrefix == 'QY' ? bQYState = !bState : bQNState = !bState;

		if(namePrefix == 'QY')
		{
			if(f["save"].checked)// || f["save"][1].checked)
			{
				if (f["reject"] != null)
				{
					f["reject"].checked = false;
				}// if (f["reject"] != null)
			//	f["reject"].checked = false;
			}
		}
		
		if(namePrefix == 'QN')
		{
			if(f["reject"].checked)// || f["reject"][1].checked)
			{
				if (f["save"] != null)
				{
					f["save"].checked = false;
				}// if (f["save"] != null)
			//	f["save"][1].checked = false;
			}
		}
		return true;
	}

	function TabClick(SectionType)
	{
		document.InputForm.Prospect_Cart_Section_Target.value = SectionType
		document.getElementById("TabClickButton").click();
		return true;
	}

	function SetTarget(button) {
	    
		if (button == 'R')
		{
			cBoxError = OneChecked();
			if(cBoxError == true)
			{
				document.InputForm.Multi_Report_Flag.value = "Y";
				
				//ITG #539888, BT, 12/09/08 - DotNet Report Selection Page
			    if(mgDotNetReportSelector) //open .Net Report Selection Page  
			    {
			        var selectedListingsObj = document.createElement("INPUT");
	        
				    selectedListingsObj = document.createElement("INPUT");
	                selectedListingsObj.name = "hdnSelectedListings";
	                selectedListingsObj.value = fnBuildCBString(checkBoxTotal);

                    //create Other RID String for Hotsheet, Open House and Broker Tours
			        if(document.getElementById('IsHotsheet') || document.getElementById('IsOpenHouse') || document.getElementById('IsBrokerTour'))
			        {
			            var selectedOtherRidsObj = document.createElement("INPUT");
			            var strPrefix = "";

			            if(document.getElementById('IsHotsheet') && document.getElementById('IsHotsheet').value=="yes")
			            {
                            strPrefix = "HS";
			            } 
			            else if (document.getElementById('IsOpenHouse') || document.getElementById('IsBrokerTour'))
			            {
			                strPrefix = "OH";
			            }
			
				        selectedOtherRidsObj = document.createElement("INPUT");
	                    selectedOtherRidsObj.name = "Other_RID_String";
	                    selectedOtherRidsObj.value = fnBuildCBString(checkBoxTotal,strPrefix,null,null,null,"CB"); //function fnBuildCBString(iEnd, sPrefix, sDelimiter, iBegin, oForm, sCBPrefix)	
	                    
	                    document.InputForm.appendChild(selectedOtherRidsObj);	
                    }


	                document.InputForm.appendChild(selectedListingsObj);
	                document.InputForm.action = LoginDomain + "Reports/ReportSelection.aspx";

			    }
			    else //open Magic Report Selection Page
			    {
			    	sWindowTitle = "Multiple Report Select";
			        openReportWindow(document.InputForm, sWindowTitle, 0);
			    }

				//for Citrix solution uncomment the next line: FD 12/01/04
				//return false;
			}
			else
			return cBoxError;
		}
		else if (button == 'F')
		{
			cBoxError = OneChecked();
			if(cBoxError == true)
			{
				document.InputForm.Multi_Report_Flag.value = "Y";
				sWindowTitle = "Multiple Report Select";
				//openReportWindow(document.InputForm, sWindowTitle, 0);
				//for Citrix solution uncomment the next line: FD 12/01/04
				//return false;
			}
			else
			return cBoxError;
		}
		else if (button == 'M')
		{
			// ITG #221548
			if(OneChecked())
			{
				if (selectedListingsCount() <= 250)
				{
				
					//ITG #374061, BT, 07/18/07 - IDV Map Listings Integration Enhancement
					if (mapAppType == 1)
					{
						var checkedRidList;
						var checkedRidListSortOrder;

						checkedRidList = fnBuildCBString(checkBoxTotal);
						checkedRidListSortOrder = fnBuildCBString(checkBoxTotal,'N');
						//alert (checkedRidList);
						//alert (checkedRidListSortOrder);
						
						ShowMapApplication('',checkedRidList,'L','false',checkedRidListSortOrder);
						return false;
					} //mapAppType == 1
					else
					{
						var mapWindow = window.open('about:blank', 'mapWin', 'menubar=no,toolbar=no,resizable=yes,directories=no,scrollbars=yes,status=no');
						document.InputForm.target = 'mapWin';
					}
					
					//var mapWindow = window.open('', 'mapWin', 'menubar=no,toolbar=no,resizable=yes,directories=no,scrollbars=yes,status=no');
					//document.InputForm.target = 'mapWin';
				}
				else 
				{
					alert('The map listings feature can only be used for up to 250 listings.');
					return false;
				}
			}
			else
			{
				return false;
			}
		}
		else if (button == 'X')
		{
			var iSelectedListingsCount = selectedListingsCount();
			document.InputForm.target = '_self';
			document.InputForm.Multi_Report_Flag.value = "";
			if(iSelectedListingsCount  > iDownloadResultsLimit)
			{
				alert('                    ' + iSelectedListingsCount + ' listings checked.\n\nWhen exporting, the maximum number of listings allowed is ' + iDownloadResultsLimit + '.\nPlease select fewer listings and try again.');
				return false;
			}	
		}
		else
		{
		    //RNI# 090318-000123, BT, 11/18/09 - update AgentName
		    document.InputForm.AgentName.value = mgAgentName;
		    document.InputForm.Multi_Report_Flag.value = "";
			document.InputForm.target = (button == null) ? '_self' : '_blank';
			document.InputForm.action =  MagicDomain + '/scripts/mgrqispi.dll';
		}

		return true;
	}
	function UpdateComments(ListingRID,RowCB,MLNumber)
	{
		var myHeight = 350; 
		var myWidth = 750; 
		var myTop = (window.screen.height - myHeight ) / 2; 
		var myLeft = (window.screen.width - myWidth ) / 2;
		var winURL = '/scripts/mgrqispi.dll?APPNAME=' + mgAppName + '&PRGNAME=MLSCartProspectComments&ARGUMENTS=-N' + mgSessionNumber + ',-N0,-N' + numProspectRID + ',-N0,-N'+ListingRID+',-N'+ RowCB+',-N'+MLNumber;
		openLookUpWinWHLT(winURL,myWidth,myHeight,myLeft,myTop);
		//var sCommentsWindow = window.open(winURL , 'updateComments', 'menubar=no,toolbar=no,resizable=no,directories=no,scrollbars=no,status=no,width='+myWidth+',height='+myHeight+',left=' + myLeft + ',top=' + myTop)
	}

	function UpdateCartProspectComments(RowCB,strDateShown,strComments)
	{
		document.InputForm.document.getElementById('Date'+RowCB).innerHTML = strDateShown;
		document.InputForm.document.getElementById('Comment'+RowCB).innerHTML = strComments;
	}


	function DoSearch(iProspectRID, iSearchRID, iOption)
	{
		var strURL = "/scripts/mgrqispi.dll?APPNAME=" + mgAppName + "&PRGNAME=MLSViewContacts&ARGUMENTS=-N" + mgSessionNumber + ",-N" + iOption + ",-N" + iProspectRID + ",-N" + iSearchRID;
		window.location.href=strURL;
		return true;
	}

	// SBI# 9451, MM, 11/6/09 - added searchname as a query string parameter
	function DoASPSearch(iProspectRID, iSearchRID, iSearchType, iProspectName, iMLS, iSessionNumber, iAction, iRevise)
	{
	    var strProspectName = escape(iProspectName);
	    var strASPURL = SearchDomain + "search.aspx?hidMLS=" + iMLS + "&SearchRid=" + iSearchRID + "&SearchType=" + iSearchType + "&SearchName=" + searchName + "&MLS=" + iMLS + "&SessionNumber=" + iSessionNumber + "&ProspectName=" + strProspectName + "&ProspectRID=" + iProspectRID + "&Action=" + iAction + "&IsReviseCriteria=" + iRevise;
		window.location.href=strASPURL;
		return true;
	}
	
	function CreateSearch(iProspectRID)
	{
		var strURL = "/scripts/mgrqispi.dll?APPNAME=" + mgAppName + "&PRGNAME=MLSContactSearchSetup&ARGUMENTS=-N" + mgSessionNumber + ",-N0,-N"+iProspectRID+",-AVIEW,-N" + mgGroupCodeSelected;
		window.location.href=strURL;
		return true;
	}
	function OpenCriteriaWindow(iProspectNumber)
	{
		var iScreenHeight = parseInt(window.screen.height, 10);
		var iScreenWidth = parseInt(window.screen.width, 10);
		var iReportHeight = 200;
		var iReportWidth = 500;
		var iReportTop = parseInt((iScreenHeight - iReportHeight) / 2, 10);
		var iReportLeft = parseInt((iScreenWidth - iReportWidth) / 2, 10);
		var oCriteriaWindow = window.open('/scripts/mgrqispi.dll?APPNAME=' + mgAppName + '&PRGNAME=MLSSearchLookUp&ARGUMENTS=-N' + mgSessionNumber + ',-N3,-APC,-A,-A,-A,-A,-A,-A,-A,-A,-A,-A,-A,-A,-A,-A,-A,-A,-N' + iProspectNumber, 'newWin', 'menubar=no,toolbar=no,resizable=yes,directories=no,scrollbars=no,status=no,top=' + iReportTop + ',left=' + iReportLeft + ',width=' + iReportWidth + ',height=' + iReportHeight);
		// Maintain Focus on the window with the report
		oCriteriaWindow.focus();
	return true;
	}

// Function to open new window without Frameset (To fix the PDF print from Browser File menu
	function openReportNewWindow(oTargetForm, sWindowTitle, iScreensBack)
	{
//		var sContent = "";

		if(iScreensBack == null){iScreensBack = 1;}

		// Set Report Window size and position
		var iScreenHeight = parseInt(window.screen.height, 10) + 75;
		var iScreenWidth = parseInt(window.screen.width, 10);
		var iReportHeight = parseInt(iScreenHeight * .75, 10);
		var iReportWidth = parseInt(iScreenWidth * .80, 10);
		var iReportTop = parseInt(((iScreenHeight - iReportHeight) / 2) - 75, 10);
		var iReportLeft = parseInt((iScreenWidth - iReportWidth) / 2, 10);
		//alert('Window opened '+(oReportWindow != null ? oReportWindow.closed : 'Null!'));
		// Create Report Window
		var oReportWindow = window.open("", "MLSReportWindow", 'menubar=no,toolbar=no,resizable=yes,directories=no,scrollbars=no,status=no,top=' + iReportTop + ',left=' + iReportLeft + ',width=' + iReportWidth + ',height=' + iReportHeight);

		oTargetForm.target = "MLSReportWindow";

		oReportWindow.focus();
		// Go back n number of screens or update Forms Target property to original value
		if(parseInt(iScreensBack, 10) > 0)
			window.setTimeout("history.go(-" + iScreensBack + ");", 550, "JavaScript");
		else
			window.setTimeout("document.InputForm.target = '" + self.name + "';", 550, "JavaScript");

		return oReportWindow
	}

function insertProspectModule()
	{
		if (document.getElementById('ExpandableModule_'+strPropertyType_Code[0]))
		{
			for (i in strPropertyType_Code)
			{
					var myHTML = "<table BORDER='0' WIDTH='100%' CELLSPACING='0' CELLPADDING='0'>"
					+"<tr HEIGHT='30' CLASS='sNavyTextB'> </tr>"
				+"</table>"
				+"<table CELLSPACING='0' CELLPADDING='0' BORDER='0' WIDTH='100%' CLASS='PodBorder'>"
					+"<tr >"
						+"<td CLASS='PodBorder ExpandibleHeader' NOWRAP valign='middle' >"
							+"<div ID='Prospect_Searches"+strPropertyType_Code[i]+"' STYLE='cursor:hand' onClick='ShowHideTab(\"Prospect_Searches"+strPropertyType_Code[i]+"\")'><img SRC='" + mgRapMLSImages + "plus_s.gif' WIDTH='9' align='absmiddle' HEIGHT='9' ID='FT_Prospect_Searches"+strPropertyType_Code[i]+"' STYLE='cursor:hand'>&nbsp;Saved Searches for<a CLASS='sBlueLink' STYLE='padding-left:5px' 'HREF='javascript:document.location.href=\"/scripts/mgrqispi.dll?APPNAME=" + mgAppName + "&PRGNAME=MLSContactDetail&ARGUMENTS=-N" + mgSessionNumber + ",-N" + numProspectRID + ",-AVIEW,-N0\"'>" + mgProspectName + "</a><font CLASS='sBlackText'>";
							if(mgMergeEmail) myHTML += "&nbsp;&nbsp;&nbsp;<a HREF='mailto:" + mgEmailTo + "?cc=" + mgEmailCc + "' TARGET='_new'><img SRC='" + "mgRapMLSImages" + "new_mail.gif' WIDTH='9' HEIGHT='9' BORDER='0' TITLE='Send Email'></a>";
							if(mgMergeStreetAddress) myHTML += "&nbsp;" + mgStreetAddress;
							if(mgMergeCity) myHTML += "&nbsp;" + mgCityStateZip;
							if(mgMergeContactPhone) myHTML += "&nbsp;" + mgContactPhone;
							myHTML = myHTML + "</font></div></div></td>"
					+"</tr>"
					+"<tr>"
						+"<td COLSPAN='2'>"
							+"<div ID='DIV_Prospect_Searches"+strPropertyType_Code[i]+"' STYLE='display:none'><div style='height:75px; overflow:auto'>"
							+"<table  CLASS='bgWhiteBarsBlackText' BORDER='0' WIDTH='100%' CELLSPACING='0' CELLPADDING='0'>"
							+ sProspectSearchesHTML
								+"<tr CLASS='" + mgRowClassR1 + ">"
									+"<td COLSPAN='5' STYLE='padding:5 0 5 15' > <a CLASS='sBlueLink' HREF='javascript:CreateSearch(" + numProspectRID + ");'><img SRC='" + mgRapMLSImages + "add.gif' BORDER='0' WIDTH='16' HEIGHT='16'></a>&nbsp; <a CLASS='sBlueLink' HREF=\"javascript:CreateSearch(" + numProspectRID + ");\">Add a search</a>&nbsp; </td>"
								+"</tr>"
							+"</table></div>"
						+"</td>"
					+"</tr>"
				+"</table>"
				+"</DIV><BR>";
				document.getElementById('ExpandableModule_'+strPropertyType_Code[i]).innerHTML = myHTML;
			}
		}
	}


// Function to open Public Open House report (PDF version). ITG #514448, BT, 10/15/08
	function openPublicOHReport()
	{
		var myWidth =380;
		var myHeight = myWidth * .75;
		var myTop = (window.screen.height - myHeight)/2;
		var myLeft = (window.screen.width - myWidth)/2;
		var objReportWindow = window.open ('/scripts/mgrqispi.dll?APPNAME='+mgAppName+'&PRGNAME=MLSReportOpenHouse&ARGUMENTS='
			+'-N' + mgSessionNumber
			+',-AS'						//cart type
			+',-AR'						//record type
			+',-A'						//record code
			+',-N'+mgSearchRidP			//search_rid
			+',-A'						//listing_rid string
			+',-AARDTTMPR|AAAAA'		//sort: Area_Sort, OH Date, OH Time, Price
			+',-APDF'					//report format
			+'&OTHER_RID_String=' + strOpenHouseRIDs //Open HouseRID string
			,'newWin', 'menubar=no,toolbar=no,resizable=yes,directories=no,scrollbars=no,status=no,width=700,height=750,left=' + myLeft + ',top=' + myTop);
	}

	// RNI# 091124-000069 JL 12/04/09
	/*
	    Added hideDiv to resolve an issue with search results pages that 
	    have View Criteria and Quick Stats divs. The problem was that if
	    users clicked on Quick Stats, and then clicked on View Criteria 
	    without closing Quick Stats, the larger Quick Stats div would cover
	    up View Criteria. Now the onclick/onmousedown event for these divs
	    will first make sure the other is closed before opening the new one
	*/
	function showHideDiv(id)
	{
	    var oDiv = document.getElementById(id);
	    oDiv.style.display = (oDiv.style.display == "inline") ? "none" : "inline";
	}

	function hideDiv(id) 
	{
	    if (document.getElementById(id))
	    {
	        var oDiv = document.getElementById(id);
	        oDiv.style.display = "none"
	    }
	}

	//Cross Browser AttachEvent
	//Call like this AttachEvent(window, 'load', AddPageButtons)
	//Note the omitted 'on' from the evt string parameter
	var LITERAL_BOOL_TRUE = true;
	var LITERAL_BOOL_FALSE = false;
	var LITERAL_ON = "on";
	function mlsAttachEvent(obj, evt, func, useCap) {

	    var returnValue;

	    if (!useCap) {
	        useCap = LITERAL_BOOL_FALSE;
	    } //if (!useCap)
	    if (obj.addEventListener) {
	        obj.addEventListener(evt, func, useCap)
	        returnValue = LITERAL_BOOL_TRUE;
	    } //if (obj.addEventListener)
	    else if (obj.attachEvent) {
	        returnValue = obj.attachEvent(LITERAL_ON + evt, func);
	    } //if (obj.attachEvent)

	    return returnValue;
	}

	function ShowMap(show, listingNum, latitude, longitude) 
	{
	    var newHeight = 0;
	    
	    if (show) {
            mgLatitude = latitude;
            mgLongitude = longitude;
            var latlong = new VELatLong(latitude, longitude);
            rapMap.SetCenterAndZoom(latlong, 15);
            if (rapPin == null) 
            {
                rapPin = new VEShape(VEShapeType.Pushpin, latlong);
                rapPin.SetCustomIcon(mgRapMLSImages + '/map/pins/rooftop.png');
                rapMap.AddShape(rapPin);
            }

	        $(".Lightbox .Header label").html("Listing #" + listingNum);
	        $("#divScreenCover").css({ display: "block" });
	        $("#divMapContainer").css({ display: "block" });
	        newHeight = $("#divMapContainer").height() - 30;
	        $("#divFadeLoad").css({ display: "block", height: newHeight});
	        ResizeMap($("#divMapContainer").width() - 2, newHeight);
	        setTimeout("DoShow()", 500);
	    }
	    else {
	        if (rapMap != null) {
	            rapMap.Clear();
	        }
	        rapPin = null;
	        $("#divMapContainer").animate({ opacity: 0 }, 500, function() { $("#divMapContainer").css({ display: "none" }); $("#divFadeLoad").animate({opactity: 1}); $("#divFadeLoad").css({ display: "block" }); });
	        $("#divScreenCover").animate({ opacity: 0 }, 500, function() { $("#divScreenCover").css({display: "none"}); });
	    }
	}
	
	function DoShow() {

	    if (getIsIE()) {
	        $("#divScreenCover").animate({ opacity: 0.6 }, 1500, function() { $("#divMapContainer").animate({ opacity: 1 }, 2000, function() { $("#divFadeLoad").css({ display: "none" }); }); });
	    }
	    else {
	        $("#divScreenCover").animate({ opacity: 0.6 }, 1500, function() { $("#divMapContainer").animate({ opacity: 1 }, 2000, function() { $("#divFadeLoad").animate({ opacity: 0 }, 500, function() { $("#divFadeLoad").css({ display: "none" }); }); }); });
	    }

	}