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 Jammy
function Id(key){return document.getElementById(key);}
function Tag(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();}
function over(sender,maxwid,minpad)//over-flow
{
	var obj=Id(sender);
	var link=Tag(obj,"a");
	if(link.length==0)link=Tag(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){
		var size=Style(link[0],"fontSize");
		size=parseInt(size)-1;
		wid=0;
		for(var i=0;i<link.length;i++)
		{
			link[i].style.fontSize=size+"px";
			wid+=link[i].offsetWidth;
		}
	}
	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 tables()
{
	var tables=Tag("table");
	for(var i=0;i<tables.length;i++)
	{
		tables[i].border="0";
		tables[i].cellpadding="0";
		tables[i].cellspacing="0";
	}
}

//Start Run
init();
function init()
{
	try{document.execCommand("BackgroundImageCache",false,true);}catch(e){}
	over("mainmenu",800,10);//overflow
	over("secondmenu",790,10);//overflow
	//over("title1",205,10);over("title2",205,10);over("title3",205,10);over("title4",205,10);//over(sender,max-width,min-padding);

	var lang=Id("lang");
	var tran=Id("trans");
	lang.onmouseover=function(){this.style.cursor="pointer";tran.style.visibility="visible";}
	lang.onclick=stopBubble;
	document.onclick=function(){tran.style.visibility="hidden";}
	var trans=Tag(tran,"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);};
	}

	var q=Id("q");var searchbut=Id("searchbut");
	q.onkeyup=function(e){var key=window.event?window.event.keyCode:e.which;if(key==13)searchbut.click();}
	searchbut.onclick=function()
	{
		var num=document.location.href.lastIndexOf('/');
		var base=document.location.href.substring(0,num);
		document.location.href=base+"/search.php?q="+q.value;
	}

	tables();
	for(var i in A=['desp2','desp3'])if(document.getElementById(A[i]))Id(A[i]).innerHTML=Id(A[i]).innerHTML.replace(/<\/h(?=\d>\w)/gi,' </h');
}

function show(){
	var time = new Date();var i=time.getSeconds()%3*2+1;var j=i+1;
	Id('show1').src='images/show'+i+'.jpg';
	Id('show2').style.backgroundImage='url(images/show'+j+'.jpg)';
	Id('show2').innerHTML=i==1?'2008 Beijing':i==3?'2009 Nuremberg':'2009 Shanghai';
}
function banner(){
	ban_count++;if(ban_count>90)ban_count=1;
	if(ban_count<30){
		if(Id('banner2').style.opacity>0)Id('banner2').style.opacity=0;
		if(!Id('banner3').style.opacity)Id('banner3').style.opacity=1;
		if(Id('banner3').style.opacity>0)Id('banner3').style.opacity=parseFloat(Id('banner3').style.opacity)-0.2;
		if(Id('banner3').filters[0].opacity>0)Id('banner3').filters[0].opacity-=20;}
	else if(ban_count<60){
		if(!Id('banner2').style.opacity)Id('banner2').style.opacity=0;
		if(Id('banner2').style.opacity<1)Id('banner2').style.opacity=parseFloat(Id('banner2').style.opacity)+0.2;
		if(Id('banner2').filters[0].opacity<100)Id('banner2').filters[0].opacity+=20;
		Id('banner3').style.opacity=0;Id('banner3').filters[0].opacity=0;}
	else if(ban_count<90){
		if(!Id('banner3').style.opacity)Id('banner3').style.opacity=0;
		if(Id('banner3').style.opacity<1)Id('banner3').style.opacity=parseFloat(Id('banner3').style.opacity)+0.2;
		if(Id('banner3').filters[0].opacity<100)Id('banner3').filters[0].opacity+=20;
		if(Id('banner3').filters[0].opacity>=100){Id('banner2').style.opacity=0;Id('banner2').filters[0].opacity=0;}}
}
var ban_count=1;setInterval('banner()',100);

//menu products
	Id('menu_pr').onmouseout=Id('mdrop').onmouseout=function(){Id('mdrop').style.display='none';}
	Id('menu_pr').onmouseover=Id('mdrop').onmouseover=function(){
		var iefox=15;if(navigator.userAgent.indexOf("MSIE 6")!=-1)iefox=Id('head').offsetLeft+15;
		if(navigator.userAgent.indexOf("MSIE 7")!=-1)iefox=Id('head').offsetLeft+Id('mainmenu').offsetLeft;
		Id('mdrop').style.left=Id('menu_pr').offsetLeft+iefox+'px';Id('mdrop').style.display='block';}