//This script scans the page for a specific item of text and replaces it.  In case it doesn't 
//work on all browsers, it also calls for any visits to forgotpassword.asp to redirect.

var newText = 'https://www.spokaneschools.org/account'; 
var oldText = 'forgottenpassword.asp';

//Do not change from here down.
var cPath = location.href;
//alert(cPath);

if (cPath.indexOf('login.asp') > 0) {
	//alert(cPath.indexOf('login.asp'));
	var runOnce = 0;
	
	// following code attempts to execute the change as soon as the DOM is ready (as opposed to window.load)
	if (document.addEventListener){  
		// For Firefox
		document.addEventListener("DOMContentLoaded", function(){changeText(newText, oldText);}, false);  
	}
	else if (document.all && !window.opera){  
		// For IE.  IE doesn not have a DOM load indicator, so write to the dom and then check for success
		document.write('<script type="text/javascript" id="domIsReady" defer="defer" src="javascript:void(0)"><\/script>');
		var domReadytag=document.getElementById("domIsReady");
		domReadytag.onreadystatechange=function(){
			if (this.readyState=="complete"){
				  changeText(newText, oldText);
			}
		}
	}
	
	window.onLoad = function(){ //for anything missed above
		window.setTimeout("if (!runOnce){changeText(newText,oldText);", 50);	
	}
}

function changeText(newT, oldT){
	node = document.getElementsByTagName("body")[0];
	var bodyContent = node.innerHTML;
	document.getElementsByTagName("body")[0].innerHTML = bodyContent.replace(oldT, newT);
	runOnce = 1;
	//alert("ran once");
}

if (cPath.indexOf('forgottenpassword.asp') > 0) {
	window.location = 'https://www.spokaneschools.org/account';
}
