function rollover( imageobj )
{
	var mystring = imageobj.src;
	imageobj.src = mystring.replace( /\.gif/gi, '_ON.gif' );	
}

function rollout( imageobj )
{
	var mystring = imageobj.src;
	imageobj.src = mystring.replace( /\_ON\.gif/gi, '.gif' );
}

function firdom()
{
	if(document.getElementsByTagName && document.createElement){
		for( var l=1; l<=6; l++ )
		{
			var h1s = document.getElementsByTagName('h'+l);
			scanandreplace( h1s,'h'+l );
		}
	}
}

function scanandreplace( h1s, tag )
{
	for( var i=0; i < h1s.length; i++ )
	{
		for( var f=0; f < replaceImages.length; f++ )
		{
			var chunks=replaceImages[f].split('|');
			
			// fix &amp;
			var mystring = chunks[0];
			chunks[0] 	 = mystring.replace( /amp;/gi, '' );
		
			var thish1=document.getElementsByTagName(tag)[i];
			if(thish1.firstChild.nodeValue==chunks[0])
			{
				var newImg=document.createElement('img');
				newImg.setAttribute('alt',chunks[0])
				newImg.setAttribute('src',chunks[1])
				newImg.setAttribute('border','0')
				
				// or newImg.src=chunks[1];
				thish1.replaceChild(newImg,thish1.firstChild)
				break;
			}
		}
	}
}

var oldlinkcolour = '#000000';

function showSub(i)
{
	oldlinkcolour = document.getElementById('navlink'+i).style.color;
	document.getElementById('subnav'+i).style.visibility="visible";
}

function hideSub(i)
{
	document.getElementById('subnav'+i).style.visibility="hidden";
}

function setRoll(i)
{
	oldlinkcolour = document.getElementById('navlink'+i).style.color;
}

function unsetRoll(i)
{
	
}


function hiliteRow(i)
{
	document.getElementById('navrow'+i).style.backgroundColor="#ffffff";
	document.getElementById('navlink'+i).style.color="#FE4110";
}

function loliteRow(i)
{
	document.getElementById('navrow'+i).style.backgroundColor="#FFFFFF";
	
	document.getElementById('navlink'+i).style.color= oldlinkcolour;
	//document.getElementById('navlink'+i).style.color="#000000";
}


function toggleitemhover(item, hovering)
{
	if (hovering == false) { item.className = 'maindropdownitem'; }
	else { item.className = 'maindropdownitemhov'; }
}

function swaptextblock( whichtext )
{
	document.getElementById('textblock1').style.display='none';
	document.getElementById('textblock2').style.display='none';
	document.getElementById('textblock3').style.display='none';
	
	document.getElementById('textblock'+whichtext).style.display='block';
}

function swapimageblock( whichimage )
{
	document.getElementById('imageblock1').style.display='none';
	document.getElementById('imageblock2').style.display='none';
	document.getElementById('imageblock3').style.display='none';
	document.getElementById('imageblock4').style.display='none';
	document.getElementById('imageblock5').style.display='none';
	
	document.getElementById('imageblock'+whichimage).style.display='block';
}

function printpage()
{
	var winwidth	= ( screen.width  > 800 ) ? '820' : '750';
	var winheight	= ( screen.height > 600 ) ? '620' : '450';
	var winleft	= ( screen.availWidth  - 10 - winwidth  ) / 2;
	var wintop	= ( screen.availHeight - 20 - winheight ) / 2;

	printable = window.open('/engine/print/'+escape(location.href), 'printable', 'toolbar=yes, scrollbars=yes, resizable=yes, menubar=yes, status=yes, directories=no, location=no, top=' + wintop + ',left=' + winleft + ', screenY=' + wintop + ',screenx=' + winleft +', width='+winwidth+', height='+winheight);
	printable.focus();
	printable.print();
}

function emailpage()
{
	var winwidth	= '450';
	var winheight	= '510';
	var winleft	= ( screen.availWidth  - 10 - winwidth  ) / 2;
	var wintop	= ( screen.availHeight - 20 - winheight ) / 2;

	email = window.open('/engine/email/'+escape(location.href), 'email', 'toolbar=no, scrollbars=no, resizable=no, menubar=no, status=yes, directories=no, location=no, top=' + wintop + ',left=' + winleft + ', screenY=' + wintop + ',screenx=' + winleft +', width='+winwidth+', height='+winheight);
	email.focus();
}

function popImage(imageURL,imageTitle)
{
	PositionX	= 100;
	PositionY	= 100;
	defaultWidth	= 500;
	defaultHeight	= 500;
	var AutoClose	= true;

	if (parseInt(navigator.appVersion.charAt(0))>=4){
	var isNN=(navigator.appName=="Netscape")?1:0;
	var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
	var optNN='resizable=yes,scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
	var optIE='resizable=yes,scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;

	if (isNN){imgWin=window.open('about:blank','',optNN);}
	if (isIE){imgWin=window.open('about:blank','',optIE);}

	with (imgWin.document)
	{
		writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
		writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
		writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
		writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
		writeln('width=100-(document.body.clientWidth-document.images[0].width);');
		writeln('height=100-(document.body.clientHeight-document.images[0].height);');
		writeln('window.resizeTo(width,height);}');writeln('if (isNN){');
		writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
		writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
		if (!AutoClose) writeln('</head><body bgcolor=ffffff scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
		else writeln('</head><body bgcolor=ffffff scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
		writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
		close();
	}
}

function testpassword(fieldname)
{
	// declare variables
	var savepword	= document.getElementById( fieldname );
	var newpword1	= document.getElementById( fieldname + '_1' );
	var newpword2	= document.getElementById( fieldname + '_2' );

	// test for empty password fields
	if( newpword1.value == '' && newpword2.value == '' )
	{
		return true;
	}

	// test for matching fields
	if( newpword1.value == newpword2.value )
	{
		savepword.value = newpword1.value;
		return true;
	}

	else if( newpword1.value != '' && newpword2.value == '' )
	{
		newpword2.focus();
		return true;
	}

	else
	{
		alert( 'Passwords do not match!' );
		newpword1.value = '';
		newpword2.value = '';
		newpword1.focus();
		return false;
	}
}

/* BROWSER DETECTION SCRIPT: http://www.dynamicdrive.com/dynamicindex9/browsersniffer.htm */

var exclude=1;
var agt=navigator.userAgent.toLowerCase();
var win=0;var mac=0;var lin=1;
if(agt.indexOf('win')!=-1){win=1;lin=0;}
if(agt.indexOf('mac')!=-1){mac=1;lin=0;}
var lnx=0;if(lin){lnx=1;}
var ice=0;
var ie=0;var ie4=0;var ie5=0;var ie6=0;var com=0;var dcm;
var op5=0;var op6=0;var op7=0;
var ns4=0;var ns6=0;var ns7=0;var mz7=0;var kde=0;var saf=0;
if(typeof navigator.vendor!="undefined" && navigator.vendor=="KDE"){
	var thisKDE=agt;
	var splitKDE=thisKDE.split("konqueror/");
	var aKDE=splitKDE[1].split("; ");
	var KDEn=parseFloat(aKDE[0]);
	if(KDEn>=2.2){
		kde=1;
		ns6=1;
		exclude=0;
		}
	}
else if(agt.indexOf('webtv')!=-1){exclude=1;}
else if(typeof window.opera!="undefined"){
	exclude=0;
	if(agt.indexOf("opera/5")!=-1||agt.indexOf("opera 5")!=-1){op5=1;}
	if(agt.indexOf("opera/6")!=-1||agt.indexOf("opera 6")!=-1){op6=1;}
	if(agt.indexOf("opera/7")!=-1||agt.indexOf("opera 7")!=-1){op7=1;}
	}
else if(typeof document.all!="undefined"&&!kde){
	exclude=0;
	ie=1;
	if(typeof document.getElementById!="undefined"){
		ie5=1;
		if(agt.indexOf("msie 6")!=-1){
			ie6=1;
			dcm=document.compatMode;
			if(dcm!="BackCompat"){com=1;}
			}
		}
	else{ie4=1;}
	}
else if(typeof document.getElementById!="undefined"){
	exclude=0;
	if(agt.indexOf("netscape/6")!=-1||agt.indexOf("netscape6")!=-1){ns6=1;}
	else if(agt.indexOf("netscape/7")!=-1||agt.indexOf("netscape7")!=-1){ns6=1;ns7=1;}
	else if(agt.indexOf("gecko")!=-1){ns6=1;mz7=1;}
	if(agt.indexOf("safari")!=-1 || (typeof document.childNodes!="undefined" && typeof document.all=="undefined" && typeof navigator.taintEnabled=="undefined")){mz7=0;ns6=1;saf=1;}
	}
else if((agt.indexOf('mozilla')!=-1)&&(parseInt(navigator.appVersion)>=4)){
	exclude=0;
	ns4=1;
	if(typeof navigator.mimeTypes['*']=="undefined"){
		exclude=1;
		ns4=0;
		}
	}
if(agt.indexOf('escape')!=-1){exclude=1;ns4=0;}
if(typeof navigator.__ice_version!="undefined"){exclude=1;ie4=0;}
