<!--

var PrintWindow=0;
var PrintHelp=0;
var Multiview=0;
var Go=false;
var CMA=false;

// print helper for ie4
function printIsNativeSupport() {
  var agent = window.navigator.userAgent;
  var i = agent.indexOf("MSIE ")+5;
  return parseInt(agent.substr(i)) >= 5 && agent.indexOf("5.0b1") < 0;
}


function PrintReport2_back()
{
	if (confirm("Click OK to print a cover page with your report. Click Cancel to print the report without a cover page.")) {
		divReportCover.style.display = "block";
		divPageBreak.style.pageBreakAfter = "always";
		}
	else {
		divReportCover.style.display = "none";
		divPageBreak.style.pageBreakAfter = "";
		}

	TogglePrintDisplay(false);
	if ( printIsNativeSupport() )
	{
		window.print();
		TogglePrintDisplay(true);
	}
	divReportCover.style.display = "none";
}

function PrintReport2()
{
	//if (confirm("Click OK to print a cover page with your report. Click Cancel to print the report without a cover page.")) {
		{
		divReportCover.style.display = "block";
        divPageBreak.style.display = "block";
		divPageBreak.style.pageBreakAfter = "always";
		}
	//else {
	//	divReportCover.style.display = "none";
	//	divPageBreak.style.pageBreakAfter = "";
	//	}

	TogglePrintDisplay(false);
//	if ( printIsNativeSupport() )
//	{
		window.print();
		TogglePrintDisplay(true);
//	}
	divReportCover.style.display = "none";
}

// pops print dialog in ie5
function PrintReport()
{
//cross-browser	if ( printIsNativeSupport() )
//	{
		if (!window.ActiveXObject){
		TogglePrintDisplay(false);
		window.print();
//		alert('Click on "OK" when printing has completed');
		setTimeout("TogglePrintDisplay(true);",3000)
		}else{
		TogglePrintDisplay(false);
		window.print();
		TogglePrintDisplay(true)
		}
//	}
}

// Called when user toggles show photos on and off
function ShowPhotosClick( chkBox )
{
	if(!Go)
		RefreshPage();
	else
	{
		if ( chkBox.checked )
			mainform.elements('ShowPhotos').value = 1;
		else
			mainform.elements('ShowPhotos').value = 0;
	}
}


// Routine returns true if checkbox is for data row
function IsDataCheckbox( formElement )
{
	if (( formElement.type == "checkbox" ) && 
		( formElement.name != 'SetSpecialOrder' ) && 
		( formElement.name != 'PrintLandscape' ) &&
		( formElement.name != 'ShowPhotosChkBox' ))
		return true;
	else
		return false;
}


// Routine to addup the number of checked data records in the form and display to user
function ResultsCountTagged(myform) 
{
	var myitem=myform.multiview;
	if(!Go)
		RefreshPage();
	else
	{
		var intCount = 0;
		for(count=0;count<myform.elements.length-1;count++)
		{
			if ( IsDataCheckbox( myform.elements[count] ) && myform.elements[count].checked )
				intCount++;
		}
		alert("You have " + intCount + " properties tagged");
	}
}

// Routine to re-add check labels after a search results page is reordered.  Needed
// as otherwise when going 'back' to the page the numbers in the labels are gone
function ResultsUpdateLabels( blnForce )
{
	var chkBox;
	var intOrder = -1;
	var blnOrdered = false;
	
	try
	{
		blnOrdered = mainform.elements('SetSpecialOrder').checked;
	}
	catch(e){}
	
	if ( Go &&  blnOrdered)
	{
		var colSpan = document.all.tags("SPAN");
		
		mainform.elements('SpecialOrder').value = 1;
			
		for ( i=0; i<mainform.elements.length; i++ )
		{
			chkBox = mainform.elements(i);
			if ( IsDataCheckbox( chkBox ) )
			{
				if ( chkBox.checked )
				{
					if (( Number(chkBox.value) == -1 ) || ( intOrder != -1 ))
					{
						if ( intOrder == -1 )
						{
							// First checked one - abort if labels already there
							intOrder = 1;
							if (( colSpan(chkBox.name + '-LABEL').innerHTML != '' ) && !blnForce )
								return;
						}
						chkBox.value = intOrder;
						intOrder = intOrder + 1;
					}
					colSpan(chkBox.name + '-LABEL').innerHTML = Number(chkBox.value);
				}
				else
				{
					chkBox.value = -1;
					colSpan(chkBox.name + '-LABEL').innerHTML = '';
				}
			}
		}
	}
}

function PrintListing(objChk,strID,headid,footid)
{
//	alert (objChk+' '+strID+' '+headid+' ' +footid)
//	alert(objChk.name + ' ' + objChk.value + ' ' + objChk.id);
//	var obj = document.all(strID);
	var obj = document.getElementById(strID);
//	alert(obj)
//public open house force removal of listings from map
//	alert(document.getElementById(objChk.id).length);
	if(obj){
	if ( !objChk.checked )
		obj.className='np';
	else
		obj.className='xx';
	}
	var head = document.all(headid);
	if (head != null)
	{
		if ( !objChk.checked )
			head.className='np';
		else
			head.className='xx';
	}
	var foot = document.all(footid);
	if (foot != null)
	{
		if ( !objChk.checked )
			foot.className='np';
		else
			foot.className='xx';
	}
	// cbettis 2002-06-06
	if ((document.emailform != null) && (document.emailform.ListingID != null))
	{
		var hitems = document.emailform.ListingID;
		for (var k = 0; k < hitems.length; k++)
		{
			if (hitems[k].value == headid.slice(1))
			{
				hitems[k].removeNode();
			}
		}
	}
}
// Called when user toggles show order labels on and off
function ResultsShowOrder( chkOrder )
{
	var chkBox;
	var intOrder = 1;
	var blnShowSpecialOrder = chkOrder.checked;

	if(!Go)
		RefreshPage();
	else
	{
		var colSpan = document.all.tags("SPAN");
		
		if ( blnShowSpecialOrder )
			mainform.elements('SpecialOrder').value = 1;
		else
			mainform.elements('SpecialOrder').value = 0;
			
		for ( i=0; i<mainform.elements.length; i++ )
		{
			chkBox = mainform.elements(i);
			if ( IsDataCheckbox( chkBox ) )
			{
				if ( blnShowSpecialOrder && chkBox.checked )
				{
					chkBox.value = intOrder;
					colSpan(chkBox.name + '-LABEL').innerHTML = intOrder;
					intOrder = intOrder + 1;
				}
				else
				{
					chkBox.value = -1;
					colSpan(chkBox.name + '-LABEL').innerHTML = '';
				}
			}
		}
	}
}


// Checks or unchecks all checkboxes on search results supporting ordering
function x_ResultsCheckAll( mainform, bCheck )//replace function cross-browser
{
	var chkBox;
	var blnShowSpecialOrder = false;
	var colSpan = document.all.tags("SPAN")
	
	try
	{
		blnShowSpecialOrder = mainform.elements('SetSpecialOrder').checked;
	}
	catch(e){}
	
	if(!Go)
		RefreshPage();
	else
	{
		var iRowOrder = 1

		for ( i=0; i<mainform.elements.length; i++ )
		{
			chkBox = mainform.elements(i);
			if ( IsDataCheckbox( chkBox ) )
			{
				chkBox.checked = bCheck;
				if ( !bCheck )
				{
					// Removing all checks
					chkBox.value = -1;
					if ( blnShowSpecialOrder )
						colSpan(chkBox.name + '-LABEL').innerHTML = '';
				}
				else
				{
					// Checking so add order text
					chkBox.value = iRowOrder;
					if ( blnShowSpecialOrder )
						colSpan(chkBox.name + '-LABEL').innerHTML = iRowOrder;
					iRowOrder++;
				}
			}

		}
	}
}

function ResultsCheckAll( mainform, bCheck )
{
	var chkBox;
//cross-browser	var blnShowSpecialOrder = mainform.elements('SetSpecialOrder').checked;
	var blnShowSpecialOrder = false;	//cross-browser
	if (window.ActiveXObject){
	var colSpan = document.all.tags("SPAN")
	}else{
	var colSpan = document.getElementById("SPAN")
	}
	try//cross-browser
	{
		blnShowSpecialOrder = mainform.elements('SetSpecialOrder').checked;
	}
	catch(e){}//cross-browser - end

	if(!Go)
		RefreshPage();
	else
	{
		var iRowOrder = 1

		for ( i=0; i<mainform.elements.length; i++ )
		{
			chkBox = mainform.elements[i];//cross-browser change ( to [
			if ( IsDataCheckbox( chkBox ) )
			{
				chkBox.checked = bCheck;
				if ( !bCheck )
				{
					// Removing all checks
					chkBox.value = -1;
					if ( blnShowSpecialOrder )
						colSpan(chkBox.name + '-LABEL').innerHTML = '';
				}
				else
				{
					// Checking so add order text
					chkBox.value = iRowOrder;
					if ( blnShowSpecialOrder )
						colSpan(chkBox.name + '-LABEL').innerHTML = iRowOrder;
					iRowOrder++;
				}
			}

		}
	}
}


// Adjust the row order in SR report due to a check/uncheck.
function ResultsChangeOrder( chkRow )
{
	var intChangedOrder;
	var chkBox;
	var intOrder;
	var blnOrder = false;
	
	try
	{
		blnOrder = mainform.elements('SetSpecialOrder').checked;
	}
	catch(e){}
	
	if ( blnOrder )
	{
		var colSpan = document.all.tags("SPAN");
		
		if ( chkRow.checked )
		{
			// Just checked one - scan to see greatest number 
			intChangedOrder = 0;
			for ( i=0; i<mainform.elements.length; i++ )
			{
				chkBox = mainform.elements(i);
				if ( IsDataCheckbox( chkBox ) )
				{
					intOrder = Number(chkBox.value);
					if ( intOrder > intChangedOrder )
						intChangedOrder = intOrder;
				}
			}
			intChangedOrder++;
			chkRow.value = intChangedOrder;
			ShowCheckOrder(chkRow);
			colSpan(chkRow.name + '-LABEL').innerHTML = intChangedOrder;
		}
		else
		{
			// We just unchecked this row - clear order
			intChangedOrder = Number(chkRow.value);
			chkRow.value = -1;
			ShowCheckOrder(chkRow);
			colSpan(chkRow.name + '-LABEL').innerHTML = '';

			// Adjust other orders above one unchecked
			for ( i=0; i<mainform.elements.length; i++ )
			{
				chkBox = mainform.elements(i);
				if ( IsDataCheckbox( chkBox ) )
				{
					intOrder = Number(chkBox.value);
					if ( intOrder > intChangedOrder )
					{
						chkBox.value = intOrder-1;
						colSpan(chkBox.name + '-LABEL').innerHTML = intOrder-1;
					}
				}
			}
		}
	}
}


// Show the check order in the status bar
function ShowCheckOrder( chkBox )
{
	try
	{
		if ( mainform.elements('SetSpecialOrder').checked )
		{
			if ( chkBox.checked && ( Number(chkBox.value) != -1 ))
				window.status = 'Report order ' + chkBox.value;
			else
				window.status = 'Unchecked';
		}
		else
			window.status = '';
	}
	catch(e){}
}


// Following 4 routines support the GridReport.asp code
// Add fields selected in listbox to those selected in column checkboxes via server trip
function GridReviseReport()
{
	var strURL = 'GridReport.asp?ReportID=Grid&PropType=' + strPropType;
	var blnFirst = true;
	var chkBox;
	var colSpan = document.all.tags("SPAN");

	// See how many field selection columns are checked
	var intChecked = 0;
	for ( i=0; i<mainform.elements.length; i++ )
	{
		chkBox = mainform.elements(i);
		if (( chkBox.type == 'checkbox' ) && ( chkBox.checked ))
			if ( chkBox.name.substr(0,8) == 'gridCOL-' )
				intChecked++;
	}

	// If some checked add these in order of check
	if ( intChecked > 0 )
	{
		var intNext = 1;
		
		while ( intNext <= intChecked )
		{	
			var intWasNext = intNext;
			for ( i=0; i<mainform.elements.length; i++ )
			{
				chkBox = mainform.elements(i);
				if (( chkBox.type == 'checkbox' ) && ( chkBox.checked ))
				{
					if ( chkBox.name.substr(0,8) == 'gridCOL-' )
					{
						if ( Number(chkBox.value) == intNext )
						{
							if ( !blnFirst )
								strURL = strURL + ',';
							else
							{
								strURL = strURL + '&Fields=';
								blnFirst = false;
							}

							var strValue = colSpan(chkBox.name + '-LABEL').value;
							if ( strValue != 'undefined' )
								strURL = strURL + strValue;

							intNext++;
						}
					}
				}
			}
			if ( intWasNext == intNext )
				intChecked = 0;
		}
	}

	// Add on any new fields from list box
	var objList = mainform.elements['gridNewFields']
	for ( i=0; i<objList.length; i++ )
	{
		if ( objList.options(i).selected )
		{
			if ( !blnFirst )
				strURL = strURL + ',';
			else
			{
				blnFirst = false;
				strURL = strURL + '&Fields=';
			}

			strURL = strURL + objList.options(i).value;
		}
	}

	// If no columns checked and no new fields send 'none' to remove any on screen
	if ( blnFirst )
		strURL = strURL + '&Fields=none';
	
	// See how many sort order columns are checked
	blnFirst = true;
	intChecked = 0;
	for ( i=0; i<mainform.elements.length; i++ )
	{
		chkBox = mainform.elements(i);
		if (( chkBox.type == 'checkbox' ) && ( chkBox.checked ))
			if ( chkBox.name.substr(0,9) == 'gridSORT-' )
				intChecked++;
	}

	// If some checked add these in order of check for forced sort order
	if ( intChecked == 0 )
		strURL = strURL + '&Sort=none';
	else
	{
		var intNext = 1;
		while ( intNext <= intChecked )
		{
			var intWasNext = intNext;
			for ( i=0; i<mainform.elements.length; i++ )
			{
				chkBox = mainform.elements(i);
				if (( chkBox.type == 'checkbox' ) && ( chkBox.checked ))
				{
					if ( chkBox.name.substr(0,9) == 'gridSORT-' )
					{
						if ( Number(chkBox.value) == intNext )
						{
							if ( !blnFirst )
								strURL = strURL + ',';
							else
							{
								strURL = strURL + '&Sort=';
								blnFirst = false;
							}

							var strValue = colSpan(chkBox.name + '-LABEL').value;
							if ( strValue != 'undefined' )
								strURL = strURL + strValue;

							intNext++;
						}
					}
				}
			}
			if ( intWasNext == intNext )
				intChecked = 0;
		}
	}

	// If specialorder before retain order flag
	if ( intSpecialOrder == 1 )
		strURL = strURL + '&SpecialOrder=1';
	
	// And redo report via server trip
	location.href = strURL;
}


// Adjust the column order due to a check/uncheck
function GridColOrder( chkCol, strType )
{
	var iChangedOrder, iOrder, chkBox;
	var colSpan = document.all.tags("SPAN");

	if ( chkCol.checked )
	{
		// Just checked one - scan to see greatest number 
		iChangedOrder = 0;
		for ( i=0; i<mainform.elements.length; i++ )
		{
			chkBox = mainform.elements(i);
			if (( chkBox.type == 'checkbox' ) && ( chkBox.checked ))
			{
				if ( chkBox.name.substr(0,5+strType.length) == 'grid' + strType + '-' )
				{
					iOrder = Number(chkBox.value);
					if ( iOrder > iChangedOrder )
						iChangedOrder = iOrder;
				}
			}
		}
		iChangedOrder++;
		colSpan(chkCol.name + '-LABEL').innerHTML = iChangedOrder;
		chkCol.value = iChangedOrder;
	}
	else
	{
		// We just unchecked this col - clear order
		iChangedOrder = Number(chkCol.value);
		colSpan(chkCol.name + '-LABEL').innerHTML = '';
		chkCol.value = 0;

		// Adjust other orders above one unchecked
		for ( i=0; i<mainform.elements.length; i++ )
		{
			chkBox = mainform.elements(i);
			if (( chkBox.type == 'checkbox' ) && ( chkBox.checked ))
			{
				if ( chkBox.name.substr(0,5+strType.length) == 'grid' + strType + '-' )
				{
					iOrder = Number(chkBox.value);
					if ( iOrder > iChangedOrder )
					{
						colSpan(chkBox.name + '-LABEL').innerHTML = iOrder - 1;
						chkBox.value = iOrder - 1;
					}
				}
			}
		}
	}
}


// Checks or unchecks all column checkboxes on grid report
function GridCheckAll( mainform, bCheck )
{
	var chkBox;
	
	if(!Go)
		RefreshPage();
	else
	{
		var iColOrder = 1
		var colSpan = document.all.tags("SPAN");

		for ( i=0; i<mainform.elements.length; i++ )
		{
			chkBox = mainform.elements(i);
			if (( chkBox.type == "checkbox" ) && ( chkBox.name != "PrintLandscape" ) && ( chkBox.name.substr(0,8) == 'gridCOL-' ))
			{
				chkBox.checked = bCheck;
				if ( !bCheck )
				{
					// /Unchecking so remove label
					colSpan(chkBox.name + '-LABEL').innerHTML = '';
					chkBox.value = 0;
				}
				else
				{
					// Checking so add order text
					colSpan(chkBox.name + '-LABEL').innerHTML = iColOrder;
					chkBox.value = iColOrder;
					iColOrder++;
				}
			}
		}
	}
}



// Setup keystroke handler - inactive until handler set to function
var fntHandleEnter = null;
var fntHandleEscape = null;
function disableEnterKey(e)
{
     var key;      
     if(window.event)
          key = window.event.keyCode; //IE
     else
          key = e.which; //firefox      

     return (key != 13);
}

function fntKeyPress(d)
{
	if (blnNetscape4) 
		var key=d.which;
	else
	if (blnIE4)
		var key=event.keyCode;

	if ((key==13) && ( fntHandleEnter != null )) // enter
		fntHandleEnter();
	else
	if ((key==27) && ( fntHandleEscape != null )) // escape
		fntHandleEscape();
}

if (navigator.appName.indexOf("Netscape") >= 0 && parseInt(navigator.appVersion) >= 4)
{
	var blnNetscape4 = true
	document.captureEvents(Event.KEYDOWN);
}
else
if (navigator.appName.indexOf("Explorer") >= 0 && parseInt(navigator.appVersion) >= 4) 
	var blnIE4 = true

document.onkeypress = fntKeyPress;

// Changes to the specified report
function SelectReport( where )
{
	switch (where)
	{
	case 0: // edit report
		mainform.multiview.value=where;
		document.mainform.submit();
		break;
	case -1: // return to search results
		history.go(-1);
		break;
	case 1: // search results checked
//		document.mainform.CMA.value=""; what is this for?
		ViewReport(document.mainform,where);
		break;

	case 2: // search results all
		mainform.multiview.value=where;
		document.mainform.submit();
		break;

	case 3: // summary report checked
		ViewReport(document.mainform,where);
		break;

	case 4: // summary all records
		mainform.multiview.value=where;
		document.mainform.submit();
		break;

	case 5: // current report printed
		if (navigator.appName.indexOf("Explorer") >= 0 && parseInt(navigator.appVersion) >= 4) 
			TogglePrintDisplay(false); // go to printmode
		else
			DoPrint(0);
		break;

	case 6: // current report printed with print help
		PrintHelp=window.open(protocol + domain + "/print_help.asp","Help","resizable=yes,status=no,scrollbars=yes,width=600,height=400");
		break;

	case 7: // open house results checked
		ViewReport(document.mainform,where);
		break;

	case 8: // open house results all
		mainform.multiview.value=where;
		document.mainform.submit();
		break;

	case 9:	 // CMA subject property
		ViewReport(document.mainform,where);
		break;
	
	case 10: // broker tour results checked
		ViewReport(document.mainform,where);
		break;

	case 11: // broker tour results all
		mainform.multiview.value=where;
		document.mainform.submit();
		break;

	case 12: // hotsheet search results checked
		ViewReport(document.mainform,where);
		break;

	case 13: // hotsheet search results all
		mainform.multiview.value=where;
		document.mainform.submit();
		break;

	case -13: // Revise Search
		mainform.multiview.value=where;
		document.mainform.submit();
		break;
//addcomps
	case -14: // delete properties from saved cma
		mainform.multiview.value=where;
		document.mainform.action= protocol+domain+"/cma_report/delComps.asp"
		document.mainform.submit();
		break;

	case -15: // add properties to saved cma
		mainform.multiview.value=where;
		document.mainform.action= protocol+domain+"/cma_report/addComps.asp"
		document.mainform.submit();
		break;

	case -130: //	Go back one public open house 61986
//		history.go(-1);
		self.location.href="OpenHouseResults.asp?SU=3&PropType="+mainform.prop_type.value+"&SearchID="+mainform.SearchID.value
		break;
	case -131: // idx go back
		self.location.href="SearchResultsReport.asp?PropType=1";
		break;
	case 666: // grid report
		mainform.multiview.value=where;
		document.mainform.submit();
		break;

//NOTE: --RMEL-- 3/16/01 Added -998, -999 for CMAPlus/L2000 integration.		
	case -998:
		IRISExport("L2000");
		break;

	case -999:
		IRISExport("CMA");
		break;

	default: // all other normal report selections
		ViewReport(document.mainform,where);
		break;
	}
}

// Toggle print mode with styles - if from body ignore unless in printmode
function x_TogglePrintDisplay(bFromBody)//cross-browser
{
	var bCurrentPrintMode = false;
	var col = document.styleSheets(0);

	// See if document has a landscape option
	var blnLandscape = false;
	var formMain = document.forms('mainform');
	if ( formMain != null )
	{
		var chkLandscape = mainform.elements('PrintLandscape')
		if ( chkLandscape != null )
			blnLandscape = chkLandscape.checked;
	}

	if (col!=null) 
	{
		if (col.rules!=null) 
		{
			// Set bCurrentPrintMode to the current mode
			for (i=0; i<col.rules.length; i++)
			{
//ie 8.0 cares about case				if ( col.rules(i).selectorText == ".np" ) 
					if ( col.rules(i).selectorText == ".np"||col.rules(i).selectorText == ".NP" ) //IE 8.0

				{
					if ( col.rules(i).style.display == "none" )
					{
						bCurrentPrintMode = true;

						// Changing back from print mode so put navbar back in place if from body
						// Next 2 lines by Robert Overman
						if ( bFromBody )
							RestoreMenuBar();

						break;
					}
				}
			}

			// Toggle styles as long as not in displaymode and clicked on body
			if ( !bFromBody || ( bFromBody && bCurrentPrintMode ))
			{
				for ( i=0; i<col.rules.length; i++ )
				{
//ie 8.0					if ( col.rules(i).selectorText == ".np" ) 
					if ( col.rules(i).selectorText == ".np"||col.rules(i).selectorText == ".NP" ) //IE 8.0

					{
						if ( !bCurrentPrintMode )
							col.rules(i).style.display = "none";
						else
							col.rules(i).style.display = "inline";
					}
					else
//					if ( col.rules(i).selectorText == ".p" ) 
					if ( col.rules(i).selectorText == ".p"||col.rules(i).selectorText == ".P" ) //IE 8.0

					{
						if ( !bCurrentPrintMode )
							col.rules(i).style.display = "inline";
						else
							col.rules(i).style.display = "none";
					}
					else
					if ( col.rules(i).selectorText == ".r1" ) 
					{
						if ( !bCurrentPrintMode )
							col.rules(i).style.backgroundColor = "white";
						else
							col.rules(i).style.backgroundColor = "#F0E9D9";
					}
					else
					if ( col.rules(i).selectorText == ".r2" ) 
					{
						if ( !bCurrentPrintMode )
							col.rules(i).style.backgroundColor = "white";
						else
							col.rules(i).style.backgroundColor = "#969696";
					}
					else
					if ( col.rules(i).selectorText == "A" ) 
					{
						if ( !bCurrentPrintMode )
						{
							document.linkColor = "black";
							col.rules(i).style.textDecoration = "none";
						}
						else
						{
							document.linkColor = "blue";
							col.rules(i).style.textDecoration = "underline";
						}
					}
					else
					if ( col.rules(i).selectorText == "BODY" ) 
					{
						if ( !bCurrentPrintMode )
							col.rules(i).style.margin = "0px";
						else
						{
							// edited fro IE8 support
							// Rob Overman 9/3/2008
							//col.rules(i).style.margin = "10px"; // this doesn't cascade properly in IE8
							col.rules(i).style.margin = "0px";
						}
					}
				}
			}
		}
	}

	// Toggle table widths as long as not from body in display mode
	if ( !bFromBody || ( bFromBody && bCurrentPrintMode ))
	{
		var col = null;
		if ( document.forms.length > 0 )
		{
			col = document.forms("mainform");
			if (col!=null) 
				col = col.children;
		}
		if (col!=null) 
		{
			for (i=0; i<col.length; i++)
			{
				if ( col.item(i).tagName == "TABLE" )
				{
					if ( !bCurrentPrintMode && ( col.item(i).width > 700 ))
					{
						if ( blnLandscape )
							col.item(i).width = 960;
						else
							col.item(i).width = 710;
					}
					else
					if ( bCurrentPrintMode && ( col.item(i).width > 700 ))
						col.item(i).width = 750;
				}
			}
		}
	}
	
	// If changing to print mode move the menu bar frame off screen so it ever gets the focus
	// Next 2 lines by Robert Overman
	if ( !bFromBody && !bCurrentPrintMode )
		HideMenuBar();
}
function TogglePrintDisplay(bFromBody)
{
	var bCurrentPrintMode = false;
//	var col = document.styleSheets[0];//cross-browser change (0) to [0]
    var col //getting confused on which stylsheet we're using
	var blnLandscape = false;
	var fav = false;
	if (bFromBody == "fav"){
//	    alert("should be making things visible")
		bFromBody = true;
		fav = true;
	}
    for ( i = 0; i < document.styleSheets.length; i++ ){
        //alert(document.styleSheets[i].href)
        if(document.styleSheets[i].href!=null){
          //  alert(document.styleSheets[i].href.toLowerCase().indexOf("report"))
            if (document.styleSheets[i].href.toLowerCase().indexOf("report") > -1){
                col = document.styleSheets[i];//getting confused on what stylsheet we're using
            }
        }
    }
//    alert(col.href)		
	var formMain = document.forms['mainform'];
//	alert("TPD2");
	if ( formMain != null )
	{
//		var chkLandscape = document.mainform.elements['PrintLandscape']
//		if ( chkLandscape != null )
//			blnLandscape = chkLandscape.checked;
	}
	if (navigator.userAgent.toUpperCase().indexOf("MSIE") > -1){//cross-browser
//	alert("MSIE")
	if (col!=null) 
	{
		if (col.rules!=null) 
		{
			// Set bCurrentPrintMode to the current mode
			for (i=0; i<col.rules.length; i++)
			{
				if ( col.rules(i).selectorText == ".np"||col.rules(i).selectorText == ".NP" ) //IE 8.0
				{
					if ( col.rules(i).style.display == "none" )
					{
						bCurrentPrintMode = true;

						// Changing back from print mode so put navbar back in place if from body
						// Next 2 lines by Robert Overman
						if ( bFromBody )
							RestoreMenuBar();

						break;
					}
				}
			}

			// Toggle styles as long as not in displaymode and clicked on body
			if ( !bFromBody || ( bFromBody && bCurrentPrintMode ))
			{
				for ( i=0; i<col.rules.length; i++ )
				{
					if ( col.rules(i).selectorText == ".np"||col.rules(i).selectorText == ".NP" ) //IE 8.0
					{
						if ( !bCurrentPrintMode )
							col.rules(i).style.display = "none";
						else
							col.rules(i).style.display = "inline";
					}
					else
					if ( col.rules(i).selectorText == ".p"||col.rules(i).selectorText == ".P" ) //IE 8.0
					{
						if ( !bCurrentPrintMode )
							col.rules(i).style.display = "inline";
						else
							col.rules(i).style.display = "none";
					}
					else
					if ( col.rules(i).selectorText == ".r1" ) 
					{
						if ( !bCurrentPrintMode )
							col.rules(i).style.backgroundColor = "white";
						else
							col.rules(i).style.backgroundColor = "#F0E9D9";
					}
					else
					if ( col.rules(i).selectorText == ".r2" ) 
					{
						if ( !bCurrentPrintMode )
							col.rules(i).style.backgroundColor = "white";
						else
							col.rules(i).style.backgroundColor = "#969696";
					}
					else
					if ( col.rules(i).selectorText == "A" ) 
					{
						if ( !bCurrentPrintMode )
						{
							document.linkColor = "black";
							col.rules(i).style.textDecoration = "none";
						}
						else
						{
							document.linkColor = "blue";
							col.rules(i).style.textDecoration = "underline";
						}
					}
					else
					if ( col.rules(i).selectorText == "BODY" ) 
					{
						if ( !bCurrentPrintMode )
							col.rules(i).style.margin = "0px";
						else
							col.rules(i).style.margin = "10px";
					}
				}
			}
		}
	}
	if(document.getElementById("banner")){
		if(!bFromBody)
		document.getElementById("banner").style.display = "none";
		else
		document.getElementById("banner").style.display = "inline";
	}
	}else{//not IE
//		alert("here"+col)
		if (col!=null) 
		{
			if (col.cssRules!=null) 
			{
				if (!bFromBody)//we be getting ready to print
				{
					for ( i=0; i<col.cssRules.length; i++ )
					{
						if ( col.cssRules[i].selectorText == ".np"||col.cssRules[i].selectorText == ".NP" ) //IE 8.0
						{
							col.cssRules[i].style.visibility = "collapse";
						}
						if ( col.cssRules[i].selectorText == ".npd"||col.cssRules[i].selectorText == ".NPD" ) //IE 8.0
						{
							col.cssRules[i].style.display = "none";
						}

						if ( col.cssRules[i].selectorText == ".p"||col.cssRules[i].selectorText == ".P" ) //IE 8.0
						{
							col.cssRules[i].style.visibility = "visible";
						}
						if ( col.cssRules[i].selectorText == ".pn"||col.cssRules[i].selectorText == ".PN" ) //IE 8.0
						{
							col.cssRules[i].style.display = "inline";
						}
						if ( col.cssRules[i].selectorText == ".xx"||col.cssRules[i].selectorText == ".XX" ) //IE 8.0
						{
							col.cssRules[i].style.visibility = "visible";
						}
						if ( col.cssRules[i].selectorText == ".r1" ) 
						{
							col.cssRules[i].style.backgroundColor = "white";
						}
						if ( col.cssRules[i].selectorText == ".r2" ) 
						{
							col.cssRules[i].style.backgroundColor = "white";
						}
						if ( col.cssRules[i].selectorText == "A" ) 
						{
							document.linkColor = "black";
						}
					
						if ( col.cssRules[i].selectorText == "BODY" ) 
						{
							col.cssRules[i].style.margin = "0px";
						}
					}
					if(document.getElementById("banner")){
					    document.getElementById("banner").style.visibility = "collapse";
                        document.getElementById("banner").style.display = "none";
                    }
				}
				else//we be done printing
				{
					for ( i=0; i<col.cssRules.length; i++ )
					{
						if ( col.cssRules[i].selectorText == ".np"||col.cssRules[i].selectorText == ".NP" ) //IE 8.0
						{
							col.cssRules[i].style.visibility = "visible";
//							col.cssRules[i].style.display = "inherit";
							if(fav){
							col.cssRules[i].style.display = "inline";
							}
						}
						if ( col.cssRules[i].selectorText == ".npd"||col.cssRules[i].selectorText == ".NPD" ) //IE 8.0
						{
							col.cssRules[i].style.display = "inline";						
						}
						if ( col.cssRules[i].selectorText == ".p"||col.cssRules[i].selectorText == ".P" ) //IE 8.0
						{
							col.cssRules[i].style.visibility = "collapse";
						}
						if ( col.cssRules[i].selectorText == ".pn"||col.cssRules[i].selectorText == ".PN" ) //IE 8.0
						{
							col.cssRules[i].style.display = "none";
						}

						if ( col.cssRules[i].selectorText == ".xx"||col.cssRules[i].selectorText == ".XX" ) //IE 8.0
						{
							col.cssRules[i].style.visibility = "collapse";
						}

						if ( col.cssRules[i].selectorText == ".r1" ) 
						{
							col.cssRules(i).style.backgroundColor = "#F0E9D9";
						}
						if ( col.cssRules[i].selectorText == ".r2" ) 
						{
							col.cssRules(i).style.backgroundColor = "#969696";
						}
						if ( col.cssRules[i].selectorText == "A" ) 
						{
							document.linkColor = "blue";
							col.cssRules(i).style.textDecoration = "underline";
						}
					
						if ( col.cssRules[i].selectorText == "BODY" ) 
						{
							col.cssRules[i].style.margin = "10px";
						}
					}
					if(document.getElementById("banner")){
					    document.getElementById("banner").style.visibility = "visible";
                        document.getElementById("banner").style.display = "inline";
                    }
				}
			}
		}
	}
	// Toggle table widths as long as not from body in display mode
	if ( !bFromBody || ( bFromBody && bCurrentPrintMode ))
	{
		var col = null;
		var formMain = document.forms['mainform'];
		if ( formMain != null )
//		if ( document.forms.length > 0 )
		{
			col = document.forms["mainform"];
			if (col!=null) 
				col = col.children;
		}
		if (col!=null) 
		{
			for (i=0; i<col.length; i++)
			{
				if ( col.item(i).tagName == "TABLE" )
				{
					if ( !bCurrentPrintMode && ( col.item(i).width > 700 ))
					{
						if ( blnLandscape )
							col.item(i).width = 960;
						else
							col.item(i).width = 710;
					}
					else
					if ( bCurrentPrintMode && ( col.item(i).width > 700 ))
						col.item(i).width = 750;
				}
			}
		}
	}
	
	// If changing to print mode move the menu bar frame off screen so it ever gets the focus
	// Next 2 lines by Robert Overman
	if ( !bFromBody && !bCurrentPrintMode )
		HideMenuBar();
	if (bFromBody)
		RestoreMenuBar();

}

// Routine called to Restore the New Menu Bar
// written by Robert Overman
function HideMenuBar()
{
	try {
	// This should be set at the start of the page
	//var NavColor;
	//48746 - 3072 no more toolbar, so no more idtoobar comment this back out
	if(!NavColor=="")
	{
	try{
    idToolbar.style.visibility = "collapse";
	idToolbar.style.display ='none';}
	catch(e){}
	return true;
	}
	//48746 - 3072 end
	}
	catch(e){}
}

// Routine called to Restore the New Menu Bar
// written by Robert Overman
function RestoreMenuBar()
{
	// This should be set at the start of the page
	//var NavColor;
	
	if(!NavColor=="")
	{
    document.getElementById("idToolbar").style.visibility = "visible";
    document.getElementById("idToolbar").style.display = "inline";
	//document.getElementById("idToolbar").style.display ='block';
	return true;
	}
}

// Prompt to load page
function RefreshPage()
{
	alert("Please refresh this page by right clicking over the page\nand selecting the refresh option, then wait for the page\nto finish re-loading (or click on back to change the search\ncriteria).");
}

// Filter called to limit display of rows to those checked.  Only works on ie and requires table with property
// defined by MLS number in value of checkbox to have an id=P#######
function Filter( myform, bCheckedOnly )
{
	var checked=false;
	if(!Go)
	{
		RefreshPage();
		return false;
	}

	for ( count=0; count<myform.elements.length-1; count++ )
	{
		if ( myform.elements[count].checked )
		{
			checked=true;
			break;
		}
	}

	if ( bCheckedOnly && !checked )
	{
		alert("You need to select at least one property to do this.");
		return false;
	}

	for ( count=0; count<myform.elements.length-1; count++ )
	 {
		if ( myform.elements[count].type == "checkbox" && !myform.elements[count].checked )
		{
			if ( bCheckedOnly )
				document.all.item("P"+myform.elements[count].value).style.display = "none";
			else
				document.all.item("P"+myform.elements[count].value).style.display = "inline";
		}
	}
}

// Only for netscape or when going to different report - makes sure at least 1 record is checked
function Checkit(myform) 
{
	var checked=false;
	var myitem=myform.multiview;
	if(!Go)
	{
		RefreshPage();
		return false;
	}
	myitem.value=0;
	//********************************************************************************************
	// added code to support spreadsheet grid java applet
	// RJO - 8/11/2005
	//********************************************************************************************
	var bSpreadsheet = false;
	try
	{
		bSpreadsheet = (myform.SpreadsheetGrid.value == '1');
	}
	catch(e){}
	
//	if(bSpreadsheet)
	if(bSpreadsheet || myform.ReportID.value=="AP1004MC")
	{
		checked=true;
	}
	else
	{
		for(count=0;count<myform.elements.length-1;count++)
		{
			if ( IsDataCheckbox( myform.elements[count] ) && myform.elements[count].checked )
			{
				checked=true;
				break;
			}
		}
	}
	//********************************************************************************************
//	if ( checked || ( myform.SwitchReport.value == 1 ))
//	{
//		myitem.value=Multiview;
//		myform.submit();
//		return true;
//	}
//	else
//	{
	if ( checked || ( myform.SwitchReport.value == 1 ))
	{
		myitem.value=Multiview;
        //alert(Multiview);
		if (Multiview == "-99"){// multiple reports
			GetMultipleReports()
			return true;
		}else{// multiple reports end
			myform.submit();
			return true;
		}
	}
	else
	{
		alert("You need to select at least one property to do this.");
		return false;
	}
}

// Checks the page is loaded then calls SelectReport to display it
function GetMultipleReports(){//multiple reports
	var theURL = "GetMultipleReports.asp?prop_type="+document.mainform.prop_type.value
	var reportselwin = window.open(theURL,"ReportSelection","resizable=yes,status=no,scrollbars=yes,width=300,height=300");
	reportselwin.creator = self;
}

function DisplayReport( intReport )
{
	if(!Go && intReport !='-1')
		RefreshPage();
	else
	{
		//if(CMA)
			//UpdateSubjectProperty();
			//SelectReport( intReport );
			//bwf 042502 9815
			if(intReport > 10000)
			{
				SelectReport( intReport - 10000);
			}
			else
			{
				SelectReport( intReport);
			}
	}
}

//bwf 042502 9815
function DisplayReport2( intReport, myform )
{
	if(!Go)
		RefreshPage();
	else
	{
		//if(CMA)
			//UpdateSubjectProperty();
			//SelectReport( intReport );
			
			//bwf 042502 9815
			if(intReport > 10000)
			{
				//jtf 051302 10170
				myform.EmailOnly.value = "0";
				SelectReport( intReport - 10000);
				 
			}
			else
			{
				//jtf 051302 10170
				myform.EmailOnly.value = "0";
				SelectReport( intReport);
				 
			}
		//alert("EmailOnly="+myform.EmailOnly.value)
		//myform.EmailOnly.value = "0";
		//alert("EmailOnly="+myform.EmailOnly.value)	
	}
}

//bwf 042502 9815
function EmailReport( intReport, myform )
{
	if(!Go)
		RefreshPage();
	else
	{
		//if(CMA)
			//UpdateSubjectProperty();
			//SelectReport( intReport );
			//alert("Selected Report: " + intReport);
			
			//bwf 042502 9815
			if(intReport > 10000)
			{
				myform.EmailOnly.value = "1";
				SelectReport( intReport - 10000);
			}
			else
				alert ("This report cannot be emailed from Search Results");

	}
}

function ViewReport(myform,viewnumber)
{
	Multiview=viewnumber;
	if(!Checkit(myform))
		Multiview=0;
}

// Checks or unchecks all checkboxes on searchresults report
function checkAll(myform, bCheck) {
	if(!Go)
		RefreshPage();
	else
	{
		for(i=0;i<myform.elements.length;i++)
		{
			if(myform.elements[i].type == "checkbox")
				myform.elements[i].checked=bCheck;
		}
	}
}
//cma add comps
function WhackChecked(myform){
	if(confirm("You are about to delete comps, are you sure?")){
	myform.multiview2.value = ''
	for(i=0;i<myform.elements.length;i++){
		if(myform.elements[i].type == "checkbox"&&!isNaN(myform.elements[i].name)){
			//alert(myform.elements[i].name + ' ' + myform.elements[i].checked)
			if (!myform.elements[i].checked){
				if (myform.multiview2.value == ''){
					myform.multiview2.value = myform.elements[i].name
				}else{
				myform.multiview2.value = myform.multiview2.value + ", " +myform.elements[i].name
			}	}
	}	}
	DisplayReport(-14)
	}
}
function AddChecked(myform){
	myform.MLSSTRING.value = ''
	for(i=0;i<myform.elements.length;i++){
		if(myform.elements[i].type == "checkbox"&&!isNaN(myform.elements[i].name)){
			//alert(myform.elements[i].name + ' ' + myform.elements[i].checked)
			if (myform.elements[i].checked){
				if (myform.MLSSTRING.value == ''){
					myform.MLSSTRING.value = myform.elements[i].name
				}else{
				myform.MLSSTRING.value = myform.MLSSTRING.value + ", " +myform.elements[i].name
			}	}
	}	}
	DisplayReport(-15)
}


// Called in search screen
function SetForm() {
document.forms[0].fname.focus();
}

// Called in search screen
function PropType(myform, prop_type)
{
myform.prop_type.value=prop_type;
myform.submit();
}

// Called in search screen
function DoSearch(myform, search_type)
{
	if(allowSend(myform))
	{
		myform.search_type.value = search_type;
		myform.submit();
	}
}

// SwitchImage takes an Img tag object and looks for "image_no=nnofyy" where nn is the current image number and
// yy is the maximum possible.  It then increments the count and changes the SRC= part of the tag to tell
// Showimg.asp to get the next image in turn.  This routine does work but as of 08/06/99 Reports.asp does not output
// the IMG tag source URL for photos with the "image_no=nnofyy" component and showimg.asp does not check for this
// when extracting an image.
//
// Example URL in img SRC= tag is 
//
//"http://dev.xxxxxx.terradatum.com/showimg.asp?image_no=01of04&image_id=820448t"
//
function SwitchImage( objImgTag )
{
	
	var intIndex = objImgTag.src.search("image_no=")
	if ( intIndex > -1 )
	{
		var strSrc = objImgTag.src;
		var intThisImage = 0;
		var intLastImage = 0;

		var intThisImage=new Number(strSrc.substr(intIndex+9,2));
		intThisImage = intThisImage + 1;
		var intLastImage=new Number(strSrc.substr(intIndex+13,2));
		if ( intThisImage > intLastImage ) intThisImage = 1;
		var strThisImage = intThisImage.toString();
		if ( strThisImage.length == 1 ) strThisImage = "0" + strThisImage;

		objImgTag.src = strSrc.substr(0,intIndex+9) + strThisImage + strSrc.substring(intIndex+11,strSrc.length)
		alert("Image=" + objImgTag.src );
	}
}

//-->

