function cod9ec(){
	cod9ec_translation();
}

function cod9ec_translation(){
	if (!document.querySelector('rw zh, rw cn')) return;
	cod9ec_translation_individual();
	var cod9ec_h1=document.querySelectorAll('hwd, phr pd h');
	for (var i=0; i<cod9ec_h1.length; ++i){
		var trans_button=document.createElement('cod9ec_trans');
		trans_button.onclick=cod9ec_translation_button;
		cod9ec_h1[i].appendChild(trans_button);
	}
}

function cod9ec_translation_individual(){
	var cod9ec_cn=document.querySelectorAll('rw zh, rw cn');
	for (var i=0; i<cod9ec_cn.length; ++i){
		var trans_blank=document.createElement('cod9ec_trans_blank');
		trans_blank.onclick=cod9ec_translation_blank;
		cod9ec_cn[i].parentNode.insertBefore(trans_blank, cod9ec_cn[i]);
	}
}

function cod9ec_translation_blank(trans_blank){
	this.setAttribute('trans', '');
	this.nextSibling.setAttribute('trans', '');
}

function cod9ec_translation_button(){
	var cod9ec_cn=document.querySelectorAll('rw zh, rw cn, cod9ec_trans_blank');
	var cod9ec_btns=document.getElementsByTagName('cod9ec_trans');
	if(cod9ec_btns[0].hasAttribute('trans')){
		for(var i=0; i<cod9ec_btns.length; ++i){
			cod9ec_btns[i].removeAttribute('trans');
		}
		for(var i=0; i<cod9ec_cn.length; ++i){
			cod9ec_cn[i].removeAttribute('trans');
		}
	}
	else{
		for(var i=0; i<cod9ec_btns.length; ++i){
			cod9ec_btns[i].setAttribute('trans', '');
		}
		for(var i=0; i<cod9ec_cn.length; ++i){
			cod9ec_cn[i].setAttribute('trans', '');
		}
	}
}
