sniffBrowsers();

menuItemBullet = new bulletPoint("http://www.research.psu.edu/images/bullets/one/menu_off.gif","http://www.research.psu.edu/images/bullets/one/menu_on.gif");
labelBullet = new bulletPoint("http://www.research.psu.edu/images/bullets/one/header_off2.gif","http://www.research.psu.edu/images/bullets/one/header_on2.gif");
subMenuBullet = new bulletPoint("http://www.research.psu.edu/images/bullets/one/sub_header_off.gif","http://www.research.psu.edu/images/bullets/one/sub_header_on.gif");

myTest = new menuBar('myTest',558, 'horizontal', '#efeff8', '#efeff8');
myTest.addLabel(null, 'IRO Home', 1, 73, '#6666CC', '#201F65', 'http://www.research.psu.edu/iro/index.asp', 'center');
myTest.addLabel('labelBullet', 'About Us', 2, 106, '#6666CC', '#201F65', 'http://www.research.psu.edu/iro/services/index.html', 'center');
myTest.addLabel('labelBullet', 'Research', 3, 90, '#6666CC', '#201F65', 'http://www.research.psu.edu/iro/research/index.html', 'center');
myTest.addLabel('labelBullet', 'Events', 4, 73, '#6666CC', '#201F65', 'http://www.research.psu.edu/iro/events/index.asp', 'center');
myTest.addLabel('labelBullet', 'Publications', 5, 110, '#6666CC', '#201F65', 'http://www.research.psu.edu/iro/publications/index.html', 'center');
myTest.addLabel('labelBullet', 'Contact IRO', 6, 106, '#6666CC', '#201F65', 'http://www.research.psu.edu/iro/contactus.html', 'center');

myTest.height = 24;

//menus[x] = new menu(width, layout, borderdividercolor, outerbordercolor);
//menus[x]addItem(bullet, label, submenu#, width, fillcolor, hovercolor, link, position);
menus[1] = new menu(0, 'vertical', '#efeff8', '#efeff8');
menus[1].height = 0;
menus[1].addItem(null, '', null, 0, '#efeff8', '#efeff8', null, 'left');
menus[1].writeMenu();
//menus[1].writeMenu();  REMOVE "//" IF YOU WISH TO SHOW SUBMENU

menus[2] = new menu(220, 'vertical', null, '#efeff8');
menus[2].height = 24;
menus[2].addItem('menuItemBullet', 'Services for Industry Partners', null, 186, '#201F65', '#6666CC', 'http://www.research.psu.edu/iro/services/industry.html', 'left');
menus[2].addItem('menuItemBullet', 'Services for Faculty Members', null, 186, '#201F65', '#6666CC', 'http://www.research.psu.edu/iro/services/faculty.html', 'left');
menus[2].addItem('menuItemBullet', 'Economic Development', null, 200, '#201F65', '#6666CC', 'http://www.research.psu.edu/iro/services/economic.html', 'left');
menus[2].addItem('menuItemBullet', 'Contracts FAQ', null, 150, '#201F65', '#6666CC', 'http://www.research.psu.edu/iro/services/contracts.html', 'left');
menus[2].addItem('menuItemBullet', 'Useful Links', null, 150, '#201F65', '#6666CC', 'http://www.research.psu.edu/iro/links.html', 'left');
menus[2].addItem('menuItemBullet', 'Staff Directory', null, 150, '#201F65', '#6666CC', 'http://www.research.psu.edu/iro/staff.html', 'left');
menus[2].writeMenu();

menus[3] = new menu(216, 'vertical', null, '#efeff8');
menus[3].height = 24;
menus[3].addItem('menuItemBullet', 'Research Centers and Institutes', null, 220, '#201F65', '#6666CC', 'http://www.research.psu.edu/iro/irosearch.cgi', 'left');
menus[3].addItem('menuItemBullet', 'Biotechnology', null, 220, '#201F65', '#6666CC', 'http://www.research.psu.edu/iro/events/tradeshows/BIO/index.html', 'left');
menus[3].addItem('menuItemBullet', 'Materials and Nanotechnology', null, 220, '#201F65', '#6666CC', 'http://www.research.psu.edu/iro/events/tradeshows/nano/index.html', 'left');
menus[3].addItem('menuItemBullet', 'Renewable Energy', null, 220, '#201F65', '#6666CC', 'http://www.research.psu.edu/iro/events/tradeshows/ebw/index.html', 'left');
menus[3].addItem('menuItemBullet', 'Transportation', null, 220, '#201F65', '#6666CC', 'http://www.research.psu.edu/iro/research/transportation/index.html', 'left');
menus[3].addItem('menuItemBullet', 'Videos', null, 220, '#201F65', '#6666CC', 'http://www.research.psu.edu/iro/video/index.asp', 'left');
menus[3].writeMenu();

menus[4] = new menu(180, 'vertical', null, '#efeff8');
menus[4].height = 24;
menus[4].addItem('menuItemBullet', 'Calendar', null, 100, '#201F65', '#6666CC', 'http://www.research.psu.edu/iro/events/index.asp', 'left');
/*menus[4].addItem('subMenuBullet', 'Penn State Events', 7, 150, '#201F65', '#6666CC', 'http://www.research.psu.edu/iro/events/pennstate/index.html', 'left');
menus[4].addItem('subMenuBullet', 'Online Trade Show Exhibits', 7, 100, '#201F65', '#6666CC', 'http://www.research.psu.edu/iro/events/tradeshows/index.html', 'left');*/
menus[4].addItem('menuItemBullet', 'Schedule Meeting at Event', null, 165, '#201F65', '#6666CC', 'http://www.research.psu.edu/iro/events/checkin.asp', 'left');
menus[4].writeMenu();

menus[5] = new menu(216, 'vertical', null, '#efeff8');
menus[5].height = 24;
menus[5].targetType = 'self';
menus[5].targetFrame = '_self';
menus[5].addItem('menuItemBullet', 'Tech Transfer Brochure (PDF)', null, 100, '#201F65', '#6666CC', 'http://www.research.psu.edu/iro/publications/tech-transfer-brochure.pdf', 'left');
menus[5].addItem('menuItemBullet', 'IRO Newsletter', null, 175, '#201F65', '#6666CC', 'http://www.research.psu.edu/iro/theiron/index.html', 'left');
/*menus[5].targetType = 'new';
menus[5].targetFrame = '_blank';*/
menus[5].addItem('menuItemBullet', 'Annual Research Report (PDF)', null, 175, '#201F65', '#6666CC', 'http://www.research.psu.edu/iro/publications/annrep08.pdf', 'left');
menus[5].addItem('menuItemBullet', 'More...', null, 175, '#201F65', '#6666CC', 'http://www.research.psu.edu/iro/publications/index.html', 'left');
/*menus[5].addItem('menuItemBullet', 'Institutes of Energy &amp; Environment Annual Report (PDF)', null, 175, '#201F65', '#6666CC', 'http://www.research.psu.edu/iro/publications/PSIEE2009AnnualReport.pdf', 'left');
menus[5].addItem('menuItemBullet', 'Materials Research Institute Annual Research Report (PDF)', null, 175, '#201F65', '#6666CC', 'http://www.research.psu.edu/iro/publications/MRI2008ResearchActivity.pdf', 'left');
menus[5].addItem('menuItemBullet', 'Energy Task Force Report (PDF)', null, 175, '#201F65', '#6666CC', 'http://www.research.psu.edu/EnergyReport.pdf', 'left');
menus[5].addItem('menuItemBullet', 'Grants for Academic Liaison with Industry', null, 175, '#201F65', '#6666CC', 'http://www.research.psu.edu/iro/services/goali.html', 'left');*/
menus[5].writeMenu();


/* CODE TO OPEN NEW WINDOW
menus[5].targetType = 'new';
menus[5].targetFrame = '_blank';
*/

/*
menus[5] = new menu(195, 'vertical', null, '#efeff8');
menus[5].height = 24;
menus[5].addItem('menuItemBullet', 'American Chemical Society', null, 200, '#201F65', '#6666CC', 'http://www.chemistry.org/', 'left');
menus[5].addItem('menuItemBullet', 'I-99 Innovation Corridor', null, 220, '#201F65', '#6666CC', 'http://www.i99corridor.org/', 'left');
menus[5].addItem('menuItemBullet', 'National Center for Defense Manufacturing &amp; Machining', null, 220, '#201F65', '#6666CC', 'http://www.ncdmm.org/', 'left');
menus[5].addItem('menuItemBullet', 'Research Penn State', null, 150, '#201F65', '#6666CC', 'http://www.rps.psu.edu/', 'left');
menus[5].addItem('menuItemBullet', 'Technology Council of Central Pennsylvania', null, 200, '#201F65', '#6666CC', 'http://www.tccp.org/', 'left');
menus[5].addItem('menuItemBullet', 'More', null, 220, '#201F65', '#6666CC', 'http://www.research.psu.edu/iro/links.html', 'left');
menus[5].writeMenu();
*/

menus[6] = new menu(106, 'vertical', null, '#efeff8');
menus[6].height = 24;
menus[6].addItem('menuItemBullet', 'E-mail Us', null, 115, '#201F65', '#6666CC', 'http://www.research.psu.edu/iro/contactus.html', 'left');
menus[6].addItem('menuItemBullet', 'Staff Directory', null, 150, '#201F65', '#6666CC', 'http://www.research.psu.edu/iro/staff.html', 'left');
menus[6].addItem('menuItemBullet', 'Directions', null, 170, '#201F65', '#6666CC', 'http://www.research.psu.edu/iro/directions.html', 'left');
menus[6].writeMenu();

//menus[7] = new menu(210, 'vertical', null, '#efeff8');
//menus[7].height = 24;
//menus[7].addItem('menuItemBullet', 'College of Engineering Research Symposium', null, 210, '#6666CC', '#6666CC', 'http://www.research.psu.edu/iro/events/pennstate/cers/index.html', 'left');
//menus[7].addItem('menuItemBullet', 'Materials Day', null, 210, '#6666CC', '#6666CC', 'http://www.research.psu.edu/iro/events/pennstate/materialsday/index.html', 'left');
//menus[7].addItem('menuItemBullet', 'Hybrid and Hydrogen Vehicle Research Laboratory Workshop', null, 210, '#6666CC', '#6666CC', 'http://www.research.psu.edu/iro/events/pennstate/hhvrl/index.html', 'left');
//menus[7].addItem('menuItemBullet', 'College of Engineering Project Showcase', null, 210, '#6666CC', '#6666CC', 'http://www.research.psu.edu/iro/events/pennstate/lf/index.html', 'left');
//menus[7].addItem('menuItemBullet', 'Microbial Fuel Cell Symposium', null, 210, '#6666CC', '#6666CC', 'http://www.research.psu.edu/iro/events/pennstate/mfc/index.html', 'left');
//menus[7].addItem('menuItemBullet', 'Cellulosic Biofuels Short Course', null, 210, '#6666CC', '#6666CC', 'http://www.research.psu.edu/iro/newsredirects/richard-biofuels-shortcourse.html', 'left');
//menus[7].addItem('menuItemBullet', 'Innoventure', null, 210, '#6666CC', '#6666CC', 'http://www.research.psu.edu/iro/events/pennstate/innoventure/index.html', 'left');
//menus[7].addItem('menuItemBullet', 'CrossOver', null, 210, '#6666CC', '#6666CC', 'http://www.research.psu.edu/iro/events/pennstate/crossover/index.html', 'left');
//menus[7].addItem('menuItemBullet', 'Energy Innovation Forum', null, 210, '#6666CC', '#6666CC', 'http://www.research.psu.edu/iro/events/pennstate/energyforum/index.html', 'left');
//menus[7].addItem('menuItemBullet', 'ERC Workshop', null, 150, '#6666CC', '#6666CC', 'http://www.research.psu.edu/iro/events/pennstate/erc/index.html', 'left');
//menus[7].writeMenu();

/*menus[7] = new menu(210, 'vertical', null, '#efeff8');
menus[7].height = 24;
menus[7].addItem('menuItemBullet', 'BIO International Convention', null, 210, '#6666CC', '#6666CC', 'http://www.research.psu.edu/iro/events/tradeshows/bio/index.html', 'left');
menus[7].addItem('menuItemBullet', 'Commercialization of NanoMaterials', null, 210, '#6666CC', '#6666CC', 'http://www.research.psu.edu/iro/events/tradeshows/cnm/index.html', 'left');
menus[7].addItem('menuItemBullet', 'Energy from Biomass &amp; Waste', null, 210, '#6666CC', '#6666CC', 'http://www.research.psu.edu/iro/events/tradeshows/ebw/index.html', 'left');
menus[7].addItem('menuItemBullet', 'NHA Hydrogen', null, 210, '#6666CC', '#6666CC', 'http://www.research.psu.edu/iro/events/tradeshows/nha/index.html', 'left');
menus[7].addItem('menuItemBullet', 'NSTI Nanotech', null, 210, '#6666CC', '#6666CC', 'http://www.research.psu.edu/iro/events/tradeshows/nano/index.html', 'left');
menus[7].addItem('menuItemBullet', 'Photonics West', null, 210, '#6666CC', '#6666CC', 'http://www.research.psu.edu/iro/events/tradeshows/photonicswest/index.html', 'left');
menus[7].addItem('menuItemBullet', 'WIREC - Washington International Renewable Energy Conference', null, 210, '#6666CC', '#6666CC', 'http://www.research.psu.edu/iro/events/tradeshows/wirec/index.html', 'left');
menus[7].addItem('menuItemBullet', 'World Energy Engineering Congress', null, 210, '#6666CC', '#6666CC', 'http://www.iro.psu.edu/weec', 'left');
menus[7].writeMenu();*/

//"left" "right" or "justify" to align submenu with left side of menu bar
menus[1].align='left';
menus[2].align='left';
menus[3].align='left';
menus[4].align='left';
menus[5].align='left';
menus[6].align='left';
//menus[7].align='right';
//menus[7].align='right';


/* Nifty Corners Cube - rounded corners with CSS and Javascript
Copyright 2006 Alessandro Fulciniti (a.fulciniti@html.it)

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

var niftyOk=(document.getElementById && document.createElement && Array.prototype.push);
var niftyCss=false;

String.prototype.find=function(what){
return(this.indexOf(what)>=0 ? true : false);
}

var oldonload=window.onload;
if(typeof(NiftyLoad)!='function') NiftyLoad=function(){};
if(typeof(oldonload)=='function')
    window.onload=function(){oldonload();AddCss();NiftyLoad()};
else window.onload=function(){AddCss();NiftyLoad()};

function AddCss(){
niftyCss=true;
var l=CreateEl("link");
l.setAttribute("type","text/css");
l.setAttribute("rel","stylesheet");
l.setAttribute("href","niftyCorners.css");
l.setAttribute("media","screen");
document.getElementsByTagName("head")[0].appendChild(l);
}

function Nifty(selector,options){
if(niftyOk==false) return;
if(niftyCss==false) AddCss();
var i,v=selector.split(","),h=0;
if(options==null) options="";
if(options.find("fixed-height"))
    h=getElementsBySelector(v[0])[0].offsetHeight;
for(i=0;i<v.length;i++)
    Rounded(v[i],options);
if(options.find("height")) SameHeight(selector,h);
}

function Rounded(selector,options){
var i,top="",bottom="",v=new Array();
if(options!=""){
    options=options.replace("left","tl bl");
    options=options.replace("right","tr br");
    options=options.replace("top","tr tl");
    options=options.replace("bottom","br bl");
    options=options.replace("transparent","alias");
    if(options.find("tl")){
        top="both";
        if(!options.find("tr")) top="left";
        }
    else if(options.find("tr")) top="right";
    if(options.find("bl")){
        bottom="both";
        if(!options.find("br")) bottom="left";
        }
    else if(options.find("br")) bottom="right";
    }
if(top=="" && bottom=="" && !options.find("none")){top="both";bottom="both";}
v=getElementsBySelector(selector);
for(i=0;i<v.length;i++){
    FixIE(v[i]);
    if(top!="") AddTop(v[i],top,options);
    if(bottom!="") AddBottom(v[i],bottom,options);
    }
}

function AddTop(el,side,options){
var d=CreateEl("b"),lim=4,border="",p,i,btype="r",bk,color;
d.style.marginLeft="-"+getPadding(el,"Left")+"px";
d.style.marginRight="-"+getPadding(el,"Right")+"px";
if(options.find("alias") || (color=getBk(el))=="transparent"){
    color="transparent";bk="transparent"; border=getParentBk(el);btype="t";
    }
else{
    bk=getParentBk(el); border=Mix(color,bk);
    }
d.style.background=bk;
d.className="niftycorners";
p=getPadding(el,"Top");
if(options.find("small")){
    d.style.marginBottom=(p-2)+"px";
    btype+="s"; lim=2;
    }
else if(options.find("big")){
    d.style.marginBottom=(p-10)+"px";
    btype+="b"; lim=8;
    }
else d.style.marginBottom=(p-5)+"px";
for(i=1;i<=lim;i++)
    d.appendChild(CreateStrip(i,side,color,border,btype));
el.style.paddingTop="0";
el.insertBefore(d,el.firstChild);
}

function AddBottom(el,side,options){
var d=CreateEl("b"),lim=4,border="",p,i,btype="r",bk,color;
d.style.marginLeft="-"+getPadding(el,"Left")+"px";
d.style.marginRight="-"+getPadding(el,"Right")+"px";
if(options.find("alias") || (color=getBk(el))=="transparent"){
    color="transparent";bk="transparent"; border=getParentBk(el);btype="t";
    }
else{
    bk=getParentBk(el); border=Mix(color,bk);
    }
d.style.background=bk;
d.className="niftycorners";
p=getPadding(el,"Bottom");
if(options.find("small")){
    d.style.marginTop=(p-2)+"px";
    btype+="s"; lim=2;
    }
else if(options.find("big")){
    d.style.marginTop=(p-10)+"px";
    btype+="b"; lim=8;
    }
else d.style.marginTop=(p-5)+"px";
for(i=lim;i>0;i--)
    d.appendChild(CreateStrip(i,side,color,border,btype));
el.style.paddingBottom=0;
el.appendChild(d);
}

function CreateStrip(index,side,color,border,btype){
var x=CreateEl("b");
x.className=btype+index;
x.style.backgroundColor=color;
x.style.borderColor=border;
if(side=="left"){
    x.style.borderRightWidth="0";
    x.style.marginRight="0";
    }
else if(side=="right"){
    x.style.borderLeftWidth="0";
    x.style.marginLeft="0";
    }
return(x);
}

function CreateEl(x){
return(document.createElement(x));
}

function FixIE(el){
if(el.currentStyle!=null && el.currentStyle.hasLayout!=null && el.currentStyle.hasLayout==false)
    el.style.display="inline-block";
}

function SameHeight(selector,maxh){
var i,v=selector.split(","),t,j,els=[],gap;
for(i=0;i<v.length;i++){
    t=getElementsBySelector(v[i]);
    els=els.concat(t);
    }
for(i=0;i<els.length;i++){
    if(els[i].offsetHeight>maxh) maxh=els[i].offsetHeight;
    els[i].style.height="auto";
    }
for(i=0;i<els.length;i++){
    gap=maxh-els[i].offsetHeight;
    if(gap>0){
        t=CreateEl("b");t.className="niftyfill";t.style.height=gap+"px";
        nc=els[i].lastChild;
        if(nc.className=="niftycorners")
            els[i].insertBefore(t,nc);
        else els[i].appendChild(t);
        }
    }
}

function getElementsBySelector(selector){
var i,j,selid="",selclass="",tag=selector,tag2="",v2,k,f,a,s=[],objlist=[],c;
if(selector.find("#")){ //id selector like "tag#id"
    if(selector.find(" ")){  //descendant selector like "tag#id tag"
        s=selector.split(" ");
        var fs=s[0].split("#");
        if(fs.length==1) return(objlist);
        f=document.getElementById(fs[1]);
        if(f){
            v=f.getElementsByTagName(s[1]);
            for(i=0;i<v.length;i++) objlist.push(v[i]);
            }
        return(objlist);
        }
    else{
        s=selector.split("#");
        tag=s[0];
        selid=s[1];
        if(selid!=""){
            f=document.getElementById(selid);
            if(f) objlist.push(f);
            return(objlist);
            }
        }
    }
if(selector.find(".")){      //class selector like "tag.class"
    s=selector.split(".");
    tag=s[0];
    selclass=s[1];
    if(selclass.find(" ")){   //descendant selector like tag1.classname tag2
        s=selclass.split(" ");
        selclass=s[0];
        tag2=s[1];
        }
    }
var v=document.getElementsByTagName(tag);  // tag selector like "tag"
if(selclass==""){
    for(i=0;i<v.length;i++) objlist.push(v[i]);
    return(objlist);
    }
for(i=0;i<v.length;i++){
    c=v[i].className.split(" ");
    for(j=0;j<c.length;j++){
        if(c[j]==selclass){
            if(tag2=="") objlist.push(v[i]);
            else{
                v2=v[i].getElementsByTagName(tag2);
                for(k=0;k<v2.length;k++) objlist.push(v2[k]);
                }
            }
        }
    }
return(objlist);
}

function getParentBk(x){
var el=x.parentNode,c;
while(el.tagName.toUpperCase()!="HTML" && (c=getBk(el))=="transparent")
    el=el.parentNode;
if(c=="transparent") c="#FFFFFF";
return(c);
}

function getBk(x){
var c=getStyleProp(x,"backgroundColor");
if(c==null || c=="transparent" || c.find("rgba(0, 0, 0, 0)"))
    return("transparent");
if(c.find("rgb")) c=rgb2hex(c);
return(c);
}

function getPadding(x,side){
var p=getStyleProp(x,"padding"+side);
if(p==null || !p.find("px")) return(0);
return(parseInt(p));
}

function getStyleProp(x,prop){
if(x.currentStyle)
    return(x.currentStyle[prop]);
if(document.defaultView.getComputedStyle)
    return(document.defaultView.getComputedStyle(x,'')[prop]);
return(null);
}

function rgb2hex(value){
var hex="",v,h,i;
var regexp=/([0-9]+)[, ]+([0-9]+)[, ]+([0-9]+)/;
var h=regexp.exec(value);
for(i=1;i<4;i++){
    v=parseInt(h[i]).toString(16);
    if(v.length==1) hex+="0"+v;
    else hex+=v;
    }
return("#"+hex);
}

function Mix(c1,c2){
var i,step1,step2,x,y,r=new Array(3);
if(c1.length==4)step1=1;
else step1=2;
if(c2.length==4) step2=1;
else step2=2;
for(i=0;i<3;i++){
    x=parseInt(c1.substr(1+step1*i,step1),16);
    if(step1==1) x=16*x+x;
    y=parseInt(c2.substr(1+step2*i,step2),16);
    if(step2==1) y=16*y+y;
    r[i]=Math.floor((x*50+y*50)/100);
    r[i]=r[i].toString(16);
    if(r[i].length==1) r[i]="0"+r[i];
    }
return("#"+r[0]+r[1]+r[2]);
}

/*nifty corners layout*/
window.onload=function(){
Nifty("div#checkin","big transparent top");
/*Nifty("ul#intro li","same-height");
Nifty("div.date");
Nifty("div#content,div#side","same-height");
Nifty("div.comments div");
Nifty("div#footer");
Nifty("div#container","bottom");*/
}
