/* Global Variables */
var DISABLE_PAGE = "DisablePage";
var OK_BUTTON = "OKButton";
var TEXT = "Text";
var BUTTONS = "Buttons";
var LOADING = "Loading";
var url = "";
var new_window;
var varX;
var varY;
var currentY;

//Constants
var PIXEL_ABBREVIATION = "px";
var DISPLAY_STYLE_NONE = "none";
var JAVASCRIPT_SPLITTER = ":";
var JAVESCRIPT_HEADER = "javascript";
var HTML_MAILTO_HEADER = "mailto";
var HTML_LINK_SPLITTER = "/";
var STRING_EMPTY = "";
var MESSAGE_BOX_WIDTH = "30%";
var TOP_MESSAGE_BOX_PART = "Top";
var AZ_INDEX_NAME = "AZIndex";
var FLOATING_AZMENU_NAME = "floatingMenu";
var DISPLAY_STYLE_BLOCK = "block";

/*Start General Page Functions*/
function PrintPage()
{
	javascript:window.print();
}
/* End General Page Functions*/

/*Start Previous and Next Summary Functions*/
//Gets the coordinates of a given element
function FindPos(obj) 
{
        var curleft = curtop = 0;
        
        if (obj.offsetParent) 
        {
               curleft = obj.offsetLeft;
               curtop = obj.offsetTop;
               
               while (obj = obj.offsetParent) 
               {
                       curleft += obj.offsetLeft;
                       curtop += obj.offsetTop;
               }
        }
        
        return [curleft,curtop];
}

function PopUp(elementId, button, varPosition)
{	
	var BoxMargin = 25;
	var StyleOffset = 10;

	var coordinates = FindPos(button);	
	var displayElement = document.getElementById(elementId);
	
	var topPosition = coordinates[1];
	
	if(displayElement != null)
	{		
		if (displayElement.innerHTML != STRING_EMPTY)
		{
			with( displayElement.style ) 
			{	
				display = DISPLAY_STYLE_BLOCK;
				
				if (button.id.match(TOP_MESSAGE_BOX_PART))
				{
					topPosition = topPosition + BoxMargin + StyleOffset;
				}
				else
				{
					topPosition = topPosition - displayElement.offsetHeight - StyleOffset;
				}

				top = topPosition + PIXEL_ABBREVIATION;								

			}
		}
	}
}

function UnPop( objID ) 
{ 
	var obj = document.getElementById(objID);
	if(obj != null)
	{
		obj.style.display = DISPLAY_STYLE_NONE; 
	}
}
/*End Previous and Next Summary Functions*/

/*Start Get Current Mouse Position Functions*/
//function getXYPosition()
function GetXYPosition(evt)
{
	if (!evt) var evt = window.event;

	if (evt.pageX) 
		varX = evt.pageX; 
	else if (evt.clientX)
		varX = evt.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft); 
	else 
		varX = null;

	if (evt.pageY) 
		varY = evt.pageY; 
	else if (evt.clientY)
		varY = evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); 
	else 
		varY = null;
}
/*End Get Current Mouse Position Functions*/

/*Start A-Z Index Floating Menu*/
function LaunchFloatingMenu(evt)
{

	var url;
	if(document.URLUnencoded)
	{
		url = document.URLUnencoded;		
	}
	else
	{
		url = location.href;
	}
	
	if(url.match("AZIndex") != null )
	{	
		SetFloatingPaneMenu('floatingMenu');	
	}				
}

function PrepareMoveFloatingMenu()
{	
	LaunchFloatingMenu();
}

//when showing the A-Z index page this function handles the positioning of the floating index menu.
function SetFloatingPaneMenu(objID)
{	
	var BoxHeight = 60;
	var BoxWidth = 250;
	var BoxRight = 15;
	var BoxTop = 200;
	var obj = document.getElementById(objID);
	if(obj != null)
	{			
		with( obj.style ) 
		{			
			var screenOffset;
			if(document.documentElement.scrollTop)
			{
				screenOffset = document.documentElement.scrollTop
			}
			else
			{
				screenOffset = document.body.scrollTop
			}
			display = DISPLAY_STYLE_BLOCK;
			top = (BoxTop + screenOffset) + PIXEL_ABBREVIATION;
			right= BoxRight + PIXEL_ABBREVIATION;			
			height = BoxHeight + PIXEL_ABBREVIATION;
			width = BoxWidth + PIXEL_ABBREVIATION;			
		}
	}	
}
/*End A-Z Index Floating Menu*/

/* Major Hack To bypass the inability to detect if browser has CSS turned off will hide the redundant CSA crest if
CSS is turned off.*/
function HideExtraLabel()
{
	var alertVal;
	// this element is used to determine if CSS is enabled in the web page (if it's style for cursor is set
	// ro crosshairs then you know it was set in the CSS)
	var obj = document.getElementById("cssEnabledDetect");	
	
	// this is used to get the currently applied style for either firefox or ie and store
	// the value of the cursor for a later comparison
	if(!obj.currentStyle)
	{	
		alertVal = window.getComputedStyle(obj,null).cursor
	}
	else
	{		
		alertVal = obj.currentStyle.cursor;
	}	
		
	// if the value is equal to crosshairs then you know that css is being applied
	// now we set the src and alt properties to that of the image as it should be when css is enabled.
	if(alertVal == "crosshair")
	{
		var objToHide = document.getElementById("PrintLogo");
		objToHide.src = "Resources/Images/CSACrestprint.gif";
		objToHide.alt = "Australian Government Child Support Agency Crest";
	}			
}