
/* Called in body onload */

function init(){
	initializeLayerPositions();
}

function rotate() {

	if (document.images) {
	
		if (document.adBanner.complete) {
		
			thisAd++
		
			if (thisAd == imgCt) {
		
				thisAd = 0
			
			}
		
		document.adBanner.src=adImages[thisAd]

		}		
		setTimeout("rotate()", 3 * 1000)
		
		}
		
	}
	
		

/* Global variables for the Flash */ 

var flashinstalled = 0;
var flashinstalled = 0;
var flashversion   = 0;
MSDetect = "false";
if (navigator.plugins && navigator.plugins.length)
{
	x = navigator.plugins["Shockwave Flash"];
	if (x)
	{
		flashinstalled = 2;
		if (x.description)
		{
			y = x.description;
			flashversion = y.charAt(y.indexOf('.')-1);
		}
	}
	else
		flashinstalled = 1;
	if (navigator.plugins["Shockwave Flash 2.0"])
	{
		flashinstalled = 2;
		flashversion = 2;
	}
}
else if (navigator.mimeTypes && navigator.mimeTypes.length)
{
  x = navigator.mimeTypes['application/x-shockwave-flash'];
  if (x && x.enabledPlugin)
    flashinstalled = 2;
  else
    flashinstalled = 1;
}
else
	MSDetect = "true";
 

/* Global Nav */
var timerID = null; 
var timerOn = false; 
/* Menu will hide after this timeout (ms) */
var timecount = 400; 

function navOver(layerName){hideAll(); showLayer(layerName); stopTime();}
function navOut(){ startTime(); }


function showLayer(layerName) { 
	if (document.getElementById) {
		document.getElementById(layerName).style.left = ((getAnchorPosition(layerName+'Link').x)-1) + 'px';
		document.getElementById(layerName).style.visibility="visible"; 
	}
	} 
function hideLayer(layerName) { 	if (document.getElementById) {document.getElementById(layerName).style.visibility="hidden";} } 

function hideAll() {
	//Put all layers used in the nav here.  
	if (document.getElementById) {
	hideLayer("navSolutions"); hideLayer("navProducts"); hideLayer("navServices"); hideLayer("navPartners");  
	}
} 

function startTime() {  if (timerOn == false) {  timerID=setTimeout("hideAll()" , timecount);  timerOn = true;  }  } 
function stopTime() {  if (timerOn) {  clearTimeout(timerID);  timerID = null;  timerOn = false;  }  } 
function onLoad() {  init();  } 


/*

Browser detection

Used for homepage Flash 
*/

    // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();
    
    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is_ie5up to detect IE5.
    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);
    var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie3    = (is_ie && (is_major < 4));
    var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
    var is_ie4up  = (is_ie && (is_major >= 4));
    var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
    var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
    var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
    var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
    var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);
    var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
     var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    var is_nav6 = (is_nav && (is_major == 5));



/*
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/

function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_on'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

//window.onload = initRollovers;
//Moved this into the layer initialization code



// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download. 
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================

/* 
AnchorPosition.js
Author: Matt Kruse
Last modified: 10/11/02

DESCRIPTION: These functions find the position of an <A> tag in a document,
so other elements can be positioned relative to it.

COMPATABILITY: Netscape 4.x,6.x,Mozilla, IE 5.x,6.x on Windows. Some small
positioning errors - usually with Window positioning - occur on the 
Macintosh platform.

FUNCTIONS:
getAnchorPosition(anchorname)
  Returns an Object() having .x and .y properties of the pixel coordinates
  of the upper-left corner of the anchor. Position is relative to the PAGE.

getAnchorWindowPosition(anchorname)
  Returns an Object() having .x and .y properties of the pixel coordinates
  of the upper-left corner of the anchor, relative to the WHOLE SCREEN.

NOTES:

1) For popping up separate browser windows, use getAnchorWindowPosition. 
   Otherwise, use getAnchorPosition

2) Your anchor tag MUST contain both NAME and ID attributes which are the 
   same. For example:
   <A NAME="test" ID="test"> </A>

3) There must be at least a space between <A> </A> for IE5.5 to see the 
   anchor tag correctly. Do not do <A></A> with no space.
*/ 

// getAnchorPosition(anchorname)
//   This function returns an object having .x and .y properties which are the coordinates
//   of the named anchor, relative to the page.
function getAnchorPosition(anchorname) {
	// This function will return an Object with x and y properties
	var useWindow=false;
	var coordinates=new Object();
	var x=0,y=0;
	// Browser capability sniffing
	var use_gebi=false, use_css=false, use_layers=false;
	if (document.getElementById) { use_gebi=true; }
	else if (document.all) { use_css=true; }
	else if (document.layers) { use_layers=true; }
	// Logic to find position
 	if (use_gebi && document.all) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_gebi) {
		var o=document.getElementById(anchorname);
		x=AnchorPosition_getPageOffsetLeft(o);
		y=AnchorPosition_getPageOffsetTop(o);
		}
 	else if (use_css) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_layers) {
		var found=0;
		for (var i=0; i<document.anchors.length; i++) {
			if (document.anchors[i].name==anchorname) { found=1; break; }
			}
		if (found==0) {
			coordinates.x=0; coordinates.y=0; return coordinates;
			}
		x=document.anchors[i].x;
		y=document.anchors[i].y;
		}
	else {
		coordinates.x=0; coordinates.y=0; return coordinates;
		}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
	}

// getAnchorWindowPosition(anchorname)
//   This function returns an object having .x and .y properties which are the coordinates
//   of the named anchor, relative to the window
function getAnchorWindowPosition(anchorname) {
	var coordinates=getAnchorPosition(anchorname);
	var x=0;
	var y=0;
	if (document.getElementById) {
		if (isNaN(window.screenX)) {
			x=coordinates.x-document.body.scrollLeft+window.screenLeft;
			y=coordinates.y-document.body.scrollTop+window.screenTop;
			}
		else {
			x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
			y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
			}
		}
	else if (document.all) {
		x=coordinates.x-document.body.scrollLeft+window.screenLeft;
		y=coordinates.y-document.body.scrollTop+window.screenTop;
		}
	else if (document.layers) {
		x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
		y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
		}
	coordinates.x=x;
	coordinates.y=y;
	  window.status=x; 
        return true; 
//        return coordinates;
	}
	
// Functions for IE to get position of an object
function AnchorPosition_getPageOffsetLeft (el) {
	var ol=el.offsetLeft;
	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
	return ol;
	}
function AnchorPosition_getWindowOffsetLeft (el) {
	return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
	}	
function AnchorPosition_getPageOffsetTop (el) {
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null) { ot += el.offsetTop; }
	return ot;
	}
function AnchorPosition_getWindowOffsetTop (el) {
	return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
	}


 function hideInputs(object){
  var menuIndex = object.options[object.selectedIndex].value;
    if (menuIndex == 'Afghanistan' || menuIndex == 'Albania' || menuIndex == 'Algeria' || menuIndex == 'Andorra' || menuIndex == 'Angola' || menuIndex == 'Armenia' || menuIndex == 'Austria' || menuIndex == 'Azerbaijan' || menuIndex == 'Bahrain' || menuIndex == 'Bangladesh' || menuIndex == 'Belarus' || menuIndex == 'Belgium' || menuIndex == 'Benin' || menuIndex == 'Bhutan' || menuIndex == 'Bosnia-Herzegovina' || menuIndex == 'Botswana' || menuIndex == 'Bulgaria' || menuIndex == 'Burkina' || menuIndex == 'Burundi' || menuIndex == 'Cambodia' || menuIndex == 'Cameroon' || menuIndex == 'Cape Verde' || menuIndex == 'Central African Republic' || menuIndex == 'Chad' || menuIndex == 'Comoros' || menuIndex == 'Congo' || menuIndex == 'Congo (Dem. Rep.)' || menuIndex == 'Croatia' || menuIndex == 'Cyprus' || menuIndex == 'Czech Republic' || menuIndex == 'Denmark' || menuIndex == 'Djibouti' || menuIndex == 'Egypt' || menuIndex == 'Equatorial Guinea' || menuIndex == 'Eritrea' || menuIndex == 'Estonia' || menuIndex == 'Ethiopia' || menuIndex == 'Finland' || menuIndex == 'France' || menuIndex == 'Gabon' || menuIndex == 'Gambia' || menuIndex == 'Georgia' || menuIndex == 'Germany' || menuIndex == 'Ghana' || menuIndex == 'Greece' || menuIndex == 'Guinea' || menuIndex == 'Guinea-Bissau' || menuIndex == 'Hungary' || menuIndex == 'Iceland' || menuIndex == 'India' || menuIndex == 'Ireland' || menuIndex == 'Israel' || menuIndex == 'Italy' || menuIndex == 'Ivory Coast' || menuIndex == 'Jordan' || menuIndex == 'Kazakhstan' || menuIndex == 'Kenya' || menuIndex == 'Kuwait' || menuIndex == 'Kyrgyzstan' || menuIndex == 'Latvia' || menuIndex == 'Lebanon' || menuIndex == 'Lesotho' || menuIndex == 'Liberia' || menuIndex == 'Liechtenstein' || menuIndex == 'Lithuania' || menuIndex == 'Luxembourg' || menuIndex == 'Macedonia' || menuIndex == 'Madagascar' || menuIndex == 'Malawi' || menuIndex == 'Maldives' || menuIndex == 'Mali' || menuIndex == 'Malta' || menuIndex == 'Mauritania' || menuIndex == 'Mauritius' || menuIndex == 'Moldova' || menuIndex == 'Monaco' || menuIndex == 'Morocco' || menuIndex == 'Mozambique' || menuIndex == 'Namibia' || menuIndex == 'Nepal' || menuIndex == 'Netherlands' || menuIndex == 'Niger' || menuIndex == 'Nigeria' || menuIndex == 'Norway' || menuIndex == 'Oman' || menuIndex == 'Pakistan' || menuIndex == 'Poland' || menuIndex == 'Portugal' || menuIndex == 'Qatar' || menuIndex == 'Romania' || menuIndex == 'Russian Federation' || menuIndex == 'Rwanda' || menuIndex == 'San Marino' || menuIndex == 'Sao Tome & Principe' || menuIndex == 'Saudi Arabia' || menuIndex == 'Senegal' || menuIndex == 'Serbia/Montenegro (Yugoslavia)' || menuIndex == 'Seychelles' || menuIndex == 'Sierra Leone' || menuIndex == 'Slovakia' || menuIndex == 'Slovenia' || menuIndex == 'Somalia' || menuIndex == 'South Africa' || menuIndex == 'Spain' || menuIndex == 'Sri Lanka' || menuIndex == 'Swaziland' || menuIndex == 'Sweden' || menuIndex == 'Switzerland' || menuIndex == 'Tajikistan' || menuIndex == 'Tanzania' || menuIndex == 'Togo' || menuIndex == 'Tunisia' || menuIndex == 'Turkey' || menuIndex == 'Turkmenistan' || menuIndex == 'Uganda' || menuIndex == 'Ukraine' || menuIndex == 'United Arab Emirates (UAE)' || menuIndex == 'United Kingdom' || menuIndex == 'Uzbekistan' || menuIndex == 'Vatican City' || menuIndex == 'Yemen' || menuIndex == 'Zambia' || menuIndex == 'Zimbabwe'){
      document.getElementById("hide").style.display = 'block';
                               }
     else
     {
       document.getElementById("hide").style.display = 'none';
      }
   
    if (menuIndex == 'United States' || menuIndex == 'Canada')
    { 
     document.getElementById("hidestate").style.display = 'block';
    } 
    else 
    {
     document.getElementById("hidestate").style.display = 'none';
     document.finfo.state.options[0].selected = true;
     
     if(document.finfo.acode)
     {
      document.getElementById("hideacode").style.display = 'none'; 
      document.finfo.acode.options[0].selected = true;
     } 
   }   
 }     
      
 function hideCode(object){
  var menuIndex = object.options[object.selectedIndex].value;
    
    if (menuIndex == 'CA')
    { 
     document.getElementById("hideacode").style.display = 'block';
    } 
    else 
    {
     document.getElementById("hideacode").style.display = 'none';
    } 
   
   }   
      
      
 
 function ValidateAll()
{
	if(CheckName(document.finfo.name.value) == false) return false;
	if(CheckJobtitle(document.finfo.title.value) == false) return false;
	if(CheckCompany(document.finfo.company.value) == false) return false;
	if(CheckCountry(document.finfo.country.value) == false) return false;
	if(CheckEmail(document.finfo.email.value) == false) return false;
	if(CheckIndustry(document.finfo.industry.value) == false) return false;
	return true;
}

function StripSpacesFromEnds(s)
{

	while((s.indexOf(' ',0) == 0) && (s.length > 1))
	{
		s = s.substring(1,s.length);
	}
	while((s.lastIndexOf(' ') == (s.length - 1) && (s.length > 1)))
	{
		s = s.substring(0,(s.length - 1));
	}
	if((s.indexOf(' ',0) == 0) && (s.length == 1)) s = '';
	return s;
}

function IsItPresent(s,explanation)
{

	s = StripSpacesFromEnds(s);
	if(s.length) return s;
	alert('Please ' + explanation + '.');
	return '';
}

function CheckName(s_name)
{

	s_name = IsItPresent(s_name,'enter your name');
	if(! s_name) return false;

	document.finfo.name.value = s_name;
	return true;
}

function CheckJobtitle(s_title)
{

	s_title = IsItPresent(s_title,'select your job title');
	if(! s_title) return false;

	document.finfo.title.value = s_title;
	return true;
}

function CheckCompany(s_company)
{

	s_company = IsItPresent(s_company,'enter your company');
	if(! s_company) return false;

	document.finfo.company.value = s_company;
	return true;
}

function CheckState(s_state)
{
	s_state = IsItPresent(s_state,'select your state');
	if(! s_state) return false;

	document.finfo.state.value = s_state;
	return true;
}

function CheckCountry(s_country)
{

	s_country = IsItPresent(s_country,'select your country');
	if(! s_country) return false;

	document.finfo.country.value = s_country;
	
	
	
	if((document.finfo.country.value == 'United States' || document.finfo.country.value == 'Canada') && document.finfo.state && document.finfo.state.value == "")

	{ 
	  alert("Please select state");
	  return false;
	}

        if((document.finfo.country.value != 'United States' && document.finfo.country.value != 'Canada'))
	
	{
	
	 document.finfo.state.value = "";
	 
	 }

	if(document.finfo.state.value != 'CA')
	
	{
	
	 document.finfo.acode.value = "";
	 
	 }
	 	

	if(document.finfo.state && (document.finfo.country.value== 'United States' || document.finfo.country.value== 'Canada') && document.finfo.state.value=="CA" && document.finfo.acode.value=="")

	{

	  alert("Please select area code");
	  return false;

	}  
	

	return true;
}

function CheckEmail(s_email)
{

	s_email = IsItPresent(s_email,'enter your email address');
	if(! s_email) return false;
	var i = s_email.indexOf(' ',0);
	while(i > -1)
	{
		s_email = s_email.substring(0,i) +
			s_email.substring((i + 1),s_email.length);
		i = s_email.indexOf(' ',0);
	}
	document.finfo.email.value = s_email;
	if((s_email.length < 6) ||
	   (s_email.indexOf('@',0) < 1) ||
	   (s_email.lastIndexOf('@') != s_email.indexOf('@',0)) ||
	   (s_email.lastIndexOf('@') > (s_email.length - 5)) ||
	   (s_email.lastIndexOf('.') > (s_email.length - 3)) ||
	   (s_email.lastIndexOf('.') < (s_email.length - 4)) ||
	   (s_email.indexOf('..',0) > -1) ||
	   (s_email.indexOf('@.',0) > -1) ||
	   (s_email.indexOf('.@',0) > -1) ||
	   (s_email.indexOf(',',0) > -1))
	{
		alert('The email address "' + s_email + '" is not valid. Please re-enter.');
		return false;
	}
	return true;
}

function CheckPhone(s_phone)
{

	s_phone = IsItPresent(s_phone,'enter your phone');
	if(! s_phone) return false;

	document.finfo.phone.value = s_phone;
	return true;
}

function CheckIndustry(s_industry)
{

	s_industry = IsItPresent(s_industry,'select your industry');
	if(! s_industry) return false;

	document.finfo.industry.value = s_industry;
	return true;
}
function CheckVertical(s_vertical)
{

	s_vertical = IsItPresent(s_vertical,'select your vertical');
	if(! s_vertical) return false;

	document.finfo.vertical.value = s_vertical;
	return true;
}
