//styles.js
//
//Configuration info
//The following variables need to be set in the top of each page before this script is included:

//var section = ""; // If this is blank then we use the directory to define a section.
//unique_stylesheet = false; // Does each different section have a seperate style sheet.
//var subsection;  //This is used as the class name for sub navigation images.

//The two lines above can be uncommented if the site isn't going to require the overriding of any section names or unique styles.
//The following needs to be added into the body tag of your HTML page:

//onload="set_styles();"

//Links need the id setting to the following, if they are to be controlled by this script:
//nb.  Section name is the toplevel directory that the page resides in, unless overriden.  home is the homepage.

//NB. Standard Macromedia mouseovers can be used for image hovers.

//image links: id="img_sectionname"
//header text links: link_sectionname
//footer text links: footer_sectionname

//The following styles need to be included in your stylesheet (you can change the properties to whatever you like:

//	.navselected, .navselected:hover {
//	color:#cccccc;
//	text-decoration:none;
//	cursor: default;
//	font-weight : bold;
//	}

//	.navfootselected, .navfootselected:hover {
//	color:#cccccc;
//	text-decoration:none;
//	cursor: default;
//	font-weight : bold;
//	}

//The following two variables need to be set:

var image_path = "../images/template/navigation/index.html";
var styles_path = "index.html";

//Don't edit below here

function section_name()
{
	var p, pos, dir;
		
	p = window.location.href;
	
	pos = p.indexOf('//');
	p = p.substr(pos+2, p.length - pos - 2)
	
	pos = p.indexOf('../index.html');
	p = p.substr(pos+1, p.length - pos - 1)
	
	pos = p.indexOf('../index.html');
	if (pos == -1)
		{
		dir = 'home';
		}
	else
		{
		dir = p.substr(0, pos);
		}
	
	return dir;
}

function section2_name()
{
	var p, pos, dir;
		
	p = window.location.href;
	
	pos = p.indexOf('//');
	p = p.substr(pos+2, p.length - pos - 2)
	
	pos = p.indexOf('../index.html');
	p = p.substr(pos+1, p.length - pos - 1)
	
	pos = p.indexOf('../index.html');
	p = p.substr(pos+1, p.length - pos - 1)

	pos = p.indexOf('../index.html');
	if (pos == -1)
		{
		dir = '';
		}
	else
		{
		dir = p.substr(0, pos);
		}
	
	return dir;
}



function select_images()
{ 
	var image, imgSel;
	
	image = image_path + "n_" + section + "_n.gif";

	preloadImages(image);
	
	//IE & W3C DOM
	if ((document.all) || (document.getElementById))
		{
		if (!document.all)
			{ 	//handle W3C DOM browsers
			imgSel = document.getElementById(["img_" + section]);					
			}
		else
			{
			imgSel = document.all["img_" + section];
			}
			
		if (imgSel != null)
			{
			imgSel.src= image;
			}
		}
	else //Netscape 4 or below
		{
		eval("document.img_" + section + ".src= '" + image + "'");
		}
		
}

function select_mainnav()
{
	var obj;
	
	//IE & W3C DOM
	if ((document.all) || (document.getElementById))
		{
		if (!document.all)
			{ 	//handle W3C DOM browsers
			obj = document.getElementById(["nav_" + section]);					
			}
		else
			{
			obj = document.all["nav_" + section];
			}
			
		if (obj != null)
			{
			obj.className = "mainnavselected";
			}
		}
}


function select_footer()
{
	var obj;
	
	//IE & W3C DOM
	if ((document.all) || (document.getElementById))
		{
		if (!document.all)
			{ 	//handle W3C DOM browsers
			obj = document.getElementById(["foot_" + section]);					
			}
		else
			{
			obj = document.all["foot_" + section];
			}
			
		if (obj != null)
			{
			obj.className = "navfootselected";
			}
		}
}

function select_subnav()
{
	var obj;
	
	//IE & W3C DOM
	if ((document.all) || (document.getElementById))
		{
		if (!document.all)
			{ 	//handle W3C DOM browsers
			obj = document.getElementById(["subnav_" + subsection]);					
			}
		else
			{
			obj = document.all["subnav_" + subsection];
			}
			
		if (obj != null)
			{
			obj.className = "subnavselected";
			}
		}
}

function select_leftnav()
{
	var obj;
	
	//IE & W3C DOM
	if ((document.all) || (document.getElementById))
		{
		if (!document.all)
			{ 	//handle W3C DOM browsers
			obj = document.getElementById(["leftnav_" +section]);					
			}
		else
			{
			obj = document.all["leftnav_" + section];
			}
			
		if (obj != null)
			{
			obj.className = "leftnavselected";
			}
		}
}

function select_cells()
{
	var obj;
	
	//IE & W3C DOM
	if ((document.all) || (document.getElementById))
		{
		if (!document.all)
			{ 	//handle W3C DOM browsers
			obj = document.getElementById(["cell_" +section]);					
			}
		else
			{
			obj = document.all["cell_" + section];
			}
			
		if (obj != null)
			{
			obj.className = "mainnavselected";
			}
		}
}


function select_subimages()
{ 
	var image, imgSel;
	
	image = image_path + "n_" + section + "_" + sub_section + "_n." + image_extension;

	preloadImages(image);
	
	//IE & W3C DOM
	if ((document.all) || (document.getElementById))
		{
		if (!document.all)
			{ 	//handle W3C DOM browsers
			imgSel = document.getElementById(["img_" + section + "_" + sub_section]);					
			}
		else
			{
			imgSel = document.all["img_" + section + "_" + sub_section];
			}
			
		if (imgSel != null)
			{
			imgSel.src= image;
			}
		}
	else //Netscape 4 or below
		{
		eval("document.img_" + section + "_" + sub_section + ".src= '" + image + "'");
		}
		
}

function preloadImages() { 
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function set_styles()
{
	select_images();
	select_footer();
	select_subnav();
	//select_mainnav();
	//select_subimages();
	select_leftnav();
	//select_cells();
}


if (section == "")
	{
	section = section_name();
	}

if (unique_stylesheet)
	{
	document.write('<link rel="stylesheet" href="'+ styles_path + section +'.css" type="text/css">');	
	//alert(styles_path + section + '.css')
	}
