// JavaScript Document
// header for english website of Urumqi Observatory
// 2007-4-25

//the number of global navigation items
var numofitems = 5;

//show the present local data and time
var dayNames = new Array ();
dayNames[0]="Sunday";
dayNames[1]="Monday";
dayNames[2]="Tuesday";
dayNames[3]="Wednesday";
dayNames[4]="Thursday";
dayNames[5]="Friday";
dayNames[6]="Saturday";

var monthNames = new Array ();
monthNames[0]="January";
monthNames[1]="February";
monthNames[2]="March";
monthNames[3]="April";
monthNames[4]="May";
monthNames[5]="June";
monthNames[6]="July";
monthNames[7]="August";
monthNames[8]="September";
monthNames[9]="October";
monthNames[10]="November";
monthNames[11]="December";

var now = new Date();
var day = now.getDay();
var month = now.getMonth();
var year = now.getFullYear();
var date = now.getDate();

//header string
var headstr="";

//menu constructor
function menu(allitems,thisitem,startstate){ 
  callname= "gl"+thisitem;
  divname="subglobal"+thisitem;  
  this.numberofmenuitems = allitems;
  this.caller = document.getElementById(callname);
  this.thediv = document.getElementById(divname);
  this.thediv.style.visibility = startstate;
}

//menu methods
function ehandler(event,theobj){
  for (var i=2; i<= theobj.numberofmenuitems; i++){
    var shutdiv =eval( "menuitem"+i+".thediv");
    shutdiv.style.visibility="hidden";
  }
  theobj.thediv.style.visibility="visible";
}
				
function closesubnav(event){
  if ((event.clientY <48)||(event.clientY > 107)){
    for (var i=2; i<= numofitems; i++){
      var shutdiv =eval('menuitem'+i+'.thediv');
      shutdiv.style.visibility='hidden';
    }
  }
}

function showdw() {
  var dw = "";
  dw+=dayNames[day]+"&nbsp;";
  dw+=monthNames[month]+"&nbsp;";
  dw+=date+",&nbsp;"+year;
  document.write(dw);
}
//document.onmousemove = closesubnav;
//common head html code to output
//Note: the string must not inlude reteun-newline character!!! Otherwise the string operations occur error.

//the body tag is created here and attachs a mouse event.
//the top-left of page shows current date and week by showdw function.
headstr="<div class='datetime'><script type='text/javascript'>showdw();</script></div>";
//the site name and other useful links in the top-left.
headstr+="<div id='masthead'><h1 id='top' class='siteName'>Urumqi Observatory, NAOC</h1>";
headstr+="<div id='utility'><a href='contact.htm' title='Transport, Postal Address'>Contact</a> | <a href='http://www.uao.ac.cn/uao/link.htm' target='_blank' title='useful links to resources about astronomy'>Resources</a> | <a href='http://www.uao.ac.cn/index.php' title='Contents in Chinese'>Chinese</a> </div>";

//5 global navigation menus
headstr+="<div id='globalNav'> <img alt='' src='images/gblnav_left.gif' height='32' width='4' id='gnl' /> <img alt='' src='images/glbnav_right.gif' height='32' width='4' id='gnr' />";

headstr+="<div id='globalLink'><a href='enhome.htm' id='gl1' class='glink'>Home</a><a href='research.htm' id='gl2' class='glink' onmouseover='ehandler(event,menuitem2);'>Research</a><a href='facility_telescope.htm' id='gl3' class='glink' onmouseover='ehandler(event,menuitem3);'>Facilities</a><a href='organization.htm' id='gl4' class='glink' onmouseover='ehandler(event,menuitem4);'>Organizations</a><a href='pressroom.htm' id='gl5' class='glink' onmouseover='ehandler(event,menuitem5);'>Press Room</a></div>";
		
//add google search service for this site
headstr+="<form id='search' action='http://www.google.com/search' target='_blank'><input type='hidden' name='ie' value='UTF-8'><input type='hidden' name='oe' value='UTF-8'><a href='http://www.google.com/'><img src='images/google.gif' border='0' alt='Google'></a><input type='text' name='q' size='10' maxlength='255' value='' style='position:relative; top:-10px;padding: 0px;	margin: 0px;left:1px;z-index: 100;font-family: arial, sans-serif; font-size: 11px; font-style: normal; background: #FFFFFF; color: #000000;' /><input type='hidden' name='hl' value='zh-CN'><input type='hidden' name='domains' value='www.uao.ac.cn'><input type='submit' value='Search UO' style='position:relative; top:-9px;padding: 0px;margin: 0px;left:0px;z-index:100;font-family: arial, sans-serif; font-size: 11px; font-style: normal; background: #A6BF2E; color: #FFFFFF;'/></form></div>";
	
//submenuitems of each global navigation item
headstr+="<div id='subglobal1' class='subglobalNav'></div><div id='subglobal2' class='subglobalNav'><a href='#'>Pulsar</a> | <a href='#'>VLBI</a> | <a href='#'>Interstellar Molecule</a> | <a href='#'>GPS</a></div><div id='subglobal3' class='subglobalNav'> <a href='facility_telescope.htm'>Telescope</a> | <a href='facility_receiver.htm'>Receivers</a> | <a href='facility_time.htm'>Time</a> | <a href='facility_dataterminal.htm'>Data Terminals</a> | <a href='facility_controlsystem.htm'>Control System</a> | <a href='facility_vo.htm'>Virtual Observatory</a></div><div id='subglobal4' class='subglobalNav'> <a href='#'>Academic Committee</a> | <a href='#'>Astronomers</a> | <a href='#'>Engineers</a> | <a href='#'>Office</a> </div><div id='subglobal5' class='subglobalNav'> <a href='#'>News</a> | <a href='#'>Awards</a> | <a href='#'>Meeting</a> | <a href='#'>Papers</a></div></div>";
//write headstr to the html stream
document.write(headstr);
var menuitem2 = new menu(5,2,"hidden"); 
var menuitem3 = new menu(5,3,"hidden"); 
var menuitem4 = new menu(5,4,"hidden"); 
var menuitem5 = new menu(5,5,"hidden"); 

