/*** 
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.
**/

//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]
}



//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=0
oCMenu.menuPlacement=0
                                                             
oCMenu.offlineRoot="" 
oCMenu.onlineRoot="" 
oCMenu.resizeCheck=1 
oCMenu.wait=1000 
oCMenu.fillImg="images/blank.gif"
oCMenu.zIndex=0

//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="550"
oCMenu.level[0].height=30 
oCMenu.level[0].regClass="clLevel0"
oCMenu.level[0].overClass=""
oCMenu.level[0].borderX=0
oCMenu.level[0].borderY=0
oCMenu.level[0].borderClass=""
oCMenu.level[0].offsetX=0
oCMenu.level[0].offsetY=5
oCMenu.level[0].rows=0
oCMenu.level[0].arrow=0
oCMenu.level[0].arrowWidth=0
oCMenu.level[0].arrowHeight=0
oCMenu.level[0].align="bottom"


/******************************************
Menu item creation:
myCoolMenu.makeMenu(name, parent_name, text, link, target, width, height, regImage, overImage, regClass, overClass , align, rows, nolink, onclick, onmouseover, onmouseout) 
*************************************/

oCMenu.makeMenu('top0', '', '', 'index.php', '', '87', '30', 'images/menu1_welcome.gif', 'images/menu1_welcome_ov.gif') ;
   // oCMenu.makeMenu('sub00','top0','&nbsp;&nbsp;&nbsp;<img src=images/bullet.gif width=8 height=10>Philosophy ','philosophy.asp');

	
oCMenu.makeMenu('top1', '', '', 'asian_destinations.php', '', '120', '30', 'images/menu2_asian_destination.gif', 'images/menu2_asian_destination_ov.gif') ;
oCMenu.makeMenu('top2', '', '', 'thai_culture.php', '', '88', '30', 'images/menu3_thai_culture.gif', 'images/menu3_thai_culture_ov.gif') ;
   oCMenu.makeMenu('sub20','top2','<font size="1" face="Verdana"><a href="music_dance.php" class="uw">Music & Dance </a> | <a href="craft_cooking.php" class="uw">Craft & Cooking</a> | <a href="thai_massage.php" class="uw">Thai Massage</a> | <a href="isan_folk_life.php" class="uw">Isan Folk Life</a></font> ','');
oCMenu.makeMenu('top3', '', '', 'textile_tour.php', '', '56', '30', 'images/menu4_textile.gif', 'images/menu4_textile_ov.gif') ;
   oCMenu.makeMenu('sub30','top3','<font size="1" face="Verdana"><a href="lanna_pattern.php" class="uw">Lanna Pattern</a> | <a href="chok_tai_textile.php" class="uw">Chok & Tai Textile</a> | <a href="tai_lao_textile.php" class="uw">Tai & Lao Textile</a> | <a href="silk_route1.php" class="uw">Silk Route 1</a> | <a href="silk_route2.php" class="uw">Silk Route 2</a></font> ','');
oCMenu.makeMenu('top4', '', '', 'architecture.php', '', '92', '30', 'images/menu5_architecture.gif', 'images/menu5_architecture_ov.gif') ;
    oCMenu.makeMenu('sub40','top4','<font size="1" face="Verdana"><a href="lanna_style.php" class="uw">Lanna style</a> | <a href="northern_impression.php" class="uw">Northern Impression</a> | <a href="architecture_river.php" class="uw">Architecture & River</a> | <a href="home_garden.php" class="uw">Home & Garden</a> | <a href="the_inheritace.php" class="uw">The Inheritance</a></font> ','');
oCMenu.makeMenu('top5', '', '', 'garden.php ', '', '67', '30', 'images/menu6_garden.gif', 'images/menu6_garden_ov.gif') ;
oCMenu.makeMenu('top6', '', '', 'thai_custom.php', '', '89', '30', 'images/menu7_thai_custom.gif', 'images/menu7_thai_custom_ov.gif') ;
oCMenu.makeMenu('top7', '', '', 'links.php', '', '53', '30', 'images/menu8_links.gif', 'images/menu8_links_ov.gif') ;
oCMenu.makeMenu('top8', '', '', 'contact.php', '', '79', '30', 'images/menu9_contact.gif', 'images/menu9_contact_ov.gif') ;



//Leave this line - it constructs the menu
oCMenu.construct()		

function placeElements(){
  //Changing the position of ALL top items:
  pos = findPos(0)
  oCMenu.m["top0"].b.moveIt(pos[0],pos[1])
  pos = findPos(1)
  oCMenu.m["top1"].b.moveIt(pos[0],pos[1])
  pos = findPos(2)
  oCMenu.m["top2"].b.moveIt(pos[0],pos[1])
  pos = findPos(3)
  oCMenu.m["top3"].b.moveIt(pos[0],pos[1])
  pos = findPos(4)
  oCMenu.m["top4"].b.moveIt(pos[0],pos[1])
  pos = findPos(5)
  oCMenu.m["top5"].b.moveIt(pos[0],pos[1])
  pos = findPos(6)
  oCMenu.m["top6"].b.moveIt(pos[0],pos[1])
  pos = findPos(7)
  oCMenu.m["top7"].b.moveIt(pos[0],pos[1])
  pos = findPos(8)
  oCMenu.m["top8"].b.moveIt(pos[0],pos[1])

  
  //Setting the fromtop value
  oCMenu.fromTop = pos[1]
}
placeElements()
//Setting it to re place the elements after resize - the resize is not perfect though..
oCMenu.onafterresize="placeElements()"
