function doSearch(bodyText, searchTerm) 
{

    linkStartTag = "<a href=/#/>";
    linkEndTag = "</a>";
  
  // find all occurences of the search term in the given text,
  // and add some "highlight" tags to them (we're not using a
  // regular expression search, because we want to filter out
  // matches that occur within HTML tags and script blocks, so
  // we have to do a little extra validation)
  var newText = "";
  var i = -1;
  var lcSearchTerm = searchTerm.toLowerCase();
  var lcBodyText = bodyText.toLowerCase();
    
  while (bodyText.length > 0) {
    i = lcBodyText.indexOf(lcSearchTerm, i+1);
    if (i < 0) {
      newText += bodyText;
      bodyText = "";
    } else {
      // skip anything inside an HTML tag
      if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)) {
        // skip anything inside a <script> block
        if (lcBodyText.lastIndexOf("/script>", i) >= lcBodyText.lastIndexOf("<script", i)) {
          newText += bodyText.substring(0, i) + linkStartTag + bodyText.substr(i, searchTerm.length) + linkEndTag;
          bodyText = bodyText.substr(i + searchTerm.length);
          lcBodyText = bodyText.toLowerCase();
          i = -1;
        }
      }
    }
  }
  
  return newText;
}


/*
 * This is sort of a wrapper function to the doHighlight function.
 * It takes the searchText that you pass, optionally splits it into
 * separate words, and transforms the text on the current web page.
 * Only the "searchText" parameter is required; all other parameters
 * are optional and can be omitted.
 */
function SearchWord(searchText, treatAsPhrase, warnOnFailure, highlightStartTag, highlightEndTag)
{
  // if the treatAsPhrase parameter is true, then we should search for 
  // the entire phrase that was entered; otherwise, we will split the
  // search string so that each word is searched for and highlighted
  // individually
  if (treatAsPhrase) {
    searchArray = [searchText];
  } else {
    searchArray = searchText.split(" ");
  }
  
  if (!document.body || typeof(document.body.innerHTML) == "undefined") {
    if (warnOnFailure) {
      alert("Sorry, for some reason the text of this page is unavailable. Searching will not work.");
    }
    return false;
  }
  
  var bodyText = document.body.innerHTML;
  for (var i = 0; i < searchArray.length; i++) {
    bodyText = doSearch(bodyText, searchArray[i], highlightStartTag, highlightEndTag);
  }
  
  document.body.innerHTML = bodyText;
  return true;
}












function grayOut(vis, options) {
	
  var options = options || {}; 
  var zindex = options.zindex || 50;
  var opacity = options.opacity || 70;
  var opaque = (opacity / 100);
  var bgcolor = options.bgcolor || '#000000';
  var dark=document.getElementById('darkenScreenObject');
  var Imgmap=document.getElementById('Imgmap');
  var AcImg=document.getElementById('AcImg');
  var TextBox=document.getElementById('textbox');
    if (!dark) {
    // The dark layer doesn't exist, it's never been created.  So we'll
    // create it here and apply some basic styles.
    // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
    var tbody = document.getElementsByTagName("body")[0];
    var tnode = document.createElement('div');           // Create the layer.
        tnode.style.position='absolute';                 // Position absolutely
        tnode.style.top='0px';                           // In the top
        tnode.style.left='0px';                          // Left corner of the page
        tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
        tnode.style.display='none';                      // Start out Hidden
        tnode.id='darkenScreenObject';                   // Name it so we can find it later
    tbody.appendChild(tnode);                            // Add it to the web page
    dark=document.getElementById('darkenScreenObject');  // Get the object.
  }
  if (!Imgmap){
  	var tbodyA = document.getElementsByTagName("body")[0];
    var tnodeA = document.createElement('div');  
        tnodeA.style.overflow='hidden';                   // Try to avoid making scroll bars            
        tnodeA.style.display='none';                     // Start out Hidden
        tnodeA.style.position='absolute';                 // Position absolutely
        tnodeA.style.top='0px';   		                     // In the top
     if (window.screen.width <= 1024){
        tnodeA.style.left='0px';}
     else {tnodeA.style.left='10%';}
        tnodeA.style.zIndex=46;
        tnodeA.id='Imgmap';                 // Name it so we can find it later
    tbodyA.appendChild(tnodeA);               // Add it to the web page
    //create <img> tage
    timg = document.createElement('img');
    timg.id='AcImg';
    timg.name='AcImg';
    timg.useMap='#expansion';
    tnodeA.appendChild(timg);
    
    tcoffee=document.createElement('img');
    tcoffee.src='images/expansion/expansion_coffee.jpg';
    tcoffee.id='CoffeeImg';
    tcoffee.name='CoffeeImg';
    tcoffee.style.display='none';
    tcoffee.useMap='#expansion';
    tcoffee.style.cursor="crosshair";
    tnodeA.appendChild(tcoffee);
    
    tbell=document.createElement('img');
    tbell.src='images/expansion/expansion_belltower.jpg';
    tbell.id='BellImg';
    tbell.name='BellImg';
    tbell.style.display='none';
    tbell.useMap='#expansion';
   	tbell.style.cursor="crosshair";
    tnodeA.appendChild(tbell);
    
    tconvent=document.createElement('img');
    tconvent.src='images/expansion/expansion_convent.jpg';
    tconvent.id='ConventImg';
    tconvent.name='ConventImg';
    tconvent.style.display='none';
    tconvent.useMap='#expansion';
    tconvent.style.cursor="crosshair";
    tnodeA.appendChild(tconvent);
    
    tfield=document.createElement('img');
    tfield.src='images/expansion/expansion_field.jpg';
    tfield.id='FieldImg';
    tfield.name='FieldImg';
    tfield.style.display='none';
    tfield.useMap='#expansion';
    tfield.style.cursor="crosshair";
    tnodeA.appendChild(tfield);
    
    trec=document.createElement('img');
    trec.src='images/expansion/expansion_rec.jpg';
    trec.id='RecImg';
    trec.name='RecImg';
    trec.style.display='none';
    trec.useMap='#expansion';
    trec.style.cursor="crosshair";
    tnodeA.appendChild(trec);
    
    tgrad=document.createElement('img');
    tgrad.src='images/expansion/expansion_grad.jpg';
    tgrad.id='GradImg';
    tgrad.name='GradImg';
    tgrad.style.display='none';
    tgrad.useMap='#expansion';
    tgrad.style.cursor="crosshair";
    tnodeA.appendChild(tgrad);
    
    tnewman=document.createElement('img');
    tnewman.src='images/expansion/expansion_newman.jpg';
    tnewman.id='NewmanImg';
    tnewman.name='NewmanImg';
    tnewman.style.display='none';
    tnewman.useMap='#expansion';
    tnewman.style.cursor="crosshair";
    tnodeA.appendChild(tnewman);
    
    tst=document.createElement('img');
    tst.src='images/expansion/expansion_student.jpg';
    tst.id='StudentImg';
    tst.name='StudentImg';
    tst.style.display='none';
    tst.useMap='#expansion';
    tst.style.cursor="crosshair";
    tnodeA.appendChild(tst);
    
    tclose=document.createElement('img');
    tclose.src='images/expansion/expansion_close.jpg';
    tclose.id='CloseImg';
    tclose.name='CloseImg';
    tclose.style.display='none';
    tclose.useMap='#expansion';
    tclose.style.cursor="crosshair";
    tnodeA.appendChild(tclose);
    
    tload=document.createElement('img');
    tload.src='images/expansion/expansion_load.jpg';
    tload.id='LoadImg';
    tload.name='LoadImg';
    tload.style.display='block';
    tnodeA.appendChild(tload);
    
    //create <div> textbox tag
    tdiv=document.createElement('div');
    tdiv.id='textbox';
    tdiv.name='texbox';
    tdiv.style.display='none';
    tdiv.style.position='absolute';
    tdiv.style.top='276px';                           // In the top
    tdiv.style.left='10%';
    tdiv.style.zIndex=47;
    tnodeA.appendChild(tdiv);
    // Get the object.
    TextBox=document.getElementById('textbox');
    Imgmap=document.getElementById('Imgmap');
    AcImg=document.getElementById('AcImg');
  } 
  if (vis) {document.body.style.overflow='hidden';
    // Calculate the page width and height 
    if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
        var pageWidth = document.body.scrollWidth+'px';
        var pageHeight = document.body.scrollHeight+'px';
    } else if( document.body.offsetWidth ) {
      var pageWidth = document.body.offsetWidth+'px';
      var pageHeight = document.body.offsetHeight+'px';
    } else {
       var pageWidth='100%';
       var pageHeight='100%';
    }   
    //set the shader to cover the entire page and make it visible.
    dark.style.opacity=opaque;                      
    dark.style.MozOpacity=opaque;                   
    dark.style.filter='alpha(opacity='+opacity+')'; 
    dark.style.zIndex=45;        
    dark.style.backgroundColor=bgcolor;  
    dark.style.width= pageWidth;
    dark.style.height= pageHeight;
    dark.style.display='block';
    AcImg.style.display='none';
    
    comp=0
    tclose.onLoad=comp++;
    tst.onLoad=comp++;
    tnewman.onLoad=comp++;
    tgrad.onLoad=comp++;
    trec.onLoad=comp++;
    tfield.onLoad=comp++;
    tconvent.onLoad=comp++;
    tbell.onLoad=comp++;
    tcoffee.onLoad=comp++;
    document.body.style.cursor='wait';
    
    if (comp==9) {
    AcImg.style.display='block';
    tload.style.display='none';
    document.body.style.cursor='auto';
    }
    
    
    
    
    AcImg.src="images/expansion/expansion.jpg"
    AcImg.style.cursor="crosshair";
    Imgmap.style.display="block";
    Imgmap.style.height='552px';
    TextBox.style.display='block';
    TextBox.innerHTML='<div><h3>Expansion Project</h3></div><p>Use your mouse to explore the map above.</p>';
    
  } else {
     dark.style.display='none';
     Imgmap.style.display='none';
     LoadImg.style.display='none';
     TextBox.style.display='none';
     document.body.style.overflow='scroll';
  }
}


function writeInfo(area) {
	if (navigator.appName=="Netscape") { //need bottom code to work in Firefox ?? don't now about opra
	AcImg=document.getElementById("AcImg");
	CoffeeImg=document.getElementById("CoffeeImg");
	ConventImg=document.getElementById("ConventImg");
	FieldImg=document.getElementById("FieldImg");
	GradImg=document.getElementById("GradImg");
	NewmanImg=document.getElementById("NewmanImg");
	RecImg=document.getElementById("RecImg");
	StudentImg=document.getElementById("StudentImg");
	CloseImg=document.getElementById("CloseImg");
	BellImg=document.getElementById("BellImg");}
	textBox=document.getElementById("textbox");
	if (area == "") {
		AcImg.style.display='block';
		CoffeeImg.style.display='none';
		CloseImg.style.display='none';
		BellImg.style.display='none';
		NewmanImg.style.display='none';
		RecImg.style.display='none';
		ConventImg.style.display='none';
		FieldImg.style.display='none';
		StudentImg.style.display='none';
		GradImg.style.display='none';
		
		AcImg.style.cursor="crosshair";
		textBox.innerHTML="<div><h3>Expansion Project</h3></div><p>Use your mouse to explore the map above.</p>";}
	if (area == "gradhouse"){
		AcImg.style.display="none";
		GradImg.style.display="block";
		textBox.innerHTML="<div><h3>Graduate Student / Family Housing</h3></div><p><b>Graduate Student</b> / <b>Family Housing</b> will be made available through apartments on the south side of the plot.  Built as townhouses, they will provide additional revenue for the Newman Center and housing for nontraditional students or students with families.</p>";
	}
	if (area == "field"){
		AcImg.style.display="none";
		FieldImg.style.display="block";
		textBox.innerHTML="<div><h3>The Field</h3></div><p>The center of the campus will remain open, creating a <b>Quad</b> for concerts, games, sports and miscellaneous good times.  A <b>pond</b> will be installed for drainage but will also serve to beautify the area.</p>";
	}
	if (area == "convent"){
		AcImg.style.display="none";
		ConventImg.style.display="block";
		textBox.innerHTML="<div><h3>The Convent</h3></div><p>The <b>Convent</b> will house a group of women religious who will serve the students of the St. Francis Newman Center through ministry and administrative work, while being a visible Catholic presence on campus. We are currently in communication with a young, habit-wearing community about their possible future at the Newman Center and convent.</p>";
	}
	if (area == "coffee"){
		AcImg.style.display="none";
		CoffeeImg.style.display="block";
		textBox.innerHTML="<div><h3>The Coffee Shop</h3></div><p>The <b>Coffee Shop</b> will provide a much needed commercial venture on the north side of campus. More importantly however, it will serve as an evangelization tool in and of itself, attracting a variety of students from the nearby apartments, classrooms and dorm, some who may not otherwise set foot on the Newman Center's Catholic campus.</p>";
	}
	if (area == "belltower"){
		AcImg.style.display="none";
		BellImg.style.display="block";
		textBox.innerHTML="<div><h3>The Bell Tower</h3></div><p>The Newman Center sits on one of the busiest streets on campus, yet it is not distinctly Catholic. The addition of the <b>Bell Tower</b> in the front lawn will serve as a dignified announcement to all of campus that they have reached the Catholic Student Center at WIU.</p>";
	}
	if (area == "rec"){
		AcImg.style.display="none";
		RecImg.style.display="block";
		textBox.innerHTML="<div><h3>The Rectory</h3></div><p>The <b>Rectory</b> will be built to house the Newman Center's chaplains, along with being open for any priests serving in the rural, western counties of the Diocese of Peoria.</p>";
	}
	if (area == "student"){
		AcImg.style.display="none";
		StudentImg.style.display="block";
		textBox.innerHTML = "<div><h3>Student Residence Housing</h3></div><p>There will be a total of six <b>Student Residences</b>, three for men and three for women, and they will be coupled together by a shared outside patio.  Each residence will hold seven people with three suites on the second floor and a handicap accessible room on the ground level. The ground floor will also include a full kitchen, living room, study rooms and an extra bath. These residences will provide a family-like environment where grace may build on nature, so that as our students grow in their friendships with one another they may also experience God's love for them. Here will be a place of security and accountability, so our Catholic students can excel in academics and grace.</p>";
	}
	if (area == "newman"){
		AcImg.style.display="none";
		NewmanImg.style.display="block";
		textBox.innerHTML = "<div><h3>The Newman Center</h3></div><p>The <b>Newman Center</b> itself will undergo a facelift as its entryway is expanded. This addition will serve several purposes: create more elegance in the simple architecture of the existing building, make the Newman Center more appealing and inviting to new students, and expand the gathering area for students to socialize before and after Mass, thus creating a quiet area near the Chapel door.</p>";
	}
	
	if (area == "close"){
		AcImg.style.display="none";
		CloseImg.style.display="block";
		CloseImg.style.cursor="pointer";
	}


}

 function timeline(key) {
 	document.body.style.overflow='hidden';
 	var timeLine = document.getElementById('timeLine');
 	var darkSide = document.getElementById('darklayer');
 	var Body = document.body;
 	if (!timeLine){ 
 	var the_body = document.getElementsByTagName("body")[0];
 	//size:
 	if(document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
        var pageWidth = document.body.scrollWidth+'px';
        var pageHeight = document.body.scrollHeight+'px';
    } else if( document.body.offsetWidth ) {
      var pageWidth = document.body.offsetWidth+'px';
      var pageHeight = document.body.offsetHeight+'px';
    } else {
       var pageWidth='100%';
       var pageHeight='100%';
    }   
 	
 	var timediv = document.createElement('div');
 		timediv.style.opacity='0.7';
 		timediv.style.position='absolute';
        timediv.style.top='0px';                           
        timediv.style.left='0px';                       
   		timediv.style.MozOpacity='0.7';
   		timediv.style.filter='alpha(opacity=70)';
   		timediv.style.backgroundColor="#000000";
   		timediv.style.width=pageWidth;
   		timediv.style.height=pageHeight;
 		timediv.style.overflow='hidden';                   // Try to avoid making scroll bars            
        timediv.style.display='block';
        timediv.id='darklayer';
 	
 	
    var ttime = document.createElement('div');           // white div layer
        ttime.style.position='absolute';
        ttime.style.top='10%';                           // In the top
        ttime.style.left='10%';
        ttime.style.width="75%";
        ttime.style.height="500px";
        ttime.style.backgroundColor="white";
        ttime.style.overflow='hidden';                   // Try to avoid making scroll bars            
        ttime.style.display='block';
        ttime.id='timeLine';
        ttime.innerHTML="<div style=\"text-align:right\"><img src=\"images/expansion/close.jpg\" usemap=\"#close_button\" id=\"closeimg\" name=\"closeimg\"/><map name=\"close_button\"><area shape=\"circle\" coords=\"104,20,12\" href=\"#\" onmouseover=\"Javascript:closeme=document.getElementById('closeimg');closeme.src='images/expansion/close_on.jpg'\" onmouseout=\"Javascript:closeme=document.getElementById('closeimg');closeme.src='images/expansion/close.jpg'\" onclick=\"timeline(false)\"></map></div><div style=\"text-align:center; margin-top:-3em;\"><h3>Expansion Project Timeline</h3><img src=\"images/expansion/expansion_house.jpg\" alt=\"expansion_house\"/></div><div style=\"margin: 0 0.5em 0 0.5em\"><p><b>Phase I: </b>We are currently in Phase I of the expansion project. This consists of doing feasibility studies and assessing the needs of the students and staff.</p><p><b>Phase II: </b>Fundraising. Once plans have been finalized, a capital campaign will begin to raise the funds needed to build.</p><p><b>Phase III: </b>Construction. The exciting part begins when the construction crews arrive and make our dreams and plans a reality.</p></div>";
        the_body.appendChild(timediv);
        the_body.appendChild(ttime);}
     if (key==true){
     timeLine.style.display='block'; darkSide.style.display='block'; timeLine.innerHTML="<div style=\"text-align:right\"><img src=\"images/expansion/close.jpg\" usemap=\"#close_button\" id=\"closeimg\" name=\"closeimg\"/><map name=\"close_button\"><area shape=\"circle\" coords=\"104,20,12\" href=\"#\" onmouseover=\"Javascript:closeme=document.getElementById('closeimg');closeme.src='images/expansion/close_on.jpg'\" onmouseout=\"Javascript:closeme=document.getElementById('closeimg');closeme.src='images/expansion/close.jpg'\" onclick=\"timeline(false)\"></map></div><div style=\"text-align:center; margin-top:-3em;\"><h3>Expansion Project Timeline</h3><img src=\"images/expansion/expansion_house.jpg\" alt=\"expansion_house\"/></div><div style=\"margin: 0 0.5em 0 0.5em\"><p><b>Phase I: </b>We are currently in Phase I of the expansion project. This consists of doing feasibility studies and assessing the needs of the students and staff.</p><p><b>Phase II: </b>Fundraising. Once plans have been finalized, a capital campaign will begin to raise the funds needed to build.</p><p><b>Phase III: </b>Construction. The exciting part begins when the construction crews arrive and make our dreams and plans a reality.</p></div>";
     }
     if (key==false) {timeLine.style.display='none'; darkSide.style.display='none'; document.body.style.overflow='scroll'; timeLine.innerHTML="";}
 }
 function coSt(key) {
 	document.body.style.overflow='hidden';
 	var costvar = document.getElementById('costvar');
 	var darkSideA = document.getElementById('darklayerA');
 	var Body = document.body;
 	if (!costvar){ 
 	var the_body = document.getElementsByTagName("body")[0];
 	//size:
 	if(document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
        var pageWidth = document.body.scrollWidth+'px';
        var pageHeight = document.body.scrollHeight+'px';
    } else if( document.body.offsetWidth ) {
      var pageWidth = document.body.offsetWidth+'px';
      var pageHeight = document.body.offsetHeight+'px';
    } else {
       var pageWidth='100%';
       var pageHeight='100%';
    }   
 	
 	var costdiv = document.createElement('div');
 		costdiv.style.opacity='0.7';
 		costdiv.style.position='absolute';
        costdiv.style.top='0px';                           
        costdiv.style.left='0px';                       
   		costdiv.style.MozOpacity='0.7';
   		costdiv.style.filter='alpha(opacity=70)';
   		costdiv.style.backgroundColor="#000000";
   		costdiv.style.width=pageWidth;
   		costdiv.style.height=pageHeight;
 		costdiv.style.overflow='hidden';                   // Try to avoid making scroll bars            
        costdiv.style.display='block';
        costdiv.id='darklayerA';
 	
 	
    var tcost = document.createElement('div');           // white div layer
        tcost.style.position='absolute';
        tcost.style.top='10%';                           // In the top
        tcost.style.left='10%';
        tcost.style.width="75%";
        tcost.style.height="500px";
        tcost.style.backgroundColor="white";
        tcost.style.overflow='hidden';                   // Try to avoid making scroll bars            
        tcost.style.display='block';   
        tcost.id='costvar';
        tcost.innerHTML="<div style=\"text-align:right\"><img src=\"images/expansion/close.jpg\" usemap=\"#close_button\" id=\"closeimgA\" name=\"closeimgA\"/><map name=\"close_button\"><area shape=\"circle\" coords=\"104,20,12\" href=\"#\" onmouseover=\"Javascript:closemeA=document.getElementById('closeimgA');closemeA.src='images/expansion/close_on.jpg'\" onmouseout=\"Javascript:closemeA=document.getElementById('closeimgA');closemeA.src='images/expansion/close.jpg'\" onclick=\"coSt(false)\"></map></div><div style=\"text-align:center; margin-top:-3em;\"><h3>Expansion Project Costs</h3><img src=\"images/expansion/expansion_house2.jpg\" alt=\"expansion_house\"/></div><div style=\"margin: 0 0.5em 0 0.5em\"><p><b>Student Residence:</b>  $405,000 per house ($2.43 million for all 6 houses)<br/><b>Convent:</b> $900,000<br/><b>Rectory:</b> $520,000<br/><b>Coffee Shop:</b> $180,000<br/><b>Newman Center Expansion:</b> $45,000<br/><b>Bell Tower:</b> $80,000<br/><b>Graduate Student / Family Housing:</b> $1.6 million</p><p><b>*Additional Costs:</b> parking lots, sidewalks, landscaping, fences, terraces: $590,000 Fees for attorney & engineers, municipal fees: $80,000</p></div>";
		the_body.appendChild(costdiv);
        the_body.appendChild(tcost);}
     if (key==true){
     costvar.style.display='block'; darkSideA.style.display='block'; costvar.innerHTML="<div style=\"text-align:right\"><img src=\"images/expansion/close.jpg\" usemap=\"#close_button\" id=\"closeimgA\" name=\"closeimgA\"/><map name=\"close_button\"><area shape=\"circle\" coords=\"104,20,12\" href=\"#\" onmouseover=\"Javascript:closemeA=document.getElementById('closeimgA');closemeA.src='images/expansion/close_on.jpg'\" onmouseout=\"Javascript:closemeA=document.getElementById('closeimgA');closemeA.src='images/expansion/close.jpg'\" onclick=\"coSt(false)\"></map></div><div style=\"text-align:center; margin-top:-3em;\"><h3>Expansion Project Costs</h3><img src=\"images/expansion/expansion_house2.jpg\" alt=\"expansion_house\"/></div><div style=\"margin: 0 0.5em 0 0.5em\"><p><b>Student Residence:</b>  $405,000 per house ($2.43 million for all 6 houses)<br/><b>Convent:</b> $900,000<br/><b>Rectory:</b> $520,000<br/><b>Coffee Shop:</b> $180,000<br/><b>Newman Center Expansion:</b> $45,000<br/><b>Bell Tower:</b> $80,000<br/><b>Graduate Student / Family Housing:</b> $1.6 million</p><p><b>*Additional Costs:</b> parking lots, sidewalks, landscaping, fences, terraces: $590,000 Fees for attorney & engineers, municipal fees: $80,000</p></div>";}
     if (key==false) {costvar.style.display='none'; darkSideA.style.display='none'; document.body.style.overflow='scroll';
     costvar.innerHTML="";}
 }

