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(SDate, Frm, Field)
{
	strPopupURL = document.location.protocol + '\/\/' + document.location.host;

	window.open(strPopupURL + '/popups/datepicker.cfm?sdate=' + SDate + '&frm=' + Frm + '&field=' + Field, 'datepicker', 'width=300,height=150,-resizable,-scrollbars,-menu');
}


function ScrollToTop()
{
	document.body.scrollTop = 0;
}

function ScrollToBottom()
{
	document.body.scrollTop = document.body.offsetHeight;
}


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;
}


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;
}
