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()
{
	var href=document.location.href;
	if(href.indexOf("66.163.168.225")!=-1)//translator error
	{
		if(window.event)
		{
			var a=Name("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);
		}
		var form=Name("form");
		if(form.length)
		{
			for(var i=0;i<form.length;i++)
			{
				form[i].action=Name(form[i],"input")[2].value;
			}
		}
	}
}

	if(Name(Id("leftdiv"),"p")[0].parentNode.className!="line")
	{
		var line=document.createElement("div");
		line.className="line";
		line.appendChild(Name(Id("leftdiv"),"p")[0]);
		Id("leftdiv").appendChild(line);//js layout
	}
	
	if(Id("title3")==null)
	{
		var cer=document.createElement("div");
		cer.innerHTML="<h2 id='title3'><span>Certificate</span></h2><div class='line'><p><a href='images/cerb.jpg' target='_blank' class='cerb'><img src='images/cer.jpg' /></a></p></div>";
		Id("leftdiv").appendChild(cer);//add Certificate
	}
	
	over("menudiv",652,5);//overflow
	over("title1",190,10);over("title2",190,10);over("title3",190,10);//over(sender,max-width,min-padding);
	var ctlist=Name(Id("leftdiv"),"ul")[0];
	var cts=Name(ctlist,"a");
	for(var i=0;i<cts.length;i++)
	{
		while(cts[i].offsetWidth>168)
		{
			var size=Style(cts[i],"fontSize");
			size=parseInt(size);
			cts[i].style.fontSize=size-1+"px";
		}
	}
	Id("righttitle").innerHTML="Welcome to Shenzhen Creation Precision Mould&Die Co., Ltd.";
	Name(Id("leftdiv"),"ul")[0].appendChild(Id("searchdiv"));
	var href=document.location.href;
	
	Id("lang").onmouseover=function(){this.style.cursor="pointer";Id("trans").style.visibility="visible";}
	Id("lang").onclick=stopBubble;
	document.onclick=function(){Id("trans").style.visibility="hidden";}
	var trans=Name(Id("trans"),"dd");
	for(var i=0;i<trans.length;i++)
	{
		trans[i].onmouseover=function(){this.style.cursor="pointer";}
		trans[i].onclick=function(){translator("en|"+this.id);};
	}
	try{document.execCommand("BackgroundImageCache",false,true);}catch(e){}

	tables();
	
	if(/index.html/gi.test(href)==true)
	{
		var hr1=Name(Id("rightdiv"),"hr")[0];
		var pr=document.createElement("p");
		pr.id="htitle";
		pr.innerHTML="<a href='products.html'>Our Products</a><a href='products.html' class='more'>more &gt;&gt;</a>";
		Id("rightdiv").insertBefore(pr,hr1);
	}

//overflow
function over(sender,maxwid,minpad)

{
	var obj=Id(sender);
	var link=Name(obj,"a");
	if(link.length==0)link=Name(obj,"span");
	var wid=0;
	for(var i=0;i<link.length;i++)
	{
		link[i].style.paddingLeft=minpad+"px";
		link[i].style.paddingRight=minpad+"px";
		wid+=link[i].offsetWidth;
	}
	while(wid>maxwid){wid=fontSize(link,-1);}
	var pad=(maxwid-wid+link.length*minpad*2)/(link.length*2);
	for(var i=0;i<link.length;i++)
	{
		link[i].style.paddingLeft=pad+"px";
		link[i].style.paddingRight=pad+"px";
	}
}
function fontSize(link,step)
{
	var size=Style(link[0],"fontSize");
	size=parseInt(size)+step;
	var wid=0;
	for(var i=0;i<link.length;i++)
	{
		link[i].style.fontSize=size+"px";
		wid+=link[i].offsetWidth;
	}
	return wid;
}
function tables()
{
	var tables=Name("table");
	if(tables.length>0)
	{
		for(var i=0;i<tables.length;i++)
		{
			tables[i].border="0";
			tables[i].cellpadding="0";
			tables[i].cellspacing="0";
		}
	}
}
function Id(key){return document.getElementById(key);}
function Name(obj,key){if(key==null)return document.getElementsByTagName(obj);else return obj.getElementsByTagName(key);}
function Style(obj,key){return obj.currentStyle?obj.currentStyle[key]:document.defaultView.getComputedStyle(obj,null)[key];}
function stopBubble(){if(window.event)window.event.cancelBubble=true;else arguments[0].stopPropagation();}