var imgArr1 = new Array('tabHover-bg.gif','tabSelected-bg.gif','tabMenu-bg.gif');

function preLoadImages(array) {
    array=eval(array);
    var varArr = new Array();
    var len=array.length
    for(i=0;i<len;i++) {
        varArr[i] = new Image();
        varArr[i].src = '/images/'+array[i];
    }
}

preLoadImages(imgArr1);

function J$ (elemId) { return document.getElementById(elemId); }

function changeCursor(cntrl,choice) { cntrl.style.cursor=choice; }

function changeleftNavbg(cntrl,choice) {
    if(cntrl.className!="leftNavItemsSelected" && cntrl.className!="leftNavCategorySelected"  && cntrl.className!="leftNavSubItemsSelected"){
    switch(choice) {
        case 1: {
                    cntrl.style.cursor='pointer';
                    cntrl.className="leftNavItemsHover";
                    break;
                }
        case 2: {
                    cntrl.style.cursor='default';
                    cntrl.className="leftNavItems";
                    break;
                }
       case 3: {
                    cntrl.style.cursor='pointer';
                    cntrl.className="leftNavSubItemsHover";
                    break;
                }
        case 4: {
                    cntrl.style.cursor='default';
                    cntrl.className="leftNavSubItems";
                    break;
                }         
    }
   }
}

function goToUrl(url) {
    window.location.href=url;
}

/*
 *@description This function adds the selected class for the given divId
 *@Used in LeftNav
*/
function changeClass(divId) {
    if (J$(divId)) {
        J$(divId).className=J$(divId).className+"Selected";
    }
}

/* function for downloading/playing movies on the commercials page*/
function opMovWin(mov){
    window.open(mov,'theWin','width=360,height=305')
}

/******** Start the Advertisers horizontal nav functions *********/
var audience=['unitedonline','classmates_aud','nz_jn','mysite_aud','mypoints_aud'];
var adprograms=['classmates_ad','nz_jn_ad'];
var display=['banner','leaderboard','skyscraper','graphic','popup'];
var banner=['standard','vertical'];
var graphic=['premier', 'skybutton', 'searchbox', 'graphicbox','texticon', 'mediumrect', 'halfpage','loginout'];

function selectLink(linkName,arr) {
    arr=eval(arr);
    for(var i=0;i<arr.length;i++){
        J$(arr[i]).className="link fLeft";
        J$(arr[i]+"div").className="hide";
    }
    J$(linkName).className="selectedLink";
    J$(linkName+'div').className="";
}
/******** End the adformat nav functions *********/

/************ Start TAB functions **************/
var menu1Text=new Array ("About United Online","Management","Our History","UNTD FAQ's");
var menu1Link=new Array ("http://www.untd.com/companyinfo/about.html","http://www.untd.com/companyinfo/management.html","http://www.untd.com/companyinfo/history.html","http://www.untd.com/companyinfo/faqs.html");
var menu2Text=new Array ("Company Profile","Earnings Releases","Financial Data","SEC Filings","Press Releases","Email Alerts","Events Calendar","Management","Contact IR","Analyst Coverage","Corporate Governance","Stock Information","Information Request","Investor FAQ's");
var menu2Link=new Array ("http://investor.untd.com/index.cfm","http://investor.untd.com/earnings.cfm","http://investor.untd.com/financials.cfm","http://investor.untd.com/sec.cfm","http://investor.untd.com/releases.cfm","http://investor.untd.com/alerts.cfm","http://investor.untd.com/events.cfm","http://investor.untd.com/management.cfm","http://investor.untd.com/contactus.cfm","http://investor.untd.com/analysts.cfm","http://investor.untd.com/governance.cfm","http://investor.untd.com/stockquote.cfm","http://www.corpcom.net/fs/nzro/materialrequest.aspx","http://investor.untd.com/faq.cfm");
var menu3Text=new Array ("Press Releases","TV Commercials","Press Kit","Contact PR");
var menu3Link=new Array ("http://www.untd.com/presscenter/pressreleases.html","http://www.untd.com/presscenter/tvcommercials.html","http://www.untd.com/presscenter/presskit.html","http://www.untd.com/presscenter/contactpr.html");
var menu4Text=new Array ("Advertising Solutions","Case Studies","Sites","Audience","Ad Format","Ad Programs","Ad Specs","Ad Guidelines","Contact Media Group");
var menu4Link=new Array ("http://www.untd.com/advertisers/revamp_2008/adsolutions.html","http://www.untd.com/advertisers/revamp_2008/casestudies.html","http://www.untd.com/advertisers/revamp_2008/classmates.html","http://www.untd.com/advertisers/revamp_2008/mempurchasingpower.html","http://www.untd.com/advertisers/revamp_2008/display.html","http://www.untd.com/advertisers/revamp_2008/targeting.html","http://www.untd.com/advertisers/revamp_2008/adspecs.html","http://www.untd.com/advertisers/revamp_2008/adguidelines.html","http://www.untd.com/advertisers/revamp_2008/contactus.html");
var menu5Text=new Array ("Careers Overview","Benefits");
var menu5Link=new Array ("http://www.untd.com/careers/index.html","http://www.untd.com/careers/benefits.html");
var menu6Text=new Array ("Contact Info","Contact Form");
var menu6Link=new Array ("http://www.untd.com/contact/info.html","http://www.untd.com/contact/form.html");

var disappeardelay=50  //menu disappear speed onMouseout (in miliseconds)
var horizontaloffset=-13 //horizontal offset of menu from default location. (0-5 is a good value)
var tabOnId='';
var selectedTabId='';

function getElementPosition(elemID) {
    var offsetTrail = document.getElementById(elemID);
    var offsetLeft = 0;
    var offsetTop = 0;
    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != "undefined") {
        offsetLeft += parseInt(document.body.leftMargin);
        offsetTop += parseInt(document.body.topMargin);
    }
    return {left:offsetLeft, top:offsetTop};
}

function tabOn(obj,evt,tabId,textArr,linkArr) {
    changeCursor(obj,'pointer');
    dropdownMenu(evt,tabId,textArr,linkArr);
    for(i=1;i<7;i++)
        changeTabClass(tabId);
    if(tabId=='presscenter' || tabId=='contact')
        J$(tabId).className="tabHover156";
    else
        J$(tabId).className="tabHover157";
}

function changeTabClass(tab){
    if(tab=='presscenter' || tab=='contact') {
        if(tab==selectedTabId)
            J$(tab).className="tabSelectDiv156";
        else
            J$(tab).className="tabDiv156";
    }
    else {
        if(tab==selectedTabId)
            J$(tab).className="tabSelectDiv157";
        else
            J$(tab).className="tabDiv157";
    }
}

function dropdownMenu(e,tabId,textArr,linkArr){
    if (window.event) event.cancelBubble=true
    else if (e.stopPropagation) e.stopPropagation()
    clearHideMenu();
    menuObj=J$("tabMenu");
    if ((tabOnId!=tabId) && (tabOnId!='') && (tabOnId!=null)&& (tabOnId!='undefined'))
        changeTabClass(tabOnId);
    populateMenu(tabId,textArr,linkArr);
    menuObj.x=getElementPosition(tabId).left;
    menuObj.y=getElementPosition(tabId).top;
    menuObj.style.left=menuObj.x+"px"
    menuObj.style.top=menuObj.y+J$(tabId).offsetHeight+horizontaloffset+"px"
    showHide(menuObj.style, e);
    tabOnId=tabId;
    return true;
}

function clearHideMenu(){
    if (typeof delayhide!="undefined")
    clearTimeout(delayhide)
}

function populateMenu(tabId,textArr,linkArr){
    if(tabId=='presscenter' || tabId=='contact')
        J$('tabMenu').style.width="156px";
    else
        J$('tabMenu').style.width="157px";
    content="";
    len=textArr.length;
    for(i=0;i<len;i++) {
        if (i!=0) {
            content+="<div class='tabMenuSpacer'>&nbsp;</div>"
        }
        content+="<div class='tabMenuDiv' onclick=goToUrl('"+linkArr[i]+"') onMouseover=\"this.className='tabMenuDivHover'\" onmouseout=\"this.className='tabMenuDiv'\">"+textArr[i]+"</div>"
    }
    J$('menuContent').innerHTML=content;
}

function showHide(obj, e){
    if (e.type=="click" && obj.display==none || e.type=="mouseover")
        obj.display='block'
    else if (e.type=="click") {
        obj.display='none';
        changeTabClass(tabOnId);
        tabOnId='';
    }
}

function tabOff(obj,tabId) {
    changeCursor(obj,'default');
    delayHideMenu();
    tabOnId=tabId;
}

function delayHideMenu(){
    delayhide=setTimeout("hideMenu()",disappeardelay)
}

function hideMenu(e){
    if (typeof menuObj!="undefined") {
        menuObj.style.display="none";
        changeTabClass(tabOnId);
        tabOnId='';
    }
}

function selectTab(tab) {
    if(J$(tab)){
        selectedTabId=tab;
        if(tab=='presscenter' || tab=='contact')
            J$(tab).className="tabSelectDiv156";
        else
            J$(tab).className="tabSelectDiv157";
        J$(tab).className="tabSelectDiv156";
    }
}
/************* End TAB functions ***************/

/***************Function for window.open*************/

function PopUp(mypage, myname, w, h, title, menu,dir, tool, loc, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',titlebar='+title+',menubar='+menu+',directories='+dir+' ,toolbar='+tool+',location='+loc+',scrollbars='+scroll+',resizable';
win = window.open(mypage, myname, winprops);
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}


/****************GOOGLE TOOLBAR Autofill field highlighting Correction ***************************/
/* The following code will correct the issue for autofil enabled fields being highlighted yellow. It will
show an explanation to the user about why their fields are yellow and provide them a way to go and shut
it off. 

Requires the following in the page

<div id="googleblurb" style="display:none;">
  You can use the AutoFill function on the Google toolbar to fill out
  the highlighted fields on this form.
  <a href="http://toolbar.google.com/autofill_help.html"
  title="AutoFill Help Page">Learn more</a>.
</div>

*/


  if(window.attachEvent)
    window.attachEvent("onload",setListeners);
  
  function setListeners(){
    inputList = document.getElementsByTagName("INPUT");
    for(i=0;i<inputList.length;i++){
      inputList[i].attachEvent("onpropertychange",restoreStyles);
      inputList[i].style.backgroundColor = "";
    }
    selectList = document.getElementsByTagName("SELECT");
    for(i=0;i<selectList.length;i++){
      selectList[i].attachEvent("onpropertychange",restoreStyles);
      selectList[i].style.backgroundColor = "";
    }
  }

  function restoreStyles(){
    if(event.srcElement.style.backgroundColor != "" && event.srcElement.style.backgroundColor != "#a0d0ff"){
      event.srcElement.style.backgroundColor = "#e3e3e3"; /* color of choice for AutoFill */
      document.all['googleblurb'].style.display = "block";
    }
  }