//styles.js
//
//Configuration info
//The following variables need to be set in the top of each page before this script is included:

var section = "";
var unique_style = false;

//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 three variables need to be set:

var image_path = "/images/template/";
var image_extension = "gif";
var styles_path = "/script_library/";

//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('/');
	p = p.substr(pos+1, p.length - pos - 1)
	
	pos = p.indexOf('/');
	if (pos == -1)
		{
		dir = 'home';
		}
	else
		{
		dir = p.substr(0, pos);
		}
	
	return dir;
}

function select_nav()
{
	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.onmouseover = "";
			}
		}
}

function select_images()
{ 
	var image, imgSel;
	
	image = image_path + "n_" + 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]);					
			}
		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_links()
{
	var obj;
	
	//IE & W3C DOM
	if ((document.all) || (document.getElementById))
		{
		if (!document.all)
			{ 	//handle W3C DOM browsers
			obj = document.getElementById(["link_" + section]);					
			}
		else
			{
			obj = document.all["link_" + section];
			}
			
		if (obj != null)
			{
			obj.className = "navselected";
			}
		}
}


function select_footer()
{
	var obj;
	
	//IE & W3C DOM
	if ((document.all) || (document.getElementById))
		{
		if (!document.all)
			{ 	//handle W3C DOM browsers
			obj = document.getElementById(["footer_" + section]);					
			}
		else
			{
			obj = document.all["footer_" + section];
			}
			
		if (obj != null)
			{
			obj.className = "navfootselected";
			}
		}
}

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_links();
	select_footer();
	select_nav();
}


if (section == "")
	{
	section = section_name();
	}

if (unique_style)
	{
	document.write('<link rel="stylesheet" href="'+ styles_path + section +'.css" type="text/css">');	
	//alert(styles_path + section + '.css')
	}

