//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.


//The following two variables need to be set:
var image_path = "/images/navigation/";
var styles_path = "/script_library/";

var sub_section="";
var page="";

var languages = "french,german,italian,spanish";

//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 sub_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('/');
	p = p.substr(pos+1, p.length - pos - 1)

	pos = p.indexOf('/');
	if (pos == -1)
		{
		dir = '';
		}
	else
		{
		dir = p.substr(0, pos);
		}
	
	return dir;
}

function page_name()
{
	var p, pos, page;
		
	p = window.location.href;
	
	pos = p.lastIndexOf('/')
	p = p.substr(pos+1, p.length - pos - 1)

	pos = p.indexOf('.')
	page = p.substr(0, pos) 

	return page;
}

// This was editied replacing "section" with "navspacer" - Sam 19/12/2005

function select_images()
{ 
	var image, imgSel;
	
	image = image_path + "n_navspacer_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 + "'");
		}
		
}

// Rollover for the home page - for this web site only - for others use a different Styles JS

function select_imageshome()
{ 
	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(["imghome_" + section]);					
			}
		else
			{
			imgSel = document.all["imghome_" + section];
			}
			
		if (imgSel != null)
			{
			imgSel.src= image;
			}
		}
	else //Netscape 4 or below
		{
		eval("document.imghome_" + section + ".src= '" + imagehome + "'");
		}
		
}

function select_mainnav(){
	var obj;
	
	var foundLanguage = false;
	for(spt = 0; spt < languages.split(",").length; spt++){
		var tmp = languages.split(",");
		var sn = section_name();
		if( tmp[spt]==sn ){
			foundLanguage = true
		}
	}
	
	if( foundLanguage == true ){
		if( sub_section=="" )
			section="home"
		else
			section = sub_section;
	}
	
	//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_pagenav()
{
	var obj;
	
	//IE & W3C DOM
	if ((document.all) || (document.getElementById))
		{
		if (!document.all)
			{ 	//handle W3C DOM browsers
			obj = document.getElementById(["pagenav_" + page]);					
			}
		else
			{
			obj = document.all["pagenav_" + page];
			}
			
		if (obj != null)
			{
			obj.className = "subnavselected";			
			}
		}
}


function select_arrowImg()
{
		
	var image, imgSel;
	
	image = image_path + "sn_subnav_n.gif";

	preloadImages(image);
	
	//IE & W3C DOM
	if ((document.all) || (document.getElementById)) {
		if (!document.all) { 	//handle W3C DOM browsers
			imgSel = document.getElementById(["imga_" + page]);
		}
		else {
			imgSel = document.all["imga_" + page];
		}
		
		if (imgSel != null) {
			imgSel.src= image;
		}
	}
	else { //Netscape 4 or below
		//eval("document.img_" + section + ".src= '" + image + "'");
	}
}




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_topnav()
{
	var obj;
	
	//IE & W3C DOM
	if ((document.all) || (document.getElementById))
		{
		if (!document.all)
			{ 	//handle W3C DOM browsers
			obj = document.getElementById(["topnav_" +section]);					
			}
		else
			{
			obj = document.all["topnav_" + section];
			}
			
		if (obj != null)
			{
			obj.className = "topnavselected";
			}
		}
}


function select_subnav()
{
	var obj;

	//IE & W3C DOM
	if ((document.all) || (document.getElementById))
		{
		if (!document.all)
			{ 	//handle W3C DOM browsers
			obj = document.getElementById(["subnav_" + page]);					
			}
		else
			{
			obj = document.all["subnav_" + page];
			}
			
		if (obj != null)
			{
			obj.className = "subnavselected";
			}
		}
}


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 select_thispagenav()
{

	//SetObjectProperty("pagenav_" + page, "src","/images/"+section+"/i_nav_"+section+".gif");

	var obj;
	
	//IE & W3C DOM
	if ((document.all) || (document.getElementById))
	{
		if (!document.all)
		{ 	//handle W3C DOM browsers
			obj = document.getElementById(["pagenav_" + page]);					
		}
		else
		{
			obj = document.all["pagenav_" + page];
		}
			
		if (obj != null)
		{
			//obj.className = "mainnavselected";			
			obj.src="/images/i_bullet_flash.gif";
		}
	}
	
	//IE & W3C DOM
	if ((document.all) || (document.getElementById))
	{
		if (!document.all)
		{ 	//handle W3C DOM browsers
			obj = document.getElementById(["pagenav_row_" + sub_section]);					
		}
		else
		{
			obj = document.all["pagenav_row_" + sub_section];
		}
			
		if (obj != null)
		{
			//obj.className = "mainnavselected";			
			//alert(obj.style.bgcolor);
			obj.bgColor=navColour;
			//alert(obj.style.bgcolor);
		}
	}

}

function SetObjectProperty(objName, propName, propValue)
{
	var obj;
	
	//IE & W3C DOM
	if ((document.all) || (document.getElementById))
	{
		if (!document.all)
		{ 	//handle W3C DOM browsers
			obj = document.getElementById([objName]);
		}
		else
		{
			obj = document.all[objName];
		}
		if (obj != null)
		{
			alert();
			//eval("obj."+propName+" = "+propValue+";");

		}				
	}

}

function set_styles()
{
	select_mainnav();		
	//select_images();
	//select_imageshome();
	//select_topnav();
	//select_subnav();
	//select_thispagenav();
	select_footer();
	//select_arrowImg();
	//select_pagenav();
}


if (section == "")
	{
	section = section_name();
	}

if (! window.navColour) navColour="#183482";
sub_section = sub_section_name();
page = page_name();

// This function hides all elements on the page with the id

// This function hides all elements on the page with the id

function Hide(id){

	var d = window.document.all;
	for (var i = 0; i < d.length; i++)
	{
		
		if (d[i].id==id)
		{
			d[i].style.display="none";
			d[i].style.visibility="hidden";
		}
	
	}
	//ChangeBGColor();
}

function ChangeBGColor()
{
	if (document.bgColor=="#ffffff") document.bgColor="#000000";
	else document.bgColor="#ffffff";
}
// This function shows all elements on the page with the id
function Show(id){

	//ChangeBGColor();
	var d = window.document.all;
	for (var i = 0; i < d.length; i++)
	{
		if (d[i].id==id)
		{
			d[i].style.display="block";
			d[i].style.visibility="visible";
		}
	
	}
	
}

// This is the code for the Navigation

