function translator(pattern) {
	var open_in_same_window = 0;
	var my_location = unescape(document.location.toString());
	var new_location ='';
	var new_pattern = '';
	var islocal = 1;
	if(my_location.indexOf('babelfish/translate_url_content?') != -1){
		var indexof_u = my_location.indexOf('&trurl=');
		if (indexof_u == -1) new_location = document.location;
		else {
			var subs = my_location.substring(indexof_u, my_location.length);
			var ss = subs.split('&');
			new_location = ss[1].substring(6, ss[1].length);
			islocal = 0;
		}
	} else {
		new_location = document.location;
		
	}

	indexof_p = pattern.indexOf('|');
	var isen = '';
	var lg = '';
	if (indexof_p == -1) {
		indexof_p1 = pattern.indexOf('><');
		if (indexof_p1 == -1) {
			new_pattern = pattern;
			if (pattern == 'en') isen = 1;
		}
		else {
			var psplit = pattern.split('><');
			new_pattern = psplit[0] + '_' + psplit[1];
			if (psplit[1] == 'en') isen = 1;
			else lg = psplit[1];
		}
	}
	else {
		var psplit = pattern.split('|');
		new_pattern = psplit[0]+'_'+psplit[1];
		if (psplit[1] == 'en') isen = 1;
		else lg = psplit[1];
	}

	var thisurl = '';
	if (isen == 1) thisurl = new_location;
	else {
		new_location = escape(new_location);
		if (islocal == 1) {
			thisurl = "language.php?to=" + lg + "&url=" + new_location;
		} else {
			open_in_same_window = 1;
			thisurl = "http://66.163.168.225/babelfish/translate_url_content?lp=" + new_pattern + "&trurl=" + new_location;
		}
	}

	if (open_in_same_window == 1) window.location.href = thisurl;
	else {
		msgWindow=window.open('' ,'subwindow','toolbar=yes,location=yes,directories=yes,status=yes,scrollbars=yes,menubar=yes,resizable=yes,left=0,top=0');
		msgWindow.focus();
		msgWindow.location.href = thisurl;
	}
}

//Zhe following is Writed By Jamy
window.onload=function()
{
	if(document.firstChild.nodeValue==null && window.event)
	{
		var a=document.getElementsByTagName("html")[0].outerHTML;
		document.write("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>\n"+a);
	}
	document.getElementById("curlanguage").onmouseover=view;
	document.getElementById("curlanguage").onclick=stopbubble;
	document.getElementById("translator").onclick=stopbubble;
	document.onclick=hidden;
	menuRoot = document.getElementById("menu");
	for (i=0; i<menuRoot.childNodes.length; i++)
	{
		node = menuRoot.childNodes[i];
		if (node.nodeName=="LI")
		{
			node.onmouseover=over;
			node.onmouseout=unover;
		  }
	}
}
function over()
{
	this.className+=" over";
}
function unover()
{
	this.className="";
}
function view(){
	var obj=document.getElementById("translator");
	obj.style.zIndex="2";
}
function stopbubble()
{
	if(window.event)
	{
		window.event.cancelBubble=true;
	}
	else
	{
		arguments[0].stopPropagation();
	}
}
function hidden()
{
	document.getElementById("translator").style.zIndex="0";
}
