function CU_openBrWindow(theURL,winName,features) { 
	window.open(theURL,winName,features);
	return false;
}
function CU_openHelpWindow(theTopic) { 
	window.open('/realestate/help.aspx?topic='+theTopic,'_crsHelpWin','menubar=no,status=yes,scrollbars=yes,resizable=yes,top=0,left=0,width=640,height=550');
	return false;
}
function CU_openFeedbackWindow() { 
	window.open('/realestate/Feedback.aspx','_crsFBWin','menubar=no,status=yes,scrollbars=no,resizable=yes,top=0,left=0,width=660,height=420');
	return false;
}
function CU_openTrendReportWindow() { 
	window.open('/realestate/TrendReport.aspx','_crsTRWin','menubar=no,status=yes,scrollbars=no,resizable=yes,top=0,left=0,width=660,height=420');
	return false;
}
function CU_openMySettingsWindow() { 
	window.open('/realestate/user/mySettings.aspx','_crsMySettingsWin','menubar=no,status=yes,scrollbars=yes,resizable=yes,top=0,left=0,width=560,height=600');
	return false;
}
function CU_openCurrencyWindow() {
	window.open('/realestate/datacurrency.aspx','_crsCurrencyWin','menubar=no,status=yes,scrollbars=yes,resizable=yes,top=0,left=0,width=760,height=600');
	return false;
}
function CU_openFormLetters() {
	window.open('/realestate/formletters.aspx','_crsFormLettersWin','menubar=no,status=yes,scrollbars=yes,resizable=yes,top=0,left=0,width=760,height=600');
	return false;
}
function CU_openReferralWindow() { 
	window.open('/realestate/referral.aspx','_crsRefWin','menubar=no,status=yes,scrollbars=yes,resizable=yes,top=0,left=0,width=660,height=550');
	return false;
}
function CU_openEmailWindow() {
	var irc = CU_saveToDisk();
	alert('To email this page, click \'Open\' in the File Download Box, then select the \'Email\' button from the Adobe toolbar.');
	return irc;
}
function CU_openEmailCondensedWindow() {
	var irc = CU_saveCondensedToDisk();
	alert('To email this page, click \'Open\' in the File Download Box, then select the \'Email\' button from the Adobe toolbar.');
	return irc;
}
function CU_openBrPpvDeedWindow(theURL) { 
   window.open(theURL,'_crsdeedwin','toolbar=yes,location=no,directories=no,status=yes,menubar=yes,resizable=yes,copyhistory=no,scrollbars=yes,top=0,left=0,height=430,width=480');
	return false;
}
function CU_openAVMwindow(theURL)
   { 
   window.open(theURL,'_homesmart','toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,resizable=yes,copyhistory=no,scrollbars=yes,top=0,left=0,height=480,width=770');
   }

function CU_openBrDefaultWindow(theURL,winName) { 
	window.open(theURL,winName,'status=yes,scrollbars=yes,menubar=no,toolbar=no,resizable=yes,copyhistory=no,top=0,left=0,width=720,height=500');
	return false;
}

function CU_openMapImageWindow(theURL, winName, winWidth, winHeight) {
    window.open(theURL, winName, 'status=yes,scrollbars=yes,menubar=no,toolbar=no,resizable=yes,copyhistory=no,top=0,left=0,width=' + winWidth + ',height=' + winHeight + '');
    return false;
}
function CU_openPrcWindow(theURL, winName) {
    window.open(theURL, winName, 'status=yes,scrollbars=yes,menubar=no,toolbar=yes,resizable=yes,copyhistory=no,top=0,left=0,width=810,height=500');
    return false;
}

function CU_openMLSListingWindow(theURL, winName) {
    var winWidth = ((screen.width / 3) * 2);
    var winHeight = ((screen.height/3)*2);
    window.open(theURL, winName, "toolbar=yes,location=no,directories=no,status=yes,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,top=0,left=0,width='" + winWidth + "',height='" + winHeight + "'");
    return false;
}

var cuSessionWindow;
function CU_EstSession_Finish(sessionWindow, theURL, winName) {
    goodWin = window.open(theURL, winName, 'status=yes,scrollbars=yes,menubar=no,toolbar=no,resizable=yes,copyhistory=no,top=0,left=0,width=720,height=500');
    sessionWindow.close();
    goodWin.focus();
}
function CU_EstSession_openBrDefaultWindow(sSessionURL, theURL, winName) {
    cuSessionWindow = window.open(sSessionURL, '_junkpage', 'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no,top=0,left=0,width=100,height=100');
    setTimeout("CU_EstSession_Finish(cuSessionWindow, '" + theURL + "', '" + winName + "')", 750);
    return false;
}
//function CU_EstSession_openBrDefaultWindow(sSessionURL, theURL, winName)
//{
//newWin = window.open(sSessionURL,'_junkpage','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no,top=0,left=0,width=100,height=100');
//goodWin = window.open(theURL,winName,'status=yes,scrollbars=yes,menubar=no,toolbar=no,resizable=yes,copyhistory=no,top=0,left=0,width=720,height=500');
//goodWin.focus();
//newWin.close();
//return false;
//}
function checkOpenerStatus() {
    var strOpener = opener.location.href;
    if(strOpener.indexOf("success.php") != -1 ||
strOpener.indexOf("error.php") != -1) {
     // I am going to close now
     self.close();
    }
} 

function CU_EstSession_openBrDefaultWindow2(sSessionURL, theURL, winName)
{
newWin = window.open(sSessionURL,'_junkpage2','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no,top=0,left=0,width=100,height=100');
goodWin = window.open(theURL,winName,'status=yes,scrollbars=yes,menubar=no,toolbar=no,resizable=yes,copyhistory=no,top=100,left=100,width=720,height=500');
goodWin.focus();
newWin.close();
return false;
//window.open('','_CRSlinkWin','toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,resizable=yes,copyhistory=no,scrollbars=yes');
}
function CU_openBrDefaultWindow2(theURL,winName) { 
	window.open(theURL,winName,'status=yes,scrollbars=yes,toolbar=yes,resizable=yes,copyhistory=no,top=40,left=40,width=770,height=440');
	return false;
}
function CU_openBrDefaultWindow3(theURL, winName) {
    window.open(theURL, winName, 'status=yes,scrollbars=yes,toolbar=yes,resizable=yes,copyhistory=no,top=40,left=40,width=1024,height=768');
    return false;
}
function crsGetObject(name)
{
  var obj;
  if( document.getElementById )
    obj = document.getElementById(name);
  if( !obj && (document.all) )
	obj = document.all[name];
  if( !obj && (document.layers) )
	obj = crsGetObjectNN4(document,name);
  if( obj ) 
	return obj;
  else if ( window.jQuery )
  {
	if( !$.browser.msie )
	{
		var Jobj = $('#' + name)
		if( Jobj.length <= 0 )
			Jobj = $('[name=' + name + ']')
		if( Jobj.length > 0 ) return Jobj.get(0);
	}
  }
}

function crsGetObjectNN4(obj,name)
{
	var x = obj.layers;
	var foundLayer;
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id == name)
		 	foundLayer = x[i];
		else if (x[i].layers.length)
			var tmp = crsGetObjectNN4(x[i],name);
		if (tmp) foundLayer = tmp;
	}
	return foundLayer;
}
function CU_closeWindow()
{
	self.close();
}
function CU_focusOpener()
{
	if( self.opener )
		self.opener.focus();
}
function CU_saveToDisk()
{
	document.Form1.pdf.value="1";
	if( document.Form1.btnUpdateSearch )
		document.Form1.btnUpdateSearch.click();
	else
	{
		if( document.Form1.onsubmit ) document.Form1.onsubmit();
		document.Form1.submit();
	}
	document.Form1.pdf.value="";
	return false;
}
function CU_saveCondensedToDisk()
{
	document.Form1.pdf.value="2";
	if( document.Form1.btnUpdateSearch )
		document.Form1.btnUpdateSearch.click();
	else
	{
		if( document.Form1.onsubmit ) document.Form1.onsubmit();
		document.Form1.submit();
	}
	document.Form1.pdf.value="";
	return false;
}
function verifyItemSelected(curObjectName)
{
	var curObject = crsGetObject(curObjectName);
	if(curObject.options[curObject.selectedIndex].value.length != 0) 
	{
		return true;	
	}else 
	{
		return false;
	}
}
function verifyDelete(curObjectName)
{
	if(verifyItemSelected(curObjectName)) 
	{
		return confirm('Are you sure you want to Delete the selected Item?');		
	}else 
	{
		alert('You must Select an item to Delete.');
	}
	return false;
}
function crsGreyMeOut(item)
{
	if(item) 
	{
		var divObject = crsGetObject('div' + item.id.substring(3))
		if(divObject)
		{
			var curhid = divObject.getElementsByTagName('input');
			if( curhid[0].value != '1' )
			{
				divObject.className = '';
				var curimages = divObject.getElementsByTagName('img');
				for (i=0; i < curimages.length;i++ )
				{
					curimages[i].src = 'images/xSmall.gif';
					curimages[i].alt = 'Do not print this value';
					curimages[i].title = curimages[i].alt;
				}
				var curdiv = divObject.getElementsByTagName('div');
				for (i=0; i < curdiv.length;i++ )
				{
					curdiv[i].className = '';
				}
				for (i=0; i < curhid.length;i++ )
					curhid[i].value = '1';
					
				if( divObject.id == 'divEstimatesTotal' || divObject.id == 'divEstimatesHPCI' || divObject.id == 'divEstimatesTaxes' )
				{
					var div1 = crsGetObject('divEstimatesTotal');
					var div2 = crsGetObject('divEstimatesHPCI');
					var div3 = crsGetObject('divEstimatesTaxes');
					var div4 = crsGetObject('divEstimatesAll');
					if( div1 && div2 && div3 && div4 )
					{
						if(( div1.className == '' ) || ( div2.className == '' ) || ( div3.className == '' ) )
						{
							var img4 = crsGetObject('imgEstimatesAll');
							if( img4 != null )
							{
								div4.className = '';
								img4.src = 'images/xSmall.gif';
								img4.alt = 'Do not print this value';
								img4.title = img4.alt;
								var curhid = div4.getElementsByTagName('input');
								if( curhid != null )
									curhid[0].value = '1';
							}
						}
					}
				}
			}
			else
			{
				//Turn Off
				divObject.className = 'greyedOut';
				var curimages = divObject.getElementsByTagName('img');
				for (i=0; i < curimages.length;i++ )
				{
					curimages[i].src = 'images/checkSmall.gif';
					curimages[i].alt = 'Print this value';
					curimages[i].title = curimages[i].alt;
				}
				var curdiv = divObject.getElementsByTagName('div');
				for (i=0; i < curdiv.length;i++ )
					curdiv[i].className = 'greyedOut';
			
				for (i=0; i < curhid.length;i++ )
					curhid[i].value = '0';
					
				if( divObject.id == 'divEstimatesTotal' || divObject.id == 'divEstimatesHPCI' || divObject.id == 'divEstimatesTaxes' )
				{
					var div1 = crsGetObject('divEstimatesTotal');
					var div2 = crsGetObject('divEstimatesHPCI');
					var div3 = crsGetObject('divEstimatesTaxes');
					var div4 = crsGetObject('divEstimatesAll');
					if( div1 && div2 && div3 && div4 )
					{
						if(( div1.className == 'greyedOut' ) && ( div2.className == 'greyedOut' ) && ( div3.className == 'greyedOut' ) )
						{
							var img4 = crsGetObject('imgEstimatesAll');
							if( img4 != null )
							{
								div4.className = 'greyedOut';
								img4.src = 'images/checkSmall.gif';
								img4.alt = 'Print this value';
								img4.title = img4.alt;
								var curhid = div4.getElementsByTagName('input');
								if( curhid != null )
									curhid[0].value = '0';
							}
						}
					}
				}
			}	
		} 
	}
	return false;
}

function crsGreyMeOutWithDesc(item)
{
	if(item) 
	{
		var divObject = crsGetObject('div' + item.id.substring(3))
		//new code
		var divObjectDesc = crsGetObject('divDesc' + item.id.substring(3))
		
		if(divObject)
		{
			var curhid = divObject.getElementsByTagName('input');
			if( curhid[0].value != '1' )
			{
				divObject.className = '';
				divObjectDesc.className = '';
				
				
				
				var curimages = divObject.getElementsByTagName('img');
				for (i=0; i < curimages.length;i++ )
				{
					curimages[i].src = 'images/xSmall.gif';
					curimages[i].alt = 'Do not print this value';
					curimages[i].title = curimages[i].alt;
				}
				var curdiv = divObject.getElementsByTagName('div');
				for (i=0; i < curdiv.length;i++ )
				{
					curdiv[i].className = '';
				}
				for (i=0; i < curhid.length;i++ )
					curhid[i].value = '1';
					
					
				var curdescdiv = divObjectDesc.getElementsByTagName('div');
				for (i=0; i < curdescdiv.length;i++ )
				{
					curdescdiv[i].className = '';
				}
				var curdeschid = divObjectDesc.getElementsByTagName('input');
				for (i=0; i < curdeschid.length;i++ )
					curdeschid[i].value = '1';
				
					
				if( divObject.id == 'divEstimatesTotal' || divObject.id == 'divEstimatesHPCI' || divObject.id == 'divEstimatesTaxes' )
				{
					var div1 = crsGetObject('divEstimatesTotal');
					var div2 = crsGetObject('divEstimatesHPCI');
					var div3 = crsGetObject('divEstimatesTaxes');
					var div4 = crsGetObject('divEstimatesAll');
					
					if( div1 && div2 && div3 && div4 )
					{
						if(( div1.className == '' ) || ( div2.className == '' ) || ( div3.className == '' ) )
						{
							var img4 = crsGetObject('imgEstimatesAll');
							var desc4 = crsGetObject('divDescEstimatesAll');
							if( img4 != null )
							{
								div4.className = '';
								desc4.className = '';
								img4.src = 'images/xSmall.gif';
								img4.alt = 'Do not print this value';
								img4.title = img4.alt;
								var curhid = div4.getElementsByTagName('input');
								if( curhid != null )
									curhid[0].value = '1';
							}
						}
					}
				}
			}
			else
			{
				//Turn Off
				divObject.className = 'greyedOut';
				divObjectDesc.className = 'greyedOut';
				var curimages = divObject.getElementsByTagName('img');
				for (i=0; i < curimages.length;i++ )
				{
					curimages[i].src = 'images/checkSmall.gif';
					curimages[i].alt = 'Print this value';
					curimages[i].title = curimages[i].alt;
				}
				var curdiv = divObject.getElementsByTagName('div');
				for (i=0; i < curdiv.length;i++ )
					curdiv[i].className = 'greyedOut';
			
				for (i=0; i < curhid.length;i++ )
					curhid[i].value = '0';
					
					
				var curdescdiv = divObjectDesc.getElementsByTagName('div');
				for (i=0; i < curdescdiv.length;i++ )
				{
					curdescdiv[i].className = 'greyedOut';
				}
				var curdeschid = divObjectDesc.getElementsByTagName('input');
				for (i=0; i < curdeschid.length;i++ )
					curdeschid[i].value = '0';
					
					
					
				if( divObject.id == 'divEstimatesTotal' || divObject.id == 'divEstimatesHPCI' || divObject.id == 'divEstimatesTaxes' )
				{
					var div1 = crsGetObject('divEstimatesTotal');
					var div2 = crsGetObject('divEstimatesHPCI');
					var div3 = crsGetObject('divEstimatesTaxes');
					var div4 = crsGetObject('divEstimatesAll');
					
					if( div1 && div2 && div3 && div4 )
					{
						if(( div1.className == 'greyedOut' ) && ( div2.className == 'greyedOut' ) && ( div3.className == 'greyedOut' ) )
						{
							var img4 = crsGetObject('imgEstimatesAll');
							var desc4 = crsGetObject('divDescEstimatesAll');
							if( img4 != null )
							{
								div4.className = 'greyedOut';
								desc4.className = 'greyedOut';
								img4.src = 'images/checkSmall.gif';
								img4.alt = 'Print this value';
								img4.title = img4.alt;
								var curhid = div4.getElementsByTagName('input');
								if( curhid != null )
									curhid[0].value = '0';
							}
						}
					}
				}
			}	
		} 
	}
	return false;
}
function getLoadingBox(statsURL)
{
	var win = document.createElement("div");
	win.setAttribute('id', 'dialog');
	var arrayPageSize = WindowUtilities.getPageSize();
	var arrayPageScroll = WindowUtilities.getPageScroll();
	win.style.left = (((arrayPageSize[0] - 200) / 2) + 'px');
	win.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 20) / 2) + 'px');
	win.className = "dialog";
	win.innerHTML = "<div style='border-width:1px;border-color:black;'><img src='/realestate/eval/images/loading.gif' alt='Loading'/> Loading data...</div>";
	var objBody = document.getElementsByTagName("body").item(0);
	objBody.insertBefore(win, objBody.firstChild);
	window.location = statsURL;
	return false;
}
//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
var WindowUtilities = {
 	getPageScroll :function() {
		var yScroll;

		if (self.pageYOffset) {
			yScroll = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
			yScroll = document.documentElement.scrollTop;
		} else if (document.body) {// all other Explorers
			yScroll = document.body.scrollTop;
		}

		arrayPageScroll = new Array('',yScroll) 
		return arrayPageScroll;
	},

	// getPageSize()
	// Returns array with page width, height and window width, height
	// Core code from - quirksmode.org
	// Edit for Firefox by pHaez
	getPageSize: function(){
		var xScroll, yScroll;
	
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
	
		var windowWidth, windowHeight;
		if (self.innerHeight) {	// all except Explorer
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
	
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}

		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = windowWidth;
		} else {
			pageWidth = xScroll;
		}

		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
		return arrayPageSize;
	}
}