//navController Class
function navController () {
	//Make the navigation images available to the class for src altering
	this.navImgs = document.getElementById('Navigation').getElementsByTagName('Img')
	//preload all the On state images into the browsers cache
	this.initiate()
	//Assign navigation image mouse events
	
}
	//navController Methods
	//Preload all the On state navigation images
	//Set all the images to the off state by default
	//Set the current pages link to the On state and do not provide it mouse events
	navController.prototype.initiate = function () {
		for(var i in this.navImgs) {
			if (this.navImgs[i].src != undefined) {		
				var ObjArr = this.isolateSrc(this.navImgs[i].src)
				switch (ObjArr[1]) {
					case 'On': var newStatus = 'Off'; break;
					case 'Off': var newStatus = 'On'; break;
				}
				//Preload the On state images
				var tmpImg = new Image()
					tmpImg.setAttribute('src', 'Media/Layout/' + ObjArr[0] + '_' + newStatus + '.jpg')
				
				//clear any current on states for this image
				this.navImgs[i].setAttribute('src', 'Media/Layout/' + ObjArr[0] + '_Off.jpg')
				
				//Set the current page's name / nav link to the on position
				this.currentPage = window.location.href.split('/')
				this.currentPage = this.currentPage[this.currentPage.length - 1]
				this.currentPage = this.currentPage.split('.')
				this.currentPage = this.currentPage[0]
				if (ObjArr[0] == this.currentPage || (ObjArr[0] == 'index' && this.currentPage == '')) {
					this.navImgs[i].setAttribute('src', 'Media/Layout/' + ObjArr[0] + '_On.jpg')
				} else {
					this.assignEvents(this.navImgs[i])
				}
			}
		}
	}
	//Assign mouse events
	navController.prototype.assignEvents = function (navImg) {
		//Assign mouse events to the navigation image
		var oThis = this
		navImg.onmouseover = function () {
			oThis.hover(this)
		}
		navImg.onmouseout = function () {
			oThis.hover(this)
		}				
	}
	navController.prototype.setPageRelativeLink = function () {
		this.currentPage = window.location.href.split('/')
		this.currentPage = this.currentPage[this.currentPage.length - 1]
		for(var i in this.navImgs) {
			if (this.navImgs[i].src != undefined) {
				
			}
		}
		alert(this.currentPage)
		
	}
	//Function to isolate the image navigation image src filename 
	//PRE: http://www.mysite.com/Media/Layout/Home_On.jpg 
	//POST: [0]Home [1]On
	navController.prototype.isolateSrc = function (input_src) {
		var src = input_src.split('/')
			src = src[src.length - 1]
			src = src.split('.')
			src = src[0]
		var output_src = src.split('_')
		return output_src
	}
	//Toggle Navigation Image Hover 
	navController.prototype.hover = function (Obj) {
		ObjArr = this.isolateSrc(Obj.src)
		switch (ObjArr[1]) {
			case 'On': var newStatus = 'Off'; break;
			case 'Off': var newStatus = 'On'; break;
		}
		//Update image src to new state
		Obj.setAttribute('src', 'Media/Layout/' + ObjArr[0] + '_' + newStatus + '.jpg')
	}