function translation_init(user_language,other_langs_code,other_langs_name,dir) {
	shortcut.add("Ctrl+Alt+7", function() {
		if (window.getSelection) {
			translate(window.getSelection(),user_language,other_langs_code,other_langs_name,dir);
			done = true;
		}
		if (document.getSelection) {
			translate(document.getSelection(),user_language,other_langs_code,other_langs_name,dir);
		}
		if (document.selection) {
			  translate(document.selection.createRange().text,user_language,other_langs_code,other_langs_name,dir);
		}
	});
}

function translate(text,user_language,other_langs_code,other_langs_name,other_langs_dir){
	text = nl2br_12(text);
	var translated = document.getElementById("translation_box");
	if(translation_box_js!=null){
		translated.innerHTML = '<table cellspacing="0" cellpadding="0" style="padding:0px;width:100%"><tr><td style="width:100%;padding:0px"><img src="/img/ajax/loaderb16.gif"></td><td style="padding:0px;white-space:nowrap;">&nbsp;&nbsp;&nbsp;<img src="/img/del.png" title="" alt="" onclick="hideTranslation(\'translation_box\')" style="cursor:pointer"/></td></tr></table>';
	}
	var other_lang_code = eval(other_langs_code);
	var other_lang_name = eval(other_langs_name);
	var other_lang_dir = eval(other_langs_dir);
	var other_lang_code2 = "";
	var other_lang_name2 = "";
	var other_lang_dir2 = "";
	var options = "";
	var dir = "";
	  for(var i=0;i<other_lang_name.length;i++){
		  if(user_language==other_lang_code[i]){
			  options += '<option value="'+other_lang_code[i]+'" selected="selected">'+other_lang_name[i]+'</option>';
			  dir = other_lang_dir[i];
		  }else{
			  options += '<option value="'+other_lang_code[i]+'">'+other_lang_name[i]+'</option>';
		  }
		  other_lang_code2 += ',\''+other_lang_code[i]+'\'';
		  other_lang_name2 += ',\''+other_lang_name[i]+'\'';
		  other_lang_dir2 += ',\''+other_lang_dir[i]+'\'';
	  }
	  other_lang_code2 = '['+other_lang_code2.substring(1)+']';
	  other_lang_name2 = '['+other_lang_name2.substring(1)+']';
	  other_lang_dir2 = '['+other_lang_dir2.substring(1)+']';
	  google.language.detect(text, function(result) {
	    if (!result.error && result.language) {
	      google.language.translate(text, result.language, user_language,
	                                function(result) {
	        var old = document.getElementById("translation_box_old");
	        if (result.translation) {
	          showTranslation("translation_box");
	          translated.innerHTML = '<table cellspacing="0" cellpadding="0" style="padding:0px;width:100%"><tr><td style="width:100%;padding:0px">Translation (powered by Google)</td><td style="padding:0px"><select onchange="translate(\''+addslashes(text)+'\',this.value,'+other_lang_code2+','+other_lang_name2+','+other_lang_dir2+')">'+options+'</select></td><td style="padding:0px;white-space:nowrap;">&nbsp;&nbsp;&nbsp;<img src="/img/del.png" title="" alt="" onclick="hideTranslation(\'translation_box\')" style="cursor:pointer"/></td></tr></table><br/><br/><span dir="'+dir+'">'+result.translation+'</span>';
	        }
	      });
	    }
	  });
}

translation_box_js = null;
function showTranslation(id) {
	translation_box_js = document.getElementById(id);
	translation_box_js.style.display = "block";
}
function hideTranslation() {
	translation_box_js.style.display = "none";
}
function nl2br_12(str) {
	if(typeof(str)=="string") return str.replace(/(\r\n)|(\n\r)|\r|\n/g,"<BR>");
	else return str;
}