/*
Already in PageHeader:
	var sMagicPath = '/scripts/mgrqispi.dll?APPNAME=MLSDevelop06&PRGNAME=' // Mg Tag
	var sMLS = "SWMR" // Mg Tag
	var sRapMLSImages = 'http://media1010.rapmlsdev.com/MLS1010.Media/rapmlsimages/'; // Mg Tag
	var isRapStaff = true // Mg Tag
	var isIDX = false // Mg Tag
	var IDXHeaderColor = ""; // Mg Tag
	var IDXHeaderFontColor = ""; // Mg Tag
//		alert(typeof(parent.document));
	var hasNETMenu = typeof(parent.document)=='unknown' ? false : parent.document.getElementById('uwmMainMenu_MainM');
	var MagicDomain = "http://mlsdevelop06.rapmlsdev.com";
	var SearchDomain = "http://search.rapmlsdev.com/MLS1010.Web/";
	var LoginDomain = "http://login1010.rapmlsdev.com/MLS1010.Web/";
	var MediaURL = 'http://media1010.rapmlsdev.com/MLS1010.Media/';
	var MappingDomain = 'http://maps10.rapmlsdev.com/MlsMap1010/';
	var isPageHeaderPublic = false; // Mg Tag
*/
	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();
/*
	if (mgRealtorEmtpy)
	{
		// Declaring first element of Array if no Listings exist to insert EpandableModule
		strPropertyType_Code[0] = 'Empty'; 
	}
*/
	var mgSetTab;

	var bShowingTime;
	var st_image;
	var nIncrement;
	var bSortAsSelected;
	var strCartSectionType;
	var strProspectSectionLabel;
	var intProspectTotalListings;
	var strCartLabel;

	//numProspectRID = <!$MG_Prospect_RID>; // Magic Tags;
	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;

	//mgSearchRidP = <!$MG_Search_RID_P>; use numProspectRID
	var mgSearchTypeP;
	//mgMLS = <!$MG_MLS_P>; use sMLS

	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;
	//ITG #281495, BT, 06/06/07 - SF Tuesday Tour
	var mgShowTuesdayTours;
	var mgTuesdayToursChecked;
	var mgTuesdayToursLabel;
	// ITG #416947, BT, 11/30/07 - Private Listings Enhancement
	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;

	function InitForm()
	{		
		//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; reAlign();}// Resize Fixed Header Header
			
			if (document.readyState != 'complete')
			{
				document.attachEvent("onreadystatechange",isBackButton())
			}
			
			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').innerText = 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 
			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;
		}
		//alert(parent.iSelectedTabIndex);
		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).innerText = '(' + 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 = document.InputForm.elements;
		var SortSelected=document.styleSheets[document.styleSheets.length-1].rules[0];
		bSortAsSelected = checkBox.checked;
		if (f.elements['N1'])
		{
			SortSelected.style.display = (bSortAsSelected? 'block':'none')
			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 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>'
											}
											sTempExpandHTML +=
											 '<td></td>'
										+'</tr>'
										+'<tr>'
											+'<td CLASS="mBlackTextB" NOWRAP >'
												+'<select NAME="Property_Status" onChange="updateStatusFromDate(this)">'
													+ sPTOptionsString
												+'</select>'
											+'</td>'
											+'<td NOWRAP>'
												+'<input TYPE="text" SIZE="8" NAME="Status_From_Date" MAXLENGTH="8" VALUE="' + mgStatusFromDate + '" STYLE="position: relative">&nbsp;'
												+'<img ALIGN="top" BORDER="0" SRC="' + mgRapMLSImages + 'popCalendar.gif" STYLE="position: relative; cursor: hand " TITLE="View Calendar" onClick="CalFrame.getCalendarFor(this.parentNode.childNodes[0])"> </td>'
											+'<td NOWRAP>'
												+'<input TYPE="text" SIZE="8" NAME="Status_Thru_Date" MAXLENGTH="8" VALUE="' + mgStatusThruDate + '" STYLE="position: relative">&nbsp;'
												+'<img ALIGN="top" BORDER="0" SRC="' + mgRapMLSImages + 'popCalendar.gif" STYLE="position: relative; cursor: hand " TITLE="View Calendar" onClick="CalFrame.getCalendarFor(this.parentNode.childNodes[0])"> </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
		}
	}
	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.InputForm.document.getElementById(sHitCounterFontID +sHitCounterMLNumber).innerText = 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;

		if(document.InputForm.Property_Status)
		{
			document.InputForm.Status_From_Date.value = objCbox.options[objCbox.selectedIndex].name;
		}
	}

/** Begin Virtual Media **/
	function openVirtualMediaWindow(MLNumber,sMLSOrigin)
	{
		var myWidth = 800;
		var myHeight = 600;
		var myTop = 75;
		var myLeft = 100;
		//window.open changed to add scrollbar per Bret
		var openVirtualMediaWindow = window.open ('/scripts/mgrqispi.dll?APPNAME=' + mgAppName + '&PRGNAME=MLSVirtualMedia&ARGUMENTS=-N' + mgSessionNumber + ',-N' + MLNumber + ',-N3&MLSOrigin='+sMLSOrigin, '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);

		var myHeight = 150;
		var myWidth = 350;
		var myTop = (window.screen.height - myHeight ) / 2;
		var myLeft = (window.screen.width - myWidth ) / 2;

		var winURL = '/scripts/mls/MLSAddToListingCart.htm';
		var sAddToCart = window.open(winURL , 'addToCart', 'menubar=no,toolbar=no,resizable=no,directories=no,scrollbars=no,status=no,width='+myWidth+',height='+myHeight+',left=' + myLeft + ',top=' + myTop)
	}

	function UpdateCartQuantity(cartTotal,cartAdded)
	{
		//document.getElementById('cartQuantity').innerText = 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+')');
		}
	}

	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
		{
			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).innerText = strDateShown;
		document.InputForm.document.getElementById('Comment'+RowCB).innerText = 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;
	}
	
	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 + "&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);
	}
