/********************************************************************
* 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];}
}
//-->


function make_blank(controlID)
{
    var control = document.getElementById(findControl(controlID));
    if (control != null) {
        if (control.value == "")//search the site
        {    
        control.value= "";
        }
    }
}
function fill_box(controlID)
{
    var control = document.getElementById(findControl(controlID));
    if (control != null) {
        if (control.value == "")
        {    
        control.value= "search the site";
        }
    }
}




function $(id) {
	return document.getElementById(id);
    }
function show(id)
{
 
   im = $("s" + id) ;

	imsrc = new String(im.src);  
 
   if (imsrc.indexOf("/images/li_callout.gif") > -1 )
   {
        im.src = "/images/li_callout_open.gif" ;

	  
  }
   else
   {
        im.src = "/images/li_callout.gif" ;
   
   }
 
}
function isValidEmail(email, required) {
    if (required==undefined) {   // if not specified, assume it's required
        required=true;
    }
    if (email==null) {
        if (required) {
            return false;
        }
        return true;
    }
    if (email.length==0) {  
        if (required) {
            return false;
        }
        return true;
    }
    if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
        return false;
    } else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
        return false;
    } else if (email.indexOf("@") == email.length) {  // @ must not be the last character
        return false;
    } else if (email.indexOf("..") >=0) { // two periods in a row is not valid
	return false;
    } else if (email.indexOf(".") == email.length) {  // . must not be the last character
	return false;
    }
    return true;
}
function allValidChars(email) {
  var parsed = true;
  var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
  for (var i=0; i < email.length; i++) {
    var letter = email.charAt(i).toLowerCase();
    if (validchars.indexOf(letter) != -1)
      continue;
    parsed = false;
    break;
  }
  return parsed;
}


function findControlSpan(controlid)
{
    var spanElements = document.getElementsByTagName('span');
	for (y=0; y < spanElements.length;y++)
	{
	    f = spanElements[y] ;
	
	    if (f != null)
	    {
		    if (f.id.indexOf(controlid) > 0 )
		    {
			    return f.id ;
		    }
	    }
    }
}


function ClientValidate(source, arguments)
{
    if (arguments.Value == "")
    {
        var lbl=document.getElementById(findControlSpan(source.name));
        lbl.className="required";
    }
    else
    {
        var lbl=document.getElementById(findControlSpan(source.name));
        lbl.className="formLabel";
    }
}
	
function doSearchPageHome()
{
	val = document.getElementById("txtSearch").value ;
	if ((val !== "") && (val !== "search the site"))
	{
		window.location.href = "/search/default.aspx?zoom_query=" + val ;
	}
}
function checkEnter(e)
{
					
	if (!e) var e = window.event
	if (e.keyCode) code = e.keyCode;
	else if (e.which) code = e.which;

			
	if (code == 13) {
			
		doSearchPageHome();
		return false;
				
		}
				
}

function show(id)
{        
    el2 = document.getElementById (id); 
    stropen = "/images/li_callout_open.gif";   
    strclosed =  "/images/li_callout.gif";          
    if (id == "gn1")
    {
        
        if (el2.src.indexOf("/images/li_callout_open.gif") == -1)
        {
            document.getElementById ("bn1").src = strclosed;
            el2.src = stropen
        }
        else
        {
            // do nothing
        }    
    
    }
    else
    {
         if (el2.src.indexOf("/images/li_callout_open.gif") == -1)
        {
            document.getElementById ("gn1").src = strclosed;
            el2.src = stropen
        }
        else
        {
            // do nothing
        }    
    
    }  
    

}


function doSubmit()
{
       
    var errors = "";
    var q = "";
    
    var em = document.getElementById ("Oemail").value;
    var fname = document.getElementById ("Ofirstname").value;
    var lname = document.getElementById ("Olastname").value;
    var company = document.getElementById ("Ocompany").value;
    var el = document.getElementById ("Oindustries");
    var industry = el.options[el.selectedIndex].value ;
    document.getElementById ("errors").innerHTML = "";
	
	document.getElementById ("reqf").className = "";
	document.getElementById ("reqe").className = "";
	if(!isValidEmail(em) )
	{
	        document.getElementById ("reqf").className = "required";
	      	document.getElementById ("reqf").innerHTML = "<b>*</b>";
	      	errors = "1";
	}
	
	if (fname == "")
	{
	        document.getElementById ("reqe").className = "required";
	      	document.getElementById ("reqe").innerHTML = "<b>*</b>";
	      	errors = "1";
	}
	
	if (errors.length > 0)
	{
	    document.getElementById ("errors").innerHTML = "<span class='required'>Please correct the following</span>";
	}
	else
	{
	
	    q="/ui/submitOptin.aspx?email=" + em + "&firstname=" + fname + "&lastname=" + lname + "&company=" + company + "&industry=" + industry; 
	    var loader1 = new net.ContentLoader(q, updatedisplay,null,"GET","");	
	}

}
function updatedisplay()
{
   
    if (this.req.responseText == "1")
    {
      
        document.getElementById ("titleimage").src = "/images/thankyou.gif";
        document.getElementById ("Oemail").value = "";
        document.getElementById ("Ofirstname").value = "";
        document.getElementById ("Olastname").value = "";
        document.getElementById ("Ocompany").value = "";
        
    }
    else
    {
        respo = "We're sorry, there was a problem adding you to the list, please try again later.";
        document.getElementById ("errors").innerHTML = respo;
    }
   
}

function closePop() {

    var obj;
    if (typeof(jQuery) != 'undefined')
        obj = jQuery('a[id*="FooterNav_rptFooter"]')[0];
    else
        obj = document.getElementById("ctl00_FooterNav_rptFooter_ctl00_link");
    var frompos = new Spry.Effect.Utils.Position();
    frompos.x = 500;
    frompos.y = findPosY(obj) - 345;
    var topos = new Spry.Effect.Utils.Position();
    topos.x = 500;
    topos.y = findPosY(obj);
    Spry.Effect.makePositioned(document.getElementById("popcontainer"));

    var slide_toggle = new Spry.Effect.Move ('popcontainer',frompos,topos,{duration:700, toggle: true, finish: turnoff} ); //{duration:1300,from:'0px', to:'1694px'});
    slide_toggle.start();
}
function turnoff()
{
    document.getElementById ("popcontainer").style.display = "none";
}
function openpop()
{

    var obj;
    if (typeof (jQuery) != 'undefined')
        obj = jQuery('a[id*="FooterNav_rptFooter"]')[0];
    else
        obj = document.getElementById("ctl00_FooterNav_rptFooter_ctl00_link");
    document.getElementById("popcontainer").style.display = "block";
    var frompos = new Spry.Effect.Utils.Position();
    frompos.x = 500;
    frompos.y = findPosY(obj);
    var topos = new Spry.Effect.Utils.Position();
    topos.x = 500;
    topos.y = findPosY(obj) - 345;
    Spry.Effect.makePositioned(document.getElementById("popcontainer"));

    var slide_toggle = new Spry.Effect.Move ('popcontainer',frompos,topos,{duration:700, toggle: true} ); //{duration:1300,from:'0px', to:'1694px'});
    slide_toggle.start();
}

function opennextstep(link, container) {

    var obj = document.getElementById(link);
    //document.getElementById(container).style.display = "block";
    var frompos = new Spry.Effect.Utils.Position();
    frompos.x = 500;
    frompos.y = findPosY(obj);
    var topos = new Spry.Effect.Utils.Position();
    topos.x = 500;
    topos.y = findPosY(obj) - 345;
    Spry.Effect.makePositioned(document.getElementById(container));
    document.getElementById(container).style.top = frompos.y + 'px';
    //var slide_toggle = new Spry.Effect.Move(container, frompos, topos, { duration: 700, toggle: true }); //{duration:1300,from:'0px', to:'1694px'});
    var slide_toggle = new Spry.Effect.Slide(container, { duration: 200, from: '0px', to: '200px', horizontal: true, toggle: true });

    slide_toggle.start();
}

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
}

function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent)
        while (1) {
        curleft += obj.offsetLeft;
        if (!obj.offsetParent)
            break;
        obj = obj.offsetParent;
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}
  function swapSubmit(f)
  {
    if (f==1)
    {
    document.getElementById ("btnsubmit").src = "/images/btn_submit_on.gif";
    }
    else
    {
    document.getElementById ("btnsubmit").src = "/images/btn_submit.gif";
    }
  }
  
  function doSubmit2()
{
       
    var errors = "";
    var q = "";
    
    var em = document.getElementById ("Oemail2").value;
    var fname = document.getElementById ("Ofirstname2").value;
    var lname = document.getElementById ("Olastname2").value;
    var company = document.getElementById ("Ocompany2").value;
    var el = document.getElementById ("Oindustries2");
    var industry = el.options[el.selectedIndex].value ;
    document.getElementById ("errors2").innerHTML = "";
	
	document.getElementById ("reqf2").className = "";
	document.getElementById ("reqe2").className = "";
	if(!isValidEmail(em) )
	{
	        document.getElementById ("reqf2").className = "required";
	      	document.getElementById ("reqf2").innerHTML = "<b>*</b>";
	      	errors = "1";
	}
	
	if (fname == "")
	{
	        document.getElementById ("reqe2").className = "required";
	      	document.getElementById ("reqe2").innerHTML = "<b>*</b>";
	      	errors = "1";
	}
	
	if (errors.length > 0)
	{
	    document.getElementById ("errors2").innerHTML = "<span class='required'>Please correct the following</span>";
	}
	else
	{
	
	    q="/ui/submitOptin.aspx?email=" + em + "&firstname=" + fname + "&lastname=" + lname + "&company=" + company + "&industry=" + industry; 
	    var loader1 = new net.ContentLoader(q, updatedisplay2,null,"GET","");	
	}

}
function updatedisplay2()
{
   
    if (this.req.responseText == "1")
    {
      
        document.getElementById ("titleimage2").src = "/images/thankyou.gif";
        document.getElementById ("Oemail2").value = "";
        document.getElementById ("Ofirstname2").value = "";
        document.getElementById ("Olastname2").value = "";
        document.getElementById ("Ocompany2").value = "";
        
    }
    else
    {
        respo = "We're sorry, there was a problem adding you to the list, please try again later.";
        document.getElementById ("errors2").innerHTML = respo;
    }
   
}

function closePop2()
{
    var obj = document.getElementById ("optinlink");
    var frompos = new Spry.Effect.Utils.Position();
    frompos.x = 500;
    frompos.y = findPosY(obj) - 50;
    var topos = new Spry.Effect.Utils.Position();
    topos.x = 500;
    //topos.y = findPosY(obj);
    topos.y = -500 ;
    Spry.Effect.makePositioned(document.getElementById("popcontainer2"));

    var slide_toggle = new Spry.Effect.Move ('popcontainer2',frompos,topos,{duration:700, toggle: true, finish: turnoff} ); //{duration:1300,from:'0px', to:'1694px'});
    slide_toggle.start();
}
function turnoff2()
{
    document.getElementById ("popcontainer2").style.display = "none";
}
function openpop2()
{

    var obj = document.getElementById ("optinlink");
    document.getElementById ("popcontainer2").style.display = "block";
    var frompos = new Spry.Effect.Utils.Position();
    frompos.x = 500;
   // frompos.y = findPosY(obj);
    frompos.y = -500;
    var topos = new Spry.Effect.Utils.Position();
    topos.x = 500;
    topos.y = findPosY(obj) - 50;
    Spry.Effect.makePositioned(document.getElementById("popcontainer2"));

    var slide_toggle = new Spry.Effect.Move ('popcontainer2',frompos,topos,{duration:700, toggle: true} ); //{duration:1300,from:'0px', to:'1694px'});
    slide_toggle.start();
}
