/*
MDBG free online Chinese-English dictionary Javascript support file

Copyrights MDBG 2006
*/

function GoBack()
{
	if(location.hash=="#top")
		history.go(-2);
	else
		history.go(-1);
}

function as(unicode) {
	var popup=window.open('popup_animation_strokes.php?uvd='+unicode, 'radical', 'resizable=yes,scrollbars=yes,width=380,height=420');

	return false;
}

function radicalPopup(radicalNumber, radical, comment, mandarin, definition) {
	var popup=window.open('', 'radical', 'resizable=yes,scrollbars=yes,width=240,height=225');

	var popupHtml='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n';
	popupHtml+='<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh" lang="zh"><head><title>Radical</title><link rel="stylesheet" href="rsc/css/style.css?dummy=1" type="text/css" /></head><body>';
	popupHtml+='<script type="text/javascript">\n';
	popupHtml+='	window.onload=setFocus;\n';
	popupHtml+='	function setFocus()\n';
	popupHtml+='	{\n';
	popupHtml+='		linkElement = document.getElementById("closelink");\n';
	popupHtml+='		linkElement.focus();\n';
	popupHtml+='	}\n';
	popupHtml+='</script>\n';
	popupHtml+='<br />\n';
	popupHtml+='<div style="text-align: center" class="panel">';
	popupHtml+='<table>'
	popupHtml+='<tr><td>Radical:</td><td class="rad">'+radical+'</td></tr>';
	popupHtml+='<tr><td>&nbsp;</td><td><div class="optiontext">'+comment+'</div></td></tr>';
	popupHtml+='<tr><td>Mandarin:</td><td>'+mandarin+'</td></tr>';
	popupHtml+='<tr><td>Definition:</td><td>'+definition+'</td></tr>';
	popupHtml+='<tr><td>KangXi no.:</td><td>'+radicalNumber+'</td></tr>';
	popupHtml+='</table>';
	popupHtml+='</div>';
	popupHtml+='<div align="center"><a id="closelink" href="#" onclick="javascript:window.close();">Close</a></div>\n';
	popupHtml+='</body></html>';

	popup.document.write(popupHtml);
	popup.document.close();
	return false;
}

function voicePopup(filename, display) {
	var popup=window.open('', 'voice', 'resizable=yes,scrollbars=yes,width=200,height=170');

/*
	if (window.focus) {
		popup.focus();
	}
*/

	var popupHtml='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n';
	popupHtml+='<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh" lang="zh"><head><title>'+display+'</title><link rel="stylesheet" href="rsc/css/style.css?dummy=1" type="text/css" /></head><body>';
	popupHtml+='<br />';
	popupHtml+='<div align="center">';
	popupHtml+='<table class="panel"><tr><td>';
	popupHtml+='<object type="application/x-shockwave-flash" data="rsc/swf/button_player/musicplayer_f6.swf?autoplay=true&amp;song_url='+filename+'" width="17" height="17">';
	popupHtml+='<param name="movie" value="rsc/swf/button_player/musicplayer_f6.swf?autoplay=true&amp;song_url='+filename+'" />';
	popupHtml+='<img src="rsc/swf/button_player/noflash.gif" width="17" height="17" alt="" />';
	popupHtml+='</object>';
	popupHtml+='</td></tr></table>';
	popupHtml+='</div>';
	popupHtml+='<div align="center">';
	popupHtml+='<p>'+display+'</p>';
	popupHtml+='<p><a href="#" onclick="javascript:window.close();">Close window</a></p>';
	popupHtml+='<p style="font-size: 62%"><a title="Click using right mouse button and choose \'Save As\'" target="_blank" href="'+filename+'">(download)</a></p>';
	popupHtml+='</div>';
	popupHtml+='</body></html>';

/*
	var popupHtml='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n';
	popupHtml+='<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh" lang="zh"><head><title>'+display+'</title><link rel="stylesheet" href="rsc/css/style.css?dummy=1" type="text/css" /></head><body>';
	popupHtml+='<br /><table width="100%"><tr align="center"><td><embed src="'+filename+'" width="180" height="45" /></td></tr></table>';
	popupHtml+='<div align="center"><p>Pinyin: '+display+'</p><p><a href="#" onclick="javascript:window.close();">Close window</a></p><p class="hinttext"><a target="_blank" href="http://www.apple.com/quicktime/download/standalone.html">Click here to install Apple Quicktime if audio doesn\'t play</a></p></div>';
	popupHtml+='</body></html>';
*/

	popup.document.write(popupHtml);
	popup.document.close();
	return false;
}

function popup(url) {
	var popup=window.open(url, '_blank', 'resizable=yes,scrollbars=yes');
	return false;
}

function zc(character, description) {
	var popup=window.open('', '_blank', 'resizable=yes,scrollbars=yes,width=380,height=460');

	var popupHtml='';
	popupHtml+='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n';
	popupHtml+='<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh" lang="zh"><head><title>Character Zoom</title><link rel="stylesheet" href="rsc/css/style.css?dummy=1" type="text/css" /></head><body>\n';
	popupHtml+='<script type="text/javascript">\n';
	popupHtml+='	window.onload=setFocus;\n';
	popupHtml+='	function setFocus()\n';
	popupHtml+='	{\n';
	popupHtml+='		linkElement = document.getElementById("closelink");\n';
	popupHtml+='		linkElement.focus();\n';
	popupHtml+='	}\n';
	popupHtml+='</script>\n';
	popupHtml+='<br /><table width="100%"><tr align="center"><td>\n';
	popupHtml+='<div class="zoomchar">' + character + '</div>\n';
	popupHtml+='</td></tr></table>\n';
	popupHtml+='<div align="center"><p>'+description+'</p><p><a id="closelink" href="#" onclick="javascript:window.close();">Close</a></p></div>\n';
	popupHtml+='</body></html>\n';

	popup.document.write(popupHtml);
	popup.document.close();

	return false;
}

function gb(charNum) {
	var popup=window.open('', '_blank', 'resizable=yes,scrollbars=yes,width=350,height=360');

	var popupHtml='';
	popupHtml+='<!DOCTYPE html \n';
	popupHtml+='     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\n';
	popupHtml+='     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n';
	popupHtml+='<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh" lang="zh">\n';
	popupHtml+='<head>\n';
	popupHtml+='<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />\n';
	popupHtml+='<title>Character Details</title>\n';
	popupHtml+='</head>\n';
	popupHtml+='<body style="font-family: Arial, Sans-Serif">\n';
	popupHtml+='<script type="text/javascript">\n';
	popupHtml+='	window.onload=setFocus;\n';
	popupHtml+='	function setFocus()\n';
	popupHtml+='	{\n';
	popupHtml+='		linkElement = document.getElementById("closelink");\n';
	popupHtml+='		linkElement.focus();\n';
	popupHtml+='	}\n';
	popupHtml+='</script>\n';
	popupHtml+='\n';
	popupHtml+='<div align="center">\n';
	popupHtml+='\n';
	popupHtml+='<table>\n';
	popupHtml+='<tr>\n';
	popupHtml+='<td>\n';
	popupHtml+='<img width="56" height="56" src="rsc/img/chargif/GB48h/anim/' + charNum + '.gif" />\n';
	popupHtml+='<br />\n';
	popupHtml+='<br />\n';
	popupHtml+='<img width="56" height="224" src="rsc/img/chargif/GB48all4/vert/' + charNum + '.gif" />\n';
	popupHtml+='</td>\n';
	popupHtml+='<td rowspan="2">\n';
	popupHtml+='<div align="center">\n';
	popupHtml+='<img width="256" height="256" src="rsc/img/chargif/GB256s/stat/' + charNum + '.gif" />\n';
	popupHtml+='<br />\n';
	popupHtml+='<a id="closelink" href="#" onclick="window.close();">Close</a>\n';
	popupHtml+='</div>\n';
	popupHtml+='</td>\n';
	popupHtml+='</tr>\n';
	popupHtml+='</table>\n';
	popupHtml+='\n';
	popupHtml+='</div>\n';
	popupHtml+='\n';
	popupHtml+='</body>\n';
	popupHtml+='</html>\n';

	popup.document.write(popupHtml);
	popup.document.close();

	return false;
}

function b5(charNum) {
	var popup=window.open('', '_blank', 'resizable=yes,scrollbars=yes,width=180,height=160');

	var popupHtml='';
	popupHtml+='<!DOCTYPE html \n';
	popupHtml+='     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\n';
	popupHtml+='     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n';
	popupHtml+='<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh" lang="zh">\n';
	popupHtml+='<head>\n';
	popupHtml+='<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />\n';
	popupHtml+='<title>Character Details</title>\n';
	popupHtml+='</head>\n';
	popupHtml+='<body style="font-family: Arial, Sans-Serif">\n';
	popupHtml+='<script type="text/javascript">\n';
	popupHtml+='	window.onload=setFocus;\n';
	popupHtml+='	function setFocus()\n';
	popupHtml+='	{\n';
	popupHtml+='		linkElement = document.getElementById("closelink");\n';
	popupHtml+='		linkElement.focus();\n';
	popupHtml+='	}\n';
	popupHtml+='</script>\n';
	popupHtml+='\n';
	popupHtml+='<div align="center">\n';
	popupHtml+='\n';
	popupHtml+='<table>\n';
	popupHtml+='<tr>\n';
	popupHtml+='<td valign="middle">\n';
	popupHtml+='<img width="56" height="56" src="rsc/img/chargif/B548/anim/' + charNum + '.gif" />\n';
	popupHtml+='</td>\n';
	popupHtml+='<td>\n';
	popupHtml+='&nbsp;\n';
	popupHtml+='</td>\n';
	popupHtml+='<td>\n';
	popupHtml+='<img width="64" height="64" src="rsc/img/chargif/B564/' + charNum + '.gif" />\n';
	popupHtml+='</td>\n';
	popupHtml+='</tr>\n';
	popupHtml+='</table>\n';
	popupHtml+='\n';
	popupHtml+='<a id="closelink" href="#" onclick="window.close();">Close</a>\n';
	popupHtml+='\n';
	popupHtml+='</div>\n';
	popupHtml+='\n';
	popupHtml+='</body>\n';
	popupHtml+='</html>\n';

	popup.document.write(popupHtml);
	popup.document.close();

	return false;
}

function addSearchEngine(name,ext,cat)
{
	if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function"))
	{
		//cat="Web";
		//cat=prompt("In what category should this engine be installed?","Web")
		window.sidebar.addSearchEngine(
			"http://www.xuezhongwen.net/chindict/extras/searchplugins/"+name+".src",
			"http://www.xuezhongwen.net/chindict/extras/searchplugins/"+name+"."+ext,
			name,
			cat );
	}
	else
	{
		alert("Mozilla Firefox is needed to install this plugin");
	}
}
