/*****************************************************
/	Javascript Library
/		for www.NorthWilkesboroPD.com
/
/*****************************************************/

// Global Variables 
	var home = "http://www.northwilkesboropd.com";


/*****************************************************
TRANSITION BETWEEN IMAGES */

	var preLoad = new Array();
	var currentImg = 0;
	var t;

	// Preload images
	function preloadImg() {
		for (i = 0; i < arrLength; i++) { 
			preLoad[i] = new Image();
			preLoad[i].src = imgArr[i];
		}
	}

	// Slideshow 
	function runSlideShow(filterFunction) {
		var filterable = false;

		// If Filters work 
		if ((document.images.SlideShow) && (document.images.SlideShow.style) && (document.images.SlideShow.style.filters)) {
			filterable = true;
			target = document.images.SlideShow;
		}

		if (document.getElementById("SlideShow")) {
			filterable = true;
			target = document.getElementById("SlideShow");
		}

		// Checks to make sure it's preloaded 
		if (preLoad[currentImg].complete) {
			if (filterable) {
				if (filterFunction == null) filterFunction = "blendTrans(duration=" + duration + ")"

				target.style.filter = filterFunction;

				if ((target.filters) && (target.filters[0])) {
					target.filters[0].Apply();
					target.filters[0].Play();
				}
			}

			document.images.SlideShow.src = preLoad[currentImg].src;

			currentImg = currentImg + 1;
			if (currentImg > (arrLength - 1)) currentImg = 0;

			t = setTimeout('runSlideShow()', speed);
		}
	}


/*****************************************************
SHOW ARROW IN NAVIGATION */

	function showArrow(loc, flip) {
		if (flip == "on") {
			var arrowPath = home + "/images/arrow.gif";
			var font_color = "#FF5F11";
		}

		if (flip == "off") {
			var arrowPath = home + "/images/spacer.gif";
			var font_color = "#000080";
		}

		if (document.getElementById) {
			document.getElementById(loc + "_arrow").innerHTML = "<img src=" + arrowPath + " width=30 height=10 border=0>";
			document.getElementById(loc + "_text").style.color = font_color;
		}

		else if (document.all) {
			document.all[loc + "_arrow"].innerHTML = "<img src=" + arrowPath + " width=30 height=10 border=0>";
			document.all[loc + "_text"].style.color = font_color;
		}

		else if (document.layers) { 
			document.layers[loc + "_arrow"].document.write("<img src=" + arrowPath + " width=30 height=10 border=0>");
			document.layers[loc + "_arrow"].document.close();
		}
	}


/*****************************************************
FLIP FROM IMAGE TO TEXT IN INPUT FIELD */
	function setInputBackground(whichInput, bgImgName) {
		if ((bgImgName) && (document.login.elements[whichInput].value == ""))
			document.login.elements[whichInput].style.backgroundImage= "url(" + home + "/images/" + bgImgName + ".gif)";

		else
			document.login.elements[whichInput].style.backgroundImage="none";
	}

