/*
*  This script is used to replace 'www.tchain.com' with 'www.dizziness-and-balance.com' and vice versa.
*  The other parts of the url, like the directory/file path, remain the same
*  This script may not give the desired results, unless run from the web server.
*
*  Add this tag <script src="directory_path/changeurl.js"></script> wherever you want the statement to be printed
*  Written by Namit Saxena (namit_saxena@hotmail.com)
* 4/12/03 TCH modified to ignore "otoneurology" == stringArray[3]
*/
function print()
{
	var url = document.URL;			//get the url in the address bar

	url1="www.dizziness-and-balance.com";	//store the 2 urls in variables
	url2="www.tchain.com";			//for convenience


	if(url.indexOf("http") == -1 )	//check if the URL contains 'http'. URL must contain 2 initail '//'
	{
		//The url doesn't contain 'http'(unlikely event)- print some general message and return.
		document.write("<A HREF='http://www.dizziness-and-balance.com'>www.dizziness-and-balance.com</A> contains all the updated pages");
		return;
	}

	//Split the URL using '/' as delimiter
	var separator = '/';				//Use this character as separator
	var stringArray = url.split(separator);		//put all the different parts in an array

	//The 3 parts of the URL used in this script
	var preurl  = "";	//contains the initial part of the url, ie http or https
	var mainurl = "";	//contains the main url ie www.dizziness-and-balance.com or www.tchain.com
	var posturl = "";	//contains the directory path of the url

	for (var i=0; i < stringArray.length; i++)	//add all the split substrings into one of the 3 parts (show above)
	{
		if(i < 2 ) 		//store in preurl, all the information found before the main url
			preurl += stringArray[i];

		if(i == 2)		//store the main url for further analysis
			mainurl = stringArray[i];
		if(i == 3)		//should check to see if is otoneurology
			;
		if(i > 3)		//store in string posturl all the subdirectory information
			posturl += "/" + stringArray[i];
	}

	//Replace the mainurl with that of the other website and construct a new url. Also print the relevant statement.
	var newurl;
	if(mainurl == "www.tchain.com")
	{
		newurl = preurl + "//" + url1 + posturl;	
		document.write("This page is no longer being updated.")
		document.write(" Click <A HREF='" + newurl + "'>HERE</A> to go to the more recent version");
	}
}

print();	//Call the above function to print