<!--
/* Script that is commonly used for all the pages.
 * Author: Takako Hara (takakoh@u.washington.edu)
 * Created: 06/04
 * Last modified: 08/16/04
 */
//---------------------------------------------Date Related function -----------------------------------------------------
var date =new Date()
var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var monthname=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
function renderDate(){
	document.write(weekday[date.getDay()] + " ");
	document.write(date.getDate() + ", ");
	document.write(monthname[date.getMonth()] + " ");
	document.write(date.getFullYear());
}
//---------------------------------------------Date Related function -----------------------------------------------------
function openPage(num){
	switch(num){
		case 0 : top.location.href = "./japanpg.html"; break;
		case 1 : top.location.href = "./japanpg1.html"; break;
		case 2 : top.location.href = "./japanpg2.html"; break;
		case 3 : top.location.href = "./japanpg3.html"; break;
		case 4 : top.location.href = "./japanpg4.html"; break; 
		case 5 : top.location.href = "./japanpg5.html"; break; 	
		case 6 : top.location.href = "./japanpg6.html"; break; 
		case 7 : top.location.href = "./japanpg7.html"; break; 	
		default : break;
	}
}

function goToRefCatalog(){
	subNaviNumber = 4; 
	window.location.href = './reference.html';
}
function goToBySub(){
	window.location.href = './bysubject.html';
}
function changeToHover(num){
	//obj.style.background='#5A7A98';
	//obj.style.fontColor="Silver";
	document.getElementById("mainNavi" + num).style.background = '#6D89A3';
	document.getElementById("mainNaviSpan" + num).style.color = 'E6EFEF';
}
function changeToOut(num){
	//obj.style.background = '#B8D5A6';
	document.getElementById("mainNavi" + num).style.background = '#B8D5A6';
	document.getElementById("mainNaviSpan" + num).style.color = '#1E4B75';
}
//---------------------------------------Sub Navi realted functions commonly used in all pages -----------------------------
// all the page specific functions are in a respective files
function changeSubNaviPropertyToSelectedState(subNaviNum){
 	var subNaviId = "sub" + subNaviNum;
 	var selectedSubNavi = document.getElementById(subNaviId);
 	//selectedSubNavi.style.color = "#666699";
 	//selectedSubNavi.style.borderBottom = "2px #000066 solid";
 	selectedSubNavi.style.borderBottom = "2px #144470 solid";
 	selectedSubNavi.style.fontWeight = "bold";
}

function setSubNaviPropertyToUnselected(numSubNavi){
	for(i = 0; i<numSubNavi; i++){
  		var str ="";
		str = str.concat("sub" + i);
  		var subNavi = document.getElementById(str);
  		//subNavi.style.color = "lightGrey";
  		subNavi.style.borderBottom = "1px lightGrey solid";	
  		subNavi.background = "";
  		subNavi.style.fontWeight = "normal";
  		subNavi.style.fontSize = "12px";
 	}
}
//--------------------------------------- Structure --------------------------------------------
// class linkInfo that carries the link name, URL and it's detail.
function linkInfo(){
	var name = "";
	var url = "";
	var detail = "";
}
//--------------------------------------- Debugging functions -------------------------------------
function testCall(str){
	document.getElementById("test").innerHTML = str;
}

//--------------------------------------- Image related functions -------------------------------------
function changeImageToOver(obj){
	var imageSrc = obj.src;
	imageSrc = imageSrc.substring(0, imageSrc.length - 4);
	imageSrc = imageSrc + "_over.gif";
	obj.src = imageSrc;
}
function changeImageTo(obj){
	var imageSrc = obj.src;
	imageSrc = imageSrc.substring(0, imageSrc.length - 9);
	imageSrc = imageSrc + ".gif";
	obj.src = imageSrc;
}
function preloadImages(images){
	for (var i=0; i<images.length; i++){
		newImages[i] = new Image();
		newImages[i].src = images[i];
	}
}
function nadgeTsuru(){
	document.getElementById("tsuru").src =  "./images/icon_home_red_s_over.gif"
}
//---------------------------------------------- Open Window functions ----------------------------------------
function openPopUp(url, height, width, idName){
	posX = getObjLeftPos(document.getElementById(idName));
	posY = getObjTopPos(document.getElementById(idName));
	winObj = window.open(url, 'name', 
					"resizable = 1, scrollbars=0, toolbar = 0, menubar=0, location=0, status=0"
					+ ", width=" + width 
					+ ", height=" + height
					+ ", left=" + posX
					+ ", top=" + posY);

}
function openWin(url, height, width, idName){
	posX = getObjLeftPos(document.getElementById(idName));
	posY = getObjTopPos(document.getElementById(idName));
	window.open(url, 'name', 
					"resizable = 1, scrollbars=1, toolbar = 0, menubar=1, location=0, status=0"
					+ ", width=" + width 
					+ ", height=" + height
					+ ", left=" + posX 
					+ ", top=" + posY);
}
//------------------------------------------ Other helper functions ------------------------------------
 
// To get position of the layer. (got this from the web...)
function AnchorPosition_getPageOffsetLeft(obj) {
	var leftPos=obj.offsetLeft;
	while ((obj=obj.offsetParent) != null) { 
		leftPos += obj.offsetLeft; 
		}
	return window.screenLeft + leftPos;
	}
function getObjLeftPos (obj) {
	return AnchorPosition_getPageOffsetLeft(obj)-document.body.scrollLeft;
	}	
function AnchorPosition_getPageOffsetTop (obj) {
	var topPos=obj.offsetTop;
	while((obj=obj.offsetParent) != null) { 
		topPos += obj.offsetTop; 
		}
	return window.screenTop + topPos;
	}
function getObjTopPos(obj) {
	return AnchorPosition_getPageOffsetTop(obj)-document.body.scrollTop;
	}

//-->
