// JavaScript Document: navimg2.js

//global variables
var last_img = '';
var last_div_Class='';

//*************************************************************************************
function change_img(img_id,in_obj,mode)
{
	//get image id to replace.
	var img_path = document.getElementById(img_id).src;
	//create new image name, to be used on mouse over/out
	var commonID = in_obj.id.substr(2);
	var new_img_name = commonID + '_s.png';
	//create new div id to use in mouse over/out
	var new_div_id = 'd_' + commonID;
	//split img_path variable by  /  so replacement of filename is last element
	var pathArray = img_path.split("/");
	//get length of array for later use to concatenate string to create new src location with new name
	var arrayLen = pathArray.length;
	{
		if (mode == 'over')
		{
			//store current image to be used later for mouseout
			 last_img=img_path;
			 //store current class to be used later for mouseout
			 last_div_Class = document.getElementById(new_div_id).className;
			 pathArray[arrayLen-1] = new_img_name;
			 var newPath = '';
			 for(i=0;i<arrayLen;i++)
				newPath += pathArray[i] + '/';
			  newPath = newPath.substring(0,newPath.length-1);
			document.getElementById(img_id).src = newPath;
			document.getElementById(new_div_id).className = 'divover';
		}
		
		if (mode == 'out')
		{
			document.getElementById(img_id).src = last_img;
			document.getElementById(new_div_id).className = last_div_Class;

		}
		
		if (mode == 'click')
		{
			 pathArray[arrayLen-1] = new_img_name;
			 var newPath = '';
			 for(i=0;i<arrayLen;i++)
				newPath += pathArray[i] + '/';
			// remove last slash / from path
			newPath = newPath.substring(0,newPath.length-1);
			//insert new image to id
			document.getElementById(img_id).src = newPath;
			//find divselected items and reset to divout
			resetDiv = getElementsByClass('divselected');
			for(i=0;i<resetDiv.length;i++)
				resetDiv[i].className = 'divout';
			//set current item to divselected;
//			alert(new_div_id);
			document.getElementById(new_div_id).className = 'divselected';
			//to prevent mouseout from changing it to old divnotselected
			last_div_Class = 'divselected';
			//to prevent mouseout from changing image back to previous image
			last_img = newPath;
		}

	}
}

//*************************************************************************************
function setnavlocation(page)
{

}

//*************************************************************************************
/*
	parseUri 1.2.1
	(c) 2007 Steven Levithan <stevenlevithan.com>
	MIT License
*/
//*************************************************************************************
function parseUri (str) {
	var	o   = parseUri.options,
		m   = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
		uri = {},
		i   = 14;

	while (i--) uri[o.key[i]] = m[i] || "";

	uri[o.q.name] = {};
	uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
		if ($1) uri[o.q.name][$1] = $2;
	});

	return uri;
};

parseUri.options = {
	strictMode: false,
	key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
	q:   {
		name:   "queryKey",
		parser: /(?:^|&)([^&=]*)=?([^&]*)/g
	},
	parser: {
		strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
		loose:  /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
	}
};

