/********************************************************************
* Copyright ©  Acsys, Inc.  All rights reserved.
* 
* This material contains the valuable properties and trade secrets of
* Acsys, Inc. embodying substantial creative efforts and confidential 
* information, ideas, and expressions, no part of which may be 
* reproduced or transmitted in any form or by any means, electronic, 
* mechanical, or otherwise, including photocopying and recording or 
* in connection with any information storage or retrieval system 
* without the permission in writing of Acsys, Inc.
*/

/********************************************************************
* This is the main Acsys javascript library. When working with any
* of the javascript libraries, it is recommended that you include
* this file. This library also defines a class for sniffing the 
* browser type and plug-in support.  It is roughly meant to be a 
* client side browser capabilities object.
*/

/********************************************************************
* 
* Dependencies: 
*	None
*/

// Constants used by this file
var MAX_FLASH_VERSION = 6

// Create a global browser capabilities.
var browser = new BrowserCapabilities();
// array for storing references to onload functions
var onLoadFunctionsAcsys=[];

var onLoadAttached = false;


/********************************************************************
* The input argument must be a string type.
*/

function AddWindowOnload(f)
{
    if(!document.getElementById)
    {
        return;
    }
    
	if (typeof(f) != "string") return;
	onLoadFunctionsAcsys[onLoadFunctionsAcsys.length] = f;

	if (!onLoadAttached)
	{
		if (window.addEventListener)
		{
			window.addEventListener('load', AcsysWindowLoad, false);
		}
		else
		{
			window.attachEvent('onload', AcsysWindowLoad);
		}
	}
}

function AcsysWindowLoad()
{
	for (var i=0,len=onLoadFunctionsAcsys.length;
		i<len;
		eval(onLoadFunctionsAcsys[i++])
	);
}


/********************************************************************
* This class encapsulates the version of the current browser and also
* provides information javascript and flash capabilities.
*/
function BrowserCapabilities()
{
	this.IsMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
	this.IsWindows = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;
	this.IsNN4 = (document.layers) ? true : false;
	this.IsIE = (document.all) ? true : false;
	this.IsIE4 = this.IsIE && !document.getElementById ? true : false;
	this.IsDOM = document.getElementById ? true : false;
	this.IsIEmac = ((this.IsIE)&&(this.IsMac)) ? true : false;
	this.JavaScript = new JavaScriptSupport(this);
	this.Flash = new FlashSupport(this);
}

function JavaScriptSupport(browserCapabilities)
{
	this.SniffVersions = _JavaScriptSupport_SniffVersion;
	this.SniffVersions();
	this.Browser = browserCapabilities;
	this.Version1_0 = window["JavaScript1_0"];
	this.Version1_1 = window["JavaScript1_1"];
	this.Version1_2 = window["JavaScript1_2"];
	this.Version1_3 = window["JavaScript1_3"];
	this.Version1_4 = window["JavaScript1_4"];
}

function _JavaScriptSupport_SniffVersion()
{
	window["JavaScript1_0"] = false;
	window["JavaScript1_1"] = false;
	window["JavaScript1_2"] = false;
	window["JavaScript1_3"] = false;
	window["JavaScript1_4"] = false;

	document.write('<SCR' + 'IPT LANGUAGE="JavaScript"\>\n');
	document.write('JavaScript1_0 = true;\n');
	document.write('</SCR' + 'IPT\>\n');

	document.write('<SCR' + 'IPT LANGUAGE="JavaScript1.1"\>\n');
	document.write('JavaScript1_1 = true;\n');
	document.write('</SCR' + 'IPT\>\n');

	document.write('<SCR' + 'IPT LANGUAGE="JavaScript1.2"\>\n');
	document.write('JavaScript1_2 = true;\n');
	document.write('</SCR' + 'IPT\>\n');

	document.write('<SCR' + 'IPT LANGUAGE="JavaScript1.3"\>\n');
	document.write('JavaScript1_3 = true;\n');
	document.write('</SCR' + 'IPT\>\n');

	document.write('<SCR' + 'IPT LANGUAGE="JavaScript1.4"\>\n');
	document.write('JavaScript1_4 = true;\n');
	document.write('</SCR' + 'IPT\>\n');
}

function FlashSupport(browserCapabilities)
{
	this.SniffVersions = (browserCapabilities.IsWindows && 
		browserCapabilities.IsIE && 
		browserCapabilities.JavaScript.Version1_1)
		? _FlashSupport_SniffVersion_WindowsIE
		: _FlashSupport_SniffVersion_Other;

	this.VersionNumber = -1;
	this.MaxVersion = MAX_FLASH_VERSION;
	this.SniffVersions();
	this.Browser = browserCapabilities;
	this.Version2 = window["Flash2Installed"];
	this.Version3 = window["Flash3Installed"];
	this.Version4 = window["Flash4Installed"];
	this.Version5 = window["Flash5Installed"];
	this.Version6 = window["Flash6Installed"];
}

function _FlashSupport_SniffVersion_WindowsIE()
{
	window["Flash2Installed"] = false;
	window["Flash3Installed"] = false;
	window["Flash4Installed"] = false;
	window["Flash5Installed"] = false;
	window["Flash6Installed"] = false;

	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('Flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
	document.write('Flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
	document.write('Flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
	document.write('Flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');
	document.write('Flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');
	document.write('</SCR' + 'IPT\> \n');

	for (var i = 2; i <= this.MaxVersion; i++) 
	{
		if (window["Flash" + i + "Installed"] == true) 
		{
			this.VersionNumber = i;
		}
	}
}

function _FlashSupport_SniffVersion_Other()
{
	window["Flash2Installed"] = false;
	window["Flash3Installed"] = false;
	window["Flash4Installed"] = false;
	window["Flash5Installed"] = false;
	window["Flash6Installed"] = false;

	if (navigator.plugins)
	{
		if (navigator.plugins["Shockwave Flash 2.0"] || 
			navigator.plugins["Shockwave Flash"]) 
		{
			// Set convenient references to flash 2 and the plugin description.
			var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? true : false;
			var flashDescription = navigator.plugins["Shockwave Flash" + (isVersion2 ? " 2.0" : "")].description;

			var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));

			Flash2Installed = flashVersion == 2;
			Flash3Installed = flashVersion == 3;
			Flash4Installed = flashVersion == 4;
			Flash5Installed = flashVersion >= 5;
			Flash6Installed = flashVersion >= 6;
		}
	}

	for (var i = 2; i <= this.MaxVersion; i++) 
	{
		if (window["Flash" + i + "Installed"] == true) 
		{
			this.VersionNumber = i;
		}
	}

	if(navigator.userAgent.indexOf("WebTV") != -1)
	{
		this.VersionNumber = 3;
	}
}

function HideFlash(){
    document.getElementById('flash').style.visibility = 'hidden';
}

function ShowFlash(){
    document.getElementById('flash').style.visibility = 'visible';
}
function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
    else {
      
    }
  
  } 
 return "";
}

function findControl(controlid)
{

	for (y=0; y < document.forms.length;y++)
	{
	f = document.forms[y] ;
	
	
	for (r=0;r < f.length ; r++)
	{
	
		if (f.elements[r].id.indexOf(controlid) > 0 )
		{
			return f.elements[r].id ;
		}
	
	}
	}


}


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_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_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.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];}
}
//-->