/******************************************************************************************************
' Generated by: Script Generator 2
' Written by: Ardeshir (Alex) G. Battye
' Email: agb@mangroveblue.com
' URL: www.mangroveblue.com
'******************************************************************************************************
'
'******************************************************************************************************
' Global.js
'******************************************************************************************************
' Copyright (c) 2003 : MangroveBlue.com
'
' This software is provided under the terms of a License Agreement and
' may only be used and/or copied in accordance with the terms of such an
' agreement.  Neither this software nor any copy thereof may be provided
' or otherwise made available to any other person.  No title or ownership
' of this software is hereby transferred.
'******************************************************************************************************
' CHANGE HISTORY 
'******************************************************************************************************
' 200xxxxx - Created by ScriptGenerator 
'*****************************************************************************************************/

//****************************************************************************************************/
// Detect browser
//****************************************************************************************************/
isIE = document.all;8
isNN = !document.all&&document.getElementById;
isN4 = document.layers;

//****************************************************************************************************/
// Change colour of field when focused
//****************************************************************************************************/
function fieldFocus (aobjField, aintFieldType, aintFocusYN) {
	
	var i;
	
	if (aintFocusYN == 2) 
	{			
		if (aintFieldType != 3) 
		{
			if (aintFocusYN == 2) 
				aobjField.style.background = '#FFEDCD';
		} else {
			
			selectedOption = aobjField.options.selectedIndex;
			aobjField.style.background = '#FFEDCD';
			
			if (aobjField.options.length > 15) 
			{
				aobjField.options[aobjField.options.length - 1].selected = true;
				aobjField.options[0].selected = true;
				if(selectedOption != -1)
				{
					aobjField.options[selectedOption].selected = true;
				}
			} else {
				
				for(i = 0; i < aobjField.options.length; i++)
				{					
					aobjField.options[i].selected = true;
					aobjField.options[i].selected = false;					
				}
				
				if(selectedOption != -1)
				{
					aobjField.options[selectedOption].selected = true;
				}
			}
		}
	} else {
		aobjField.style.background = '#FFFFFF';
	}
}

//****************************************************************************************************/
function confirmLogOut (astrRoot) {
	var confirmedLogOut = window.confirm("Do you want to log out?\n\nClick 'OK' to proceed.");	
	if (confirmedLogOut) 
	{
		document.location.href = astrRoot+'/LogOut.asp';
		return true;
	}	
}

//****************************************************************************************************/
// Capture XY Co-ordinates
//****************************************************************************************************/
var intXCoord = 0;
var intYCoord = 0;

if (!isIE) 
{
	document.captureEvents(Event.MOUSEMOVE)
}

// Main function to retrieve mouse x-y pos.s
function getMouseXY(e) {
	
	if (isIE) 
	{ // grab the x-y pos.s if browser is IE
		intXCoord = event.clientX + document.body.scrollLeft
		intYCoord = event.clientY + document.body.scrollTop
	} else {  // grab the x-y pos.s if browser is NS
		intXCoord = e.pageX
		intYCoord = e.pageY
	}  
	
	// catch possible negative values in NS4
	if (intXCoord < 0)
	{
		intXCoord = 0;
	}
	if (intYCoord < 0)
	{
		intYCoord = 0;
	}  
   
	return true;
}

//****************************************************************************************************/
// Floating help
//****************************************************************************************************/
isSelected = false;

function DragDropLayer(e){
	topLayer = isIE ? "BODY" : "HTML";
	whichLayer = isIE ? document.all.theLayer : document.getElementById("theLayer");  
	hotLayer =isIE ? event.srcElement : e.target;  

	while (hotLayer.id!="titleBar"&&hotLayer.tagName!=topLayer)
	{
		hotLayer=isIE ? hotLayer.parentElement : hotLayer.parentNode;
	}

	if (hotLayer.id=="titleBar"){		
		offsetx = isIE ? event.clientX : e.clientX;
		offsety = isIE ? event.clientY : e.clientY;
		
		nowX = parseInt(whichLayer.style.left);
		nowY = parseInt(whichLayer.style.top);
		
		DragDropEnabled = true;
		document.onmousemove = DragDrop;
	}
}

function DragDrop (e)
{
	if (!DragDropEnabled) return;
	whichLayer.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx; 
	whichLayer.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
	return false;  
}

function DragDropN4 (whatLayer)
{
	if (!isN4) return;
	N4 = eval(whatLayer);
	N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
	N4.onmousedown = function(e)
	{
		N4.captureEvents(Event.MOUSEMOVE);
		N4x = e.x;
		N4y = e.y;
	}
  
	N4.onmousemove = function(e)
	{
		if (isSelected)
		{
			N4.moveBy(e.x-N4x,e.y-N4y);
			return false;
		}
	}
	
	N4.onmouseup = function()
	{
		N4.releaseEvents(Event.MOUSEMOVE);
	}
}

function hideMe ()
	{
		if (isIE||isNN) 
		{
			whichLayer.style.visibility = "hidden";
		}	
		else 
		{
			alert ("W")
			if (isN4)
			{
				document.theLayer.visibility = "hide";
			}	
		}	
	}

function showMe (astrLayerHeader, astrLayerBody)
{
	//Amend contents of layer header
	var Header = document.getElementById("layerHeader");
	Header.firstChild.nodeValue = astrLayerHeader;
	
	//Amend contents of layer body
	var Body = document.getElementById("layerBody");   
	Body.firstChild.nodeValue = astrLayerBody;		
	
	//Set position of layer coordin
	var aintXAxis = intXCoord + 20;
	var aintYAxis = intYCoord;
	
	if (isIE || isNN)
	{
		whichLayer.style.visibility = "visible";
		whichLayer.style.left = aintXAxis;
		whichLayer.style.top = aintYAxis;		
	}
	else 
	{
		if (isN4) 
		{
			document.theLayer.visibility = "show";
		}
	}		
		
}

//document.onmousedown = DragDropLayer;
//document.onmouseup = Function("DragDropEnabled=false");

//****************************************************************************************************/
// Change the content of the layer
//****************************************************************************************************/
function changeLayerContent(astrLayerHeader, astrLayerBody) {  
	var Header = document.getElementById("layerHeader");
	Header.firstChild.nodeValue = astrLayerHeader;

	var Body = document.getElementById("layerBody");   
	Body.firstChild.nodeValue = astrLayerBody;
}

//****************************************************************************************************/
// Print page
//****************************************************************************************************/
function PopUpPrint() {
    document.PrintYN.target				= "_new";  
    document.PrintYN.intPrintYN.value	= 2;      
    document.PrintYN.action				= window.location.href;
    document.PrintYN.submit();
}

//****************************************************************************************************/
// Setting the level of help
//****************************************************************************************************/
function HelpLevel(aintHelpLevel) {
    document.PrintYN.target				= "";
    document.PrintYN.intPrintYN.value	= 3;
	document.PrintYN.intHelpLevel.value	= aintHelpLevel;      
    document.PrintYN.action				= window.location.href;
    document.PrintYN.submit();
}

//****************************************************************************************************/
// Setting the debug
//****************************************************************************************************/   
function Debug(aintDebugYN) {
    document.PrintYN.target				= "";
    document.PrintYN.intPrintYN.value	= 3;
    document.PrintYN.intDebugYN.value	= aintDebugYN;
    document.PrintYN.action				= window.location.href;
    document.PrintYN.submit();
}

//****************************************************************************************************/
// Setting the language
//****************************************************************************************************/   
function setSystemLanguage(astrSystemLanguage) {
    document.PrintYN.target						= "";
    document.PrintYN.intPrintYN.value			= 3;
    document.PrintYN.strSystemLanguage.value	= astrSystemLanguage;
    document.PrintYN.action						= window.location.href;
    document.PrintYN.submit();
}

//****************************************************************************************************/

<!--
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.0
  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 && document.getElementById) x=document.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_Sponsor() {
  var random = Math.random() ;
  var picnum = Math.round(random*4);
  //var picnum = 0;
  //if (picnum == 0) document.write('<A href="2008Forms/sponsorshipindd2.pdf" target="_blank"><img src=Image/Banner/SponsorUs.gif border=0></A>')
  if (picnum == 0) document.write('<A href="http://www.fugro.com/" target="_blank"><img src=Image/Banner/Fugro.jpg border=0></A>')
  if (picnum == 1) document.write('<A href="http://www.indigorye.com/" target="_blank"><img src=Image/Banner/IndigoRye.gif border=0></A>')
  if (picnum == 2) document.write('<A href="http://www.connectcatering.co.uk/" target="_blank"><img src=Image/Banner/connect.gif border=0></A>')
  if (picnum == 3) document.write('<A href="http://www.rowsehoney.co.uk/" target="_blank"><img src=Image/Banner/Rowse.jpg border=0></A>')
  if (picnum == 4) document.write('<A href="http://www.sportswize.co.uk/" target="_blank"><img src=Image/Banner/SportsWize.jpg border=0></A>')
  }

