<!--

// JAVASCRIPT FOR THE MAIN PAGE

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


// Get the browser Type
var IE = document.all?true:false;
var browsertype = new String( navigator.appName );
var IE6 = false;

// Detect Netscape
if ( browsertype == "netscape" || browsertype == "Netscape" ) {
	var ns = true; var IE = false;
// IE and compatable browsers
} else {
	var ns = false; var IE = true;
}

// What version of IE?
if ( IE ) {
	if ( 
		navigator.appVersion.indexOf( "MSIE 1" ) > -1
		||
		navigator.appVersion.indexOf( "MSIE 2" ) > -1
		||
		navigator.appVersion.indexOf( "MSIE 3" ) > -1
		||
		navigator.appVersion.indexOf( "MSIE 4" ) > -1
		||
		navigator.appVersion.indexOf( "MSIE 5" ) > -1
	) {
		var IE6 = false;
	} else {
		var IE6 = true;
	}
}


// Make Netscape / Mozilla monitor the mouse events
if ( !IE ) { document.captureEvents( Event.MOUSEMOVE ); document.captureEvents( Event.RESIZE ); }


// Set the style strings
var MenuItemNormalStyle = "border: 1px solid #3953A4; color: #FFFFFF; background-color: #3953A4; cursor: pointer; ";
var MenuItemOverStyle = "border: 1px solid #FFFFFF; color: #FFFFFF; background-color: #607AC8; cursor: pointer; ";

// ID's OF ALL LAYERS ON THE PAGE
var Layers = new Array( "services", "contact", "corporate" );




// --------------------------------------------------
// THIS IS EXECUTED WHEN THE PAGE LOADS
// It performs initial page formatting functions
function Page_Load () {
	
	// Hide All Layers
	Hide_Layers();

	// Position the Layers
	Position_Layers();

	// ROTATE THE IMAGE
	Rotate_Image();

	// Resize the document table
	if ( IE ) {
		if ( IE6 ) {
			document.getElementById( "BodyTable" ).style.height = document.documentElement.clientHeight;
		} else {
			document.getElementById( "BodyTable" ).style.height = document.body.clientHeight;
		}
	} else {
		document.getElementById( "BodyTable" ).style.height = window.innerHeight + "px";
	}

	// Tell the browser to track mouse movements
	document.onmousemove = Check_Layer_Visibility;

}




// --------------------------------------------------
// SHOW A LAYER
function Show_Layer ( Selected_Layer ) {

	document.getElementById( Selected_Layer ).style.visibility = "visible";

}




// --------------------------------------------------
// Hide All Layers
function Hide_Layers ( Exception_Layer ) {

	// Run this loop for every layer that exists on this page
	for ( x = 0; x < Layers.length; x++ ) {

		// If the user specified an exception layer then don't do anythign to that layer
		if ( Layers[x] != Exception_Layer ) {

			// Hide the layer
			document.getElementById( Layers[x] ).style.visibility = "hidden";

		}

	}

}




// --------------------------------------------------
// CHECK THE POSITION OF THE MOUSE COMPARED TO THE COORDS OF THE LAYER
// If the mouse has moved out of the tollerance range of any layer then hide that layer
function Check_Layer_Visibility ( EventArgs ) {


	// DECLARE VARAIBLES
	Tollerence = 50;		// Distance Tollerance for each layer
	

	// Cycle through the layer list and hide if mouse outside tollerance area
	for ( x = 0; x < Layers.length; x++ ) {
		
		// Select the current layer
		Selected_Layer = document.getElementById( Layers[x] );
		
		
		// ONLY DO THIS IF THE LAYER IS VISIBLE
		if ( Selected_Layer.style.visibility == "visible" ) {

			// CURRENT BROWSER IS IE
			if ( IE ) {
	
				if (
					( window.event.clientX  + document.body.scrollLeft ) < ( Selected_Layer.style.posLeft - Tollerence )
					||
					( window.event.clientX + document.body.scrollLeft ) > ( Selected_Layer.style.posLeft + parseInt( Selected_Layer.style.width ) + Tollerence )
					||
					( window.event.clientY + document.body.scrollTop ) < ( Selected_Layer.style.posTop - Tollerence )
					||
					( window.event.clientY + document.body.scrollTop ) > ( Selected_Layer.style.posTop + parseInt( Selected_Layer.style.height ) + Tollerence )
				) {
					Selected_Layer.style.visibility = "hidden";
				}
	
			// CURRENT BROWSER ISNT IE
			} else {
				
				if (
					( EventArgs.pageX  + document.body.scrollLeft ) < ( parseInt( Selected_Layer.style.left ) - Tollerence )
					||
					( EventArgs.pageX + document.body.scrollLeft ) > ( parseInt( Selected_Layer.style.left ) + parseInt( Selected_Layer.style.width ) + Tollerence )
					||
					( EventArgs.pageY + document.body.scrollTop ) < ( parseInt( Selected_Layer.style.top ) - Tollerence )
					||
					( EventArgs.pageY + document.body.scrollTop ) > ( parseInt( Selected_Layer.style.top ) + parseInt( Selected_Layer.style.height ) + Tollerence )
				) {
					Selected_Layer.style.visibility = "hidden";
				}
				
			}
		
		}

	}

}




// --------------------------------------------------
// MAKES SURE THAT THE LAYERS ARE IN THE CORRECT POSITION
function Position_Layers () {


	// DECLARE VARAIBLES
	

	// Cycle through the layer list and position each layer
	for ( x = 0; x < Layers.length; x++ ) {
		
		// Select the current layer and the current image
		Selected_Layer = document.getElementById( Layers[x] );
		Selected_Image = document.getElementById( "img" + Layers[x] );
		
		// CURRENT BROWSER IS IE
		if ( IE ) {

			Selected_Layer.style.posLeft = imgXPos( "img" + Layers[x] ) - 8;
			Selected_Layer.style.posTop = imgYPos( "img" + Layers[x] ) + 18;

		// CURRENT BROWSER ISNT IE
		} else {

			Selected_Layer.style.left = ( parseInt( Selected_Image.x ) - 8 ) + "px";
			Selected_Layer.style.top = ( parseInt( Selected_Image.y ) + 15 ) + "px";

		}

	}

}




// --------------------------------------------------
// ROTATE THE IMAGE
function Rotate_Image() {
	document.getElementById( "RandomImage" ).src = "images/front_page/photos/" + Math.floor( Math.random() * 3 ) + ".jpg";
	timer = setTimeout( "Rotate_Image()", 5000 );
}




// GET THE POSITION OF AN IMAGE IN RELATION TO THE PAGE TOP-LEFT
// IE ONLY, Mozilla etc uses IMAGE.x, IMAGE.y
function imgYPos( imgID ) {
	var imgID = document.getElementById( imgID )
	yPos = eval( imgID ).offsetTop;
	tempEl = eval( imgID ).offsetParent;
	while ( tempEl != null ) {
  		yPos += tempEl.offsetTop;
  		tempEl = tempEl.offsetParent;
	}
	return yPos;
}
function imgXPos( imgID ) {
	var imgID = document.getElementById( imgID )
	xPos = eval( imgID ).offsetLeft;
	tempEl = eval( imgID ).offsetParent;
  	while ( tempEl != null ) {
  		xPos += tempEl.offsetLeft;
  		tempEl = tempEl.offsetParent;
	}
	return xPos;
}


-->

