/*** 
This is the menu creation code - place it right after you body tag
Feel free to add this to a stand-alone js file and link it to your page.
**/

//Menu object creation
oCMenu=new makeCM("oCMenu"); //Making the menu object. Argument: menuname

//Menu properties   
oCMenu.pxBetween=0;
//Using the cm_page object to place the menu ----
oCMenu.fromLeft=0;
oCMenu.fromTop=0;
oCMenu.rows=1;
oCMenu.menuPlacement=0;
                                                             
oCMenu.offlineRoot="" ;
oCMenu.onlineRoot="http://www.americanwoodmark.com/";
//oCMenu.onlineRoot="http://ls.visimpact.com/awccorpsite/";
oCMenu.resizeCheck=1 ;
oCMenu.wait=10 ;
oCMenu.fillImg="images/spacer.gif";
oCMenu.zIndex=300;

//Background bar properties
oCMenu.useBar=0;

//Level properties - ALL properties have to be spesified in level 0
oCMenu.level[0]=new cm_makeLevel(); //Add this for each new level
oCMenu.level[0].width=101;
oCMenu.level[0].height=19;
oCMenu.level[0].regClass="clLevel0";
oCMenu.level[0].overClass="clLevel0over";
oCMenu.level[0].borderX=0;
oCMenu.level[0].borderY=0;
oCMenu.level[0].borderClass="clLevel0border";
oCMenu.level[0].offsetX=0;
oCMenu.level[0].offsetY=0;
oCMenu.level[0].rows=0;
oCMenu.level[0].align="bottom";

oCMenu.level[1]=new cm_makeLevel(); //Add this for each new level
oCMenu.level[1].width=145;
oCMenu.level[1].height=25;
oCMenu.level[1].regClass="clLevel1";
oCMenu.level[1].overClass="clLevel1over";
oCMenu.level[1].borderX=0;
oCMenu.level[1].borderY=0;
oCMenu.level[1].borderClass="clLevel1border";
oCMenu.level[1].offsetX=-10;
oCMenu.level[1].offsetY=5;
oCMenu.level[1].rows=0;
//oCMenu.level[1].arrow="images/arrow.gif";
//oCMenu.level[1].arrowWidth=3;
//oCMenu.level[1].arrowHeight=10;
//oCMenu.level[1].align="right";


/******************************************
Menu item creation:
myCoolMenu.makeMenu(name, parent_name, text, link, target, width, height, regImage, overImage, regClass, overClass , align, rows, nolink, onclick, onmouseover, onmouseout) 
*************************************/

//About American Woodmark
if (iSectionID == 1) 
	oCMenu.makeMenu("top1","","", "about.asp", "", 200, 23, "images/topNav1On.gif", "images/topNav1On.gif");
else
	oCMenu.makeMenu("top1","","", "about.asp", "", 200, 23, "images/topNav1Off.gif", "images/topNav1On.gif");
	
	oCMenu.makeMenu("sub100", "top1", "<div class='menuContainer' style='width:200px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='200' height='25'><div>Mission</div></div>", "about.asp?iAreaID=1&iSectionID=1","", 200,25);
	oCMenu.makeMenu("sub101", "top1", "<div class='menuContainer' style='width:200px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='200' height='25'><div>CITE Principles</div></div>", "about.asp?iAreaID=1&iSectionID=2","", 200,25);
	oCMenu.makeMenu("sub102", "top1", "<div class='menuContainer' style='width:200px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='200' height='25'><div>Leadership</div></div>", "about.asp?iAreaID=1&iSectionID=3","", 200,25);
	oCMenu.makeMenu("sub103", "top1", "<div class='menuContainer' style='width:200px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='200' height='25'><div>Locations/ Manufacturing Sites</div></div>", "about.asp?iAreaID=1&iSectionID=4","", 200,25);
	oCMenu.makeMenu("sub104", "top1", "<div class='menuContainer' style='width:200px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='200' height='25'><div>Ethics</div></div>", "about.asp?iAreaID=1&iSectionID=5","", 200,25);
//	oCMenu.makeMenu("sub105", "top1", "<div class='menuContainer' style='width:200px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='200' height='25'><div>Quality Culture</div></div>", "about.asp?iAreaID=1&iSectionID=6","", 200,25);
	oCMenu.makeMenu("sub106", "top1", "<div class='menuContainer' style='width:200px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='200' height='25'><div>Our Commitments</div></div>", "about.asp?iAreaID=1&iSectionID=7","", 200,25);
	oCMenu.makeMenu("sub107", "top1", "<div class='menuContainer' style='width:200px; height:35px;'><img src='"+cURL+"images/menuBackground.png' width='200' height='35'><div>Environmentally Responsible Stewardship</div></div>", "about.asp?iAreaID=1&iSectionID=8","", 200,35);

//Financial Information
if (iSectionID == 2)
	oCMenu.makeMenu("top2","","", "http://investor.shareholder.com/amwd/", "", 135, 23, "images/topNav2On.gif", "images/topNav2On.gif");
else
	oCMenu.makeMenu("top2","","", "http://investor.shareholder.com/amwd/", "", 135, 23, "images/topNav2Off.gif", "images/topNav2On.gif");
	
	oCMenu.makeMenu("sub200", "top2", "<div class='menuContainer' style='width:135px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='135' height='25'><div>Corporate Officers</div></div>", "http://investor.shareholder.com/amwd/management.cfm","", 135,25);
	oCMenu.makeMenu("sub201", "top2", "<div class='menuContainer' style='width:135px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='135' height='25'><div>Share Data</div></div>", "http://investor.shareholder.com/amwd/stockquote.cfm","", 135,25);
	//oCMenu.makeMenu("sub202", "top2", "<div class='menuContainer' style='width:135px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='135' height='25'><div>Stock Graph</div></div>", "http://www.shareholder.com/amwd/chart.cfm","", 135,25);
	//oCMenu.makeMenu("sub210", "top2", "<div class='menuContainer' style='width:135px; height:30px;'><img src='"+cURL+"images/menuBackground.png' width='135' height='30'><div style='margin-top:2px;'>Dividend & Stock<Br>Split History</div></div>", "http://www.shareholder.com/amwd/dividend.cfm","", 135,32);
	oCMenu.makeMenu("sub211", "top2", "<div class='menuContainer' style='width:135px; height:35px;'><img src='"+cURL+"images/menuBackground.png' width='135' height='35'><div style='margin-top:2px;'>Webcasts & Presentations</div></div>", "http://investor.shareholder.com/amwd/events.cfm","", 135,32);
	oCMenu.makeMenu("sub203", "top2", "<div class='menuContainer' style='width:135px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='135' height='25'><div>News Releases</div></div>", "http://investor.shareholder.com/amwd/releases.cfm","", 135,25);
	oCMenu.makeMenu("sub204", "top2", "<div class='menuContainer' style='width:135px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='135' height='25'><div>Annual Report</div></div>", "http://investor.shareholder.com/amwd/annuals.cfm","", 135,25);
	oCMenu.makeMenu("sub205", "top2", "<div class='menuContainer' style='width:135px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='135' height='25'><div>SEC Reports</div></div>", "http://investor.shareholder.com/amwd/sec.cfm","", 135,25);
	oCMenu.makeMenu("sub206", "top2", "<div class='menuContainer' style='width:135px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='135' height='25'><div>SEC 16 Reports</div></div>", "http://investor.shareholder.com/amwd/Section16.cfm","", 135,25);
	oCMenu.makeMenu("sub207", "top2", "<div class='menuContainer' style='width:135px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='135' height='25'><div>Directors Listing</div></div>", "http://investor.shareholder.com/amwd/directors.cfm","", 135,25);
	oCMenu.makeMenu("sub208", "top2", "<div class='menuContainer' style='width:135px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='135' height='25'><div>Corporate Governance</div></div>", "http://investor.shareholder.com/amwd/governance.cfm","", 135,25);
	oCMenu.makeMenu("sub212", "top2", "<div class='menuContainer' style='width:135px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='135' height='25'><div>Email Alerts</div></div>", "http://investor.shareholder.com/amwd/alerts.cfm","", 135,25);
	oCMenu.makeMenu("sub213", "top2", "<div class='menuContainer' style='width:135px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='135' height='25'><div>Information Requests</div></div>", "http://investor.shareholder.com/amwd/investorKit.cfm","", 135,25);
	oCMenu.makeMenu("sub209", "top2", "<div class='menuContainer' style='width:135px; height:30px;'><img src='"+cURL+"images/menuBackground.png' width='135' height='30'><div style='margin-top:2px;'>Investor Contact Information</div></div>", "http://investor.shareholder.com/amwd/contactus.cfm","", 135,30);
	
//Our Brands
if (iSectionID == 3)
	oCMenu.makeMenu("top3","","", "brands.asp?iAreaID=3&iSectionID=1", "", 116, 23, "images/topNav3On.gif", "images/topNav3On.gif");
else
	oCMenu.makeMenu("top3","","", "brands.asp?iAreaID=3&iSectionID=1", "", 116, 23, "images/topNav3Off.gif", "images/topNav3On.gif");
	
	oCMenu.makeMenu("sub300", "top3", "<div class='menuContainer' style='width:116px; height:30px;'><img src='"+cURL+"images/menuBackground.png' width='116' height='30'><div>American<br>Woodmark</div></div>", "brands.asp?iAreaID=3&iSectionID=1","", 116,30);
	oCMenu.makeMenu("sub301", "top3", "<div class='menuContainer' style='width:116px; height:35px;'><img src='"+cURL+"images/menuBackground.png' width='116' height='35'><div style='margin-top:6px;margin'>Shenandoah &<br>Potomac</div></div>", "brands.asp?iAreaID=3&iSectionID=2","", 116,35);
	oCMenu.makeMenu("sub302", "top3", "<div class='menuContainer' style='width:116px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='116' height='25'><div>Timberlake</div></div>", "brands.asp?iAreaID=3&iSectionID=3","", 116,25);
	oCMenu.makeMenu("sub304", "top3", "<div class='menuContainer' style='width:116px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='116' height='25'><div>Warranty</div></div>", "about.asp?iAreaID=3&iSectionID=4","", 116,25);
	oCMenu.makeMenu("sub303", "top3", "<div class='menuContainer' style='width:116px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='116' height='25'><div>CabinetTracker.com</div></div>", "http://www.cabinetTracker.com","_blank", 116,25);

//Corporate News
if (iSectionID == 4)
	oCMenu.makeMenu("top4","","", "news.asp?iAreaID=4&iSectionID=1", "", 111, 23, "images/topNav4On.gif", "images/topNav4On.gif");
else
	oCMenu.makeMenu("top4","","", "news.asp?iAreaID=4&iSectionID=1", "", 111, 23, "images/topNav4Off.gif", "images/topNav4On.gif");
	
	oCMenu.makeMenu("sub400", "top4", "<div class='menuContainer' style='width:111px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='111' height='25'><div>News Highlights</div></div>", "news.asp?iAreaID=4&iSectionID=1","", 111,25);
//	oCMenu.makeMenu("sub401", "top4", "<div class='menuContainer' style='width:111px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='111' height='25'><div>News Archives</div></div>", "news.asp?iAreaID=4&iSectionID=2","", 111,25);
	oCMenu.makeMenu("sub402", "top4", "<div class='menuContainer' style='width:111px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='111' height='25'><div>Media Information</div></div>", "mediaInfo.asp","", 111,25);
//	oCMenu.makeMenu("sub403", "top4", "<div class='menuContainer' style='width:111px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='111' height='25'><div>Upcoming Events</div></div>", "events.asp","", 111,25);
	
	
//Carrer Opp.
if (iSectionID == 5)
	oCMenu.makeMenu("top5","","", "jobOpportunities.asp", "", 153, 23, "images/topNav5On.gif", "images/topNav5On.gif");
else
	oCMenu.makeMenu("top5","","", "jobOpportunities.asp", "", 153, 23, "images/topNav5Off.gif", "images/topNav5On.gif");

	oCMenu.makeMenu("sub500", "top5", "<div class='menuContainer' style='width:153px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='153' height='25'><div>Who Is AWC</div></div>", "career.asp?iSectionID=1","", 153,25);
	oCMenu.makeMenu("sub501", "top5", "<div class='menuContainer' style='width:153px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='153' height='25'><div>Why Choose AWC</div></div>", "career.asp?iSectionID=2","", 153,25);
	oCMenu.makeMenu("sub502", "top5", "<div class='menuContainer' style='width:153px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='153' height='25'><div>Job Opportunities</div></div>", "jobOpportunities.asp","", 153,25);
	oCMenu.makeMenu("sub503", "top5", "<div class='menuContainer' style='width:153px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='153' height='25'><div>College Recruiting</div></div>", "campuscareers","", 153,25);	
	oCMenu.makeMenu("sub504", "top5", "<div class='menuContainer' style='width:153px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='153' height='25'><div>FAQs</div></div>", "career.asp?iSectionID=4","", 153,25);
//	oCMenu.makeMenu("sub504", "top5", "<div class='menuContainer' style='width:153px; height:25px;'><img src='"+cURL+"images/menuBackground.png' width='153' height='25'><div>Recruitment Brochure</div></div>", "brochure.asp","", 153,25);
	
//Leave this line - it constructs the menu
oCMenu.construct();		


//Extra code to find position:
function findPos(num){
  //alert(num)
  if(bw.ns4){   //Netscape 4
    x = document.layers["layerMenu"+num].pageX
    y = document.layers["layerMenu"+num].pageY
  }else{ //other browsers
    x=0; y=0; var el,temp
    el = bw.ie4?document.all["divMenu"+num]:document.getElementById("divMenu"+num);
    if(el.offsetParent){
      temp = el
      while(temp.offsetParent){ //Looping parent elements to get the offset of them as well
        temp=temp.offsetParent; 
        x+=temp.offsetLeft
        y+=temp.offsetTop;
      }
    }
    x+=el.offsetLeft
    y+=el.offsetTop
  }
  //Returning the x and y as an array
  return [x,y]
}
function placeElements(){
  //Changing the position of ALL top items:
  pos = findPos(0)
  oCMenu.m["top1"].b.moveIt(pos[0],pos[1])
  pos = findPos(1)
  oCMenu.m["top2"].b.moveIt(pos[0],pos[1])
  pos = findPos(2)
  oCMenu.m["top3"].b.moveIt(pos[0],pos[1])
  pos = findPos(3)
  oCMenu.m["top4"].b.moveIt(pos[0],pos[1])
  pos = findPos(4)
  oCMenu.m["top5"].b.moveIt(pos[0],pos[1])

  //Setting the fromtop value
  oCMenu.fromTop = pos[0]
}
placeElements()
//Setting it to re place the elements after resize - the resize is not perfect though..
oCMenu.onafterresize="placeElements()"
