////////////////
var mp3url = null;
function playsound() {
	if ( mp3url != null ) {
		var soundid = document.getElementById("soundid");
		soundid.innerHTML = "";
		soundid.innerHTML = "<embed src=\"" + mp3url + "\" loop=false autostart=true name=bgss width=\"0\" height=\"0\">";
	}
}
function ttt(content){
	if ( content.extra.en != null && content.extra.zh != null && content.extra.mp3 != null ) {
		var enObj = document.getElementById("en");
		var cnObj = document.getElementById("zh");
		var timeObj = document.getElementById("time");
		if ( enObj && cnObj && timeObj ) {
			mp3url = content.extra.mp3;
			enObj.innerHTML = content.extra.en + "<img src=\"./images/sound.png\" onclick=\"playsound();\" class=\"playsound\" />";
			cnObj.innerHTML = content.extra.zh;
			var myDate = new Date();
			timeObj.innerHTML = myDate.getFullYear() + " Äê " + (myDate.getMonth()+1) + " ÔÂ " + myDate.getDate() + " ÈÕ";
			
			setCookie("client_dict_en", content.extra.en, 120);
			setCookie("client_dict_zh", content.extra.zh, 120);
			setCookie("client_dict_mp3", content.extra.mp3, 120);
			setCookie("client_dict_time", timeObj.innerHTML, 120);
		}
	}
}
function requestToday() {
		var ga = document.createElement('script');
		ga.type = 'text/javascript';
		ga.async = true;
		try {
			ga.src = 'http://ketang.dict.cn/api/extra?id=1&callback=ttt';
			var s = document.getElementsByTagName('script')[0];
			s.parentNode.insertBefore(ga, s);
		}catch(e){
			throw "ganalytics attachment failed."+e;
		}
}
function onLoad() {
	HVCenter('welcome');
			
	var dict_en = getCookie("client_dict_en");
	var dict_zh = getCookie("client_dict_zh");
	var dict_mp3 = getCookie("client_dict_mp3");
	var dict_time = getCookie("client_dict_time");
	if ( dict_en != null && dict_zh != null && dict_mp3 != null && dict_time != null ) {
		var enObj = document.getElementById("en");
		var cnObj = document.getElementById("zh");
		var timeObj = document.getElementById("time");
		if ( enObj && cnObj && timeObj ) {
			mp3url = dict_mp3;
			enObj.innerHTML = dict_en + "<img src=\"./images/sound.png\" onclick=\"playsound();\" class=\"playsound\" />";
			cnObj.innerHTML = dict_zh;
			timeObj.innerHTML = dict_time;
		}
	} else {
		requestToday();
	}
	
	var helpObj = document.getElementById("help");
	if ( helpObj != null ) {
		if ( isMac() ) {
			helpObj.setAttribute("href", "http://client.dict.cn/mac/help.html");
		} else {
			helpObj.setAttribute("href", "http://client.dict.cn/help.htm");
		}
	}
}