/******************************************************************************************************
' 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;
isNN  = !document.all&&document.getElementById;
isN4  = document.layers;
isHot = false;

//****************************************************************************************************/
// Where is the bottom of the page?
//****************************************************************************************************/
var intPageBottomLocation = 0;

function pageBottomLocation (imgName) {	
	intPageBottomLocation = (document.layers)?document[imgName].y:document[imgName].offsetTop;		
}

//****************************************************************************************************/
// Apply style sheets on mouse over
//****************************************************************************************************/
/* TOP/BOTTOM Navigation Background */
function jsTopBottomNavHeadOver (aCellToAlter) {
		aCellToAlter.className = 'TopBottomNavHeadOver';
	}
	
function jsTopBottomNavHeadOut (aCellToAlter) {
		aCellToAlter.className = 'TopBottomNavHeadOut';
	}	

/* LEFT Navigation Heading Background */
function jsLeftNavHeadOver (aCellToAlter) {
		aCellToAlter.className = 'LeftNavHeadOver';
	}
	
function jsLeftNavHeadOut (aCellToAlter) {
		aCellToAlter.className = 'LeftNavHeadOut';
	}	
	
/* LEFT Navigation Sub-Heading Background */
function jsLeftNavSubHeadOver (aCellToAlter) {
		aCellToAlter.className = 'LeftNavSubHeadOver';
	}
	
function jsLeftNavSubHeadOut (aCellToAlter) {
		aCellToAlter.className = 'LeftNavSubHeadOut';
	}

function jsLeftNavSubHeadOverLight (aCellToAlter) {
		aCellToAlter.className = 'LeftNavSubHeadOverLight';
	}
	
function jsLeftNavSubHeadOutLight (aCellToAlter) {
		aCellToAlter.className = 'LeftNavSubHeadOutLight';
	}

function jsLeftNavSubHeadMove(aLink) {
	document.location.href = aLink;
}

/* CMS SubModuleMenu */
function jsSubModuleOver (aCellToAlter) {
		aCellToAlter.className = 'EmpProfSubHeadOver';
	}
	
function jsSubModuleOut (aCellToAlter) {
		aCellToAlter.className = 'EmpProfSubHeadOut';
	}

//****************************************************************************************************/
// 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;

var IE = document.all?true:false

if (!IE) document.captureEvents(Event.MOUSEMOVE)

document.onmousemove = getMouseXY;

// Main function to retrieve mouse x-y pos.s
function getMouseXY(e) {	
	if (IE) 
	{ // 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		
	}  
	
	//alert (intXCoord)			
	
	// catch possible negative values in NS4
	if (intXCoord < 0)
	{
		intXCoord = 0;
	}
	if (intYCoord < 0)
	{
		intYCoord = 0;
	}  
	
	//document.form1.MouseX.value = intXCoord;
	//document.form1.MouseY.value = intYCoord;
   
	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 (astrLayerName)
{
	switch (astrLayerName) {
    case 'topBubble':
		whichLayer = isIE ? document.all.topBubble : document.getElementById("topBubble"); 	
		if (isIE||isNN) 
		{
			whichLayer.style.visibility = "hidden";
		}	
		else 
		{
			alert ("W")
			if (isN4)
			{
				document.topBubble.visibility = "hide";
			}	
		}
		
    break;
    case 'rightBubble': 
		whichLayer = isIE ? document.all.rightBubble : document.getElementById("rightBubble"); 					
		if (isIE||isNN) 
		{
			whichLayer.style.visibility = "hidden";
		}	
		else 
		{
			alert ("W")
			if (isN4)
			{
				document.topBubble.visibility = "hide";
			}	
		}
		
    break;
    default: 
		if (isIE||isNN) 
		{
			whichLayer.style.visibility = "hidden";
		}	
		else 
		{
			alert ("W")
			if (isN4)
			{
				document.theLayer.visibility = "hide";
			}	
		}
	break;	
	}		
}

function showMe (astrLayerHeader, astrLayerBody)
{
	var intYAxis = 0;
	
	switch (astrLayerHeader) {
    case 'topBubble': 
		if (isIE || isNN)
		{
			whichLayer = isIE ? document.all.topBubble : document.getElementById("topBubble"); 			
			whichLayer.style.visibility = "visible";		
		}
		else 
		{
			if (isN4) 
			{
				alert("D");
				document.topBubble.visibility = "show";
			}
		}		
			
    break;
    case 'rightBubble':
		pageBottomLocation ('pageBottom');		
		intYAxis = (intPageBottomLocation - 200);
		
		whichLayer = isIE ? document.all.rightBubble : document.getElementById("rightBubble"); 		
		whichLayer.style.top = intYAxis;			
		whichLayer.style.visibility = "visible";
		
    break;
    default:  
	
		//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";
			}
		}		
	
	break;	
	}
	
	//Check I have Mouse Coordinates
	//alert (aintXAxis);
	//alert (aintYAxis);
			
}

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(aintSystemLanguageID) {
    document.PrintYN.target						= "";
    document.PrintYN.intPrintYN.value			= 3;    
    document.PrintYN.gintSystemLanguageID.value	= aintSystemLanguageID;
    if(document.PrintYN.strRedirectURL.value == "" || document.PrintYN.strRedirectURL.value == undefined)
    {
    document.PrintYN.action						= window.location.href;
    }
    else
    {
    document.PrintYN.action						= document.PrintYN.strRedirectURL.value;
    }
    document.PrintYN.submit();
}

//****************************************************************************************************/
