//variable to see if loading is complete
var bLoad = false;
var curTheme = "";
var curThemeFilter = "";
//community search variables
var commSearchID = 0;
var commSearchIDs = new Array('intro','pop','inc','sup','cus','com','une','edu','deg','wag','ocu','int','air','rai');
var radiusFrom = "";
var countySelList = "Alamance - NC,Alexander - NC,Alleghany - NC,Anson - NC,Ashe - NC,Avery - NC,Beaufort - NC,Bertie - NC,Bladen - NC,Brunswick - NC,Buncombe - NC,Burke - NC,Cabarrus - NC,Caldwell - NC,Camden - NC,Carteret - NC,Caswell - NC,Catawba - NC,Chatham - NC,Cherokee - NC,Chowan - NC,Clay - NC,Cleveland - NC,Columbus - NC,Craven - NC,Cumberland - NC,Currituck - NC,Dare - NC,Davidson - NC,Davie - NC,Duplin - NC,Durham - NC,Edgecombe - NC,Forsyth - NC,Franklin - NC,Gaston - NC,Gates - NC,Graham - NC,Granville - NC,Greene - NC,Guilford - NC,Halifax - NC,Harnett - NC,Haywood - NC,Henderson - NC,Hertford - NC,Hoke - NC,Hyde - NC,Iredell - NC,Jackson - NC,Johnston - NC,Jones - NC,Lee - NC,Lenoir - NC,Lincoln - NC,Macon - NC,Madison - NC,Martin - NC,McDowell - NC,Mecklenburg - NC,Mitchell - NC,Montgomery - NC,Moore - NC,Nash - NC,New Hanover - NC,Northampton - NC,Onslow - NC,Orange - NC,Pamlico - NC,Pasquotank - NC,Pender - NC,Perquimans - NC,Person - NC,Pitt - NC,Polk - NC,Randolph - NC,Richmond - NC,Robeson - NC,Rockin" +
		"gham - NC,Rowan - NC,Rutherford - NC,Sampson - NC,Scotland - NC,Stanly - NC,Stokes - NC,Surry - NC,Swain - NC,Transylvania - NC,Tyrrell - NC,Union - NC,Vance - NC,Wake - NC,Warren - NC,Washington - NC,Watauga - NC,Wayne - NC,Wilkes - NC,Wilson - NC,Yadkin - NC,Yancey - NC,Abbeville - SC,Aiken - SC,Allendale - SC,Anderson - SC,Bamberg - SC,Barnwell - SC,Beaufort - SC,Berkeley - SC,Calhoun - SC,Charleston - SC,Cherokee - SC,Chester - SC,Chesterfield - SC,Clarendon - SC,Colleton - SC,Darlington - SC,Dillon - SC,Dorchester - SC,Edgefield - SC,Fairfield - SC,Florence - SC,Georgetown - SC,Greenville - SC,Greenwood - SC,Hampton - SC,Horry - SC,Jasper - SC,Kershaw - SC,Lancaster - SC,Laurens - SC,Lee - SC,Lexington - SC,Marion - SC,Marlboro - SC,McCormick - SC,Newberry - SC,Oconee - SC,Orangeburg - SC,Pickens - SC,Richland - SC,Saluda - SC,Spartanburg - SC,Sumter - SC,Union - SC,Williamsburg - SC,York - SC";
var regionSelList = "Advantage West - Alleghany - NC,Advantage West - Ashe - NC,Advantage West - Avery - NC,Advantage West - Buncombe - NC,Advantage West - Burke - NC,Advantage West - Caldwell - NC,Advantage West - Cherokee - NC,Advantage West - Clay - NC,Advantage West - Graham - NC,Advantage West - Haywood - NC,Advantage West - Henderson - NC,Advantage West - Jackson - NC,Advantage West - Macon - NC,Advantage West - Madison - NC,Advantage West - McDowell - NC,Advantage West - Mitchell - NC,Advantage West - Polk - NC,Advantage West - Rutherford - NC,Advantage West - Swain - NC,Advantage West - Transylvania - NC,Advantage West - Watauga - NC,Advantage West - Wilkes - NC,Advantage West - Yancey - NC,Central SC Alliance - Calhoun - SC,Central SC Alliance - Fairfield - SC,Central SC Alliance - Kershaw - SC,Central SC Alliance - Lee - SC,Central SC Alliance - Lexington - SC,Central SC Alliance - Newberry - SC,Central SC Alliance - Orangeburg - SC,Central SC Alliance - Richland - SC,Central SC Alliance - Sumter - SC,Charleston " + 
		"Regional Development Alliance - Berkeley - SC,Charleston Regional Development Alliance - Charleston - SC,Charleston Regional Development Alliance - Dorchester - SC,Charlotte Regional Partnership - Alexander - NC,Charlotte Regional Partnership - Anson - NC,Charlotte Regional Partnership - Cabarrus - NC,Charlotte Regional Partnership - Catawba - NC,Charlotte Regional Partnership - Chester - SC,Charlotte Regional Partnership - Chesterfield - SC,Charlotte Regional Partnership - Cleveland - NC,Charlotte Regional Partnership - Gaston - NC,Charlotte Regional Partnership - Iredell - NC,Charlotte Regional Partnership - Lancaster - SC,Charlotte Regional Partnership - Lincoln - NC,Charlotte Regional Partnership - Mecklenburg - NC,Charlotte Regional Partnership - Rowan - NC,Charlotte Regional Partnership - Stanly - NC,Charlotte Regional Partnership - Union - NC,Charlotte Regional Partnership - York - SC,Eastern South Carolina Alliance - Darlington - SC,Eastern South Carolina Alliance - Dillon - SC,Eastern South Carolina " + 
		"Alliance - Florence - SC,Eastern South Carolina Alliance - Marion - SC,Eastern South Carolina Alliance - Marlboro - SC,Eastern South Carolina Alliance - Williamsburg - SC,Economic Development Partnership - Aiken - SC,Economic Development Partnership - Edgefield - SC,NC Southeast - Bladen - NC,NC Southeast - Brunswick - NC,NC Southeast - Columbus - NC,NC Southeast - Cumberland - NC,NC Southeast - Hoke - NC,NC Southeast - New Hanover - NC,NC Southeast - Pender - NC,NC Southeast - Richmond - NC,NC Southeast - Robeson - NC,NC Southeast - Sampson - NC,NC Southeast - Scotland - NC,No Alliance - Beaufort - SC,No Alliance - Colleton - SC,No Alliance - Jasper - SC,No Alliance - McCormick - SC,No Alliance - Saluda - SC,North Carolina Eastern Partnership - Carteret - NC,North Carolina Eastern Partnership - Craven - NC,North Carolina Eastern Partnership - Duplin - NC,North Carolina Eastern Partnership - Edgecombe - NC,North Carolina Eastern Partnership - Greene - NC,North Carolina Eastern Partnership - Jones - NC,North C" + 
		"arolina Eastern Partnership - Lenoir - NC,North Carolina Eastern Partnership - Nash - NC,North Carolina Eastern Partnership - Onslow - NC,North Carolina Eastern Partnership - Pamlico - NC,North Carolina Eastern Partnership - Pitt - NC,North Carolina Eastern Partnership - Wayne - NC,North Carolina Eastern Partnership - Wilson - NC,North Carolina Northeast Partnership - Beaufort - NC,North Carolina Northeast Partnership - Bertie - NC,North Carolina Northeast Partnership - Camden - NC,North Carolina Northeast Partnership - Chowan - NC,North Carolina Northeast Partnership - Currituck - NC,North Carolina Northeast Partnership - Dare - NC,North Carolina Northeast Partnership - Gates - NC,North Carolina Northeast Partnership - Halifax - NC,North Carolina Northeast Partnership - Hertford - NC,North Carolina Northeast Partnership - Hyde - NC,North Carolina Northeast Partnership - Martin - NC,North Carolina Northeast Partnership - Northampton - NC,North Carolina Northeast Partnership - Pasquotank - NC,North Carolina No" + 
		"rtheast Partnership - Perquimans - NC,North Carolina Northeast Partnership - Tyrrell - NC,North Carolina Northeast Partnership - Washington - NC,North Eastern Strategic Alliance (NESA) - Clarendon - SC,North Eastern Strategic Alliance (NESA) - Georgetown - SC,North Eastern Strategic Alliance (NESA) - Horry - SC,Piedmont Triad Partnership - Alamance - NC,Piedmont Triad Partnership - Caswell - NC,Piedmont Triad Partnership - Davidson - NC,Piedmont Triad Partnership - Davie - NC,Piedmont Triad Partnership - Forsyth - NC,Piedmont Triad Partnership - Guilford - NC,Piedmont Triad Partnership - Montgomery - NC,Piedmont Triad Partnership - Randolph - NC,Piedmont Triad Partnership - Rockingham - NC,Piedmont Triad Partnership - Stokes - NC,Piedmont Triad Partnership - Surry - NC,Piedmont Triad Partnership - Yadkin - NC,Research Triangle Regional Partnership - Chatham - NC,Research Triangle Regional Partnership - Durham - NC,Research Triangle Regional Partnership - Franklin - NC,Research Triangle Regional Partnership - " + 
		"Granville - NC,Research Triangle Regional Partnership - Harnett - NC,Research Triangle Regional Partnership - Johnston - NC,Research Triangle Regional Partnership - Lee - NC,Research Triangle Regional Partnership - Moore - NC,Research Triangle Regional Partnership - Orange - NC,Research Triangle Regional Partnership - Person - NC,Research Triangle Regional Partnership - Vance - NC,Research Triangle Regional Partnership - Wake - NC,Research Triangle Regional Partnership - Warren - NC,Southern Carolina Regional Development Alliance - Allendale - SC,Southern Carolina Regional Development Alliance - Bamberg - SC,Southern Carolina Regional Development Alliance - Barnwell - SC,Southern Carolina Regional Development Alliance - Hampton - SC,Upstate Alliance - Abbeville - SC,Upstate Alliance - Anderson - SC,Upstate Alliance - Cherokee - SC,Upstate Alliance - Greenville - SC,Upstate Alliance - Greenwood - SC,Upstate Alliance - Laurens - SC,Upstate Alliance - Oconee - SC,Upstate Alliance - Pickens - SC,Upstate Alliance " +
		"- Spartanburg - SC,Upstate Alliance - Union - SC";


// ##### STARTUP Functions #####
function init() {
//alert(document.frmMain.tool.value);

   //HELP - Welcome on first time
   if (document.frmMain.propertyView.value == "Expanded")
   {
		expandReport();
   } 
   else if(document.frmMain.propertyView.value == "Quick View")
   {
		reduceReport();
   }
   
   if (document.frmMain.cmd.value == "showHelpFirstTime")
   {
     launchHelp('welcome');
     document.frmMain.cmd.value = "";
   }
   
  
   
   if(document.frmMain.cmd.value == "refine_prop_search")
   {
	    //alert(document.frmMain.cmd.value);
		toggleShowHide('location');toggleShowHide('location_close');toggleShowHide('location_open');
		toggleShowHide('transportation');toggleShowHide('transportation_close');toggleShowHide('transportation_open');
		toggleShowHide('building_specs');toggleShowHide('building_specs_close');toggleShowHide('building_specs_open');
		toggleShowHide('property_name');toggleShowHide('property_name_close');toggleShowHide('property_name_open');	
		document.frmMain.cmd.value = "";		
   } 
  
   //----SET MAP SIZE----
  
   size = document.frmMain.msize.value;
   prevSize = findObj("size_" + size);
   changeMapSize(size,"false");
   //----SET MAP TAB-----
  
    panel = document.frmMain.panel.value;
    if (panel == "") //for some reason panel not set
	{
		panel = "tools";
	}
    
    prevMapDiv = findObj("tab_" + panel);
    prevMapLink = findObj("link_" + panel);
    switchMapTabs(panel);

	var propImgObj = findObj("BUILDING_PIC");
	var propImgObj2 = findObj("BUILDING_PIC2");
	if(propImgObj2 == null)
	{
		if(propImgObj != null)
		{		 
			if(propImgObj.width > 362)
			{
				propImgObj.width = 362;
			}			
		} 
	}	

   //----ACTIVATE CURRENT TOOL-----   
   
   curTool = document.frmMain.tool.value;   
   //verify that the current value is a valid tool in the tool panel
   //there are cases where this tool gets set to "report" or other values - need to get a valid prev tool set
   //or there will be an error
   
   
   //alert("tool = " + curTool + " cmd = " + document.frmMain.cmd.value);
 
   if(curTool == "zoomin" || curTool == "zoomout" || curTool == "select" || curTool == "pan" ) 
   {     	
     	document.location.href.replace("#contentview","");
   } 
   else
   {
	if(document.frmMain.maintab.value == "report" && document.location.href.indexOf("#contentview") == -1)
	{	  
	  strTool = document.frmMain.tool.value;
	  if(document.location.href.indexOf("#contentview") == -1 && strTool.indexOf("identify") != -1)
	  {
		document.location.href = document.location.href + "#contentview";
	  }
	  
	  if(strTool.indexOf("CommunityReport") == -1 && strTool.indexOf("communityProfilereport") == -1 && strTool != "Report_Radius")
	  {
		if(strTool.indexOf("BuildingReport") == -1 && strTool.indexOf("PropertyReport") == -1 && document.frmMain.activereport.value != "PropertyReport")
		{
		  document.location.href = document.location.href + "#contentview";
		}
	  }	  
   } 
     if(curTool != "identify") 
   {	  
		curTool = "zoomin";
		document.frmMain.tool.value = "zoomin";		
	}
   }
   
    prevToolDiv = findObj("tab_" + curTool);
    prevToolLink = findObj("link_" + curTool);
    changeTool(curTool,'');
  
  //----ACTIVATE THEME-----
  curTheme = document.frmMain.thematiclayer.value;
  curThemeFilter = document.frmMain.thematicfilter.value;
  
  prevThemeDiv = "";
  if (curTheme != "")
  {
    switchThemes(curTheme);
  }
  //check on communities for prop search
  chkDiv = findObj("prop_search_communities");
  if (chkDiv.style.display == "") 
  {
	lbl = findObj("lbl_prop_search_communities");
	if (lbl.text != "" && lbl.text != null)
    {
	
	 //alert("Inside Init: ldl = " + lbl.text);
	 chk = findObj("ck_prop_search_communities");
	 chk.checked = true;
	}
  }
  //ACTIVATE SEARCH DIV
    
  prevSearchDiv = findObj("div_intro");
  prevSearchLink = findObj("link_intro");
  commSearchID = document.frmMain.comm_search_id.value;
  switchCommSearch(commSearchID);

  //----ACTIVATE MAIN TAB-----
  maintab = document.frmMain.maintab.value;
  if (maintab == "") 
  {
	maintab = "comm_search";
  }
  prevMainDiv = findObj("tab_" + maintab);
  prevMainLink  = findObj("link_" + maintab);
  switchMainTabs(maintab);


  //----ACTIVATE CURRENT SCALE-----
  scale = findObj("scale"); 
  curscale = scale.value;
  if (curscale != "")
  {
    prevScaleDiv = findObj(curscale); //ex id="Carolinas"
    prevScaleDiv.className = "selected";
  }

  //----SET CURRENT COMMAND-----
  cmd = document.frmMain.cmd.value;

  //----RUN ADDITIONAL STARTUP FUNCTIONS-----
  startUp(); //in map.js

	

  if(document.frmMain.markerList.value != "" && document.frmMain.radius.value != "County")
   {
        var theForm = findObj("frmSearchProp");
		theForm.prop_state.options.selectedIndex = 0;
		theForm.prop_state.disabled = true;
		theForm.prop_state.style.background = "#ccc";
		theForm.prop_region.options.selectedIndex = 0;
		theForm.prop_region.disabled = true;
		theForm.prop_region.style.background = "#ccc";
		theForm.prop_county.options.selectedIndex = 0;
		theForm.prop_county.disabled = true;
		theForm.prop_county.style.background = "#ccc";	
		
	}
 

//set load variable = true to show load complete
bLoad = true;
hideLayer('Splash');

}


// ##### GENERAL Functions #####

function setToolNotInPalette(toolname)
{
  //will not set previous tool
  //should only be used for reporting and searching where tool will be set back to a tool pallette tool after the c# code finishes
  document.frmMain.tool.value = toolname;
  document.frmMain.cmd.value = ""; //clear command, command would be comm_search, radius or prop_search
}

function findObj(thisID) {
  if (document.getElementById) {
    return document.getElementById(thisID);
  } else if (document.all) {
    return document.all[thisID];
  } else if (document.layers) {
    return document.layers[thisID];
  }
}

function changeClass(itemID,newClass) {
  thisItem = findObj(itemID);
  thisItem.className = newClass;
}

function setCountyVal(stateVal)
{
	var cBox = document.getElementById("prop_county");	
	var cList = countySelList.split(',');
	//alert(cList);
	for(i=cBox.options.length-1;i>=0;i--)
	{
		cBox.remove(i);
	}
	
	if(stateVal == "NC")
	{	
		var j = 1;
		for(i=0;i<cList.length;i++)
		{
			if(cList[i].indexOf("- NC") != -1)
			{
				cBox.options[j] = new Option(cList[i],cList[i]);							
				j++;
			}		
		}
	}
	else if(stateVal == "SC")
	{
		var j = 1;
		for(i=0;i<cList.length;i++)
		{
			if(cList[i].indexOf("- SC") != -1)
			{
				cBox.options[j] = new Option(cList[i],cList[i]);							
				j++;
			}	
		}
	}
	else
	{	
		var j = 1;
		for(i=0;i<cList.length;i++)
		{
			cBox.options[j] = new Option(cList[i],cList[i]);
			j++;
		}
	}	
	
	
}

function setRegionVal(stateVal)
{
	var cBox = document.getElementById("prop_region");	
	var cList = regionSelList.split(',');
	//alert(cList);
	for(i=cBox.options.length-1;i>=0;i--)
	{
		cBox.remove(i);
	}	
	
	
	if(stateVal == "NC")
	{	
		var j = 1;
		var tFlag = 1;
		
		for(i=0;i<cList.length;i++)
		{			
			if(cList[i].indexOf(" - NC") != -1)
			{
				tmpStr = cList[i].substring(0,cList[i].indexOf(" - "));
				
				if(j == 1)
				{
					cBox.options[j] = new Option(tmpStr,tmpStr);							
					j++;
				}
				else
				{
					if(tmpStr != cBox.options[j-1].value)
					{
						cBox.options[j] = new Option(tmpStr,tmpStr);							
						j++;
					}
					
				}
			}		
		}
	}
	else if(stateVal == "SC")
	{
		var j = 1;
		for(i=0;i<cList.length;i++)
		{
			if(cList[i].indexOf(" - SC") != -1)
			{
				tmpStr = cList[i].substring(0,cList[i].indexOf(" - "));
			
				if(j == 1)
				{
					cBox.options[j] = new Option(tmpStr,tmpStr);							
					j++;
				}
				else
				{
					if(tmpStr != cBox.options[j-1].value)
					{
						cBox.options[j] = new Option(tmpStr,tmpStr);							
						j++;
					}
					
				}
			}	
		}
	}
	else
	{	
		var j = 1;
		for(i=0;i<cList.length;i++)
		{
			tmpStr = cList[i].substring(0,cList[i].indexOf(" - "));
			
				if(j == 1)
				{
					cBox.options[j] = new Option(tmpStr,tmpStr);							
					j++;
				}
				else
				{
					if(tmpStr != cBox.options[j-1].value)
					{
						cBox.options[j] = new Option(tmpStr,tmpStr);							
						j++;
					}
					
				}
		}
	}	
}

function setCountyFromRegion(regionVal)
{
	var cBox = document.getElementById("prop_county");	
	var rList = regionSelList.split(',');
	var cList = countySelList.split(',');
	var sList = document.getElementById("prop_state");
	var stateVal = sList.options[sList.options.selectedIndex].value;
	
	for(i=cBox.options.length-1;i>=0;i--)
	{
		cBox.remove(i);
	}	
	
	if(regionVal != "")
	{	
		var j = 1;
		var tFlag = 1;
		
		for(i=0;i<rList.length;i++)
		{			
			if(rList[i].indexOf(regionVal) != -1)
			{	
				if(stateVal.length > 1)
				{
					if(rList[i].indexOf(" - " + stateVal) != -1)
					{
						tmpStr = rList[i].substring(rList[i].indexOf(" - ")+3,rList[i].length);			
						cBox.options[j] = new Option(tmpStr,tmpStr);							
						j++;										
					}					
				}
				else
				{					
					tmpStr = rList[i].substring(rList[i].indexOf(" - ")+3,rList[i].length);			
					cBox.options[j] = new Option(tmpStr,tmpStr);							
					j++;					
				}			
			}		
		}				
	}
	
	else if(stateVal == "NC")	
	{	
		var j = 1;
		for(i=0;i<cList.length;i++)
		{
			if(cList[i].indexOf("- NC") != -1)
			{
				cBox.options[j] = new Option(cList[i],cList[i]);							
				j++;
			}		
		}
	}
	else if(stateVal == "SC")
	{
		var j = 1;
		for(i=0;i<cList.length;i++)
		{
			if(cList[i].indexOf("- SC") != -1)
			{
				cBox.options[j] = new Option(cList[i],cList[i]);							
				j++;
			}	
		}
	}
	else
	{	
		var j = 1;
		for(i=0;i<cList.length;i++)
		{
			cBox.options[j] = new Option(cList[i],cList[i]);
			j++;
		}
	}	
	
	//alert("rVal = " + regionVal + " cBox items = " + cBox.options.length);
}

function toggleShowHide(divID,justHide){ 
  thisDiv = findObj(divID);
  if (thisDiv.style.display == "none" && justHide != 0){ 
    thisDiv.style.display = ""; 
    } else { 
    thisDiv.style.display = "none"; 
  }
}


function toggleAll()
{
	document.frmMain.selbuildings.Value = "";
	document.frmMain.selproperties.Value = "";
	document.frmMain.cmd.value = "refine_prop_search";
	submitMapRequest();	
}

function selectAll(masterBox) {
  theForm = masterBox.form;
  for (i=0;i<theForm.elements.length;i++) {
    if (theForm.elements[i].type == "checkbox" && theForm.elements[i].name != "selectall") {
      theForm.elements[i].checked = masterBox.checked;
    }
  }
}

function useOpener(newURL) {
  if (!(opener == null || opener.closed)) {
    opener.location.href = newURL;
    opener.focus();
  } else {
    newOpener = window.open(newURL,'newOpener','');
    newOpener.focus();
  }
}

function changeURL(newURL)
{
  window.location.href = newURL;
}

//change selected content tab
function switchMainTabs(divID)
{
	
		
  
  //get the div for the newly selected tab
  thisDiv = findObj("tab_" + divID);
  thisLink = findObj("link_" + divID);
  
  //set the previous tab to unselected
  prevMainDiv.style.display = "none";
  //prevMainLink.className = "";
  
  //set previous tab images to unselected
  previmg = "img_" + prevMainLink.id;
  previmg = findObj(previmg);
  previmg.src = "images/maintabs_" + prevMainLink.id +".gif";

  //switch images to selected
  thisImg = findObj("img_link_" + divID);
  thisImg.src = "images/maintabs_link_"+ divID + "_selected.gif";
  
  //set class for new tab
  thisDiv.style.display = ""; 
  //thisLink.className = "selected";

  //store new tab
  prevMainDiv = thisDiv; 
  prevMainLink = thisLink;
  maintab = findObj("maintab")
  maintab.value = divID;
  
  var reportLayer;
  var headerLayer;
  headerLayer = getLayer("ReportHeaderType");

  if (divID == "report")
  {
    
    var lastReport = document.frmMain.activereport.value;
    if (headerLayer != null)
	{       
	  headerLayer.display = "inline";
	}

    if (lastReport.indexOf("Property") != -1)
    {
       
       reportLayer = getLayer("PropertyReportType");
       
       if (reportLayer != null)
	{       
	  reportLayer.display = "inline";
	}
        

    }
    else if (lastReport.indexOf("Default") != -1)
    {
       
       reportLayer = getLayer("PropertyReportType");
       

       if (reportLayer != null)
	{       
	  reportLayer.display = "inline";
	}		
    }
    else
    {
	displayReport(document.frmMain.activereport.value);
        reportLayer = getLayer("CommunityReportType");
        if (reportLayer != null)
	{       
	  reportLayer.display = "inline";
	}
    }
  }
  else
  {
       reportLayer = getLayer("PropertyReportType");
       if (reportLayer != null)
	{       
	  reportLayer.display = "none";
	}
       reportLayer = getLayer("CommunityReportType");
       if (reportLayer != null)
	{       
	  reportLayer.display = "none";
	}
        if (headerLayer != null)
	{       
	  headerLayer.display = "none";
	}
  }
  
var propImgObj = findObj("BUILDING_PIC");
var propImgObj2 = findObj("BUILDING_PIC2");
if(propImgObj2 == null)
{
	if(propImgObj != null)
	{		 
		if(propImgObj.width > 362)
		{
			propImgObj.width = 362;
		}			
		//alert(propImgObj.width);
	} 
}


  if (divID != "search_prop")
  {
	hidePropTab();
  }
  
  //set contents for tabs
  switch (divID)
  {
	case "search_comm":
	  //show search or results
	  activeDiv = findObj("comm_active_div");
	  value = activeDiv.value;
	  showCommResults(value);
	  break;
    case "search_prop":
	  //show search or results
	  activeDiv = findObj("prop_active_div");
	  value = activeDiv.value;
	  showPropResults(value);
	  renderCheckBoxes("frmPropResults");
	  break;
    case "my_comm":
          activeDiv = findObj("my_comm_active_div");
	  value = activeDiv.value;
      if (value != "")
      {
        //hide intro
  		hideMyCommIntro();
  		//show right tab inside prospects
  		switchMyCommInfo(value);
 	  }
	default:
	  break;
  }

}

function launchHelp(focus)
{
  //create query string to send with help url
  if (document.domain.substring(document.domain.indexOf('.') + 1) != "com")
      {
            document.domain = document.domain.substring(document.domain.indexOf('.') + 1);
      }
  var topic = "";
  //Welcome = topic=1-1
  if (focus == "welcome")
  {
     topic= "1-1"
  }
  if (focus == "tools") //launched from tools palette
   {
     panel = document.frmMain.panel.value;
     switch (panel)
      {
        case "tools":
          topic = "2-1";
          break;
        case "layers":
          topic = "2-3";
          break;
        case "legend":
          topic = "2-2";
          break;
        case "themes":
          topic = "2-4";
          break;
        default:
          topic = "1-1";
          break;
      }
   }
  if (focus == "maintabs") //launched from maintabs
   {
     tab = document.frmMain.maintab.value;
     switch (tab)
      {
        case "search_comm":
          topic = "3-1";
          break;
        case "search_prop":
          topic = "4-1";
          break;
        case "my_comm":
          topic = "5-1";
          break;
        case "report":
          //test for property or community report
          //property
          topic = "6-1";
          //community
          //topic = "6-2";
          break;
          case "contacts":
          topic = "7-1";
          break;
        default:
          topic = "1-1";
          break;
      }
   }
   //create new url
   theURL = "/ecdev/help/help.asp?topic=" + topic;
   //open in a new window
   //useOpener(theURL);

window.open(theURL,'help','width=400,height=400,resizable=yes,status=yes,menubar=yes')

}


function renderCheckBoxes(form)
{
     var frm = findObj(form);
    // Loop through all elements
    for (i=0; i<frm.length; i++) 
    {
	if (frm.elements[i].type == "checkbox" || frm.elements[i].type == "radio")
	{
		if (frm.elements[i].checked == true)
		{
			frm.elements[i].checked = true;
		}
	}
    }
}

function clearCheckBoxesInDataGrid(form, chkName)
{
   var frm = findObj(form);
    // Loop through all elements
    for (i=0; i<frm.length; i++) 
    {
	idval = frm.elements[i].id;
        // Look for our Header Template's Checkbox
        if (idval.indexOf (chkName) != -1) 
        {
                frm.elements[i].checked = false;
        } 
    }
}

// ##### MAP RELATED Functions #####
function changeMapSize(size, boolNewMap){	
	//dehighlight old button
	prevSize.className = "";
	//highlight button
	thisSize = findObj("size_" + size);
	thisSize.className = "selected";
        //reset prev obj to the current obj
 	prevSize = thisSize;
        //store
	document.frmMain.msize.value = size;
        
      //get new map when they click the button.  
      //don't get a new map when the page loads (just reset the highlight)
      if (boolNewMap=="true")
      {
	  //set cmd to create a cookie for new map size
	 
 	 document.frmMain.cmd.value = "change_map_size";
	 submitMapRequest();
     }
}
function changeMapScale(scale){
	//if fixed zoom then move them to the next appropriate scale
	if (scale == "FixedZoomIn") 
	{
	      switch (prevScaleDiv.id) 
		{
		case "Southeast":
		 scale = "Carolinas";
		 break;		
		case "Carolinas":
		 scale = "State";
		 break;
		case "State":
		 scale = "Region";
		 break;
		case "Region":
		 scale = "County";
		 break;
		case "County":
		 scale = "Local";
		 break;
		case "Local":
		 scale = "last";
		 break;
		default:
		 break;
	       }
	}
	if (scale == "FixedZoomOut") 
	{
	      switch (prevScaleDiv.id) 
		{
		case "Carolinas":
		 scale = "Southeast";
		 break;
		case "State":
		 scale = "Carolinas";
		 break;
		case "Region":
		 scale = "State";
		 break;
		case "County":
		 scale = "Region";
		 break;
		case "Local":
		 scale = "County";
		 break;
		case "last":
		 scale = "Local";
		 break;
		default:
		 break;
	       }
	}
	//if still at fixed zoom then set bSetScale to false
	//this will zoom them in our out a fixed amount
	if (scale == "FixedZoomIn" || scale == "FixedZoomOut") {
	  document.frmMain.bSetScale.value = "false";
	}
	else {
	 document.frmMain.bSetScale.value = "true";
	//set button area to selected
	
	}	
	thisDiv = findObj(scale);
	prevScaleDiv.className = "";
	thisDiv.className = "selected";
	prevScaleDiv = thisDiv; 
	document.frmMain.scale.value = scale;
	submitMapRequest();
}

// ##### TOOLS PANEL Functions #####

//exclusive for map tabs
function switchMapTabs(divID){ 
  thisDiv = findObj("tab_" + divID);
  thisLink = findObj("link_" + divID);

  prevMapDiv.style.display = "none";
  thisDiv.style.display = ""; 
  prevMapDiv = thisDiv; 

  prevMapLink.className = "";
  thisLink.className = "selected";
  prevMapLink = thisLink;

  panel = findObj("panel");
  panel.value = divID;
	
}

function moveArrow(thisArrow,arrowMargin) {
  arrowDiv = findObj(thisArrow);
  arrowDiv.style.marginLeft = arrowMargin;
}

function changeTool(divID,arrowMargin) {
  if (arrowMargin == "")
  {
    switch (divID)
    {
    case "zoomin":
	  arrowMargin = "18px";
	  break;	
    case "zoomout":
	  arrowMargin = "67px";
	  break;
    case "pan":
	  arrowMargin = "116px";
	  break;
    case "select":
	  arrowMargin = "165px";
	  break;
    case "identify":
	  arrowMargin = "214px";	  
	  break;
	case "identifyBusiness":
	  arrowMargin = "263px";	  
	  break;
    }
  }
  
  thisDiv = findObj("tab_" + divID);
  thisLink = findObj("link_" + divID);
  thisCursorURL = "images\\" + divID + ".cur";
  var mfrm = findObj("theMap");
  if(mfrm != null)
  {
	//if(divID == "identify")
	//{
	//	mfrm.style.cursor = "url('images\\" + divID + ".gif')";
	//}
	//else
	//{
		mfrm.style.cursor = "url('" + thisCursorURL + "')";
	//}	
  }
  //alert(thisCursorURL);
  prevToolDiv.style.display = "none";
  thisDiv.style.display = "";
  prevToolDiv = thisDiv;
  
  prevToolLink.className = "tool";
  thisLink.className = "toolselected";
  prevToolLink = thisLink;

  arrowDiv = findObj("toolarrow");
  arrowDiv.style.marginLeft = arrowMargin;
  document.frmMain.tool.value = divID;
}

// ##### THEMES Functions #####

var themePopTypes = new Array('thm_pop_under_20','thm_pop_20_29','thm_pop_30_39','thm_pop_40_49','thm_pop_50_59','thm_pop_60_64','thm_pop_over_65');
function disableThemePop(turnOn) {
  for (i=0;i<themePopTypes.length;i++) {
    var thisItem = findObj(themePopTypes[i]);
    if (turnOn == 'enable') {
      thisItem.disabled = false;
    } else {
      thisItem.disabled = true;
    }
  }
}

function RestoreDefaultTheme()
{
  //clear comm search
  document.frmMain.dynamic_county_labels.Value = "";
  document.frmMain.cmd.value = "";
  //clear theme
  document.frmMain.thematiclayer.value = "";
  document.frmMain.thematicfilter.value = "";
  switchThemes("");
  submitMapRequest();
}

function switchThemes(divID) { 

  //divID is the theme selected in the drop down list
  if(divID != "") {
  	thisDiv = findObj(divID);
  	if (prevThemeDiv != "") {
    	  prevThemeDiv.style.display = "none";
  	}
  	thisDiv.style.display = ""; 
  	prevThemeDiv = thisDiv; 
  }
  document.frmMain.thematiclayer.value = divID;

}

// ##### IDENTIFY FUNCTIONS ##############
function identifyAddProspects()
{
  document.frmMain.cmd.value = "identify_add_prospects";
  submitMapRequest();
}

// ##### RANGE SEARCH Functions #####
function setRadius(radius)
{
  if(radius != "" && radius != "clear") {
  	document.frmMain.radius.value = radius;	
  } 

}


function switchRadius(radius) { 

  if(radius != "") 
  {
  		
  	document.frmMain.report_locations.value = "";
	var reportOther = document.getElementById("reportradius_other");		
	var reportRangeBox = document.getElementById("reportrange");	
	var reportradius_other_label = document.getElementById("reportradius_other_label"); 	
		
	if (reportRangeBox != null) 
	{
 		if (radius == "County") 
 		{
 			reportRangeBox.selectedIndex = 0;
 			document.frmMain.radius.value = radius;
 			
 			reportOther.style.visibility = "hidden";
 			reportradius_other_label.style.visibility = "hidden";
		}
		else if (radius == "15") 
		{
			reportRangeBox.selectedIndex = 1;
			document.frmMain.radius.value = radius;
			
			reportOther.style.visibility = "hidden";
			reportradius_other_label.style.visibility = "hidden";
		}
		else if (radius == "30") 
		{
			reportRangeBox.selectedIndex = 2;    
			document.frmMain.radius.value = radius;
			
			reportOther.style.visibility = "hidden";
			reportradius_other_label.style.visibility = "hidden";
		}
		else if (radius == "60") 
		{
			reportRangeBox.selectedIndex = 3;   
			document.frmMain.radius.value = radius;
			
			reportOther.style.visibility = "hidden";
			reportradius_other_label.style.visibility = "hidden";
		}
		else
		{
			reportRangeBox.selectedIndex = 4;
			document.frmMain.radius.value = reportOther.value;
			
			reportOther.style.visibility = "visible";	
			reportradius_other_label.style.visibility = "visible";		
		}
	}

	var toolRangeBox = document.getElementById("range");
	var rad_other = findObj("radius_other");
	var rad_other_div=findObj('radius_other_label');
	if (toolRangeBox != null) 
	{
		
 		if (radius == "County") 
 		{
			toolRangeBox.selectedIndex = 0;
			document.frmMain.radius.value = radius;
			
			rad_other.style.visibility = "hidden";
			rad_other_div.style.visibility = "hidden";
			
		}
		else if (radius == "15") 
		{
			toolRangeBox.selectedIndex = 1;
			document.frmMain.radius.value = radius;
			
			rad_other.style.visibility = "hidden";
			rad_other_div.style.visibility = "hidden";
		}
		else if (radius == "30") 
		{
			toolRangeBox.selectedIndex = 2;
			document.frmMain.radius.value = radius;	
			
			rad_other.style.visibility = "hidden";
			rad_other_div.style.visibility = "hidden";	
		}
		else if (radius == "60") 
		{
			toolRangeBox.selectedIndex = 3;
			document.frmMain.radius.value = radius;	
			
			rad_other.style.visibility = "hidden";	
			rad_other_div.style.visibility = "hidden";
		}
		else
		{
			toolRangeBox.selectedIndex = 4;
			document.frmMain.radius.value = rad_other.value;
			
			rad_other.style.visibility = "visible";
			rad_other_div.style.visibility = "visible";
			
		}
		
	}
 
 }

}

function rangeSearchAddProspects()
{
  document.frmMain.cmd.value = "range_search_add_prospects";
  submitMapRequest();

}
// ##### Community Search #####

function showCommResults(showDiv)
{
        dgComm = findObj("dgResultsComm");
	if (showDiv == "search_comm") //hide results
	{
	 search = findObj("search_comm");
	 search.style.display = "";
	 //show results
	 results = findObj("results_comm");
	 results.style.display = "none";
     if (dgComm != null)
   	 {
  	   dgComm.visible = false;
     }	
	} 
	else //show results
	{
	 //hide search
	 search = findObj("search_comm");
	 search.style.display = "none";
	 //show results
	 results = findObj("results_comm");
	 results.style.display = "";  	 
	 if (dgComm != null)
   	 {
  	   dgComm.visible = true;
         }
	}
	activeDiv = findObj("comm_active_div");
	activeDiv.value = showDiv;	
	
}

function tagLink(linkID,clearTag) {
  thisLink = findObj("link_" + linkID);
  if (clearTag == 0) {
    thisLink.style.backgroundImage = "none";
    thisLink.name = "0";
  } else {
    thisLink.style.backgroundImage = "url(images/checkmark.gif)";
    thisLink.style.backgroundPosition = "left center";
    thisLink.style.backgroundRepeat = "no-repeat";
    thisLink.name = "1"; //change name to 1 to save that it is "checked"
  }
}

function clearTaggedLinks() {
  for (i=0;i<commSearchIDs.length;i++) {
    thisLink = findObj("link_" + commSearchIDs[i]);
    thisLink.style.backgroundImage = "none";
  }
}

function switchCommSearch(divID){ 
  //get current id - convert to number
  commid = findObj("comm_search_id");  
  currID = parseInt(commid.value);

  //ERROR CHECKING FOR NAICS CODES.
  //CUSTOMERS, SUPPLIERS, COMPETITORS
  //DON'T LET THEM OFF THE PAGE UNLESS THEY HAVE CHECKED SOMETHING
  var bNAICOK = "true";
  switch (currID)
  {
    case 3:
	bNAICOK = commSearchValidateNAICS("sup", ""); //suppliers
	break;
    case 4:
	bNAICOK = commSearchValidateNAICS("cus", ""); //customers
	break;
    case 5:
	bNAICOK = commSearchValidateNAICS("com", ""); //competitors
	break;
    default:
	break;
  }

  if (bNAICOK=="true")
  {
    //UPDATE ID TO THE PREV PAGE ID
    if (divID == "prev") 
    {
      if (currID > 0) 
      {
        currID = currID - 1;
      }
      divID = currID;
    } 
    //IF NEXT - UPDATE THE ID TO THE NEXT ID
    len = commSearchIDs.length - 1;
    if (divID == "next") 
    {
      if (currID < len) 
      {
        currID = currID + 1;
        divID = currID;
      }
      else //hit next on the last page - set to 'finish'
      {
	divID = "finish";
        currID = len;
      }
      
    } 
    if (divID != "finish")
    {
      thisDiv = findObj("div_" + commSearchIDs[divID]);
      thisLink = findObj("link_" + commSearchIDs[divID]);
      showMap = findObj("showonmap");

      prevSearchDiv.style.display = "none";
      thisDiv.style.display = ""; 
      prevSearchDiv = thisDiv; 

      prevSearchLink.className = "";
      thisLink.className = "selected";
      prevSearchLink = thisLink;

      //store id
       document.frmMain.comm_search_id.value = divID;
      var divnum = parseInt(divID); //need numeric value
      //SWITCH THEME
     
      switch (divnum)
      {
       case 0:
	document.frmMain.comm_search_themelayer.value = ""; //clear
	break;
       case 1:
	document.frmMain.comm_search_themelayer.value = "pop"; //population
	break;
       case 2:
	document.frmMain.comm_search_themelayer.value = "household"; //household income
	break;
       case 3:
	document.frmMain.comm_search_themelayer.value = "sup"; //suppliers
	break;
       case 4:
	document.frmMain.comm_search_themelayer.value = "cus"; //customers
	break;
       case 5:
	document.frmMain.comm_search_themelayer.value = "com"; //competitors
	break;
       case 6:
	document.frmMain.comm_search_themelayer.value = "unemployment"; //unemployment
	break;
       case 7:
	document.frmMain.comm_search_themelayer.value = "edu"; //education
	break;
       case 8:
	document.frmMain.comm_search_themelayer.value = "deg"; //degrees
	break;
       case 9:
	document.frmMain.comm_search_themelayer.value = "wag"; //wages
	break;
       case 10:
	document.frmMain.comm_search_themelayer.value = "ocu"; //occupations
	break;
       case 11:	
	document.frmMain.comm_search_themelayer.value = "interstate"; //interstates					
	break;
       case 12:
	document.frmMain.comm_search_themelayer.value = "airport"; //airports
	break;
       case 13:
	document.frmMain.comm_search_themelayer.value = "railroad"; //railroad
	break;
       default:
	break;
      }
      //GET PREVIOUS BUTTON
      prevbutton = findObj("comm_search_prev"); 
      //HIDE|SHOW|ENABLE|DISABLE OTHER BUTTONS BASED ON WHERE THEY ARE IN THE COMM SEARCH
      if (divnum == 0) 
      {
        showMap.style.display = "none";
        //disable previous button
        prevbutton.disabled = true;
      } else if (divnum > 10)
      {
        showMap.disabled = true;
        prevbutton.disabled = false; 
      } else
      {
        showMap.style.display = "";
        showMap.disabled = false;
        //enable previous button
        prevbutton.disabled = false;  
      }
    }//IF FINISH  - RUN THE COMM SEARCH
    else
    {
      doCommSearch();
    } 
  }
}

function selectAllMfrs(masterBox,listName) {
  for (i=311;i<340;i++) {
    if (i < 317 || (i > 320 && i < 328) || (i > 330 && i < 338) || i == 339) {
      thisBox = findObj(listName + i);
      thisBox.checked = masterBox.checked;
    }
  }
}
function commSearchRequestInfo()
{
  //ALWAYS SUBMIT THIS, EVEN IF THE FORM IS THERE SO WE CAN SUBMIT THE NEW PARAMETERS
  if(document.frmMain.comm_search_rows_checked.value == "")
  {
    alert("You have not selected any communities.  Please select at least one community.");
  } else
  { 
    document.frmMain.tool.value = "Contacts,CommSearch,true";
    clearCheckBoxesInDataGrid("frmCommSearch", "ckCounty");
    submitMapRequest();
  }  
}
function commSearchAddProspects()
{
  if(document.frmMain.comm_search_rows_checked.value == "")
  {
    alert("You have not selected any communities.  Please select at least one community.");
  } else
  { 

  document.frmMain.cmd.value = "comm_search_add_prospects";
  clearCheckBoxesInDataGrid("frmCommSearch", "ckCounty");
  submitMapRequest();
  }
}

function commSearchFindProperties()
{
  if(document.frmMain.comm_search_rows_checked.value == "")
  {
	 //alert(document.frmMain.selbuildings.value);
     alert("You have not selected any communities.  Please select at least one community.");
    }
  else
  {   	  
    //Server will check to make sure they have check boxes selected
    //DO SITE SEARCH BY DEFAULT
    
    disableBoth();
    document.frmMain.prop_search_type.value = "both";
    disableLocation();
    document.frmMain.markerList.value = "";
    document.frmMain.selX.value = "";
    document.frmMain.selY.value = "";   
  
    document.frmMain.cmd.value = "comm_search_find_prop";
    clearCheckBoxesInDataGrid("frmCommSearch", "ckCounty");
    submitMapRequest();
  }
}

function commSearchValidateNAICS(type,map)
{
  
  var bOK = "true";
  var bRateChecked = false;
  //if user has selected rating for Suppliers, Customers and Competitors, make sure there is an NAICS code checked.
  //type will = "sup", "cus", or "com" and is preface to the radio button names and check box ids.

  //get comm search form
  var theForm = findObj("frmCommSearch");

    //GET THE "IGNORE" BUTTON
    sRadioName = "comm_rate_" + type + "_0";
    rateRadio = findObj(sRadioName);
    //IF IGNORE CHECKED THEN OK
    if (rateRadio.checked == true) //boolean no quotes
    {
	bRateChecked = false;
    } else
    {
	bRateChecked = true;
    }
  if (bRateChecked || map == "map")
  {
    var totalSelected = 0;
    for (i=0;i<theForm.elements.length;i++) 
    {
      if (theForm.elements[i].type == "checkbox" && theForm.elements[i].checked) 
      {
  	var idName = theForm.elements[i].id;
         if(idName.indexOf(type) != -1)
	{
          totalSelected = totalSelected + 1;
	}
      }
    }
    if (totalSelected < 1)
    {
      s = "";
      if (type == "sup")
      {
        s = "Suppliers";
      }
      if (type == "cus")
      {
        s = "Customers";
      }
      if (type == "com")
      {
        s = "Competitors";
      }	
      	if(map == "map") //means we are checking this from the ShowOnMap button for the particular customer, supplier, competitor
	{
		alert("Please check at least one " + s + " Industry NAICS code to display on the map.");
	} else
	{
      		alert("You have chosen to rate " + s + " as important to you. Please check at least one Industry NAICS code for " + s + ".");
	}
      //reset = findObj("comm_rate_" + type + "_0");
      //reset.checked = true;
      //tagLink('sup',0)  //UNCOMMENT IF YOU WANT TO UNCHECK THEIR CATEGORY EVEN IF THEY DO NOT HAVE A CHECK
      bOK = "false";
    }
  }
  return bOK;
}


// ##### Property Search #####
function hidePropTab()
{
    frmResults = findObj("frmPropResults");
	frmSearch = findObj("frmSearchProp");
	frmSearch.style.display = "none";
  	frmResults.style.display = "none";
}

function showPropResults(showDiv)
{
    frmResults = findObj("frmPropResults");
	frmSearch = findObj("frmSearchProp");
	search = findObj("search_prop");
	results = findObj("results_prop");
	if (showDiv == "search_prop" || showDiv == "prop_search") //hide results
	{	 
	 search.style.display = ""; 
	 results.style.display = "none";
	 frmSearch.style.display = "";
  	 frmResults.style.display = "none";
	 if (document.frmMain.prop_search_type.value == "site")
	 {
		disableSites();
	 }
	 else if(document.frmMain.prop_search_type.value == "building")
	 {
		disableBuildings();  //really enables this, not disables
	 }
	 else
	 {
		disableBoth();
	 }
	
	} 
	if (showDiv == "results_prop" || showDiv == "prop_results")
	{
	 search.style.display = "none";
	 results.style.display = "";
	 frmSearch.style.display = "none";
  	 frmResults.style.display = "";
	}
	activeDiv = findObj("prop_active_div");
	activeDiv.value = showDiv;	
	
	
}

function disableSites() {
  var theForm = findObj("frmSearchProp");
  theForm.bldg_min.disabled = true;
  theForm.bldg_min.style.background = "#ccc";
  theForm.bldg_max.disabled = true;
  theForm.bldg_max.style.background = "#ccc";
  theForm.bldg_min_other.disabled = true;
  theForm.bldg_min_other.style.background = "#ccc";
  theForm.bldg_max_other.disabled = true;
  theForm.bldg_max_other.style.background = "#ccc";
  theForm.bldg_ceiling_ht.disabled = true;
  theForm.bldg_ceiling_ht.style.background = "#ccc";
  theForm.bldg_build_year.disabled = true;
  theForm.bldg_build_year.style.background = "#ccc";
  theForm.bldg_occupancy_type.disabled = true;
  theForm.bldg_occupancy_type.style.background = "#ccc";
  theForm.bldg_docks.disabled = true;
  theForm.bldg_docks.style.background = "#ccc";
  document.frmMain.prop_search_type.value = "site";
  //alert(document.frmMain.prop_search_type.value);
  chk = findObj("proptype_land");  
  chk.checked = true;  
}

function disableLocation()
{
	var theForm = findObj("frmSearchProp");
	if(theForm.ck_prop_search_communities.checked == true)
	{
		theForm.prop_state.options.selectedIndex = 0;
		theForm.prop_state.disabled = true;
		theForm.prop_state.style.background = "#ccc";
		theForm.prop_region.options.selectedIndex = 0;
		theForm.prop_region.disabled = true;
		theForm.prop_region.style.background = "#ccc";
		theForm.prop_county.options.selectedIndex = 0;
		theForm.prop_county.disabled = true;
		theForm.prop_county.style.background = "#ccc";
		//theForm.ck_prop_search_communities.checked = false;
	}
	else
	{
		theForm.prop_state.disabled = false;
		theForm.prop_state.style.background = "none";
		theForm.prop_region.disabled = false;
		theForm.prop_region.style.background = "none";
		theForm.prop_county.disabled = false;
		theForm.prop_county.style.background = "none";	
		//theForm.ck_prop_search_communities.checked = true;	
	}
}

function disableBoth() {
  var theForm = findObj("frmSearchProp");
  theForm.bldg_min.disabled = true;
  theForm.bldg_min.style.background = "#ccc";
  theForm.bldg_max.disabled = true;
  theForm.bldg_max.style.background = "#ccc";
  theForm.bldg_min_other.disabled = true;
  theForm.bldg_min_other.style.background = "#ccc";
  theForm.bldg_max_other.disabled = true;
  theForm.bldg_max_other.style.background = "#ccc";
  theForm.bldg_ceiling_ht.disabled = true;
  theForm.bldg_ceiling_ht.style.background = "#ccc";
  theForm.bldg_build_year.disabled = true;
  theForm.bldg_build_year.style.background = "#ccc";
  theForm.bldg_occupancy_type.disabled = true;
  theForm.bldg_occupancy_type.style.background = "#ccc";
  theForm.bldg_docks.disabled = true;
  theForm.bldg_docks.style.background = "#ccc";
  document.frmMain.prop_search_type.value = "both";
  //alert(document.frmMain.prop_search_type.value);
  chk = findObj("proptype_both");
  
  chk.checked = true;
  
}

function disableBuildings() {
  var theForm = findObj("frmSearchProp");
  theForm.bldg_min.disabled = false;
  theForm.bldg_min.style.background = "none";
  theForm.bldg_max.disabled = false;
  theForm.bldg_max.style.background = "none";
  theForm.bldg_min_other.disabled = false;
  theForm.bldg_min_other.style.background = "none";
  theForm.bldg_max_other.disabled = false;
  theForm.bldg_max_other.style.background = "none";
  theForm.bldg_ceiling_ht.disabled = false;
  theForm.bldg_ceiling_ht.style.background = "none";
  theForm.bldg_build_year.disabled = false;
  theForm.bldg_build_year.style.background = "none";
  theForm.bldg_occupancy_type.disabled = false;
  theForm.bldg_occupancy_type.style.background = "none";
  theForm.bldg_docks.disabled = false;
  theForm.bldg_docks.style.background = "none";
  chk = findObj("proptype_bldg");
  chk.checked = true;
  document.frmMain.prop_search_type.value = "building";
//alert(document.frmMain.prop_search_type.value);

}

var popTypeIDs = new Array('comm_pop_under_20','comm_pop_20_29','comm_pop_30_39','comm_pop_40_49','comm_pop_50_59','comm_pop_60_64','comm_pop_over_65');
function disablePopType(turnOn) {
  for (i=0;i<popTypeIDs.length;i++) {
    var thisItem = findObj(popTypeIDs[i]);
    if (turnOn == 'enable') {
      thisItem.disabled = false;
    } else {
      thisItem.disabled = true;
    }
  }
}

function validatePropSearch(frmName) {
//now called by doPropertySearch in map.js
//using this in the form.submit was causing everything to be considered a non-postback - reset all the values.

  theForm = findObj(frmName);

  var otherSelect = new Array('land_min','land_max','bldg_min','bldg_max','bldg_ceiling_ht');
  for (i=0;i<otherSelect.length;i++) {
    s = findObj(otherSelect[i]);
    t = findObj(otherSelect[i] + "_other");
    //if "other" is selected, make sure there is a value
    if (s[s.selectedIndex].value=="other" && s.disabled==false) {
      if(t.value=="") {
        alert("You must enter a value for 'Other'.");
        t.focus();
        return false;
      } else if (isNaN(t.value)) {
        alert("You must enter a numeric value for 'Other' (no commas or other characters).");
        t.select();
        return false;
      }
    }
    
  }
  if (theForm.land_min.value!="" && theForm.land_max.value!="") {
    if (theForm.land_min.value=="other") {
      var v1 = theForm.land_min_other.value;
    } else {
      var v1 = theForm.land_min[theForm.land_min.selectedIndex].value;
    }
    if (theForm.land_max.value=="other") {
      oth = findObj("land_max_other");
      var v2 = oth.value;
    } else {
      var v2 = theForm.land_max[theForm.land_max.selectedIndex].value;
    }
    var compare = v1 - v2;
    if (compare > 0) {
      alert("Land Size: Minimum Size must be smaller than Maximum Size.");
      theForm.land_min.focus();
      return false;
    }
  }

  if (theForm.bldg_min.disabled==false && theForm.bldg_min.value!="" && theForm.bldg_max.value!="") {
    if (theForm.bldg_min.value=="other") {
      var v1 = theForm.bldg_min_other.value;
    } else {
      var v1 = theForm.bldg_min[theForm.bldg_min.selectedIndex].value;
    }
    if (theForm.bldg_max.value=="other") {
      var v2 = theForm.bldg_max_other.value;
    } else {
      var v2 = theForm.bldg_max[theForm.bldg_max.selectedIndex].value;
    }
    var compare = v1 - v2;
    if (compare > 0) {
      alert("Building Size: Minimum Size must be smaller than Maximum Size.");
      theForm.bldg_min.focus();
      return false;
    }
  }
 
return true;

}

function propSearchRequestInfo()
{
  //ALWAYS SUBMIT THIS, EVEN IF THE FORM IS THERE SO WE CAN SUBMIT THE NEW PARAMETERS
  if(document.frmMain.prop_search_rows_checked.value == "")
  {
    alert("You have not selected any properties or buildings.  Please select at least one property or building.");
  } else
  { 
    document.frmMain.tool.value = "Contacts,PropSearch,true";
    clearCheckBoxesInDataGrid("frmPropResults", "ckProp");
    submitMapRequest();
  }  
}

function propSearchAddProspects()
{
  if(document.frmMain.prop_search_rows_checked.value == "")
  {
    alert("You have not selected any properties or buildings.  Please select at least one property or building.");
  } else
  { 
    document.frmMain.cmd.value = "prop_search_add_prospects";
    clearCheckBoxesInDataGrid("frmPropResults", "ckProp");
    submitMapRequest();
  }
}

// ##### My Prospects Functions #####
function hideMyCommIntro()
{
  intro = findObj("my_prop_header");
  intro.style.display = "none";
  info = findObj("my_comm_info")
  info.style.display = "";
}

function switchMyCommInfo(tab)
{

  propimg = findObj("my_comm_tab_prop");
  commimg = findObj("my_comm_tab_comm");
  commForm = findObj("formMyComm");
  propForm = findObj("formMyProp");
  activeDiv = findObj("my_comm_active_div");
  dgComm = findObj("dg_my_comm_communities");
  dgProp = findObj("dg_my_comm_properties");
  	 
  if (tab == "Property")
  {
	
   propimg.src="images/btn_properties_selected.gif"
   commimg.src="images/btn_communities.gif"
   propForm .style.display = "";   
   commForm.style.display = "none";
   activeDiv.value = 'Property';
   //show hide datagrids - border issues
   if (dgComm != null)
   {
     dgComm.visible = false;
   } 
   if (dgProp != null)
   {
     dgProp.visible = true;
   }
  }
  if (tab == "Community")
  {
   propimg.src="images/btn_properties.gif"
   commimg.src="images/btn_communities_selected.gif"
   commForm .style.display = "";   
   propForm.style.display = "none";
   activeDiv.value = 'Community';
   //show hide datagrids - border issues
   if (dgComm != null)
   {
     dgComm.visible = true;
   } 
   if (dgProp != null)
   {
     dgProp.visible = false;
   }
  }  
  //alert("Inside switchComm: " + propimg.src);
}
function myComm_Property_RequestInfo()
{
  //ALWAYS SUBMIT THIS, EVEN IF THE FORM IS THERE SO WE CAN SUBMIT THE NEW PARAMETERS
  if(document.frmMain.my_comm_prop_search_rows_checked.value == "")
  {
    alert("You have not selected any properties from My Prospects.  Please check at least one property.");
  } else
  { 
    document.frmMain.tool.value = "Contacts,MyCommProp,true";
     clearCheckBoxesInDataGrid("formMyProp", "ck_my_comm_properties");
    submitMapRequest();
  }  
}

function myComm_Property_Delete()
{
  //ALWAYS SUBMIT THIS, EVEN IF THE FORM IS THERE SO WE CAN SUBMIT THE NEW PARAMETERS
  if(document.frmMain.my_comm_prop_search_rows_checked.value == "")
  {
    alert("You have not selected any properties from My Prospects.  Please check at least one property.");
  } else
  { 

    clearCheckBoxesInDataGrid("formMyProp", "ck_my_comm_properties");
    document.frmMain.cmd.value = "my_comm_prop_delete";
    submitMapRequest();
  }  
}

function myComm_Community_RequestInfo()
{
  //ALWAYS SUBMIT THIS, EVEN IF THE FORM IS THERE SO WE CAN SUBMIT THE NEW PARAMETERS
  if(document.frmMain.my_comm_comm_search_rows_checked.value == "")
  {
    alert("You have not selected any communities from My Prospects.  Please check at least one property.");
  } else
  { 

    clearCheckBoxesInDataGrid("formMyComm", "ck_my_comm_communities");
    document.frmMain.tool.value = "Contacts,MyCommComm,true";
    submitMapRequest();
  }  
}


function myComm_Community_Find_Properties()
{
  //ALWAYS SUBMIT THIS, EVEN IF THE FORM IS THERE SO WE CAN SUBMIT THE NEW PARAMETERS
  if(document.frmMain.my_comm_comm_search_rows_checked.value == "")
  {
    alert("You have not selected any communities from My Prospects.  Please check at least one community.");
  } else
  { 
    //DO SITE SEARCH BY DEFAULT
    document.frmMain.prop_search_type.value = "site";
    disableSites();  //will actually disable the building boxes
    document.frmMain.cmd.value = "my_comm_find_prop";

    clearCheckBoxesInDataGrid("formMyComm", "ck_my_comm_communities");
    submitMapRequest();
  }  
}

function myComm_Community_Delete()
{
  //ALWAYS SUBMIT THIS, EVEN IF THE FORM IS THERE SO WE CAN SUBMIT THE NEW PARAMETERS
  if(document.frmMain.my_comm_comm_search_rows_checked.value == "")
  {
    alert("You have not selected any communities from My Prospects.  Please check at least one community.");
  } else
  { 
    document.frmMain.cmd.value = "my_comm_comm_delete";

    clearCheckBoxesInDataGrid("formMyComm", "ck_my_comm_communities");
    submitMapRequest();
  }  
}

// ##### Report Functions #####

function expandReport() {
  	var layers = document.getElementsByTagName("TR");		
	
	for (var i = 0; i < layers.length; i++) {
		var idName = layers[i].id;
		if (idName.indexOf("expand") != -1) {
			layers[i].style.display = "inline";
		}
		else if (idName.indexOf("reduce") != -1) {
			layers[i].style.display = "none";
		}
		
	}
	 replaceLayerContent("ToggleReportViews","<a href='javascript:reduceReport()'>Quick View</a> | Expanded");
	document.frmMain.propertyView.value = "Expanded";	
	//alert(document.frmMain.propertyView.value);
}

function reduceReport() {
  	var layers = document.getElementsByTagName("TR");		
	
	for (var i = 0; i < layers.length; i++) {
		var idName = layers[i].id;
		if (idName.indexOf("expand") != -1) {
			layers[i].style.display = "none";
		}
		else if (idName.indexOf("reduce") != -1) {
			layers[i].style.display = "inline";
		}
		
	}

	replaceLayerContent("ToggleReportViews","Quick View | <a href='javascript:expandReport()'>Expanded</a>");
	document.frmMain.propertyView.value = "Quick View";		
	//alert(document.frmMain.propertyView.value);
}

// replace layer content
function replaceLayerContent(name, content) {
	if (document.getElementById(name) != null) {
		document.getElementById(name).innerHTML = content;
	}
}

function displayReport(name) {

	var createdReports = document.frmMain.currentreports.value;
	
	var layers = createdReports.split(',');
	var subreport = "";
	var layerExists = "false";
	var layer;
 
	if (name.indexOf(":") != -1){
		if (name.indexOf("demographic") != -1)
		{
	 		subreport = name.substring(name.indexOf(":")+ 1);	
	 		name = name.substring(0,name.indexOf(":"));
		}
		else if (name.indexOf("wageDetailsubreport") != -1)
		{
		 	subreport = name.substring(name.indexOf(":")+ 1);	
	 		name = name.substring(0,name.indexOf(":"));	
		}
	
		else if (name.indexOf("businessDetailsubreport") != -1)
		{
			subreport = name.substring(name.indexOf(":")+ 1);	
	 		name = name.substring(0,name.indexOf(":"));	
		}
		else if (name.indexOf("levelFourBusinessReport") != -1)
		{
			subreport = name.substring(name.indexOf(":")+ 1);	
	 		name = name.substring(0,name.indexOf(":"));	
		}
		
	}

	var fullname;
	var radval = document.frmMain.radius.value;
	

	//if (name.indexOf("_County") != -1 || name.indexOf("_15") != -1 || name.indexOf("_30") != -1 || name.indexOf("_60") != -1)
	//{
	//	fullname = name;
	//}
	//else
	//{
		
	    if(name.indexOf("_" + document.frmMain.radius.value) != -1)
	    {
			fullname = name;
		}
		else
		{
		    fullname = name + "_" + document.frmMain.radius.value;
			
		}
	//}
	
	

	if (layers.length > 0) 
	{  
		for (var i = 0; i < layers.length; i++) 
		{
			var idName = layers[i];
			if (idName == fullname)
			{
				layer = getLayer(idName);
				if (layer != null)
				{
					layer.display = "inline";
					layerExists = "true";					
					document.frmMain.activereport.value = idName;
					
 					if (name.indexOf("demographicsubreport") != -1)
					{
						window.location.href = "default.aspx#" + subreport;
						//alert("Subreport = " + subreport);
					}
				}
			}
			else
			{			
				layer = getLayer(idName);
				if (layer != null)
				{
					layer.display = "none";
				}

			}
		} 
	}

	if (layerExists == "true") 
	{
		return;
	}
	if (name.indexOf(":") != -1)
	{
		subreport = name.substring(name.indexOf(":")+ 1);
		name = name.substring(0,name.indexOf(":"));
	}
 
	if(subreport == "")
	{
		document.frmMain.tool.value = name;
		
		submitMapRequest(); //in map.js
	}
	else
	{
		document.frmMain.subreport.value = subreport;
		document.frmMain.tool.value = name;
		
		submitMapRequest(); //in map.js
	}
 
	//alert(document.frmMain.tool.value);
}




function getLayer(name) {

	var theObj = document.getElementById(name);
	if(theObj != null)
	{
		return(theObj.style);
	}
	else 
	{   
		//alert("Get layer:" + name);
		if (name != "")
		{	
			if (eval('document.all.' + name) != null)
			{
			    layer = eval('document.all.' + name + '.style');
				return(layer);
			} 
		}
		else 
		{
			return(null);
		}			
	}
}

function displayRangeControl(bValue)
{
 	var layers = document.getElementsByTagName("TR");		
	
	for (var i = 0; i < layers.length; i++) {
		var idName = layers[i].id;
		if (idName.indexOf("comm_control") != -1) {
			if (bValue == "true") {
			  layers[i].style.visibility = "visible";
			}
			else {
			  layers[i].style.visibility = "hidden";
			}
		}
		
		
	}

	replaceLayerContent("ToggleReportViews","Quick View | <a href='javascript:expandReport()'>Expanded</a>");

}


function toggleReportType(name) {

var reportText;

	if (document.getElementById(name) != null) 
	{
		if (name == 'PropertyReportType') 
		{

			/*reportText = document.getElementById('PropertyReportType').innerHTML;
			
			if (reportText.length > 0) 
			{
		   	  document.getElementById('PropertyReportType').style.display = "inline";
		  	  document.getElementById('CommunityReportType').style.display = "none";
			  displayRangeControl("false");
			  document.frmMain.activereporttab.value = "property";
	      	   
			}
			else
			{
			  commSearchFindProperties();	
			  //alert("No property associated with this community");
			}*/
			commSearchFindProperties();
						  
		}
		else
		{
			reportText = document.getElementById('CommunityReportType').innerHTML;
			document.frmMain.activereporttab.value = "community";

			if (reportText.length > 0) 
			{
			  document.getElementById('PropertyReportType').style.display = "none";
		  	  document.getElementById('CommunityReportType').style.display = "inline";			  
			  //show the range drop down
			  displayRangeControl("true");
	      	 
			}
			else 
			{
			  document.frmMain.tool.value = "communityProfilereport";
			  submitMapRequest();
			}
		}
	}
}


function ReportRequestInfo()
{  
   var tagDisplay = document.getElementById('PropertyReportType').style.display;
   var name = "Property";
   if (tagDisplay.toUpperCase() == "NONE")
	{
	  name = "Community";
	}
   infoType = "Contacts,Report_" + name + ",true";
   document.frmMain.tool.value = infoType;
   submitMapRequest();
}

function ReportAddProspects()
{
   var tagDisplay = document.getElementById('PropertyReportType').style.display;
   var name = "Property";
   if (tagDisplay.toUpperCase() == "NONE")
	{
	  name = "Community";
	}
    infoType =  name + "_rpt_add_prospects";

     document.frmMain.cmd.value = infoType;  
     submitMapRequest();
}


function doPDFReport(){

	var viewMoreVal = document.frmMain.viewMoreSubreport.value;
	
	if(viewMoreVal != "")
	{
		pdfURL = document.frmMain.viewMoreUrl.value;
		var pdfWin = window.open(pdfURL, "Report", "width=500,height=400,toolbar=0,menubar=1,scrollbars=1,resizable=1,left=300,top=100");
		//document.frmMain.viewMoreSubreport.value = "";
	}
	else
	{
		document.frmMain.tool.value = "PDFReport";
		//document.frmMain.submit();
		submitMapRequest();
		
	}
}

function emailPdf(){

var viewMoreVal = document.frmMain.viewMoreSubreport.value;
	
	if(viewMoreVal != "")
	{
		activeRpt = document.frmMain.activereport.value;
		pdfURL = document.frmMain.viewMoreUrl.value;
		fileName = pdfURL.substring(pdfURL.lastIndexOf("/")+1,pdfURL.length);
		emailUrl = "MailReport.aspx?fileName=" + fileName + "&activeReport="+ activeRpt;
		pdfWin = window.open(emailUrl, "MailReport", "width=500,height=300,toolbar=0,menubar=0,scrollbars=1,resizable=1,left=300,top=100");
		//document.frmMain.viewMoreSubreport.value = "";
	}
	else
	{
		document.frmMain.tool.value = "PDFReport";
		document.frmMain.emailpdfreport.value = "True";	
		document.frmMain.submit();
	}

}

function excelReport(){
	
	excelUrl = document.frmMain.activereport.value;	
	
	if(excelUrl == "PropertyReport")
	{	
		if(document.frmMain.propertyView.value == "Expanded")
		{
			pathStr = document.frmMain.mapURL.value;
			pathStr = pathStr.substring(0,pathStr.lastIndexOf("/")+1);
			var sId = document.frmMain.sessionID.value;	
			exlUrl = pathStr + excelUrl + "EX" + sId + ".xls";	
			exlWin = window.open(exlUrl, "ExcelReport", "width=500,height=400,toolbar=0,menubar=1,scrollbars=1,resizable=1,left=300,top=100");
		}
		else
		{
			pathStr = document.frmMain.mapURL.value;
			pathStr = pathStr.substring(0,pathStr.lastIndexOf("/")+1);
			var sId = document.frmMain.sessionID.value;	
			exlUrl = pathStr + excelUrl + "QV" + sId + ".xls";	
			exlWin = window.open(exlUrl, "ExcelReport", "width=500,height=400,toolbar=0,menubar=1,scrollbars=1,resizable=1,left=300,top=100");
		}	
				
	}
	else
	{	
		pathStr = document.frmMain.mapURL.value;
		pathStr = pathStr.substring(0,pathStr.lastIndexOf("/")+1);
		var sId = document.frmMain.sessionID.value;	
		exlUrl = pathStr + excelUrl + sId + ".xls";	
		exlWin = window.open(exlUrl, "ExcelReport", "width=500,height=400,toolbar=0,menubar=1,scrollbars=1,resizable=1,left=300,top=100");
		//exlWin = window.open("excelreport.aspx?exUrl="+exlUrl, "ExcelReport", "width=500,height=400,toolbar=0,menubar=1,scrollbars=1,resizable=1,left=300,top=100");
		
	}
}

function showexcelReport()
{
	excelUrl = document.frmMain.activereport.value;	
	if(document.frmMain.exlUrl.value != "")
	{
		pathStr = document.frmMain.mapURL.value;
		pathStr = pathStr.substring(0,pathStr.lastIndexOf("/")+1);
		var sId = document.frmMain.sessionID.value;	
		document.location.href = pathStr + "propertyReport" + sId + ".xls";
		exlWin = window.open(pathStr + "propertyReport" + sId + ".xls", "ExcelReport", "width=500,height=400,toolbar=0,menubar=1,scrollbars=1,resizable=1,left=300,top=100");
		document.frmMain.exlUrl.value = "";
		//document.frmMain.pdfreport.value = "";
	}	
}

/*function showPDFReport(){
	pdfURL = document.frmMain.pdfreport.value;
	if(pdfURL != ""){
		pdfWin = window.open(pdfURL, "Report", "width=500,height=400,toolbar=0,menubar=1,scrollbars=1,resizable=1,left=300,top=0");
	}
	document.frmMain.pdfreport.value = "";
}*/

function showPDFReport(){
	
	pdfURL = document.frmMain.pdfreport.value;
	checkEmail = document.frmMain.emailpdfreport.value;
	activeRpt = document.frmMain.activereport.value;
	//setZoomBoxSettings();
	var emailUrl;	
	if((pdfURL != "") && (checkEmail != ""))
	{
		fileName = pdfURL.substring(pdfURL.lastIndexOf("/")+1,pdfURL.length);
		emailUrl = "MailReport.aspx?fileName=" + fileName + "&activeReport="+ activeRpt;
		pdfWin = window.open(emailUrl, "MailReport", "width=500,height=300,toolbar=0,menubar=0,scrollbars=1,resizable=1,left=300,top=100");
		document.frmMain.tool.value = "zoomin";	
		mouseFlag = true;
	}
	if((pdfURL != "") && (checkEmail != "True"))
	{
		pdfWin = window.open(pdfURL, "Report", "width=500,height=400,toolbar=0,menubar=1,scrollbars=1,resizable=1,left=300,top=100");
		document.frmMain.tool.value = "zoomin";	
	}
	
	document.frmMain.pdfreport.value = "";	
	document.frmMain.emailpdfreport.value = "";		
}


// ##### CONTACTS ##### 
function contactsRequestInfo()
{
    //THEY CLICKED THE REQUEST INFO BUTTON ON THE CONTACTS TAB - GENERATE THE FORM
    document.frmMain.tool.value = "Contacts,Tab,true";
    submitMapRequest();
 
}
// ##### FUNCTIONS WE ARE NOT USING - TEST AND REMOVE ##### 
function checkSelectionsMade(thisForm) {
  var theForm = eval("document." + thisForm);
  for (i=0;i<theForm.elements.length;i++) {
    if (theForm.elements[i].type == "checkbox" && theForm.elements[i].checked) {
      return true;
    }
  }
  return false;
}

function checkMultipleSelections(thisForm) {
  var theForm = eval("document." + thisForm);
  var totalSelected = 0;
  for (i=0;i<theForm.elements.length;i++) {
    if (theForm.elements[i].type == "checkbox" && theForm.elements[i].checked && theForm.elements[i].name != "selectall") {
      totalSelected = totalSelected + 1;
    }
  }
  if(totalSelected > 1 && totalSelected < 11) {
    return true;
  } else {
    return false;
  }
}

function checkAddtoProspects(thisForm,thisType) {
  if(checkSelectionsMade(thisForm)) {
    return true;
  } else {
    alert("Please select " + thisType + " to add to My Prospects.");
    return false;
  }
}

function checkCompare(thisForm,thisType) {
  if(checkMultipleSelections(thisForm)) {
    return true;
  } else {
    alert("Please select between 2 and 10 " + thisType + " to compare.");
    return false;
  }
}

function checkRequestInfo(thisForm,thisMessage,thisType) {
  if(checkSelectionsMade(thisForm)) {
    return true;
  } else {
    return confirm("You have not selected any " + thisType + ".\n\nWould you like to discuss " + thisMessage + " with a representative?");
  }
}

function checkDelete(thisForm,thisType) {
  if(checkSelectionsMade(thisForm)) {
    return confirm("Are you sure you want to permanently remove these " + thisType + " from My Prospects?");
  } else {
    alert("Please select " + thisType + " to delete.");
    return false;
  }
}
//NOT USING THIS ANYMORE SINCE WE ARE USING A DATAGRID
function checkFindProps(thisForm,thisType) {
  if(!thisForm) {thisForm = "formCommSearch"}
  if(checkSelectionsMade(thisForm)) {
    return true;
  } else {
    if(!thisType) {thisType = "results"}
    return confirm("You have not selected any communities.\n\nWould you like to search within all the communities in your " + thisType + "?");
  }
}
function rowHighlight(thisRow,rowOff) {
  if (rowOff == 0) {
    thisRow.style.background = "none"
  } else {
    thisRow.style.background = "#efefef"
  }
}