var timerID, stoprolltimer;
var menudiv = new Array('company', 'solutions', 'products', 'partners', 'support');
var disappeardelay = 200;
var rolling = 0;
var navy = 68;
var rollheight = 0;
var rolltimer,amount,theTime,thelayer;
var menus = new Array();

var domain = 'http://www.clearone.com';


// Company Menu
var thismenuname = menudiv[0];
eval("menus." + thismenuname + "= new Array()");
eval("thismenu = menus." + thismenuname);
thismenu.width = 150;
thismenu.x = 272;
thismenu.rollheight = 0;
thismenu.text = new Array();
thismenu.text[0] = 'Company';
thismenu.text[1] = 'Management';
thismenu.text[2] = 'Press Room';
thismenu.text[3] = 'Investor Relations';
thismenu.text[4] = 'Careers';
thismenu.text[5] = 'Events';
thismenu.text[6] = 'Promotions';
thismenu.text[7] = 'Awards';
thismenu.text[8] = 'Technical Alerts';
thismenu.text[9] = 'Company Policies';
thismenu.text[10] = 'Customer Success Stories';
thismenu.text[11] = 'Associations';
thismenu.text[12] = 'Community Outreach';
thismenu.text[13] = 'Contact';
//thismenu.text[14] = 'Quality';

thismenu.link = new Array();
thismenu.link[0] = domain + '/company/index.php?content=main';
thismenu.link[1] = domain + '/company/management.php?content=main';
thismenu.link[2] = domain + '/company/press.php?content=main';
thismenu.link[3] = 'http://www.b2i.us/profiles/investor/CSummary.asp?f=1&BzID=509&Nav=1&LangID=1&s=0&tPName=Profile';
thismenu.link[4] = domain + '/company/careers.php?content=main';
thismenu.link[5] = domain + '/company/events.php?content=main';
thismenu.link[6] = domain + '/company/promotions.php?content=main';
thismenu.link[7] = domain + '/company/awards.php?content=main';
thismenu.link[8] = domain + '/company/rss.php?content=main';
thismenu.link[9] = domain + '/company/policies.php?content=main';
thismenu.link[10] = domain + '/company/success.php?content=main';
thismenu.link[11] = domain + '/company/associations.php?content=main';
thismenu.link[12] = domain + '/company/community.php?content=main';
thismenu.link[13] = domain + '/company/contact.php?content=main';
//thismenu.link[14] = domain + '/company/quality.php?content=main';

// Solutions Menu
var thismenuname = menudiv[1];
eval("menus." + thismenuname + "= new Array()");
eval("thismenu = menus." + thismenuname);
thismenu.width = 150;
thismenu.x = 368;
thismenu.rollheight = 0;
thismenu.text = new Array();
thismenu.text[0] = 'Why ClearOne?';
thismenu.text[1] = 'HDConference&trade;';
thismenu.text[2] = 'DARE &trade;&trade;';
thismenu.text[3] = 'Professional Conferencing';
thismenu.text[4] = 'Premium Conferencing';
thismenu.text[5] = 'Tabletop Conferencing';
thismenu.text[6] = 'Personal Conferencing';
thismenu.text[7] = 'Conferencing Microphones';
thismenu.text[8] = 'Conferencing Furniture';

thismenu.link = new Array();
thismenu.link[0] = domain + '/solutions/index.php?content=main';
thismenu.link[1] = domain + '/solutions/technology.php?content=main';
thismenu.link[2] = domain + '/solutions/dare.php?content=main';
thismenu.link[3] = domain + '/solutions/professional.php?content=main';
thismenu.link[4] = domain + '/solutions/premium.php?content=main';
thismenu.link[5] = domain + '/solutions/tabletop.php?content=main';
thismenu.link[6] = domain + '/solutions/personal.php?content=main';
thismenu.link[7] = domain + '/solutions/microphones.php?content=main';
thismenu.link[8] = domain + '/solutions/furniture.php?content=main';

// Products Menu
var thismenuname = menudiv[2];
eval("menus." + thismenuname + "= new Array()");
eval("thismenu = menus." + thismenuname);
thismenu.width = 150;
thismenu.x = 464;
thismenu.rollheight = 0;
thismenu.text = new Array();
thismenu.text[0] = 'How to Buy';
thismenu.text[1] = 'Professional Conferencing';
thismenu.text[2] = 'Premium Conferencing';
thismenu.text[3] = 'Tabletop Conferencing';
thismenu.text[4] = 'Personal Conferencing';
thismenu.text[5] = 'Conferencing Microphones';
thismenu.text[6] = 'Conferencing Furniture';
thismenu.text[7] = 'Products A to Z';

thismenu.link = new Array();
thismenu.link[0] = domain + '/products/buy.php';
thismenu.link[1] = domain + '/Professional_Conferencing.html';
thismenu.link[2] = domain + '/Premium_Conferencing.html';
thismenu.link[3] = domain + '/Tabletop_Conferencing.html';
thismenu.link[4] = domain + '/Personal_Conferencing.html';
thismenu.link[5] = domain + '/Conferencing_Microphones.html';
thismenu.link[6] = domain + '/Conferencing_Furniture.html';
thismenu.link[7] = domain + '/products/a_to_z.php';

// Partners Menu
var thismenuname = menudiv[3];
eval("menus." + thismenuname + "= new Array()");
eval("thismenu = menus." + thismenuname);
thismenu.width = 150;
thismenu.x = 560;
thismenu.rollheight = 0;
thismenu.text = new Array();
thismenu.text[0] = 'Channel Partners';
thismenu.text[1] = 'Technology Partners';

thismenu.link = new Array();
thismenu.link[0] = domain + '/partners/index.php';
thismenu.link[1] = domain + '/partners/technology.php?content=main';


// Support Menu
var thismenuname = menudiv[4];
eval("menus." + thismenuname + "= new Array()");
eval("thismenu = menus." + thismenuname);
thismenu.width = 150;
thismenu.x = 656;
thismenu.rollheight = 0;
thismenu.text = new Array();
thismenu.text[0] = 'Customer Support';
thismenu.text[1] = 'Resource Library';
thismenu.text[2] = 'Software Downloads';
thismenu.text[3] = 'ClearOne University';
thismenu.text[4] = 'Product Registration';
thismenu.text[5] = 'ClearOne Warranty';
thismenu.text[6] = 'RoHS Compliance';
thismenu.text[7] = 'Product Notices';
thismenu.text[8] = 'Recycling';
thismenu.text[9] = 'Technical Alerts';
thismenu.text[10] = 'RMA Status';
thismenu.text[11] = 'ClearOne Forum';

thismenu.link = new Array();
thismenu.link[0] = domain + '/support/index.php?content=main';
thismenu.link[1] = domain + '/support/library.php?content=main';
thismenu.link[2] = domain + '/support/downloads.php?content=main';
thismenu.link[3] = domain + '/support/training.php?content=main';
thismenu.link[4] = domain + '/support/registration.php?content=main';
thismenu.link[5] = domain + '/support/warranty.php?content=main';
thismenu.link[6] = domain + '/support/rohs.php?content=main';
thismenu.link[7] = domain + '/support/notices.php?content=main';
thismenu.link[8] = domain + '/support/recycling.php?content=main';
thismenu.link[9] = domain + '/support/rss.php?content=main';
thismenu.link[10] = '/support/rma.php?content=main';
thismenu.link[11] = 'http://forums.clearone.com';

function swap(image, over) {
	if (over) {
		document.images[image].src = document.images[image].src.replace(/_off/gi, '_over');
	} else {
		document.images[image].src = document.images[image].src.replace(/_over/gi, '_off');
	}
}
    
function topnav_preload() {
    var preloaded = new Array();
    for (i=0;i<arguments.length;i++) {
        preloaded[i] = new Image();
        // preloaded[i].src = args[i];
        preloaded[i].src = '/img/nav_' + arguments[i] + '_over.gif';
    }
}
    
function swapMenu(name, mouse_is_on) {
    alignMenus();
    if (mouse_is_on) {
        clearTimeout(timerID);
        clearTimeout(stoprolltimer);
        turnOff(name);
        showIt(name,1);
        if (rolling == 1) rollIt(name, 6, 7);
    } else {
        clearTimeout(timerID);
        clearTimeout(stoprolltimer);
        timerID = setTimeout('turnOff("")', disappeardelay);
        stoprolltimer = setTimeout('stopRoll("' + name + '")', disappeardelay);
    }
}

function rollInit(layid) {
    eval("thismenu = menus." + layid);
    rt = thismenu.width;
    //clipIt(layid,tp,rt,bt,lf)
    clipIt (layid, 0, rt, 0, 0);
    thismenu.rollheight = 0;
}

function rollIt(layid, delay, amt) {
    layr = handleIt(layid);
    eval("thismenu = menus." + layid);
    amount = amt;
    theTime = delay;
    thelayer = layid;
    realrollIt();
}
function realrollIt() {
    rt = thismenu.width;
    maxheight = thismenu.height;
    thismenu.rollheight = thismenu.rollheight + amount;
    //alert (rollheight);
    
    if (thismenu.rollheight > maxheight) {
        thismenu.rollheight = maxheight;
        clipIt (thelayer, 0, rt, thismenu.rollheight, 0);
    } else {
        clipIt (thelayer, 0, rt, thismenu.rollheight, 0);
        rolltimer = setTimeout('realrollIt("")', theTime);
    } 
}

function stopRoll(name) {
    eval("thismenu = menus." + name);
    thismenu.rollheight = 0;
    clearTimeout(rolltimer);
}

function turnOff(name) {
    for (i=0; i<menudiv.length; i++) {
        if (name.indexOf(menudiv[i])==-1) {
            moveIt(menudiv[i],-400, navy);
            showIt(menudiv[i],0);
            stopRoll(menudiv[i]);
			swap('nav_' + menudiv[i]);  
        } 
    }
}
function alignSize() {
    //document.location.href = document.location.href;
    location.reload(true);
    //window.onresize = alignSize;
}

function changeClass(item, newclass) {
	var cell = document.getElementById(item);
	cell.className = newclass;
}
    
function alignMenus() {
    offset_value=0;
    adjust=0;
     
    if (document.layers) {  // for netscape 4.x
        placerimageloc = findPosition('navlocateimg');
        offset_value = placerimageloc[0];
    } else {
        placerimageloc = findPosition('navlocate');
        offset_value = placerimageloc[0];
    }
    for (i=0; i<menudiv.length; i++) {
        if (i==menudiv.length-1) {
            adjust=0;  // set the negative offset for the last pulldown here
        }
        moveIt(menudiv[i],menus[menudiv[i]].x + offset_value - adjust, navy);
        adjust=0;
    }
}
