var ns4 = ((navigator.appName == "Netscape") && document.layers)?1:0;
var ns6 = ((navigator.appName == "Netscape") && document.getElementById)?1:0;
var ie4 = ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4) && (navigator.userAgent.indexOf('Opera') == -1))?1:0;
var op6 = (navigator.userAgent.indexOf('Opera') != -1)?1:0;

if (op6 == 1) ns6 = 1;

function ScreenShot(Code, Type, Index1, Index2)
{
	strPopupURL = document.location.protocol + '\/\/' + document.location.host;

	window.open(strPopupURL + '/screenshot.cfm?code=' + Code + '&type=' + Type + '&index1=' + Index1 + '&index2=' + Index2, 'screenshotwin', 'width=640,height=580,resizable,scrollbars,-menu');
}
function PopupWindow(URL)
{
	strPopupURL = document.location.protocol + '\/\/' + document.location.host;

	window.open(strPopupURL + '/popup.cfm?file=' + escape(URL), '', 'width=640,height=500,-menu');
}

function PopupWindowEx(URL, Target, Width, Height)
{
	if (!Width) Width = 640;
	if (!Height) Height = 500;
	if (!Target) Target = '';
	
	window.open(URL, Target, 'width=' + Width + ',height=' + Height + ',-menu');
}

function ShowLayer(ID)
{
	bitIsVisible = -1;
	
	if (ie4 == 1)
		objLayer = document.all(ID);
	else if (ns4 == 1)
		objLayer = document.layers[ID];
	else if (ns6 == 1)
		objLayer = document.getElementById(ID);
	else
		return;

	if (ie4 == 1)
		if (objLayer.style.visibility != 'visible')
		{
			objLayer.style.visibility = 'visible';
			bitIsVisible = 1;
		}
		else
		{
			objLayer.style.visibility = 'hidden';
			bitIsVisible = 0;
		}
	else if (ns4 == 1)
		if (objLayer.visibility != 'show')
		{
			objLayer.visibility = 'show';
			
			if ((window.MouseMoveX > 0) || (window.MouseMoveY > 0))
			{
				objLayer.top = window.MouseMoveY;
				objLayer.left = window.MouseMoveX;
			}
		}
		else
			objLayer.visibility = 'hide';
	else if (ns6 == 1)
		if (objLayer.style.visibility != 'visible')
		{
			objLayer.style.visibility = 'visible';
			bitIsVisible = 1;
		}
		else
		{
			objLayer.style.visibility = 'hidden';
			bitIsVisible = 0;
		}

	return bitIsVisible;
}

function OpenerRelocate(Link)
{
	if (parent.opener)
		parent.opener.location = Link;
		
	parent.close();
}

function OpenerLink(Link)
{
	if (ie4 == 1)
	{
		if (parent.frames.length == 0)
			if (window.opener)
			{
				window.opener.location = Link;
				window.close();
			}
			else
				window.location = Link;
		else
		{
			parent.opener.location = Link;
			parent.close();
		}
	}
	else
	{
		if (parent.opener)
		{
			parent.opener.location = Link;
			parent.close();
		}
		else
			window.location = Link;
	}
}

function OpenerLinkEx(Link, Close)
{
	if (ie4 == 1)
	{
		if (parent.frames.length == 0)
			if (window.opener)
			{
				window.opener.location = Link;
				
				if (Close == 1)
					window.close();
			}
			else
				window.location = Link;
		else
		{
			parent.opener.location = Link;
			
			if (Close == 1)
				parent.close();
		}
	}
	else
	{
		if (parent.opener)
		{
			parent.opener.location = Link;
			
			if (Close == 1)
				parent.close();
		}
		else
			window.location = Link;
	}
}

function SwapImage(ID, Image)
{
	if (ie4 == 1)
		objImage = document.all(ID);
	else if (ns6 == 1)
		objImage = document.getElementById(ID);
	else
		return;

	if (ie4 == 1)
		objImage.src = Image;
	else if (ns6 == 1)
		objImage.src = Image;
}

function ShowLayerEx(ID, ImageID, ImageOn, ImageOff)
{
	bitIsVisible = ShowLayer(ID);
	
	if (bitIsVisible == 1)
		SwapImage(ImageID, ImageOn);
	else if (bitIsVisible == 0)
		SwapImage(ImageID, ImageOff);
}

function SwapLayerClass(ID, Class)
{
	if (ie4 == 1)
		objLayer = document.all(ID);
	else if (ns4 == 1)
		objLayer = document.layers[ID];
	else if (ns6 == 1)
		objLayer = document.getElementById(ID);
	else
		return;

	if (ie4 == 1)
		objLayer.className = Class;
	else if (ns4 == 1)
		objLayer.className = Class;
	else if (ns6 == 1)
		objLayer.className = Class;
}

function SwapLayerClassEx(ID, ImageID, Class, Image)
{
	SwapLayerClass(ID, Class);
	SwapImage(ImageID, Image);
}

function DatePicker(Path, SDate, Frm, Field)
{
	date_picker_win = window.open(Path + "/datepicker.htm?sdate=" + SDate + "&frm=" + Frm + "&field=" + Field, "datepicker", "width=300,height=200,-resizable,-scrollbars,-menu");
	date_picker_win.focus();
}

function HookResizeEvent(AProcedure)
{
  //window.onresize = AProcedure;
}


window.onresize = WindowResizeEventHandler;

function WindowResizeEventHandler()
{
  // Adjust screen size dependent items that are added through
  // the AddDependentScreenSizeItem function.
  AdjustScreenSizeDependentItems();


  if (window.OnResizeEvent)
    OnResizeEvent();
}


// Screen size dependent item functions
window.ScreenSizeDependentItems = new Array();
window.ScreenSizeDependentMinWidths = new Array();
window.ScreenSizeDependentMaxWidths = new Array();
window.ScreenSizeDependentAlternates = new Array();


function AddScreenSizeDependentItem(AItem, AMinWidth, AMaxWidth)
{
  window.ScreenSizeDependentItems[window.ScreenSizeDependentItems.length] = AItem;
  window.ScreenSizeDependentMinWidths[window.ScreenSizeDependentMinWidths.length] = AMinWidth;
  window.ScreenSizeDependentMaxWidths[window.ScreenSizeDependentMaxWidths.length] = AMaxWidth;
  window.ScreenSizeDependentAlternates[window.ScreenSizeDependentAlternates.length] = null;
}

function AddScreenSizeDependentItemWithAlternate(AItem, AMinWidth, AAlternate)
{
  window.ScreenSizeDependentItems[window.ScreenSizeDependentItems.length] = AItem;
  window.ScreenSizeDependentMinWidths[window.ScreenSizeDependentMinWidths.length] = AMinWidth;
  window.ScreenSizeDependentMaxWidths[window.ScreenSizeDependentMaxWidths.length] = null;
  window.ScreenSizeDependentAlternates[window.ScreenSizeDependentAlternates.length] = AAlternate;
}


function AdjustScreenSizeDependentItems()
{
  intWidth = GetDisplayWidth();
  blnVisible = false;

  if (window.ScreenSizeDependentItems.length == 0)
    return;


  for (x = 0; x < window.ScreenSizeDependentItems.length; x++)
  {
    strItem = window.ScreenSizeDependentItems[x];
    intMinWidth = window.ScreenSizeDependentMinWidths[x];
    intMaxWidth = window.ScreenSizeDependentMaxWidths[x];
    strAlternate = window.ScreenSizeDependentAlternates[x];

    if (intMinWidth == null)
      intMinWidth = 0;

    if (intMaxWidth == null)
      intMaxWidth = 999999;

    if (strAlternate == null)
      strAlternate = "";

    if ((intWidth > intMinWidth) && (intWidth < intMaxWidth))
    {
      blnVisible = true;
    }
  }  

  if (blnVisible)
  {
    SwapLayerClass(strItem, "VisibleDivClass");

    if (strAlternate != "")
      SwapLayerClass(strAlternate, "HiddenDivClass");
  }
  else
  {
    SwapLayerClass(strItem, "HiddenDivClass");

    if (strAlternate != "")
      SwapLayerClass(strAlternate, "VisibleDivClass");
  }
}


function GetDisplayWidth()
{
  if (document.body)
  {
    return document.body.clientWidth;
  }
  else
  {
    return 0;
  }
}

function ScrollToTop()
{
	document.body.scrollTop = 0;
}

function ScrollToBottom()
{
	document.body.scrollTop = document.body.offsetHeight;
}


function WindowsXpServicePack2Installed()
{
  blnResult = false;

  if (navigator.appName.indexOf("Internet Explorer") != -1)
  {
    if ((navigator.userAgent.indexOf("SV1;") != -1) || (navigator.userAgent.indexOf("SV1)") != -1))
    {
      blnResult = true;
    }
  }

  return blnResult;
}
function BrowserIsActiveXCompatible()
{
	blnResult = false;
	
	if (navigator.appName.indexOf("Internet Explorer") != -1)
	{
		// Set to true if the browser reports itself
		// as Internet Explorer
		blnResult = true;

		// Exclude Opera
		if (navigator.userAgent.indexOf("Opera") != -1)
			blnResult = false;
	}
	
	return blnResult;
}



window.setTimeout("AdjustScreenSizeDependentItems()", 100);
