//	Designed and Created by Appius
//	Tel: +44 (0) 1202 553744
//	Fax: +44 (0) 1202 553722
//	Email: info@appius.com
//	Web: http://www.appius.com

//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 = "/css/";

var sub_section="";
var page="";

//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;
}

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 + "'");
		}
		
}
<!-- INSERT START - CP 28/07/04 -->
function select_subimages()
{ 
	var image, imgSel;
	if (sub_section == "")
	{
		if (window.pagesubsection)
			sub_section=window.pagesubsection;
		else 
			sub_section="overview";
	}
	image = image_path + "sn_" + sub_section + "_n.gif";
	preloadImages(image);
	
	//IE & W3C DOM
	if ((document.all) || (document.getElementById))
		{
		if (!document.all)
			{ 	//handle W3C DOM browsers
			imgSel = document.getElementById(["img_" + sub_section]);					
			}
		else
			{
			imgSel = document.all["img_" + sub_section];
			}
			
		if (imgSel != null)
			{
			imgSel.src= image;
			}
		}
	else //Netscape 4 or below
		{
		eval("document.img_" + sub_section + ".src= '" + image + "'");
		}
		
}
<!-- INSERT END - CP 28/07/04 -->
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_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 = "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_topnav()
{
	var obj;
	
	//IE & W3C DOM
	if ((document.all) || (document.getElementById))
		{
		if (!document.all)
			{ 	//handle W3C DOM browsers
			obj = document.getElementById(["topnav_" +sub_section]);					
			}
		else
			{
			obj = document.all["topnav_" +sub_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 = section+"selected";
			}
		}
}

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_subimages(); // - CP 28/07/04
	select_mainnav();
	select_topnav();
	select_subnav();
	select_pagenav();
	select_footer();
}


if (! window.section)
{
	section = section_name();
}

sub_section = sub_section_name();
page = page_name();


// 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";
		}
	
	}
	
}

function ShowHide(id){

	var d = window.document.all;
	for (var i = 0; i < d.length; i++)
	{
		
		if (d[i].id==id)
		{
			if (d[i].style.display=="none" || d[i].style.visibility=="hidden")
			{
				d[i].style.display="block";
				d[i].style.visibility="visible";			
			}
			else
			{
				d[i].style.display="none";
				d[i].style.visibility="hidden";				
			}
			
		}
	
	}

}

<!-- This is the default mouse JavaScript inserted my Macromedia -->
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_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 MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->


<!--
// This pops open the images into a new windo on the detail pages

function dpSmartLink(u,n,w,h,p) { // v1.4 by David Powers
  var a,j,k,x,y,f='';if(!n){n='';}if(w){f+='width='+w+',';}if(h){f+='height='+h+',';}
  if(p){p=p.split(':');if(p[0]!='z'){p[0]=='c'?(x=(screen.width-w)/2):x=p[0];f+='left='+x+',';}
  if(p[1]!='z'){if(p[0]=='c'){y=(screen.height-h-p[1])/2;if(navigator.appName.indexOf('Op')!=-1){
  y-=96;y=y<0?0:y;}}else{y=p[1];}f+='top='+y+',';}}a=arguments.length;if(a>5){for (k=5;k<a;k++){
  switch(arguments[k]){case 'all':f+='toolbar,menubar,location,scrollbars,status,resizable,';break;
  case 't':f+='toolbar,';break; case 'm':f+='menubar,';break;case 'l':f+='location,';break;
  case 'sc':f+='scrollbars,';break;case 's':f+='status,';break;case 'r':f+='resizable,';}}}
  if(f.charAt(f.length-1)==','){f=f.slice(0,-1);}j=window.open(u,n,f);j.focus();
  document.MM_returnValue=false;
}

function openNewWin(mypage){
LeftPosition=(screen.availWidth)?(screen.availWidth-screen.width)/2:50;TopPosition=(screen.availHeight)?(screen.availHeight-screen.height)/2:50;
settings='width=550,height=350,top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';
win=window.open(mypage,null,settings);
if(win.focus){win.focus();}}
//-->


<!-- End -->


<!-- Added 2005-07-05 to allow the main flash movie to pickup url vars -->
function getURL_Var(){
	var var_ary = (location.href.substring( location.href.indexOf( "?" ) + 1 ) ).split("&");
	for( i = 0; i < var_ary.length; i++ ){
		 window.document.movie.SetVariable( var_ary[i].substring( 0, var_ary[i].indexOf("=") ), var_ary[i].substring( var_ary[i].indexOf("=") + 1 ) );
	}
	//alert( window.document.movie.GetVariable( "fvboat" ) );
}
<!-- End -->