//detection stuff
var bName = navigator.appName;
var bVersion = parseInt(navigator.appVersion);
var plat = navigator.platform;
ua=navigator.userAgent;

if (bName.indexOf('Netscape') != -1){
var isNS = 1;
}
else if(bName.indexOf('Microsoft') != -1){
var isIE = 1;
}

if(plat.indexOf('Win')!= -1){
var isWin = 1;
}

if(ua.indexOf('AOL') != -1){
var isAOL = 1;
}

//other platform and browser detection stuff from mtv2 site

var isIE = (navigator.appVersion.indexOf("MSIE") >=0) ? true : false;
var isMac = (navigator.appVersion.indexOf("Mac") >=0) ? true : false;
var isWin = (navigator.appVersion.indexOf("Windows") >=0) ? true : false;
var isN6 = (document.getElementById && !document.all) ? true : false;
var isN	= (document.layers) ? true : false;






/*Hide all layers and show a single specified one.
Change the value of the totallayers to the number of layers that you want to show and hide.
Change the value of l to reflect the naming system used for layers e.g. l='fred';
In sh1() below, the layers should be named lay0, lay1, lay2, lay3 etc
sh1() below works on just 1 layer
When calling sh1(), pass as an argument the name at the end of the layer you want to show (i.e. 0, 1 or 2 etc), it will hide all the other layers.
<<<<<<<<<<<<<<USAGE>>>>>>>>>>>>>>>>>
On a couple of browsers, in a framed page, the back button fails to invoke the show hide script.
To avoid this problem, in the page that is loaded, have an onLoad=sh1() in the body tag 
or if it's a frameset itself have an onLoad=sh1() in the frameset tag. 
*/
function sh1(){
var totallayers=1;
l='lay'; 

if(document.all){d='';s='.style';gs='';ge='';}
else if(document.getElementById){d='document.';gs="getElementById('";ge="')";s='.style';}
else{d='document.';s='';gs='';ge='';}

for(var i=0;i<totallayers;i++){
lc=eval(d+gs+l+[i]+ge+s);lc.visibility='hidden';}
ag=arguments;

for(var j=0;j<ag.length;j++){
ln=eval(d+gs+l+[ag[j]]+ge+s);ln.visibility="visible";}
}






//sh9() below works on 9 layers
function sh9(){
var totallayers=9;
l='lay'; 

if(document.all){d='';s='.style';gs='';ge='';}
else if(document.getElementById){d='document.';gs="getElementById('";ge="')";s='.style';}
else{d='document.';s='';gs='';ge='';}

for(var i=0;i<totallayers;i++){
lc=eval(d+gs+l+[i]+ge+s);lc.visibility='hidden';}
ag=arguments;

for(var j=0;j<ag.length;j++){
ln=eval(d+gs+l+[ag[j]]+ge+s);ln.visibility="visible";}
}






/*
To show a layer called lay2 in the frame called 'thetopframe'
Put this function in the head of the page called from a link in the nav e.g. services.htm
Call loaded() by putting an onLoad="loaded()" in the body tag of services.htm.
At the bottom of the frame named thetopframe put the script:

<script language="JavaScript">
var done=true;
</script>

*/
function loaded()
{
	if(parent.frames.thetopframe.done)
	{
		parent.frames.thetopframe.sh3('2');							
	}			
	else{setTimeout('loaded()',100);}
}		





//rich's img swap - works in all browsers (but not nn4)/pc & mac
function swap()
{
var ag = arguments;
for(var i=0;i<ag.length;i+=2)
	{
	document.images[ag[i]].src=ag[i+1];
	}
}


//copy of rich's img swap with if(document.images) - works in all browsers (but not nn4)/pc & mac
/*
function swap()
{
var ag = arguments;
if(document.images)
{
for(var i=0;i<ag.length;i+=2)
	{
	document.images[ag[i]].src=ag[i+1];
	}
}
}
*/






/*
Swap 1 image
All the following swap image scripts might benefit from if(document.images) before it does the swap.
*/
function swap1(img1,ref1)				
{			
document.images[img1].src = ref1;
}

function swap1a(img1,ref1)				
{			
document.images[img1].src = ref1;
}




//swap 2 images - this can be shortened, I'm sure - not got round to it yet
function swap2(img1,ref1,img2,ref2)				
{			
document.images[img1].src = ref1;
document.images[img2].src = ref2;
}





function swap3(img1,ref1,img2,ref2,img3,ref3)				
{			
document.images[img1].src = ref1;
document.images[img2].src = ref2;
document.images[img3].src = ref3;
}




/*
swap 1 image that is in a layer - pass the entire layer name.
The normal swap_img script does not work for images in layers in nn4.
*/
function swap1_ln(img1,ref1,layername){
        if (document.all){
			document.images[img1].src = ref1;
        
		}else if (document.getElementById){ 
			document.getElementById(img1).src = ref1;  
			
        }else  {
			document.layername.document.images[img1].src = ref1;
}
}


/*
swap 6 image that is in a layer - pass the entire layer name.
The normal swap_img script does not work for images in layers in nn4.
*/
function swap6_ln(img1,ref1,img2,ref2,img3,ref3,img4,ref4,img5,ref5,img6,ref6,layername){
        if (document.all){
			document.images[img1].src = ref1;
			document.images[img1].src = ref1;
			document.images[img1].src = ref1;
			document.images[img1].src = ref1;
			document.images[img1].src = ref1;
			document.images[img1].src = ref1;
        
		}else if (document.getElementById){ 
			document.getElementById(img1).src = ref1; 
			document.getElementById(img2).src = ref2; 
			document.getElementById(img3).src = ref3; 
			document.getElementById(img4).src = ref4; 
			document.getElementById(img5).src = ref5; 
			document.getElementById(img6).src = ref6;  
			
        }else  {
			document.layername.document.images[img1].src = ref1;
			document.layername.document.images[img2].src = ref2;
			document.layername.document.images[img3].src = ref3;
			document.layername.document.images[img4].src = ref4;
			document.layername.document.images[img5].src = ref5;
			document.layername.document.images[img6].src = ref6;
}
}




/*
swap 1 image that is in a layer - pass only the number of the layer.
The normal swap_img script does not work for images in layers in nn4.
*/
function swap1_l(img1,ref1,i){
        if (document.all){
			document.images[img1].src = ref1;
        
		}else if (document.getElementById){ 
			document.getElementById(img1).src = ref1;  
			
        }else  {
			document.eval('lay'+i).document.images[img1].src = ref1;
}
}






/*
Swap 2 images that are in layers.
The normal swap_img script does not work for images in layers in nn4 .
This can be shortened, I'm sure - not got round to it yet.
*/
function swap2_l(img1,ref1,i,img2,ref2,j){
        if (document.all){
			document.images[img1].src = ref1;
			document.images[img2].src = ref2;
			
		}else if (document.getElementById){ 
			document.getElementById(img1).src = ref1;  
			document.getElementById(img2).src = ref2;  

        }else  {
			document.eval('lay'+i).document.images[img1].src = ref1;
			document.eval('lay'+i).document.images[img2].src = ref2;
}
}



/*
Open a new window called win2.
Switch the window features on or off as required e.g. scrollbars=yes
The size is dependent on the browser/platform etc.
This could be rewritten to tie in with the detection stuff at the top of this page.
*/
function openWin(url) {
var x=10,y=10
//var x=(screen.availWidth-630)
var vs=navigator.appVersion,v=parseFloat(vs),m=(vs.indexOf('Mac')>-1?true:false),w=(vs.indexOf('Win')>-1?true:false),ie=(document.all?true:false);
var bts=vs.split(' ');for(var i=0;i<bts.length;i++){if(parseFloat(bts[i])>=5&&parseFloat(bts[i])<10)v=parseFloat(bts[i])};

	if(ie&&m&&v>=4&&v<5)
			var sz=",width=650,height=600";		

		else if(ie&&m&&v>=5) 
			var sz=",width=650,height=600";		

		else if(ie&&w&&v>=4)
			var sz=",width=650,height=600";		

		else 
			var sz=",width=650,height=600";      

window.open(url,'win2','left='+x+',top='+y+',screenX='+x+',screenY='+y+',status=yes,scrollbars=yes,resizable=no,menubar=yes'+sz);
}






/*
To prevent the bounding box on links in ie, add the following handler to the <a href> tag:
I don't think we found a global way of doing this that works on all browsers
*/
onfocus="this.blur()"






