
function Item(label,link,newlink,target) {
  this.label=label;
  this.link=link;
  this.target = target;
  this.items = new Array();
  this.parent = "";
  this.menu = "";
  this.menuOn = 0;
  this.newlink = newlink;
}

Item.prototype.addItem = function(item) {
  this.items[this.items.length] = item;
  item.parent = this;
  item.menu = this.menu;
}

Item.prototype.drawLeftNav = function (last) {

  var more="";
  if (this.items.length>0) {
    more="more";
  } else {
    if (this.menuOn>0) {
      more="alone";
    }
  }

  if (last) {
    document.write("<li class='" +more + last + "'>");
  } else {
    document.write("<li class='" + more + "'>");
  }

  if (this.newlink==1) {
    new_link_string = " <img src='/images/global/nexgen09/office/office_blue_icon_short.gif'>";
  } else {
    new_link_string = "";
  }

  if (this.menuOn>0) {
      document.write("<span class='on'>"+ this.label +  new_link_string + "</span>");
  } else {
      var strTarget="";
      if (this.target && this.target != "") { strTarget="target='"+this.target+"'";}
      document.write("<a "+strTarget+" href='"+this.link+"' title=''>"+ this.label+ new_link_string + "</a>");
  }
  if (this.items.length && this.menuOn>0) {
    document.write("<ul>");
    for(this.i=0;this.i<this.items.length;this.i++) {
      this.items[this.i].drawLeftNav();
    }
    document.write("</ul>");
  }
  document.write("</li>");
}

Item.prototype.findOn = function(link) {
  var test = this.link;
  var re = new RegExp(".*.com/", "g");
  test =test.replace(re,"/");
  re = new RegExp("index.html");
  test =test.replace(re,"");
  link = link.replace(re,"");

  if (test == link) {
    this.menuOn =1;
    this.menu.addBreadCrumb(this);
    return 1;
  }
  for(this.i=0;this.i<this.items.length;this.i++) {
    if (this.items[this.i].findOn(link)>0) {
      this.menuOn=1;
      this.menu.addBreadCrumb(this);
      return 1;
    }
  }
  return 0;
}

function Menu() {
  this.items = new Array();
  this.crumbs = new Array();
  this.link = "";
  this.label = "";
}

Menu.prototype.findOn =  function (link) {
  var test = this.link;
  var re = new RegExp(".*.com/", "g");
  test =test.replace(re,"/");
  re = new RegExp("index.html");
  test =test.replace(re,"");
  link = link.replace(re,"");
  if (test == link) {
    return 1;
  }

  for(this.i=0;this.i<this.items.length;this.i++) {
    if ( this.items[this.i].findOn(link) ) {
      return 1;
    }
  }
}

Menu.prototype.addItem = function(item) {
  this.items[this.items.length] = item;
  item.menu=this;
}

Menu.prototype.drawLeftNav = function() {
  document.write("<ul id='nav-local'>");
  for(this.i=0;this.i<this.items.length;this.i++) {
    var last="";
    if (this.items.length-1 == this.i) {last=" last";}
    this.items[this.i].drawLeftNav(last);
  }
  document.write("</ul>");

}

Menu.prototype.drawBreadCrumb = function(retString) {
  var breadcrumb = "";
  var classOn="";
  if (this.crumbs.length == 0) {
    breadcrumb = " &gt; <li class='on'>" + this.label + "</li>";
  } else {
    breadcrumb = " &gt; <li><a href='" + this.link + "'>" +  this.label + "</a>";
  }

  if (this.crumbs.length>0) {
    if (this.crumbs.length == 1) {
      breadcrumb = breadcrumb + " &gt; </li><li class='on'>" + this.crumbs[0].label + "</li>";
    } else {
      breadcrumb = breadcrumb + " &gt; </li><li><a href='" + this.crumbs[0].link +
        "'>" + this.crumbs[0].label + "</a>";
    }
  }
  if (this.crumbs.length>1) {
    breadcrumb = breadcrumb + " &gt; </li><li class='on'>" + this.crumbs[this.crumbs.length-1].label + "</li>";
  }
  if (retString) {
    return (breadcrumb);
  } else {
    document.write(breadcrumb);
  }
}

Menu.prototype.addBreadCrumb = function (crumb) {
  if (this.crumbs.length) {
    for(this.i=this.crumbs.length;this.i>0;this.i--) {
      this.crumbs[this.i]=this.crumbs[this.i-1]
    }
  }
  this.crumbs[0] = crumb;
}




var mArray = new Array();
var aMenu = -1;

var m0 = new Menu;
m0.link = "http://www.fedex.com/us/office/copyprint/index.html";
m0.label = "Copy & Print";
var i0 = new Item("Online Printing","http://www.fedex.com/us/office/copyprint/online/index.html",0,"");
m0.addItem(i0);
var i1 = new Item("FedEx Office Print Online","http://www.fedex.com/us/office/copyprint/online/print/index.html",0,"");
i0.addItem(i1);
var i2 = new Item("FedEx Office Print Online Corporate","http://www.fedex.com/us/office/copyprint/online/corporate/index.html",0,"");
i0.addItem(i2);
var i3 = new Item("Custom Cards and Calendars","http://www.fedex.com/us/office/greetings/index.html",0,"");
i0.addItem(i3);
var i4 = new Item("Convention Services","http://www.fedex.com/us/office/services/conventions/index.html",0,"");
i0.addItem(i4);
var i5 = new Item("Web Services","http://www.fedex.com/us/office/copyprint/online/webservices/index.html",0,"");
i0.addItem(i5);
var i6 = new Item("Mobile & USB Drive Printing","http://www.fedex.com/us/office/printandgo/index.html",0,"");
i0.addItem(i6);
var i7 = new Item("Copy & Print Services","http://www.fedex.com/us/office/copyprint/copy/index.html",0,"");
m0.addItem(i7);
var i8 = new Item("Copying","http://www.fedex.com/us/office/copyprint/copy/copying.html",0,"");
i7.addItem(i8);
var i9 = new Item("Digital Printing","http://www.fedex.com/us/office/copyprint/copy/digital_printing.html",0,"");
i7.addItem(i9);
var i10 = new Item("Finishing & Binding","http://www.fedex.com/us/office/copyprint/copy/finishing.html",0,"");
i7.addItem(i10);
var i11 = new Item("Print & Go","http://www.fedex.com/us/office/printandgo/index.html",0,"");
i7.addItem(i11);
var i12 = new Item("CD/DVD Duplication","http://www.fedex.com/us/office/copyprint/copy/cdduplication.html",0,"");
i7.addItem(i12);
var i13 = new Item("Finishing – Binding, Lamination","http://www.fedex.com/us/office/copyprint/copy/finishing.html",0,"");
m0.addItem(i13);
var i14 = new Item("Mobile & USB Drive Printing","http://www.fedex.com/us/office/printandgo/index.html",0,"");
m0.addItem(i14);
var i15 = new Item("Presentations","http://www.fedex.com/us/office/copyprint/presentations/presentations.html",0,"");
m0.addItem(i15);
var i16 = new Item("Flyers, Resumes","http://www.fedex.com/us/office/copyprint/brochures/flyers.html",0,"");
m0.addItem(i16);
var i17 = new Item("Manuals, Booklets, Newsletters","http://www.fedex.com/us/office/copyprint/presentations/index.html",0,"");
m0.addItem(i17);
var i18 = new Item("Manuals","http://www.fedex.com/us/office/copyprint/presentations/manuals.html",0,"");
i17.addItem(i18);
var i19 = new Item("Booklets","http://www.fedex.com/us/office/copyprint/presentations/booklets.html",0,"");
i17.addItem(i19);
var i20 = new Item("Newsletters","http://www.fedex.com/us/office/copyprint/brochures/newsletters.html",0,"");
i17.addItem(i20);
var i21 = new Item("Brochures, Postcards, Sell Sheets","http://www.fedex.com/us/office/copyprint/brochures/index.html",0,"");
m0.addItem(i21);
var i22 = new Item("Brochures","http://www.fedex.com/us/office/copyprint/brochures/tri-fold_brochures.html",0,"");
i21.addItem(i22);
var i23 = new Item("Postcards","http://www.fedex.com/us/office/copyprint/brochures/postcards.html",0,"");
i21.addItem(i23);
var i24 = new Item("Sell Sheets","http://www.fedex.com/us/office/copyprint/brochures/sellsheets.html",0,"");
i21.addItem(i24);
var i25 = new Item("Photo Printing & Enlargements","http://www.fedex.com/us/office/copyprint/photo/index.html",0,"");
m0.addItem(i25);
var i26 = new Item("Sony PictureStation","http://www.fedex.com/us/office/copyprint/photo/Picturestation.html",0,"");
i25.addItem(i26);
var i27 = new Item("Photo Enlargements","http://www.fedex.com/us/office/copyprint/photo/enlargements.html",0,"");
i25.addItem(i27);
var i28 = new Item("Passport Photos","http://www.fedex.com/us/office/copyprint/photo/passport.html",0,"");
i25.addItem(i28);
var i29 = new Item("Photo to Art Prints","http://www.fedex.com/us/office/copyprint/photo/artprints.html",0,"");
i25.addItem(i29);
var i30 = new Item("FedEx Office Photo from Snapfish","http://www.snapfish.com/fedex/welcome",0,"_blank");
i25.addItem(i30);
var i31 = new Item("Corporate Printing","http://www.fedex.com/us/office/copyprint/online/docstore/index.html",0,"");
m0.addItem(i31);
mArray[mArray.length]=m0;
var m1 = new Menu;
m1.link = "http://www.fedex.com/us/office/marketing/index.html";
m1.label = "Marketing Products";
var i32 = new Item("Banners","http://www.fedex.com/us/office/sign-banner-printing.html",0,"");
m1.addItem(i32);
var i33 = new Item("Indoor Banners","http://www.fedex.com/us/office/indoor-banner-printing.html",0,"");
i32.addItem(i33);
var i34 = new Item("Outdoor Banners","http://www.fedex.com/us/office/outdoor-banner-printing.html",0,"");
i32.addItem(i34);
var i35 = new Item("Cut Vinyl Banners","http://www.fedex.com/us/office/vinyl-banner-printing.html",0,"");
i32.addItem(i35);
var i36 = new Item("Posters","http://www.fedex.com/us/office/poster-printing.html",0,"");
m1.addItem(i36);
var i37 = new Item("Prints – Mounted, Specialty, Fine Art","http://www.fedex.com/us/office/copyprint/photo/artprints.html",0,"");
m1.addItem(i37);
var i38 = new Item("Signs – Yard, Metal, Plastic, Specialty","http://www.fedex.com/us/office/sign-printing.html",0,"");
m1.addItem(i38);
var i39 = new Item("Corrugated Plastic Signs","http://www.fedex.com/us/office/corrugated-plastic-sign-printing.html",0,"");
i38.addItem(i39);
var i40 = new Item("PVC Rigid Signs","http://www.fedex.com/us/office/pvc-sign-printing.html",0,"");
i38.addItem(i40);
var i41 = new Item("Displays & Frames","http://www.fedex.com/us/office/marketing/signsbanners/posters/prints.html",0,"");
m1.addItem(i41);
var i42 = new Item("Lettering & Decals, Vehicle Magnets","http://www.fedex.com/us/office/lettering-decal-magnet-printing.html",0,"");
m1.addItem(i42);
var i43 = new Item("Ready-to-Apply Lettering","http://www.fedex.com/us/office/lettering.html",0,"");
i42.addItem(i43);
var i44 = new Item("Decals","http://www.fedex.com/us/office/decal-printing.html",0,"");
i42.addItem(i44);
var i45 = new Item("Promotional Magnets","http://www.fedex.com/us/office/magnet-printing.html",0,"");
i42.addItem(i45);
var i46 = new Item("Vehicle Magnets","http://www.fedex.com/us/office/car-door-magnet-printing.html",0,"");
i42.addItem(i46);
var i47 = new Item("Direct Mail, Letters, List Services","http://www.fedex.com/us/office/marketing/directmail/index.html",0,"");
m1.addItem(i47);
var i48 = new Item("List Services","http://www.leadsplease.com/fedex",0,"_blank");
i47.addItem(i48);
var i49 = new Item("Business Cards, Letterhead","http://www.fedex.com/us/office/copyprint/businesscards/index.html",0,"_blank");
m1.addItem(i49);
var i50 = new Item("Cards and Calendars ","http://www.fedex.com/us/office/greetings/index.html",0,"");
m1.addItem(i50);
var i51 = new Item("Design Services","http://www.fedex.com/us/office/marketing/docdesign/index.html",0,"");
m1.addItem(i51);
mArray[mArray.length]=m1;
var m2 = new Menu;
m2.link = "http://www.fedex.com/us/office/services/index.html";
m2.label = "Office Services";
var i52 = new Item("Pack and Ship","http://www.fedex.com/us/office/services/packandship/index.html",0,"");
m2.addItem(i52);
var i53 = new Item("Shipping Supplies","http://www.fedex.com/us/office/services/packandship/supplies.html",0,"");
i52.addItem(i53);
var i54 = new Item("Packing Services","http://www.fedex.com/us/office/services/packandship/packingservices.html",0,"");
i52.addItem(i54);
var i55 = new Item("Luggage Shipping Services","http://www.fedex.com/us/office/services/packandship/luggage.html",0,"");
i52.addItem(i55);
var i56 = new Item("FedEx Shipping","http://www.fedex.com/us/office/services/packandship/shipping.html",0,"");
i55.addItem(i56);
var i57 = new Item("Hold at Location, Luggage","http://www.fedex.com/us/office/services/packandship/luggage.html",0,"");
m2.addItem(i57);
var i58 = new Item("Local Delivery","http://www.fedex.com/us/office/services/packandship/index.html",0,"");
m2.addItem(i58);
var i59 = new Item("Computer Rental","http://www.fedex.com/us/office/services/computer/index.html",0,"");
m2.addItem(i59);
var i60 = new Item("Wi-Fi","http://www.fedex.com/us/office/services/computer/wi-fi.html",0,"");
m2.addItem(i60);
var i61 = new Item("Laptop Docking Stations","http://www.fedex.com/us/office/services/computer/index.html",0,"");
m2.addItem(i61);
var i62 = new Item("Hotels & Conventions","http://www.fedex.com/us/office/services/conventions/index.html",0,"");
m2.addItem(i62);
var i63 = new Item("Fax, Scanning","http://www.fedex.com/us/office/services/fax.html",0,"");
m2.addItem(i63);
var i64 = new Item("Passport","http://www.fedex.com/us/office/services/passport.html",0,"");
m2.addItem(i64);
var i65 = new Item("Office Supplies","http://www.fedex.com/us/office/services/officesupplies.html",0,"");
m2.addItem(i65);
mArray[mArray.length]=m2;

function setupMenu (link) {
  for (var myCnt=0;myCnt<mArray.length;myCnt++) {
    if (mArray[myCnt].findOn(link)) {
      aMenu = myCnt;
      activeLabel = mArray[myCnt].label;
      if ( document.getElementById("gn"+(myCnt+1)) ) {
        document.getElementById("gn"+(myCnt+1)).className="on";
      }
      break;
    }
  }
}

function setManualBreadcrumb (bc) {
  var bc_temp = new Menu ();
  for (this.bc=bc.length-1;this.bc>4;this.bc=this.bc-2) {
    var item = new Item(bc[this.bc-1],bc[this.bc],0,"");
    bc_temp.addBreadCrumb(item);
  }
  bc_temp.label=bc[2];
  bc_temp.link=bc[3];
  var bc_div = document.getElementById("breadcrumb");
  var bc_str = bc_temp.drawBreadCrumb(1);
  bc_str = bc_str.substr(bc_str.indexOf(">")+1);
  bc_div.innerHTML = "<LI><A HREF='" + bc[1] + "'>" + bc[0] + "</a> > </LI>" + bc_str; 
}
function drawBreadCrumb(retString) {
  if (aMenu >= 0) {
    if (retString>0) {
      return mArray[aMenu].drawBreadCrumb(retString);
    } else {
      mArray[aMenu].drawBreadCrumb(retString);
    }
  }
}

function drawLeftNav() {
  if (aMenu >= 0) {
    mArray[aMenu].drawLeftNav();
  }
}


