
//Retrieve cookie, if it presents
cookie_name = "UICulture";
var YouWrote;

function getName() {
if(document.cookie)
{
index = document.cookie.indexOf(cookie_name);
if (index != -1)
{
namestart = (document.cookie.indexOf("=", index) + 1);
nameend = document.cookie.indexOf(";", index);
if (nameend == -1) {nameend = document.cookie.length;}
YouWrote = document.cookie.substring(namestart, nameend);
return YouWrote;
}
}
}

YouWrote=getName();
if (YouWrote == "UICulture")
{YouWrote = "Nothing_Entered"}


//LANGUAGE DROP DOWN MENU
//Contents for menu 1
var menu1=new Array()

if(YouWrote !=null)
{  
    switch(YouWrote)
    {
        case "en-US":
        case "fr-FR":
        case "es-MX":
        case "de-DE":
        case "pt-BR":
        case "zh-CN":
        case "ja-JP":
        case "ko-KR":
        menu1[0]='<a href="/index.aspx?country=us&remlang=1">English</a>'
        menu1[1]='<a href="/index.aspx?country=fr&remlang=1">Francais</a>'
        menu1[2]='<a href="/index.aspx?country=es&remlang=1">Espanol</a>'
        menu1[3]='<a href="/index.aspx?country=dg&remlang=1">Deutsch</a>'
        menu1[4]='<a href="/index.aspx?country=pe&remlang=1">Portuguese</a>'
        menu1[5]='<a href="/index.aspx?country=ch&remlang=1"><img src="/images/nav/title-china-gry.gif" /></a>'
        menu1[6]='<a href="/index.aspx?country=jp&remlang=1"><img src="/images/nav/title-japan-gry.gif"  /</a>'
        menu1[7]='<a href="/index.aspx?country=kr&remlang=1"><img src="/images/nav/title-korea-gry.gif" /</a>'
        break;
        default: break;
    }
}
else
{
        menu1[0]='<a href="/index.aspx?country=us&remlang=0">English</a>'
        menu1[1]='<a href="/index.aspx?country=fr&remlang=0">Francais</a>'
        menu1[2]='<a href="/index.aspx?country=es&remlang=0">Espanol</a>'
        menu1[3]='<a href="/index.aspx?country=dg&remlang=0">Deutsch</a>'
        menu1[4]='<a href="/index.aspx?country=pe&remlang=0">Portuguese</a>'
        menu1[5]='<a href="/index.aspx?country=ch&remlang=0"><img src="/images/nav/title-china-gry.gif" /></a>'
        menu1[6]='<a href="/index.aspx?country=jp&remlang=0"><img src="/images/nav/title-japan-gry.gif"  /</a>'
        menu1[7]='<a href="/index.aspx?country=kr&remlang=0"><img src="/images/nav/title-korea-gry.gif" /</a>'
    
}


/*var menu1=new Array()
menu1[0]='<a href="#">English</a>'
menu1[1]='<a href="#">Francais</a>'
menu1[2]='<a href="#">Espanol</a>'
menu1[3]='<a href="#">Deutsch</a>'
menu1[4]='<a href="#">Portuguese</a>'
menu1[5]='<a href="#"><img src="/images/nav/title-china-gry.gif" /></a>'
menu1[6]='<a href="#"><img src="/images/nav/title-japan-gry.gif"  /</a>'
menu1[7]='<a href="#"><img src="/images/nav/title-korea-gry.gif" /</a>'*/
		

var menubgcolor='black'  //menu bgcolor
var disappeardelay=150  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;background-color:'+menubgcolor+';" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top="-500px"
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden")
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu

   
   
   
   //ROTATING HOT STUF IMAGES
    var current;
    var numBtns = 5;
    var selectionBtns = new Array(numBtns);
    var imgarray = new Array(numBtns);
    imgarray[0] = '/images/home/hotstuff-sumx450a.gif';
    imgarray[1] = '/images/home/hotstuff-blk-diamond-12804c.jpg';
    imgarray[2] = '/images/home/hotstuff-summit-x450e-24p.jpg';
    imgarray[3] = '/images/home/hotstuff-blk-diamond-12804r.jpg';
    imgarray[4] = '/images/home/hotstuff-blk-diamond-12804c.jpg';

    var waitTime = 2500;

    var nextBtnTimeoutId;

    function startRotate() {
        current = 1;
        nextBtnTimeoutId = setTimeout("nextSelection()", waitTime);
    }

    function docimgChange(selection) {
        var el = document.getElementById('hotstuff');
        el.src = imgarray[selection - 1];
    }

    function nextSelection() {
        current++;
        if (current > numBtns) {
            current = 1;
        }

        //alert('highlightHotStuff('+current+')');
        highlightHotStuff('btn' + current);
	docimgChange(current);
        nextBtnTimeoutId = setTimeout("nextSelection()",waitTime);
    }

    function stopRotate() {
        window.clearTimeout(nextBtnTimeoutId);
    }
   
   
   
    //SHOWING AND HIDING DESCRIPTIONS ON SOLUTIONS PAGE(S)
    var items = new Array('solutions1', 'solutions2', 'solutions3', 'solutions4', 'solutions5', 'solutions6', 'solutions7', 'solutions8', 'solutions9', 'solutions10', 'solutions11', 'solutions12', 'solutions13', 'solutions14');
    var newItems = new Array('news', 'news2', 'news3');
    var curDiv;

var ids=new Array('a1','a2','a3','a4');

function switchid(id){	
	hideallids();
	showdiv(id);
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById && document.getElementById(id)) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers && document.id) { // Netscape 4
			document.id.display = 'none';
		}
		else if(document.all && document.all.id) { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

  //HIGHLIGHTING ACTIVE TABS IN SUBPAGES
  function highlightTab(targetBtnEl) {
    var btnIds = new Array("1", "2", "3", "4", "5");
    var targetBtnId = targetBtnEl.id;

    for (var i = 0; i < btnIds.length; i++) {
      var id = btnIds[i];
      var btnId = "tab" + id;
      var btnEl = document.getElementById(btnId);

      if (btnId == targetBtnId) {
        // target btn, so turn it on
        btnEl.className="subPageTabOn";

      } else {
        // other btns, so turn them off
        if(btnEl)
            btnEl.className="subPageTabOff";
      }
    }
  }


  //MARKER ON SOLUTIONS HUG PAGE
  function mark(targetBtnEl) {
    var btnIds = new Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12");
    var targetBtnId = targetBtnEl.id;

    for (var i = 0; i < btnIds.length; i++) {
      var id = btnIds[i];
      var btnId = "marker" + id;
      var btnEl = document.getElementById(btnId);

      if (btnId == targetBtnId) {
        // target btn, so turn it on
        btnEl.className="markerOn";

      } else {
        // other btns, so turn them off
        btnEl.className="markerOff";

      }
    }
  }



//SHOWING AND HIDING SOLUTIONS HUB DESCRIPTION TEXT

    function displayDiv(id) {
        for (var i=0; i<items.length; i++) {
            var divId = items[i];
            var divEl = document.getElementById(divId);
            if (divEl)
            {
                if (divId == id) {
                    // display the one we want
                    divEl.style.display="block";
                } else {
                    // turn off all others
                    divEl.style.display="none";
                }
            }
        }

    }
    
      //HIGHLIGHTING NUMBERS IN HOT STUFF SECTION ON HOME/INDEX PAGE
  function highlightHotStuff(targetBtnId) {
    var btnIds = new Array("1", "2", "3", "4", "5");

    for (var i = 0; i < btnIds.length; i++) {
      var id = btnIds[i];
      var btnId = "btn" + id;
      var btnEl = document.getElementById(btnId);

      var origSrc = btnEl.src;

      // get the first part of the image name, ie "/images/home/btn-hotstuff-1"
      var imagePrefix = origSrc.substring(0, origSrc.lastIndexOf("-"));
      if (btnId == targetBtnId) {
        // target btn, so turn it on
        btnEl.src = imagePrefix + "-on.gif";
      } else {
        // other btns, so turn them off
        btnEl.src = imagePrefix + "-off.gif";
      }
    }
  }



  //HIGHLIGHTING NUMBERS IN NEWS SECTION ON HOME/INDEX PAGE
  function highlightNews(targetBtnEl) {
    var btnIds = new Array("1", "2", "3");
    var targetBtnId = targetBtnEl.id;

    for (var i = 0; i < btnIds.length; i++) {
      var id = btnIds[i];
      var btnId = "btnNews" + id;
      var btnEl = document.getElementById(btnId);

      var origSrc = btnEl.src;

      // get the first part of the image name, ie "/images/home/btn-news-1"
      var imagePrefix = origSrc.substring(0, origSrc.lastIndexOf("-"));
      if (btnId == targetBtnId) {
        // target btn, so turn it on
        btnEl.src = imagePrefix + "-on.gif";
      } else {
        // other btns, so turn them off
        btnEl.src = imagePrefix + "-off.gif";
      }
    }
  }


	//SHOW AND HIDE NEWS TEXT ON INDEX/HOME PAGE
    function displayDivHome(id) {
        for (var i=0; i<newItems.length; i++) {
            var divId = newItems[i];
            var divEl = document.getElementById(divId);
            if (divEl)
            {
                if (divId == id) {
                    // display the one we want
                    divEl.style.display="block";
                } else {
                    // turn off all others
                    divEl.style.display="none";
                }
            }
        }

    }


    function addLoadEvent(func)
    {
        var oldonload = window.onload;
        if (typeof window.onload != 'function')
        {
            window.onload = func;
        }
        else
        {
            window.onload = function() {
                oldonload();
                func();
            }
        }
    }
    
    function updateContactInfo(elem)
    {
        var selectedValue = elem.options[elem.selectedIndex].value;
        var stateProvSelect = $('stateProvSelect');
        var countrySelect = $('countrySelect');
        var URL = '/data/contactInfo.aspx';
        var params = 'location=' + selectedValue;
        if (elem == stateProvSelect)
            countrySelect.selectedIndex = 0;
        else
            stateProvSelect.selectedIndex = 0;
        new Ajax.Updater('contactInfo', URL, { method: 'get', parameters: params });
    }
	
	
	//ROTATING HOME/INDEX TOP AND BOTTOM IMAGES
	var numPairs = 5;
	var topPics = new Array(numPairs);
	var bottomPics = new Array(numPairs);

	topPics[0] = "images/home/future-top.jpg";
	bottomPics[0] = "images/home/future-bottom.jpg";

	topPics[1] = "images/home/mitt-top.jpg";
	bottomPics[1] = "images/home/mitt-bottom.jpg";

	topPics[2] = "images/home/clocks-top.jpg";
	bottomPics[2] = "images/home/clocks-bottom.jpg";

	topPics[3] = "images/home/focal-top.jpg";
	bottomPics[3] = "images/home/focal-bottom.jpg";

	topPics[4] = "images/home/mask-top.jpg";
	bottomPics[4] = "images/home/mask-bottom.jpg";

	function selectPair() {
  	var randIndex=Math.floor(Math.random()*numPairs);

  	var topPicEl = document.getElementById('img1');
  	topPicEl.src = topPics[randIndex];
  	var bottomPicEl = document.getElementById('img2');
  	bottomPicEl.src = bottomPics[randIndex];

	}


	//DROP-DOWN MENU LINKING
	function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
	}



