// DOE SCRIPTS
// Use this area to add scripts for the DOE site



// SET WINDOW NAME
function setWindowName(strName) {  // Sets current browser window name
	if (isString(strName)) {
  	window.name=strName;
	}
}

// GET WINDOW NAME
function getWindowName() {  // Gets current browser window name
 	return window.name;
}


// SET SECTION
// Sets site section variable(s) for site title/path link(s)
function setSection(section, subSection, sub2Section, sub3Section) {  // Set Section function (Home, Services, Information)
 // Determine & Set Section
	if (isString(section)) {
		section = section.toLowerCase();
		if (section.indexOf("service") != -1)
  		section = serviceSection;
 	else if (section.indexOf("info") != -1)
  		section = infoSection;
 	else
  		section = homeSection;
	}
	else {
		section = homeSection;
	}
 // Set Global Section
	siteSection = section;
 // Determine & Set SubSection
	var subSectionPage = false;
 if (isString(subSection)) {
  var subSectionIndex;
  var subSectionLinks;
  subSection = subSection.toLowerCase();
  subSection = subSection.replace("doe ", "");
  subSection = subSection.replace("de ", "");
  subSection = subSection.replace("'", "&#8217;");
  subSection = subSection.replace("&", "&amp;");
  subSection = trim(subSection);
  if (section == homeSection)
    subSectionLinks = homeLinks;
  else if (section == serviceSection)
    subSectionLinks = serviceLinks;
  else  // if (section == infoSection)
    subSectionLinks = infoLinks;
 	for (var index = 0; index < subSectionLinks.length && !subSectionPage; index++) {
   	if (subSectionLinks[index].toLowerCase().indexOf(subSection) != -1) {
     	subSectionPage = true;
     	subSectionIndex = index;
   	}
 	}
 }
 // Set Global SubSection
 if (subSectionPage && !ns4)
   siteSubSection = subSectionIndex;
 else
   siteSubSection = null;
 // Determine & Set SubSubSection (Sub2Section)
	var sub2SectionPage = false;
 if (isString(sub2Section) && subSectionPage) {
   sub2SectionPage = true;
   // Process SubSubSection (Sub2Section)
   sub2Section = setSubSection(sub2Section);
 }
 // Determine & Set SubSubSubSection (Sub3Section)
	var sub3SectionPage = false;
 if (isString(sub3Section) && sub2SectionPage) {
  	sub3SectionPage = true;
   // Process SubSubSubSection (Sub3Section)
   sub3Section = setSubSection(sub3Section);
   if (sub3Section.substring(0, sub3Section.indexOf(",")) != sub2Section.substring(0, sub2Section.indexOf(","))) {
     var sub2HREF, sub3HREF;
     sub2HREF = sub2Section.substring(sub2Section.indexOf(",")+1, sub2Section.length);
     sub3HREF = sub3Section.substring(sub3Section.indexOf(",")+1, sub3Section.length);
     if (sub2HREF == "index.html") {
       if (sub3HREF == "../../" || sub3HREF == "http://www.doe.k12.de.us/") {
         sub2HREF = "../" + sub3HREF;
         sub2Section = sub2Section.replace("index.html", sub2HREF);
       }
       else if (sub3HREF == "index.html") {
         sub2HREF = "." + sub3HREF;
         sub2Section = sub2Section.replace("index.html", sub2HREF);
       }
     }
     if (sub3HREF == sub2HREF)
       sub3SectionPage = false;
   }
   else {
     sub3SectionPage = false;
   }
 }
 // Set Global SubSubSection (Sub2Section)
 if (sub2SectionPage && !ns4)
 		siteSub2Section = sub2Section;
 else
   siteSub2Section = null;
 // Set Global SubSubSubSection (Sub3Section)
 if (sub3SectionPage && !ns4)
 		siteSub3Section = sub3Section;
 else
   siteSub3Section = null;
}
// SET SUBSECTION
// Sets site subsection variable(s) for site title/path link(s)
function setSubSection(subSection) {  // Set SubSection function (SubSection 2 & 3)
	var httpRef = window.location.protocol + "//" + window.location.hostname;
 var pageFile;
 var hrefKey;
 var subSectionLink;
 var subSectionHREF;
 if (subSection.indexOf(",") != -1) {
   subSectionLink = subSection.substring(0, subSection.indexOf(","));
   subSectionHREF = subSection.substring(subSection.indexOf(",")+1, subSection.length);
   subSectionLink = trim(subSectionLink);
   subSectionHREF = trim(subSectionHREF);
 }
	else {
   subSectionLink = trim(subSection);
   subSectionHREF = "index.html";
 }
 if (subSectionHREF.charAt(0) == "_") {
   hrefKey = subSectionHREF.toLowerCase().substring(1, subSectionHREF.length);
   if (hrefKey == "self") {
     pageFile = window.location.pathname;
     pageFile = pageFile.substring(pageFile.lastIndexOf("http://www.doe.k12.de.us/")+1, pageFile.length);
     if (pageFile.indexOf(".") != -1)
       subSectionHREF = pageFile;
     else
     		subSectionHREF = "index.html";
   }
   else if (hrefKey == "grandparent") {
     subSectionHREF = "http://www.doe.k12.de.us/";
   }
   else if (hrefKey == "parent") {
     subSectionHREF = "http://www.doe.k12.de.us/";
   }
   else if (hrefKey == "default") {
     subSectionHREF = "index.html";
   }
 }
 if (subSectionLink.toLowerCase().indexOf("doe ") != -1)
   subSectionLink = subSectionLink.substring(0, subSectionLink.toLowerCase().indexOf("doe ")) + subSectionLink.substring(subSectionLink.toLowerCase().indexOf("doe ")+4, subSectionLink.length);
 else if (subSectionLink.toLowerCase().indexOf("de ") != -1)
   subSectionLink = subSectionLink.substring(0, subSectionLink.toLowerCase().indexOf("de ")) + subSectionLink.substring(subSectionLink.toLowerCase().indexOf("de ")+3, subSectionLink.length);
 subSectionLink = subSectionLink.replace("'", "&#8217;");
 subSectionLink = subSectionLink.replace("&", "&amp;");
 subSectionLink = toProperCase(subSectionLink);
 subSectionHREF = removeSp(subSectionHREF);
 subSectionHREF = subSectionHREF.toLowerCase();
 subSectionHREF = subSectionHREF.replace(httpRef, "");
 subSection = subSectionLink + "," + subSectionHREF;
 return subSection;
}

// WRITE SECTION LINK
// Writes site section variable(s) for site title/path link{s}
function writeSectionLink(section, subSection, sub2Section, sub3Section, charDiv, fullPath) {  // Write Section Link function (Home, Services, Information)
 var path;
 var preTitle = "DOE ";
 var sectionDiv = "&nbsp;";
 if (!isBoolean(fullPath))
   fullPath = true;
 if (isString(charDiv))
  trim(charDiv);
 else
  charDiv = "&gt;";
 sectionDiv += '<span class="path-pointer">' + charDiv + '</span> ';
 // Write Section
	if (section == serviceSection || section == infoSection) {
	  document.write(sectionDiv);
	  document.write('<a href="/' + section.toLowerCase() + '/" title="' + preTitle + section + '" onmouseover="return chgStatus(this.title);">');
	  document.write(section + '</a>');
	}
 // Write SubSection
 var subSectionIndex = subSection;
 if (isNumber(subSectionIndex)) {
   var subSectionLinks;
   var subSectionHREFs;
  	if (section == homeSection) {
    	subSectionLinks = homeLinks;
     subSectionHREFs = homeHREFs;
     if (subSectionIndex < 1 || subSectionIndex == subSectionLinks.length-1)
       preTitle += "- ";
   }
  	else if (section == serviceSection) {
    	subSectionLinks = serviceLinks;
     subSectionHREFs = serviceHREFs;
     preTitle += "Services ";
     // if (subSectionIndex < subSectionLinks.length-1)
     //   preTitle += "for ";
   }
  	else {  // if (section == infoSection)
    	subSectionLinks = infoLinks;
     subSectionHREFs = infoHREFs;
     preTitle = "DE ";
   }
	  document.write(sectionDiv);
	  document.write('<a href="' + subSectionHREFs[subSectionIndex] + '" title="' + preTitle + subSectionLinks[subSectionIndex].replace("&#8217;", "'") + '" onmouseover="return chgStatus(this.title);">');
	  document.write(subSectionLinks[subSectionIndex] + '</a>');
   path = subSectionLinks[subSectionIndex].replace("&#8217;", "'");
 }
 if (fullPath && isString(path)) {
	  // Write SubSubSection (Sub2Section)
   if (isString(sub2Section)) {
     path = preTitle + path;
     // Process SubSubSection (Sub2Section)
     writeSubSectionLink(sub2Section, path, sectionDiv);
   }
   // Write SubSubSubSection (Sub3Section)
   if (isString(sub3Section)) {
     path += ": " + sub2Section.substring(0, sub2Section.indexOf(",")).replace("&#8217;", "'");
     // Process SubSubSubSection (Sub3Section)
     writeSubSectionLink(sub3Section, path, sectionDiv);
   }
 }
}
// WRITE SUBSECTION LINK
// Writes site subsection variable(s) for site title/path link{s}
function writeSubSectionLink(subSection, preTitle, sectionDiv) {  // Write SubSection Link function (SubSection 2 & 3)
 var subSectionLink;
 var subSectionHREF;
 subSectionLink = subSection.substring(0, subSection.indexOf(","));
 subSectionHREF = subSection.substring(subSection.indexOf(",")+1, subSection.length);
 preTitle += " >> ";
	document.write(sectionDiv);
	document.write('<a href="' + subSectionHREF + '" title="' + subSectionLink.replace("&#8217;", "'") + '" onmouseover="return chgStatus(\'' + preTitle + subSectionLink.replace("&#8217;", "'") + '\', \'\');">');
	document.write(subSectionLink + '</a>');
}


// SETUP PAGE
// Sets page elements during the loading of the page body
function setupPage() {
 	// Sets DE Seasonal image, ALT text & link HREF
	if (document.images["imgSeasonal"]) {
		// document.images["imgSeasonal"].src="/ddoe/include/private/images/photos/seasonal_"+season.toLowerCase()+".jpg";
		document.images["imgSeasonal"].alt="Delaware in the "+season;
		document.links[1].href="/de/photos/"+season.toLowerCase();
	}
	// Display current Section menu links in navigation bar
	// displayNavLinks(siteSection);
 	// Highlight current SubSection in navigation bar
 	highlightSection(siteSubSection);
 	// Sets Quick Links menu to first option
	if (document.all("navQuickLinks") && document.forms["formSelectMenu"]) {
  	document.all("navQuickLinks").style.visibility="visible";
		document.forms["formSelectMenu"].selectMenu[0].selected=true;
	}
}
// DISPLAY NAVIGATION LINKS
// Displays current Section menu links in navigation bar
/*
function displayNavLinks(section) {
 var menu = "links";
 if (window.displayNav) {
   displayNav = displayNav.toLowerCase();
  	if (displayNav == "all")
   	section = displayNav;
  	else if (displayNav == homeSection.toLowerCase() || displayNav == serviceSection.toLowerCase() || displayNav == infoSection.toLowerCase())
   	section = toProperCase(displayNav);
 }
 if (section.toLowerCase() != "all") {
 		var menuElement = menu + section;
 		document.all(menuElement).style.display="block";
 }
 else {
 		document.all(menu+homeSection).style.display="block";
 		document.all(menu+serviceSection).style.display="block";
 		document.all(menu+infoSection).style.display="block";
 }
}
*/
// HIGHLIGHT SECTION
// Highlights current SubSection in navigation bar
function highlightSection(subSectionIndex) {
 if (isNumber(subSectionIndex)) {
   var navSectionIndex = 15;  // 1st navigation bar index
   var section = siteSection;
   var sub2Section = siteSub2Section;
   var sub3Section = siteSub3Section;
   if (isString(sub2Section))
     navSectionIndex += 1;
   if (isString(sub3Section))
     navSectionIndex += 1;
   if (section == homeSection) {
     var lastHomeLinkIndex = homeLinks.length - 2;
     if (subSectionIndex <= lastHomeLinkIndex)
      	navSectionIndex += subSectionIndex + 1 + 2*1;
     else
      	navSectionIndex = -1;
   }
  	else if (section == serviceSection) {
    	navSectionIndex += homeLinks.length + subSectionIndex + 2 + 2*2;
   }
  	else {  // if (section == infoSection)
    	navSectionIndex += homeLinks.length + serviceLinks.length + subSectionIndex + 3 + 2*3;
   }
   if (navSectionIndex != -1) {
     document.links[navSectionIndex].style.fontWeight = 'bold';
     document.links[navSectionIndex].style.borderTop = '1px solid #cccccc';
     document.links[navSectionIndex].style.borderBottom = '1px solid #cccccc';
     document.links[navSectionIndex].style.marginTop = '1px';
     document.links[navSectionIndex].style.marginBottom = '1px';
   }
 }
}


// SET FOCUS
// Sets focus to the first element of a form
function setFocus(formName, elementIndex) {
	if (document.forms[formName]) {
		if (isPosNumber(elementIndex)) {
			parseInt(elementIndex);
			elementIndex -= 1;
		}
		else {
			elementIndex = 0;
		}
		document.forms[formName].elements[elementIndex].focus();
	}
}


// DATE
// Display Today's Full Date (Weekday, Month Date, Year)
fullDate = getCurrentDate();  // Set Full Date variable
function getCurrentDate(weekday, abbreviate) {  // Get Current Date function
  var the_date = "";
  if (!isBoolean(weekday))
    weekday = true;
  if (!isBoolean(abbreviate))
    abbreviate = false;
  if (weekday)
    the_date += getWeekdayName(todaysDate.getDay(), abbreviate) + ", ";
  the_date += getMonthName(todaysDate.getMonth(), abbreviate) + " ";
  the_date += todaysDate.getDate() + ", ";
  the_date += currentYear;
  return the_date;
}
function getWeekdayName(the_day, abbreviate) {  // Get Weekday Name function
  var weekdays = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
  the_day = weekdays[the_day];
  if (!isBoolean(abbreviate))
    abbreviate = false;
  if (abbreviate)
    the_day = the_day.substr(0,3) + ".";
  return the_day;
}
function getMonthName(the_month, abbreviate) {  // Get Month Name function
 	var the_monthNo = the_month + 1;
 	var months = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
 	the_month = months[the_month];
  if (!isBoolean(abbreviate))
    abbreviate = false;
  if (abbreviate) {
				if (the_monthNo < 5 || the_monthNo > 7) {
    		if (the_monthNo != 9)
      		the_month = the_month.substr(0,3);
		 	  else
        the_month = the_month.substr(0,4);
		 		 the_month += ".";
				}
	 }
 	return the_month;
}


// SEASON
// Determine the season of the year (Winter, Spring, Summer, Fall)
season = getSeason();  // Set Season variable
function getSeason() {  // Get Season function
  var the_month = todaysDate.getMonth()+1;
  var the_date  = todaysDate.getDate();
  var the_season = "";
  var seasonStart = 21;
  var springStart = seasonStart-1;
  var summerStart = seasonStart;
  var fallStart   = seasonStart+1;
  var winterStart = seasonStart;
  // var seasonChg = false;
  // if ((the_month % 3 == 0) && (the_date >= 21))
  //   seasonChg = true;
  if (the_month <= 3) {
    the_season = "Winter";
    if (the_month == 3 && the_date >= springStart)
      the_season = "Spring";
  }
  else if (the_month <= 6) {
    the_season = "Spring";
    if (the_month == 6 && the_date >= summerStart)
      the_season = "Summer";
  }
  else if (the_month <= 9) {
    the_season = "Summer";
    if (the_month == 9 && the_date >= fallStart)
      the_season = "Fall";
  }
  else {  // if (the_month <= 12)
    the_season = "Fall";
    if (the_month == 12 && the_date >= winterStart)
      the_season = "Winter";
  }
  return the_season;
}


// SHOW/HIDE MENU
// Displays menu of links/selectors
function showMenu(section, type) {
	var navQuickLinks = true;
	var quickLinksElement = document.all("navQuickLinks");
  // if (quickLinksElement.style.visibility != "visible") {
  //   navQuickLinks = false;
  // }
  // if (navQuickLinks) {
  		section = toProperCase(section.toLowerCase());
  		type = type.toLowerCase();
  		var menuElement = document.all("links"+section);
			if (menuElement.style.display != "block") {
 				var mainLinkElement = document.all("navMainLink"+section);
 				var menuElement_bottom = document.all("table_"+type+section);
 				menuElement = document.all(type+section);
  			if (quickLinksElement.style.display == "none" || type == "select")
      		navQuickLinks = false;
  			if (navQuickLinks || (type == "select" && section == infoSection))
      		quickLinksElement.style.visibility="hidden";
  			if (type == "select") {
      		mainLinkElement.style.textDecoration="underline";
					menuElement.style.visibility="visible";
      	}
				else {  // if (type == "links")
					menuElement.style.display="block";
      	}
      	menuElement_bottom.focus();
  			if (navQuickLinks)
      		quickLinksElement.style.visibility="visible";
			}
  // }
}
// Hides menu of links/selectors
function hideMenu(section, type) {
	var navQuickLinks = true;
	var quickLinksElement = document.all("navQuickLinks");
  // if (quickLinksElement.style.visibility != "visible") {
  //   navQuickLinks = false;
  // }
  // if (navQuickLinks) {
  		section = toProperCase(section.toLowerCase());
  		type = type.toLowerCase();
  		var menuElement = document.all("links"+section);
			if (menuElement.style.display != "block") {
 				var mainLinkElement = document.all("navMainLink"+section);
 				menuElement = document.all(type+section);
  			if (quickLinksElement.style.display == "none" || type == "select")
      		navQuickLinks = false;
  			if (navQuickLinks)
      		quickLinksElement.style.visibility="hidden";
				if (type == "select") {
					menuElement.style.visibility="hidden";
      	}
				else {  // if (type == "links")
					menuElement.style.display="none";
      	}
    		mainLinkElement.style.textDecoration="none";
  			if (navQuickLinks || (type == "select" && section == infoSection))
      		quickLinksElement.style.visibility="visible";
			}
  // }
}


// CHANGE STATUS
// Changes Status Bar text
function chgStatus(text, preText) {
 if (isString(text)) {
    var pre=">>";
    var post="";
		if (preText == null) {
			preText = true;
		}
		else if (preText == "" || preText.toLowerCase() == "n/a" || preText.toLowerCase() == "none") {
			preText = false;
		}
		else if (isString(preText)) {
   if (preText.toLowerCase() == "url" || preText.toLowerCase() == "http" || preText.toLowerCase() == "redirect") {
    pre = "GO>";
  	}
   else if (preText.toLowerCase() == "email" || preText.toLowerCase() == "e-mail") {
    pre = "Send email:";
  	}
   else if (preText.toLowerCase() == "menu" || preText.toLowerCase() == "dropdown" || preText.toLowerCase() == "drop-down") {
    pre = "<<";
  	}
   else if (preText.toLowerCase() == "top") {
    pre = "^";
  	}
   else if (preText.toLowerCase() == "button" || preText.toLowerCase() == "popup" || preText.toLowerCase() == "pop-up") {
    pre = "[";
    post = " ]";
  	}
   else {
 			pre = trim(preText);
  	}
			preText = true;
		}
		if (preText) {
			pre += " ";
			text = pre + text + post;
		}
 }
 else {
		text=defaultStatus;
 }
 window.status=text;
 return true;
}


// SWAP IMAGE
// Changes Image source reference
function swapImage(name, source) {
	if (document.images[name]) {
	  document.images[name].src=source;
	}
}


// OPEN WINDOW
// Opens window for link to destination website
function openWindow(url, name) {
 var valReturn=true;
 var target="_blank";
	if (isString(url)) {
   valReturn=false;
   if (!isString(name))
     name=target;
   window.open(url, name).focus();
	}
 return valReturn;
}


// PAGE GO/REDIRECT
// Link/Redirect to Web page (href)
function goHref(url) {  // Go to Web page
	if (!isString(url)) {
		url="http://www.doe.k12.de.us/";
	}
	window.location=url;
}
function hrefRedirect(url) {  // Redirect to Web page
	goHref(url);
}


// LINK GO
// Links to page via Select menu (form)
function goLink(url) {
 var target;
	if (isString(url)) {
   if (url.indexOf(",") != -1) {
     url=removeSp(url);
     target=url.substring(url.indexOf(",")+1,url.length);
     url=url.substring(0,url.indexOf(","));
   }
   if (target) {
     window.open(url, target).focus();
   }
   else {
     window.location=url;
   }
	}
}


// CONFIRM PAGE
// Verify that page was accessed as processing follow-up
function confirmPage(redirect) {
  query = window.location.search;
  query = query.replace("?","");
	if (!isString(redirect)) {
		redirect="index.html";
	}
	if (query != "confirm") {
 		window.location.replace(redirect);
  }
}


// GET FILE INFO
// Displays/Writes file info (file format & size)
function getFileInfo(type, size, write) {
  var fileInfo = "";
  if (!isBoolean(write)) {
    write = false;
  }
  if (isString(type)) {
    fileInfo = type + getFileSize(size, false);
    fileInfo = " " + "[" + fileInfo + "]";
  }
  if (write) {
    document.write(fileInfo);
  }
  return fileInfo;
}

// GET FILE SIZE
// Displays/Writes file size & byte designation
function getFileSize(kb, write) {
  var fileSize = "";
  var bytes = "B";
  var mb;
  if (!isBoolean(write)) {
    write = false;
  }
  if (isString(kb)) {
    if (kb.indexOf(",") > 0) {
      bytes = "M" + bytes;
      mb = kb.substring(0, kb.indexOf(","));
      kb = kb.substr(kb.indexOf(",")+1, 3);
      kb = kb.substr(0, 2) + "." + kb.substr(2, 1);
      kb = parseFloat(kb);
      kb = Math.round(kb);
      if (kb < 10 || kb == 100) {
      		if (kb == 100) {
        		mb = parseInt(mb);
        		mb = mb + 1;
        		kb = 0;
      		}
        kb = "0" + kb;
      }
      fileSize = mb + "." + kb;
    }
    else {
      bytes = "K" + bytes;
      fileSize = kb;
    }
    fileSize = " " + fileSize + bytes;
  }
  if (write) {
    document.write(fileSize);
  }
  return fileSize;
}


// VALUE SPECIFIED
// Validate passed value existence & return true/false
function valueSpecified(value) {
	var passedValue = false;
	if (value && (value != null) && (value != "")) {
    passedValue = true;
  }
	return passedValue;
}

// VALIDATE ENTRY
// Validate user entry given & return true/false
function validateEntry(entry) {
	return valueSpecified(entry);
}


// IS STRING
// Validate passed value is a string
function isString(value) {
	var strValue = false;
 if (valueSpecified(value)) {
		if (typeof value == "string") {
    	strValue = true;
  	}
 }
	return strValue;
}

// IS BOOLEAN
// Validate passed value is boolean (true/false)
function isBoolean(value) {
	 var blnValue = false;
	 if (typeof value == "boolean") {
   	blnValue = true;
	 }
	return blnValue;
}

// IS NUMBER
// Validate passed value is a number
function isNumber(value) {
	var numValue = false;
 // if (valueSpecified(value) || value == 0) {
		if (typeof value == "number") {
  	numValue = true;
  }
 // }
	return numValue;
}

// IS POSITIVE NUMBER
// Validate passed value is a positive number
function isPosNumber(value) {
	var posNumValue = false;
 if (isNumber(value)) {
		if (value > 0) {
    	posNumValue = true;
  	}
 }
	return posNumValue;
}


// TWO-DIGIT FORMAT
// Formats passed number (1-digit or 2-digit) into two digits
function twoDigitFormat(number) {
  if (isNumber(number)) {
   if (number >= 1 && number < 10) {
     number = "0" + number;
   }
  }
  return number;
}


// TRIM STRING
// Removes leading, trailing, and consecutive spaces from a string
function trim(strInput) {
   // Returns input if passed string is null
   if (!isString(strInput)) { return strInput; }
   var retValue = strInput;
   var char1;
   // Removes leading spaces from the passed string
   char1 = retValue.substring(0, 1);
   while (char1 == " ") {
      retValue = retValue.substring(1, retValue.length);
      char1 = retValue.substring(0, 1);
   }
   // Removes trailing spaces from the passed string
   char1 = retValue.substring(retValue.length-1, retValue.length);
   while (char1 == " ") {
      retValue = retValue.substring(0, retValue.length-1);
      char1 = retValue.substring(retValue.length-1, retValue.length);
   }
   // Replaces consecutive spaces in the passed string with one space
   while (retValue.indexOf("  ") != -1) {
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length);
   }
   return retValue;  // Return the trimmed string
}


// REMOVE SPACES
// Removes all spaces from a string
function removeSp(strInput) {
   // Returns input if passed string is null
	 if (!isString(strInput)) { return strInput; }
   var retValue = strInput;
   retValue = trim(retValue);
   // Replaces spaces in the passed string with no (null) space
	 while (retValue.indexOf(" ") != -1) {
     retValue = retValue.substring(0, retValue.indexOf(" ")) + retValue.substring(retValue.indexOf(" ")+1, retValue.length);
   }
   return retValue;  // Return the space-free string
}


// PROPER CASE
// Converts the first letter of words to upper case
function toProperCase(strInput){
 // Returns input if passed string is null
 if (!isString(strInput)) { return strInput; }
 var strReturnValue = "";
 var strWords;
 var ct;
 var i;
 var lowercaseWords = new Array("a","an","and","at","but","by","for","in","of","on","or","the","to","with");
 var wordMatch;
 strWords = strInput.split(" ");
 for (ct = 0; ct < strWords.length; ct++) {
	  if (strWords[ct].indexOf("http://www.doe.k12.de.us/") == -1) {
		 		wordMatch = false;
		 		for (i = 0; ct > 0 && i < lowercaseWords.length && !wordMatch; i++) {
			 	  if (strWords[ct].toLowerCase() == lowercaseWords[i])
			     	wordMatch = true;
		 		}
		 		if (wordMatch) {
		   		strReturnValue += strWords[ct].toLowerCase();
		 		}
		 		else {
      	strReturnValue += strWords[ct].substr(0,1).toUpperCase();
			 	 	strReturnValue += strWords[ct].substr(1,strWords[ct].length-1);
		 		}
   }
   else {
     strReturnValue += strWords[ct].substr(0,1).toUpperCase();
		   strReturnValue += strWords[ct].substring(1,strWords[ct].indexOf("http://www.doe.k12.de.us/")+1);
     strReturnValue += strWords[ct].substr(strWords[ct].indexOf("http://www.doe.k12.de.us/")+1,1).toUpperCase();
     strReturnValue += strWords[ct].substring(strWords[ct].indexOf("http://www.doe.k12.de.us/")+2,strWords[ct].length);
   }
   if (ct < strWords.length-1)
     strReturnValue += " ";
 }
 /*
 // Converts the first letter of words to upper case and any other letters to lower case
	var iLength = strInput.length;
	var UcaseNext = false;
	strReturnValue += strInput.charAt(0).toUpperCase();
	for(var iCounter=1; iCounter < iLength; iCounter++){
		if(UcaseNext){
			strReturnValue += strInput.charAt(iCounter).toUpperCase();
		}
		else{
			strReturnValue += strInput.charAt(iCounter).toLowerCase();
		}
		var iChar = strInput.charCodeAt(iCounter);
		if(iChar == 32 || iChar == 45 || iChar == 46 || iChar == 47 || iChar == 95){  // (" ", "-", ".", "/", "_")
			UcaseNext = true;
		}
		else{
			UcaseNext = false
		}
		// if(iChar == 67 || iChar == 99){  // ("C", "c")
		// 	if(strInput.charCodeAt(iCounter-1) == 77 || strInput.charCodeAt(iCounter-1) == 109){  // ("M", "m")
		// 		UcaseNext = true;
		// 	}
		// }
	} //End For
 */
	return strReturnValue;
} //End Function
