var timerID, stoprolltimer;
var menudiv = new Array('company', 'solutions', 'products', 'partners', 'support','resources');
var disappeardelay = 200;
var rolling = 0;
var navy = 62;
var rollheight = 0;
var rolltimer,amount,theTime,thelayer;
var menus = new Array();

var domain = 'http://' + document.domain;

// Company Menu
var thismenuname = menudiv[0];
eval("menus." + thismenuname + "= new Array()");
eval("thismenu = menus." + thismenuname);
thismenu.width = 150;
thismenu.x = 303;
thismenu.rollheight = 0;
thismenu.text = new Array();
thismenu.text[0] = '公司概况';
thismenu.text[1] = '管理人员';
thismenu.text[2] = '新闻中心';
thismenu.text[3] = '投资者关系';
thismenu.text[4] = '招聘信息';
thismenu.text[5] = '活动';

thismenu.text[6] = '公益活动';
thismenu.text[7] = '联系方式';

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/community.php?content=main';
thismenu.link[7] = domain + '/company/contact.php?content=main';

// Solutions Menu
var thismenuname = menudiv[1];
eval("menus." + thismenuname + "= new Array()");
eval("thismenu = menus." + thismenuname);
thismenu.width = 150;
thismenu.x = 389;
thismenu.rollheight = 0;
thismenu.text = new Array();
thismenu.text[0] = '为什么选择 ClearOne？';
thismenu.text[1] = 'HDConference&reg;';
thismenu.text[2] = 'DARE &trade;';
thismenu.text[3] = '客户成功案例';

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 + '/company/success.php?content=main';

// Products Menu
var thismenuname = menudiv[2];
eval("menus." + thismenuname + "= new Array()");
eval("thismenu = menus." + thismenuname);
thismenu.width = 150;
thismenu.x = 491;
thismenu.rollheight = 0;
thismenu.text = new Array();
thismenu.text[0] = '如何购买';
thismenu.text[1] = '促销';
thismenu.text[2] = '获奖情况';
thismenu.text[3] = '专业会议';
thismenu.text[4] = '高级会议';
thismenu.text[5] = '桌面会议';
thismenu.text[6] = '个人会议';
thismenu.text[7] = '会议话筒';
thismenu.text[8] = '会议家具';
thismenu.text[9] = '产品 A 到 Z';

thismenu.link = new Array();
thismenu.link[0] = domain + '/products/buy.php';
thismenu.link[1] = domain + '/company/promotions.php?content=main';
thismenu.link[2] = domain + '/company/awards.php?content=main';
thismenu.link[3] = domain + '/Professional_Conferencing.html';
thismenu.link[4] = domain + '/Premium_Conferencing.html';
thismenu.link[5] = domain + '/Tabletop_Conferencing.html';
thismenu.link[6] = domain + '/Personal_Conferencing.html';
thismenu.link[7] = domain + '/Conferencing_Microphones.html';
thismenu.link[8] = domain + '/Conferencing_Furniture.html';
thismenu.link[9] = 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 = 592;
thismenu.rollheight = 0;
thismenu.text = new Array();
thismenu.text[0] = '渠道合作伙伴';
thismenu.text[1] = '技术合作伙伴';

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 = 688;
thismenu.rollheight = 0;
thismenu.text = new Array();
thismenu.text[0] = '客户支持';
thismenu.text[1] = '产品注册';
thismenu.text[2] = 'ClearOne 保证';
thismenu.text[3] = 'ClearOne RMA保证';
thismenu.text[4] = 'ClearOne 论坛';

thismenu.link = new Array();
thismenu.link[0] = domain + '/support/index.php?content=main';
thismenu.link[1] = domain + '/support/registration.php?content=main';
thismenu.link[2] = domain + '/support/warranty.php?content=main';
thismenu.link[3] = '/support/rma.php?content=main';
thismenu.link[4] = 'http://forums.clearone.com';

// Resources Menu
var thismenuname = menudiv[5];
eval("menus." + thismenuname + "= new Array()");
eval("thismenu = menus." + thismenuname);
thismenu.width = 150;
thismenu.x = 775;
thismenu.rollheight = 0;
thismenu.text = new Array();
thismenu.text[0] = '资源库';
thismenu.text[1] = 'ClearOne 大学';
thismenu.text[2] = '&#35774;&#35745;&#24037;&#20855;';
thismenu.text[3] = '添加 ClearOne RSS 种子';
thismenu.text[4] = 'RoHS 合规性';
thismenu.text[5] = '产品相关通知';
thismenu.text[6] = '回收';

thismenu.link = new Array();
thismenu.link[0] = domain + '/support/library.php?content=main';
thismenu.link[1] = domain + '/support/training.php?content=main';
thismenu.link[2] = domain + '/support/calculators.php?content=main';
thismenu.link[3] = domain + '/support/rss.php?content=main';
thismenu.link[4] = domain + '/support/rohs.php?content=main';
thismenu.link[5] = domain + '/support/notices.php?content=main';
thismenu.link[6] = domain + '/support/recycling.php?content=main';

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;
    }
}

