<!--

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.toUpperCase().indexOf("MSIE ")+5;
  return parseInt(agent.substr(i)) >= 5 && agent.indexOf("5.0b1") < 0;
}
function ChangeFooterPrintNew(what, howmany){	//49104
//alert (howmany);
	if (howmany == 1||howmany==0){
		if (what.checked){
//cross-browser			divClientFoot.style.display = "inline";
			document.getElementById("divClientFoot").style.display = "inline";
		}else{
//cross-browser			divClientFoot.style.display = "none";
			document.getElementById("divClientFoot").style.display = "none";
			document.emailform.PrintEachFoot.checked = false
		}
	
	}else{
		if (document.emailform.PrintEachFoot.checked){
			for (var i=0; i < howmany; i++ ){
				if (what.checked){
//cross-browser
					if (navigator.userAgent.toUpperCase().indexOf("MSIE") > -1){
						divClientFoot(i).style.display = "inline";
					}else{
					document.getElementsByName("divClientFoot")[i].style.display = "inline";
					//document.getElementById("divClientFoot").style.display = "inline";
					}
				}else{
//cross-browser	
					if (navigator.userAgent.toUpperCase().indexOf("MSIE") > -1){
						divClientFoot(i).style.display = "none";
					}else{
					//	document.getElementById("divClientFoot").style.display = "none";
					document.getElementsByName("divClientFoot")[i].style.display = "none";
					}
				document.emailform.PrintEachFoot.checked = false
				}
			}
		}else{
		if (howmany > 1) {
			if (what.checked){
//cross-browser
//				Alert("howmany:"+howmany)
				if (navigator.userAgent.toUpperCase().indexOf("MSIE") > -1){
					divClientFoot(howmany -1).style.display = "inline";
				}else{
					//document.getElementById("divClientFoot").style.display = "inline";
					document.getElementsByName("divClientFoot")[howmany-1].style.display = "inline";
				}
			}else{
//cross-browser
				if (navigator.userAgent.toUpperCase().indexOf("MSIE") > -1){
					divClientFoot(howmany -1).style.display = "none";
				}else{
//					document.getElementById("divClientFoot").style.display = "none";
					document.getElementsByName("divClientFoot")[howmany-1].style.display = "none";
				}
			}
		}
		}
	}	
}
function ChangeFooterMulti(what, howmany){	//49104
	if (howmany == 1){
		if (what.checked){
//cross-browser			divClientFoot.style.display = "inline";
			document.getElementById("divClientFoot").style.display = "inline";
			document.emailform.PrintFoot.checked = "true";
		}else{
//cross-browser			divClientFoot.style.display = "none";
			document.getElementById("divClientFoot").style.display = "none";
		}
	
	}else{
		if (what.checked){
			document.emailform.PrintFoot.checked = "true";
			for (var i=0; i < howmany; i++ ){
			//cross-browser
			if (navigator.userAgent.toUpperCase().indexOf("MSIE") > -1){
				divClientFoot(i).style.display = "inline";
			}else{
				document.getElementsByName("divClientFoot")[i].style.display = "inline";
//				document.getElementById("divClientFoot").style.display = "inline";
			}
			}
		}else{
			for (var i=0; i < howmany -1; i++ ){
			//cross-browser
			if (navigator.userAgent.toUpperCase().indexOf("MSIE") > -1){
				divClientFoot(i).style.display = "none";
			}else{
//				document.getElementById("divClientFoot").style.display = "none";
				document.getElementsByName("divClientFoot")[i].style.display = "none";
			}
	}	}	}
}
function ChangeEcardInfo(what, howmany){//49104
	if (howmany == 1){
		if (what.checked){
			AgentBanner.innerHTML = AgentBannerText;
			AgentText.innerHTML = AgentTextText;
		}else{
			AgentBanner.innerHTML = "";
			AgentText.innerHTML = "";
		}
	}else{
		if (what.checked){
//			alert(howmany);
			for (var i=0; i < howmany; i++ ){
			AgentBanner(i).innerHTML = AgentBannerText;
			AgentText(i).innerHTML = AgentTextText;
			}
		}else{
			for (var i=0; i < howmany; i++ ){
				AgentBanner(i).innerHTML = "";
				AgentText(i).innerHTML = "";
	}	}	}
}
function ChangeFooterPrint(what){//print - don't print personalization 
	if (what.name == "PrintFoot1"){
	if (what.checked){
	try
	{
//cross-browser			divClientFoot1.style.display = "inline";
			document.getElementById("divClientFoot1").style.display = "inline";
	}
	catch(e){}
	}else{
	try
	{
//cross-browser		divClientFoot1.style.display = "none";
			document.getElementById("divClientFoot1").style.display = "none";
	}
	catch(e){}

	}}	
	if (what.name == "PrintFoot1"){
	if (what.checked){
	try
	{
//cross-browser			divClientFoot2.style.display = "inline";
		document.getElementById("divClientFoot2").style.display = "inline";
	}
	catch(e){}
	}else{
	try
	{
//cross-browser		divClientFoot2.style.display = "none";
		document.getElementById("divClientFoot2").style.display = "none";
	}
	catch(e){}

	}}	
	if (what.name == "PrintFoot3"){
	if (what.checked){
	try
	{
//cross-browser			divClientFoot3.style.display = "inline";
		document.getElementById("divClientFoot3").style.display = "inline";
	}
	catch(e){}
	}else{
	try
	{
//cross-browser		divClientFoot3.style.display = "none";
		document.getElementById("divClientFoot3").style.display = "none";
	}
	catch(e){}

	}}	
	if (what.name == "PrintFoot4"){
	if (what.checked){
	try
	{
//cross-browser			divClientFoot4.style.display = "inline";
			document.getElementById("divClientFoot4").style.display = "inline";
	}
	catch(e){}
	}else{
	try
	{
//cross-browser		divClientFoot4.style.display = "none";
		document.getElementById("divClientFoot4").style.display = "none";
	}
	catch(e){}

	}}	
	if (what.name == "PrintFoot"){
	if (what.checked){
	try
	{
//cross-browser			divClientFoot.style.display = "inline";
		document.getElementById("divClientFoot").style.display = "inline";
	}
	catch(e){}
	}else{
	try
	{
//cross-browser		divClientFoot.style.display = "none";
		document.getElementById("divClientFoot").style.display = "none";
	}
	catch(e){}

	}}
}
// 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)
		}
//	}
}
function PrintReportSafari()
{
		TogglePrintDisplay("fav2");
		window.print();
		setTimeout("TogglePrintDisplay('fav');",3000)
}

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.pageBreakAfter = "always";
		}
	//else {
	//	divReportCover.style.display = "none";
	//	divPageBreak.style.pageBreakAfter = "";
	//	}

	TogglePrintDisplay(false);
	if ( printIsNativeSupport() )
	{
		window.print();
		TogglePrintDisplay(true);
	}
	divReportCover.style.display = "none";
}
function PrintReport2_old()
{
	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";
}

// 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;	//cross-browser
//cross-browser - start
		try
	{
		blnOrdered = mainform.elements('SetSpecialOrder').checked;
	}
	catch(e){}

//	if ( Go && mainform.elements('SetSpecialOrder').checked )
	if ( Go &&  blnOrdered)//cross-browser - end
	{
	//	var colSpan = document.all.tags("SPAN");
		var colSpan = document.getElementsByTagName("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 = '';
				}
			}
		}
	}
}


// Called when user toggles show order labels on and off
function ResultsShowOrder( chkOrder )
{
	var chkBox;
	var intOrder = 1;
	var blnShowSpecialOrder = chkOrder.checked;
//	alert(blnShowSpecialOrder);
	if(!Go)
		RefreshPage();
	else
	{
		//var colSpan = document.all.tags("SPAN");
		var colSpan = document.getElementsByTagName("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];
//			alert(IsDataCheckbox(chkBox) + " " + chkBox.name+ " " + chkBox.value)
			if ( IsDataCheckbox( chkBox ) )
			{
				if ( blnShowSpecialOrder && chkBox.checked )
				{
					chkBox.value = intOrder;
					if (window.ActiveXObject)
					colSpan(chkBox.name + '-LABEL').innerHTML = intOrder;
					else
					colSpan[chkBox.name + '-LABEL'].innerHTML = intOrder;
					intOrder = intOrder + 1;
				}
				else
				{
					chkBox.value = -1;
					if(window.ActiveXObject)
					colSpan(chkBox.name + '-LABEL').innerHTML = '';
					else
					colSpan[chkBox.name + '-LABEL'].innerHTML = '';
				}
			}
		}
	}
}

 
function PrintListing(objChk,strID,headid,footid)
{
	//cross-browser	
	if (window.ActiveXObject){
		var obj = document.all(strID);
	}else{
		var obj = document.getElementById(strID);
	}
	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();
			}
		}
	}
}

// Checks or unchecks all checkboxes on search results supporting ordering
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, chkBox, intOrder;
//cross-browser - start
	var blnOrder = false;
	try
	{
		blnOrder = mainform.elements('SetSpecialOrder').checked;
	}
	catch(e){
//		alert("catch")
		for ( i=0; i<mainform.elements.length; i++ ){
			if(mainform.elements[i].name =="SetSpecialOrder" && mainform.elements[i].checked)
				blnOrder = true;
		}
	}
//	alert(blnOrder)
	if (blnOrder)
//	if ( mainform.elements('SetSpecialOrder').checked )
//cross-browser - end
	{
//		var colSpan = document.all.tags("SPAN");
//		var colSpan = document.getElementById("SPAN")		
		var colSpan = document.getElementsByTagName("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++;
//			alert(intChangedOrder);
			chkRow.value = intChangedOrder;
			ShowCheckOrder(chkRow);
			if(window.ActiveXObject)
			colSpan(chkRow.name + '-LABEL').innerHTML = intChangedOrder;
			else
			colSpan[chkRow.name + '-LABEL'].innerHTML = intChangedOrder;
		}
		else
		{
			// We just unchecked this row - clear order
			intChangedOrder = Number(chkRow.value);
			chkRow.value = -1;
			ShowCheckOrder(chkRow);
			if(window.ActiveXObject)
			colSpan(chkRow.name + '-LABEL').innerHTML = '';
			else
			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;
						if(window.ActiveXObject)
						colSpan(chkBox.name + '-LABEL').innerHTML = intOrder-1;
						else
						colSpan[chkBox.name + '-LABEL'].innerHTML = intOrder-1;
					}
				}
			}
		}
	}
}


// Show the check order in the status bar
//cross-browser replace function
//function ShowCheckOrder( chkBox )
//{
//	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 = '';
//}
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){}
}
//cross-browser - end


// 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 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 )
{
//	alert (where);
	switch (where)
	{
	case 0: // edit report
		mainform.multiview.value=where;
		document.mainform.submit();
		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("/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;
	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 666: // grid report
		mainform.multiview.value=where;
		document.mainform.submit();
		break;

//NOTE: --RMEL-- 1/12/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;
	}
}
//set all .p to display none - not used discovered the problem was IE 8.0 is more case sensitave.
function onLoadForIE8(){
//	var col = document.styleSheets(0);
//	if (col!=null)
//	{
//		if (col.rules.length > 0) 
//		{
//			for (i=0; i<col.rules.length; i++)
//			{
//				//alert(i+ " " +col.rules(i).selectorText + " " + col.rules(i).style.display);
//				if ( col.rules(i).selectorText == ".p"||col.rules(i).selectorText == ".P" ) 
//				{
//					col.rules(i).style.display = "none";
//	}	}	}	}
}

// Toggle print mode with styles - if from body ignore unless in printmode
function TogglePrintDisplay(bFromBody)
{
	var bCurrentPrintMode = false;
	var col = document.styleSheets[0];//cross-browser change (0) to [0]
	var blnLandscape = false;
	var fav = false;
	var fav2 = false;
	if (bFromBody == "fav"){
		bFromBody = true;
		fav = true;
	}
	if (bFromBody == "fav2"){
		bFromBody = false;
		fav2 = true;
	}
		
	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(fav2){
							col.cssRules[i].style.display = "none";
							}
						}
						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";
				}
				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.rules(i).style.backgroundColor = "#F0E9D9";
						}
						if ( col.cssRules[i].selectorText == ".r2" ) 
						{
							col.rules(i).style.backgroundColor = "#969696";
						}
						if ( col.cssRules[i].selectorText == "A" ) 
						{
							document.linkColor = "blue";
							col.rules(i).style.textDecoration = "underline";
						}
					
						if ( col.cssRules[i].selectorText == "BODY" ) 
						{
							col.rules(i).style.margin = "10px";
						}
					}
					if(document.getElementById("banner"))
					document.getElementById("banner").style.visibility = "visible";
				}
			}
		}
	}
	// 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.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()
{
	try {
	// This should be set at the start of the page
	//var NavColor;
//48746 - 3072 no more toolbar, so no more idtoobar	
	if(!NavColor=="")
	{
	try{
	idToolbar.style.display ='block';}
	catch(e){}
	return true;
	}//48746 - 3072 no more toolbar, so no more idtoobar
	}
	catch(e){}
}

// 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.");
		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;
	var numchecked
	numchecked = 0
	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++)
		for(count=0;count<myform.elements.length;count++)
		{
//			alert ( count+ ' ' + myform.elements[count].name + ' ' + IsDataCheckbox( myform.elements[count] ) + ' ' + myform.elements[count].checked )
			if ( IsDataCheckbox( myform.elements[count] ) && myform.elements[count].checked )
			{
				checked=true;
				numchecked = numchecked + 1;
				//break;
			}
		} 
	} 
//	alert (numchecked + ' ' +Multiview);
	if (numchecked > 20 && Multiview == "401"){
		alert("The mapping report only shows 20 listings at a time, you have selected "+numchecked+".  Please select fewer listings or choose another report.");
		return false;
	}
	if (numchecked > 150 && Multiview == "26"){
		alert("The CMA report only allows 150 listings at a time, you have selected "+numchecked+".  Please select fewer listings or choose another report.");
		return false;
	}
	if (numchecked > 200 && Multiview == "300"){
		alert("The Master report only allows 200 records at a time, you have selected "+numchecked+".  Please select fewer records or choose another report.");
		return false;
	}
	if (numchecked > 200 && Multiview == "301"){
		alert("The Detail report only allows 200 records at a time, you have selected "+numchecked+".  Please select fewer records or choose another report.");
		return false;
	}
	if (numchecked > 200 && Multiview == "49"){
		alert("You may only download 200 records at a time, you have selected "+numchecked+".  Please select fewer records or choose another report.");
		return false;
	}

	//********************************************************************************************
	if ( checked || ( myform.SwitchReport.value == 1 ))
	{
		myitem.value=Multiview;
		if (Multiview == "-99"){// multiple reports
			GetMultipleReports()
			return true;
		}else{// multiple reports end
			myform.submit();
			return true;
			}
	}//multiple reports
	else
	{
		alert("You need to select at least one property to do this.");
		return false;
	}
}
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;
}

// Checks the page is loaded then calls SelectReport to display it
function DisplayReport( intReport )
{
	if(!Go)
		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 format cannot be e-mailed.\n\nIf you are trying to e-mail the CMA Report \nthen click the GO button as you cannot\ne-mail the CMA from the search results.");

	}
}

function DisplayRep( intReport )
{
	 
		//if(CMA)
			//UpdateSubjectProperty();
		Go = true;
		SelectReport( intReport );
 
}

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;
		}
	}
}
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
			}	}
	}	}
	if(myform.multiview2.value == ''){
		alert("This action is not permitted.  If you select to delete all of the comps, this Saved CMA will no longer be available, including all subject property information.\n\nIf you need to create a CMA using all new comps please start a new CMA Search.  When you go to create the CMA Report you can select the subject property information from the drop-down list")
		return;
	}else{
	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 );
	}
}
function x_GetNJAccessCount(listing_id){
	var sResp="";
	var xmlhttp = new XMLHttpRequest()
	xmlhttp.open("POST", "http://www.njmls.com/cf/getcount.cfm?mls_number="+listing_id, false);
//	xmlhttp.setRequestHeader ("Content-Type","application/x-www-form-urlencoded");
    xmlhttp.send("");
	sResp = String(xmlhttp.responseText);
	alert (sResp);
	return sResp;
}
function x2_GetNJAccessCount(listing_id){
	if (window.XMLHttpRequest)
	{
	var oReq = new XMLHttpRequest();
	oReq.open("GET", "http://www.njmls.com/cf/getcount.cfm?mls_number="+listing_id);
	xmlhttp.open("POST", "http://www.njmls.com/cf/getcount.cfm?mls_number="+listing_id);
	oReq.send();
	alert(oReq.statusText);
	alert(oReq.responseText);
	return(oReq.statusText);
}	}

//-->
