<!--

function getElement(elementId){
	if(document.getElementById){
		var myel = document.getElementById(elementId);
		if(myel){
			return myel	
		}
	} 
	return false;	
}

function rollOver(e){
	var src,ftype,newsrc;
	if(!e)	{
		e = event;
	}
	
	src = this.src;
	ftype = src.substring(src.lastIndexOf('.'), src.length);
	newsrc = src;
	if(/_over/.test(src))
	{
		if(e.type == 'mouseout' && this.hit)	{
				newsrc = src.replace('_over','');
		}
	}else{
		if(e.type == 'mouseover')	{
				newsrc = src.replace(ftype, '_over'+ftype);
		}
	}
	this.hit = true;
	this.src=newsrc;
}

function MT_menuImage(imageid)
 {
	var menuImages, src, ftype, newsrc, i;
	if(document.getElementById && document.getElementsByTagName)
	{
	//	var menuImages = document.getElementById(imageid);
		// Check menuImages here in case imageid doesn't exist on page
		if (menuImages = getElement(imageid))
		{
			menuImages = menuImages.getElementsByTagName('img');
			if(menuImages)
			{
					for (i = 0; i< menuImages.length; i++){
					var thisimg = menuImages[i];
					thisimg.hit = false;

					if(thisimg.className != 'graphic' && thisimg.className != 'graphic selected')
					{
						// Preload image
						src = thisimg.src;
						ftype = src.substring(src.lastIndexOf('.'), src.length);
						newsrc = src.replace(ftype, '_over'+ftype);
						preloads['img'+i] = new Image();
						preloads['img'+i].src = newsrc;
						// Attach mouse over events to image
						thisimg.onmouseover=rollOver;
						thisimg.onmouseout=rollOver;
					}
				}
			}
		}
	}
}

function MT_textFields()
{
	
	if(document.getElementsByTagName)
	{
		var textFields = document.getElementsByTagName('input');
		if(textFields)
		{
			for (i = 0; i<textFields.length; i++)
			{
				if(textFields[i].value != '')
				{
					var myTF = textFields[i]
					myTF.initVal = myTF.value;
					
					myTF.onfocus =function(){
						if(this.initVal == this.value){
							this.value = '';
						}
					}

					myTF.onblur = function(){
						if(this.value == ''){
							this.value = this.initVal;
						}
					}
				}
			}
		}
	}
}

function MT_showDiv(divID, vis){
	var myDiv;
	if(myDiv = getElement(divID)){
			if(vis){
				myDiv.style.visibility = 'visible';
			} else {
				myDiv.style.visibility = 'hidden';
			}
		}
	return false;
}

function MT_displayDate(){
	var today = new Date();
	var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
	document.write(montharray[today.getMonth()]+' '+today.getDate()+', '+today.getFullYear());
}

function MT_print(){
	print();
	return false;
}

function MT_emailPage(){
	var mailit = "mailto:?subject=Link to Matthews Asia Funds";
	mailit += "&body=%0D%0A%0D%0ABelow is a link to the website of Matthews Asia Funds%0D%0A%0D%0A";
	mailit += "To view the page, visit: "+document.location.href+"%0D%0A%0D%0A";
	mailit += "Matthews Asia Funds are distributed by BNY Mellon Distributors Inc.";
	document.location.href = mailit;
	return false;
}

function MT_closeWindow(){
	window.opener = self;
	window.close();
	return false;
}

function MT_attachClose(linkid){
	//don't use getElement or IE gets JS error
	var closebutton = document.getElementById(linkid);
	if(closebutton){
		closebutton.onclick = function(){MT_closeWindow();}
		closebutton.onkeydown = function(){MT_closeWindow();}
	}
}

function openwindow(url) {
msg=open(url,'MatthewsAsiaFunds','width=475,height=600,toolbar=no,copyhistory=no,scrollbars=yes,resizable=no,directories=no,menubar=no,status=no,location=no');
msg.focus();
return false;
}

function openwindow_lit(url) {
msg=open(url,'MatthewsAsiaFunds','width=600,height=420,toolbar=no,copyhistory=no,scrollbars=no,resizable=yes,directories=no,menubar=no,status=no,location=no');
msg.focus();
return false;
}

function openwindow_apply(url) {
msg=open(url,'MatthewsAsiaFunds','width=500,height=800,toolbar=no,copyhistory=no,scrollbars=yes,resizable=yes,directories=no,menubar=no,status=no,location=no');
msg.focus();
return false;
}

function openwindow_pnc(url) {
msg=open(url,'PNC','width=800,height=600,toolbar=no,copyhistory=no,scrollbars=yes,resizable=yes,directories=no,menubar=no,status=no,location=no');
msg.focus();
return true;
}


function MT_jumpMenu(linkElement)
{
	var le;
	if(le = getElement(linkElement)){
		le.onchange = function(){
			document.location.href = this.value;
		}
	}
}


// Container for image preloads //
var preloads;
preloads = new Object();


-->