//   java.js
// controls images swapping, tests browser version and controls
// the scrolling statusbar message.
// It's referanced from every page except the php page and thankyou pages.
//
// Designed by Freetimers.net

LastModDate = new Date(document.lastModified);
LastModString = LastModDate.toGMTString().substring(0,16);
browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);
bVer = navigator.appVersion.substring(0,4);
type = navigator.userAgent.substring(25,34);

if ((browserName == "Netscape" && browserVer >= "3")||(browserName == "Microsoft Internet Explorer" && browserVer >= "4"))
{
	version = "OK";
}
else
{
	version = "OLD";
}

if (version == "OK")
{
	button1on = new Image(158,18);
	button1on.src = "./images/homepageon.gif";
	button2on = new Image(158,18);
	button2on.src = "./images/rangeon.gif";
	button3on = new Image(158,18);
	button3on.src = "./images/ballerinaon.gif";
	button4on = new Image(158,18);
	button4on.src = "./images/velvetson.gif";
	button5on = new Image(158,18);
	button5on.src = "./images/operaon.gif";
	button6on = new Image(158,18);
	button6on.src = "./images/coatson.gif";
	button7on = new Image(158,18);
	button7on.src = "./images/orderon.gif";
	button8on = new Image(158,18);
	button8on.src = "./images/contacton.gif";
	button9on = new Image(158,18);
	button9on.src = "./images/submit2on.gif";

	button1off = new Image(158,18);
	button1off.src = "./images/homepage.gif";
	button2off = new Image(158,18);
	button2off.src = "./images/range.gif";
	button3off = new Image(158,18);
	button3off.src = "./images/ballerina.gif";
	button4off = new Image(158,18);
	button4off.src = "./images/velvets.gif";
	button5off = new Image(158,18);
	button5off.src = "./images/opera.gif";
	button6off = new Image(158,18);
	button6off.src = "./images/coats.gif";
	button7off = new Image(158,18);
	button7off.src = "./images/order.gif";
	button8off = new Image(158,18);
	button8off.src = "./images/contact.gif";
	button9off = new Image(158,18);
	button9off.src = "./images/submit2.gif";
}

var rate = 50;
var delay = 4000;
var timerID = null;
var messagerRunning = false;
var currentMessage = 0;
var offset = 0;

var ar = new Array();

	ar[0] = "Welcome to Sunday Best..."
	ar[1] = " "

if (version == "OLD")
{
	ar[2] = "You should update..."
	ar[3] = "...to a newer browser you know!!"
}
else
{
	ar[2] = " "
	ar[3] = " "
	ar[4] = " "
	ar[5] = " "
}

function haltMessager()
{
	if (messagerRunning)
		clearTimeout(timerID)

	messagerRunning = false;
}

function runMessager()
{
	var text = ar[currentMessage]

	if (offset < text.length)
	{
		if (text.charAt(offset) == " ")	offset++;
		var partialMessage = text.substring(0, offset + 1);
		window.status = partialMessage;
		offset++;
		timerID = setTimeout("runMessager()", rate);
		messagerRunning = true;
	}
	else
	{
		offset = 0;
		currentMessage++;
		if (currentMessage == ar.length) currentMessage = 0;
		timerID = setTimeout("runMessager()", delay);
		messagerRunning = true;
	}
}

function startBanner()
{
	haltMessager();
	runMessager();
}

function img_act(imgName)
{
	if (version == "OK")
	{
		imgOn = eval(imgName + "on.src");
		document [imgName].src = imgOn;
	}
}

function img_inact(imgName)
{
	if (version == "OK")
	{
		imgOff = eval(imgName + "off.src");
		document [imgName].src = imgOff;
	}
}

function stripNonNumbers(InString)
{
	OutString="";
	for (Count=0;Count<InString.length;Count++)
	{
		TempChar=InString.substring (Count,Count+1);
		Strip=false;
 		CharString="0123456789";
		for (Countx=0;Countx<CharString.length;Countx++)
		{
			StripThis=CharString.substring (Countx,Countx+1)
			if (TempChar==StripThis)
			{
				Strip=true;
				break;
			}
		}
		if (Strip)
		OutString=OutString+TempChar;
	}
	return (OutString);
}