
var coll = "";
var isNav4, isNav6, isIE, isIE4, isIE5, isIE55, isIE6, isMac;
if (parseInt(navigator.appVersion) >= 4)
{
	
	if (navigator.platform.indexOf("Mac")!=-1)
		isMac = true;
	
	if (navigator.appName == "Netscape")
	{
		if (navigator.vendor == ("Netscape6") || navigator.product == ("Gecko"))
			isNav6 = true;
		else
			isNav4 = true;
	}
	else
	{
		isIE = true;
		coll = "all.";
                if (navigator.appVersion.indexOf("MSIE 6")!=-1) 
                	isIE6 = true;
                else if (navigator.appVersion.indexOf("MSIE 5.5")!=-1) 
                	isIE55 = true;
		else if (navigator.appVersion.indexOf("MSIE 5")!=-1)
			isIE5 = true;
		else
			isIE4 = true;
	}
}


var canResize = false;
function handleResize()
{
	if(canResize) location.reload();
	return false;
}
if (isNav4)
{
	window.captureEvents(Event.RESIZE);
	window.onresize = handleResize;
}


function getObject(obj)
{
	var theObj;
	if (typeof obj == "string")
	{
		if (isNav6) 
			return document.getElementById(obj);
		theObj = eval("document." + coll + obj);
	}
	else
		theObj = obj;
	return theObj;
}


function getFormObject(divO, formO)
{
	if (isNav6) 
		return document.getElementById(formO);
	else if (isNav4)
		return eval("document." + divO + ".document." + formO);
	else
		return eval("document." + coll + formO);

}


function shiftTo(obj, x, y)
{
	if (isNav4)
		obj.moveTo(x,y);
	else if(isNav6)
	{
		obj.style.left = x;
		obj.style.top = y;
	}
	else
	{
		obj.style.pixelLeft = x;
		obj.style.pixelTop = y;
	}
}

function shiftBy(obj, dX, dY) 
{
	if (isNav4)
		obj.moveBy(dX, dY);
	else if (isNav6)
	{
		
	}
	else 
	{
		obj.pixelLeft += dX;
		obj.pixelTop += dY;
	}
}


function getWindowHeight()
{
	if(isNav4 || isNav6)
		return window.innerHeight;
	else
		return document.body.clientHeight;
}


function getWindowWidth()
{
	if(isNav4 || isNav6)
		return window.innerWidth;
	else
		return document.body.clientWidth;
}


function getObjWidth(obj)
{
	if(isNav4)
		return obj.clip.width;
	else if(isNav6)
		return obj.offsetWidth;
	else
		return obj.clientWidth;
}


function getObjHeight(obj)
{
	if(isNav4)
		return obj.clip.height;
	else if(isNav6)
		return obj.offsetHeight;
	else
		return obj.clientHeight;
}


function getObjLeft(obj)
{
	if(isNav4)
		return obj.left;
	else if(isNav6)
		return obj.offsetLeft;
	else
		return obj.style.pixelLeft;
}


function getObjTop(obj)
{
	if(isNav4)
		return obj.top;
	else if(isNav6)
		return obj.offsetTop;
	else
		return obj.style.pixelTop;
}


function getScrollY()
{
	if(isNav4 || isNav6)
		return window.pageYOffset;
	else
		return document.body.scrollTop;
}


function setZIndex(obj, z)
{
	if(isNav4)
		obj.zIndex = z;
	else
		obj.style.zIndex = z;
}


function show(obj)
{
	if(isNav4)
		obj.visibility = "visible";
	else
		obj.style.visibility = "visible";
}


function hide(obj)
{
	if(isNav4)
		obj.visibility = "hidden";
	else
		obj.style.visibility = "hidden";
}



// **************** MENU SPECIFIC FUNCTIONS ****************************




function buildItemHTML(itm)
{
	var tW;
	
	if (itm.lvl == 1)
		tW = 102;
	else
		tW = 152;
		
	var s = "<DIV id='" + itm.name + "' class='menuItems'><TABLE border='0' cellspacing='0' cellpadding='1' width='*'><TR><TD bgcolor='#000000'><TABLE border='0' cellspacing='0' cellpadding='2' width='" + tW + "'><TR>";
	if(itm.hasChildren || (itm.name == "srch"))
	{
		s += "<TD class='blackmenutext' bgcolor='#ffffff'>" + itm.displayName + "</TD>";
		s += "<TD bgcolor='#ffffff' align='right'><IMG src='images/aOff.gif' width='9' height='9' border='0'></TD>";
	}
	else
	{
		s += "<TD class='blackmenutext' bgcolor='#ffffff'>" + itm.displayName + "</TD>";
	}
	s += "</TR></TABLE></TD></TR></TABLE></DIV>\n";
	s += "<DIV id='" + itm.nameOn + "' class='menuItems'><TABLE border='0' cellspacing='0' cellpadding='1' width='*'><TR><TD bgcolor='#000000'><TABLE border='0' cellspacing='0' cellpadding='2' width='" + tW + "'><TR>";
	if(itm.hasChildren || (itm.name == "srch"))
	{
		s += "<TD class='whitemenutext' bgcolor='#cc0000'>" + itm.displayName + "</TD>";
		s += "<TD bgcolor='#cc0000' align='right'><IMG src='images/aOn.gif' width='9' height='9' border='0'></TD>";
	}
	else
	{
		s += "<TD class='whitemenutext' bgcolor='#cc0000'>" + itm.displayName + "</TD>";
	}
	s += "</TR></TABLE></TD></TR></TABLE></DIV>\n";
        s += "<DIV id='" + itm.nameTrans + "' class='transItems'></DIV>\n";
	return s;
}


function buildMenuHTML()
{
	var s = "";
	for (var i = 0; i < this.menuItems.length; i++)
		s += buildItemHTML(this.menuItems[i]);
	return s;
}


function getStackHeight(itemStack)
{
	var h = 0;
	for (var i = 0; i < itemStack.length; i++)
		h += itemStack[i].height;
	return h;
}


function liteTree()
{
	show(this.onRef);
	
	if (this.hasChildren)
	{
		if (!this.childrenSized)
			this.sizeItems();
		
		var h = getStackHeight(this.children);
		
		this.cX = this.left + this.xO;
		this.cY = this.top + this.yO;
		
		if (this.cY < getScrollY() + 4)
			this.cY = getScrollY() + 4;
			
		if (this.cY + h > getScrollY() + getWindowHeight() - 4)
			this.cY = getScrollY() + getWindowHeight() - h - 4;
			
		this.positionChildren();
		this.showChildren();
	}
}


function hideTree(newItm)
{
	if (newItm.parent != this)
	{
		if (newItm.parent == this.parent)
		{
			hide(this.onRef);
			
			if (this.hasChildren)
				this.hideChildren();
		}
		else
		{
			hide(this.onRef);
			
			if (this.hasChildren)
				this.hideChildren();
			
			this.parent.hideTree(newItm);
		}
	}
}


function positionChildren()
{
	var L = this.cX;
	var T = this.cY;
	for (var i = 0; i < this.children.length; i++)
	{
		var itm = this.children[i];
		itm.left = L;
		itm.top = T;
		itm.right = itm.left + itm.width;
		itm.bottom = itm.top + itm.height;
		shiftTo(itm.ref, L, T);
		shiftTo(itm.onRef, L, T);
		shiftTo(itm.tRef, L, T);
		T += itm.height;
		
	}
}


function hideChildren()
{
	for (var i = 0; i < this.children.length; i++)
	{
		hide(this.children[i].tRef);
		hide(this.children[i].ref);
	}
}


function showChildren()
{
	for (var i = 0; i < this.children.length; i++)
	{
		show(this.children[i].tRef);
		show(this.children[i].ref);
	}
}


function menuItem(name, displayName, dest, parentName, menuName)
{
	this.displayName = displayName;
	this.name = name;
        this.nameOn = name + "On";
        this.nameTrans = name + "Trans";
	this.dest = dest;
	this.ref;
	this.onRef;
	this.tRef;
	this.cX;
	this.cY;
	this.xO = 100;
	this.yO = -8;
	this.parent = eval(parentName);
	this.lvl = this.parent.lvl+1;
	this.parent.hasChildren = true;
	this.menu = eval(menuName);
	this.hasChildren = false;
	this.children = null;
	this.childrenSized = false;
	this.isOpen = false;
	this.top;
	this.bottom;
	this.left;
	this.right;
	this.width;
	this.height;
	this.menu.menuItems[this.menu.menuItems.length] = this;
	this.sizeItems = sizeItems;
	this.liteTree = liteTree;
	this.hideTree = hideTree;
	this.positionChildren = positionChildren;
	this.showChildren = showChildren;
	this.hideChildren = hideChildren;
}


function getDOMRefs()
{				
	for (var i = 0; i < this.menuItems.length; i++)
	{
		this.menuItems[i].ref = getObject(this.menuItems[i].name);
		this.menuItems[i].onRef = getObject(this.menuItems[i].nameOn);
		this.menuItems[i].tRef = getObject(this.menuItems[i].nameTrans);
	}
}


function makeHierachy()
{
	for (var i = 0; i < this.menuItems.length; i++)
	{
		var item = this.menuItems[i];
		var myLevel = item.parent.children;
		myLevel[myLevel.length] = item;
		if(item.hasChildren) item.children = new Array();
	}
}


function setEventCapture() {
	for (var i = 0; i < this.menuItems.length; i++) {
		if (isNav4) 
		{
			this.menuItems[i].tRef.captureEvents(Event.MOUSEOVER);
			this.menuItems[i].tRef.captureEvents(Event.MOUSEOUT);
			this.menuItems[i].tRef.captureEvents(Event.CLICK);
			document.captureEvents(Event.CLICK);
		}
		if (!isIE55 && !isIE6 && !isNav6)
		{
			this.menuItems[i].tRef.onmouseover = handleOver;
			this.menuItems[i].tRef.onmouseout = handleOut;
			this.menuItems[i].tRef.onclick = handleMenuClick;
		}
		
		document.onclick = handleClick;
	
	}
}


function sizeItems()
{

	for (var i = 0; i < this.children.length; i++)
	{
		var itm = this.children[i];
		itm.width = getObjWidth(itm.ref);
		itm.height = getObjHeight(itm.ref)-1;

		if (isIE55 || isIE6 || isNav6)
			itm.tRef.innerHTML = "<IMG id='" + itm.name + "Image' src='images/trans.gif' width='" + itm.width + "' height='" + (itm.height) + "' border='0' onMouseOver='handleOver(event)' onMouseOut='handleOut(event)' onClick='handleMenuClick(event)'>";
		else if (isIE)
		{
		        itm.tRef.style.pixelWidth = itm.width;
		        itm.tRef.style.pixelHeight = itm.height;
		}
		else
		{
			itm.tRef.clip.width = itm.width;
			itm.tRef.clip.height = itm.height;
		}
		
		setZIndex(itm.ref, 5 * itm.lvl);
		setZIndex(itm.onRef, 6 * itm.lvl);
		setZIndex(itm.tRef, 7 * itm.lvl);
		
	}

	this.childrenSized = true;
}


function handleClick(e) 
{

	if (theMenu.searchOpen || isNav4)
	{
		
		var x, y;
				
		if (isNav4 || isNav6)
		{
			x = e.pageX;
			y = e.pageY;
			if (isNav4)
				if (e.target.name == "sType")
				{
					document.routeEvent(e);
					return;
				}
		
			if (isNav6)
				if (e.target.index)
					return;
		
		}
		else
		{
			if(window.event.srcElement.name == "Language" || window.event.srcElement.name == "Subject")
				return;
			
			x = window.event.clientX;
			y = window.event.clientY;
		}
		
		if ((x > srch.left) && (x <  srch.right) && (y > srch.top) && (y < srch.bottom))
		{
			if (isNav4)
				document.routeEvent(e);
			return;
		}
		
		if (theMenu.searchOpen)
			if ((x > getObjLeft(searchPanel)) && (x < getObjLeft(searchPanel) + getObjWidth(searchPanel)) && (y > getObjTop(searchPanel)) && (y < getObjTop(searchPanel) + getObjHeight(searchPanel)))
			{
				if (isNav4)
					document.routeEvent(e);
				return;
			}
		
			
		
		if (theMenu.searchOpen)
			closeSearch();
		
		if (isNav4)
		{
			document.routeEvent(e);
		}
	}	

	return;
}


function closeSearch()
{
	
	var eX = theMenu.cX - 494;
	var sX = eX + 597;
	
	if (isNav4 || isMac)
	{
		hide(searchPanel);
	}
	else
	{
		moveSearch(searchPanel, sX - 60, eX, -60);
	}
	
	// hide(srch.onRef);
	
	theMenu.searchOpen = false;
}


function showSearch()
{
	if (!this.searchOpen)
	{
		this.searchOpen = true;
		var sX = this.cX - 494;
		var eX = sX + 597;
		
		if (isNav4 || isMac)
		{
			shiftTo(searchPanel, eX, 48);
			show(searchPanel);
		}
		else
		{
			shiftTo(searchPanel, sX, 48);
			show(searchPanel);
			moveSearch(searchPanel, sX + 60, eX, 60);
	
		}
	}
}


function moveSearch(ob, bgn, end, dX)
{
	if (Math.abs((end - bgn)) <= Math.abs(dX))
	{
		shiftTo(searchPanel, end, 48);
		if (dX < 0)
			hide(searchPanel);
	}
	else
	{
		shiftTo(ob, bgn, 48);
		theMenu.sTimer = setTimeout("moveSearch(searchPanel, " + (bgn + dX) + ", " + end + ", " + dX + ")", 25);
	}
}


function reset()
{
	this.currItem = null;
	
	for (var i = 0; i < this.menuItems.length; i++)
	{
			hide(this.menuItems[i].onRef);
		
		if (this.menuItems[i].lvl > 1)
		{
			hide(this.menuItems[i].tRef);
			hide(this.menuItems[i].ref);
		}
	}
}


function initMenu()
{
	this.getDOMRefs();
	this.makeHierachy();
	this.sizeItems();
	this.setEventCapture();
	this.positionChildren();
	this.showChildren();

}


function writeMenuHTML()
{
	document.write(theMenu.buildMenuHTML());
}


function menu(name)
{
	this.name = name;
	this.cX = 10;
	this.cY = 76;
	this.lvl = 0;
	this.lag = 100;
	this.timer;
	this.sTimer;
	this.searchOpen = false;
	this.loadSearchExp = false;
	this.hasChildren = true;
	this.childrenSized = false;
	this.isOpen = true;
	this.menuItems = new Array();
	this.children = new Array();
	this.buildMenuHTML = buildMenuHTML;
	this.initMenu = initMenu;
	this.getDOMRefs = getDOMRefs;
	this.makeHierachy = makeHierachy;
	this.sizeItems = sizeItems;
	this.setEventCapture = setEventCapture;
	this.positionChildren = positionChildren;
	this.reset = reset;
	this.hideTree = hideTree;
	this.showSearch = showSearch;
	this.showChildren = showChildren;
	this.hideChildren = hideChildren;
}


function handleOver(e) 
{

	clearTimeout(theMenu.timer);
	
	var nm;
	
	if (isIE)
	{
		event.srcElement.style.cursor = "hand";
		nm = event.srcElement.id.slice(0,-5);
	}
	else
	{
		if (isNav6)
			e.target.style.cursor = "pointer";
		nm = e.target.id.slice(0,-5);
	}

	var itm = eval(nm);
		
	if (theMenu.currItem)
			theMenu.currItem.hideTree(itm);
	
	theMenu.currItem = itm;
	
	theMenu.currItem.liteTree();
	
	return;
}


function handleOut(e) 
{
	
        theMenu.timer = setTimeout("theMenu.reset();", theMenu.lag);
	return;
}


function handleMenuClick(e) 
{
	if (theMenu.currItem.name == "srch")
	{
		if (theMenu.searchOpen)
			closeSearch();
		else
			theMenu.showSearch();
	}
	else
		window.location.href = theMenu.currItem.dest;
	return;
}


function swapDivImg(divID,imgID,imgName)
{
	if (isNav4)
	{
		var theObj;
		theObj = eval("document." + divID + ".document" );
		theObj[imgName].src = eval(imgID + ".src");
	}
	else
		document[imgName].src = eval(imgID + ".src");
}


function swap(imgID,imgName)
{
	if (document.images)
		document[imgID].src=eval(imgName + ".src");
}


function TranslationInquiry(t)
{
	searchForm.action = "Attachment_Inquiry.asp";
	searchForm.sType[1].checked = true;
	
	for (i = 0; i < searchForm.Language.options.length; i++)
	{
		if (searchForm.Language.options[i].value == t) 
		{
			searchForm.Language.options[i].selected = true;
			break;
		}
	}
	
	searchForm.Product.options[0].selected = true;
	searchForm.DateType.options[0].selected = true;
	
	ToggleDateFields(false);
	
	searchForm.FromDay.value = "";
	searchForm.FromMonth.value = "";
	searchForm.FromYear.value = "";
	searchForm.ToDay.value = "";
	searchForm.ToMonth.value = "";
	searchForm.ToYear.value = "";
	searchForm.Subject.options[0].selected = true;
	searchForm.headline.value = "";
	searchForm.PRPerPage.value = "10";
	searchForm.mood.value = "";
	searchForm.CurPage.value = "";
	searchForm.PreservedValue.value = "";
	
	searchForm.submit();
		
}


function ProductInquiry(p)
{
	searchForm.action = "Attachment_Inquiry.asp";
	searchForm.sType[2].checked = true;
	
	for (i = 0; i < searchForm.Product.options.length; i++)
	{
		if (searchForm.Product.options[i].value == p) 
		{
			searchForm.Product.options[i].selected = true;
			break;
		}
	}
	
	searchForm.Language.options[0].selected = true;
	searchForm.DateType.options[0].selected = true;
	
	ToggleDateFields(false);
	
	searchForm.FromDay.value = "";
	searchForm.FromMonth.value = "";
	searchForm.FromYear.value = "";
	searchForm.ToDay.value = "";
	searchForm.ToMonth.value = "";
	searchForm.ToYear.value = "";
	searchForm.Subject.options[0].selected = true;
	searchForm.headline.value = "";
	searchForm.PRPerPage.value = "10";
	searchForm.mood.value = "";
	searchForm.CurPage.value = "";
	searchForm.PreservedValue.value = "";
		
	searchForm.submit();
}


function CategoryInquiry(c)
{
	searchForm.action = "Inquire_pr.asp";
	searchForm.sType[0].checked = true;
	searchForm.DateType.options[0].selected = true;
	searchForm.Language.options[0].selected = true;
	
	ToggleDateFields(false);
	
	searchForm.FromDay.value = "";
	searchForm.FromMonth.value = "";
	searchForm.FromYear.value = "";
	searchForm.ToDay.value = "";
	searchForm.ToMonth.value = "";
	searchForm.ToYear.value = "";
	
	for (i = 0; i < searchForm.Subject.options.length; i++)
	{
		if (searchForm.Subject.options[i].value == c) 
		{
			searchForm.Subject.options[i].selected = true;
			break;
		}
	}
	
	searchForm.headline.value = "";
	searchForm.PRPerPage.value = "10";
	searchForm.mood.value = "";
	searchForm.CurPage.value = "";
	searchForm.PreservedValue.value = "";
		
	searchForm.submit();
}


function SpecialEventInquiry(s)
{
	searchForm.action = "Inquire_pr.asp";	
	searchForm.sType[0].checked = true;
	searchForm.Special_Event.value = s;
	searchForm.DateType.options[1].selected = true;
	searchForm.Language.options[0].selected = true;
	
	ToggleDateFields(false);
	
	searchForm.FromDay.value = "";
	searchForm.FromMonth.value = "";
	searchForm.FromYear.value = "";
	searchForm.ToDay.value = "";
	searchForm.ToMonth.value = "";
	searchForm.ToYear.value = "";
	searchForm.Subject.options[0].selected = true;
	searchForm.headline.value = "";
	searchForm.PRPerPage.value = "10";
	searchForm.mood.value = "search";
	searchForm.CurPage.value = "";
	searchForm.PreservedValue.value = "";
	
	searchForm.submit();
}


function DailySummaryInquiry()
{
	searchForm.action = "Inquire_pr.asp";	
	searchForm.sType[0].checked = true;
	searchForm.DateType.options[0].selected = true;
	
	ToggleDateFields(false);
	
	searchForm.FromDay.value = "";
	searchForm.FromMonth.value = "";
	searchForm.FromYear.value = "";
	searchForm.ToDay.value = "";
	searchForm.ToMonth.value = "";
	searchForm.ToYear.value = "";
	searchForm.Subject.options[0].selected = true;
	searchForm.headline.value = "AsiaNet Daily Summary";
	searchForm.PRPerPage.value = "10";
	
	searchForm.submit();
}


function popLink(d)
{
	window.open(d,"link");
}


function popTimeZones()
{
	window.open("http://www.timezoneconverter.com/cgi-bin/tzc.tzc","timezones");
}


xOff = new Image();
xOff.src = "images/xOff.gif";
xOn = new Image();
xOn.src = "images/xOn.gif";
slogan = new Image(1,1);
slogan.src = "images/slogan.gif";

var logo;
var searchPanel;
var sCov;
var searchForm;


function init(searchOn)
{

	searchPanel = getObject("searchPanel");
	searchForm = getFormObject("searchPanel", "SubmitForm");

 	if (isMac && isIE)
 	{
		logo = getObject("logo");
		sCov = getObject("sCov");
	
		shiftTo(sCov, xP - 500, 0);
		shiftTo(logo, xP, 10);
 	}

	setTimeout("swap('slogan','slogan');", 500);

	canResize = true;

}













