// JScript 文件 
var SiteHost="dict.hjenglish.com";
var newword_panelID="0";
var HjDictMyDictUrl="bulo.hjenglish.com"; 
//var newword_dictlang
var newword_panelID = 0;

//英文调用时，aID为null
function AddMyWord(aID){ 
	if(newword_title=="--"){
		return false;
	} 
    try{
        if(window.external.SoftVersion=="1.0.0.10"){
            alert("小D桌面版主程序版本太低，本功能不受支持，请升级！");
        }else{ 
            HJ$("amw_panel_"+newword_panelID).innerHTML='<img src="images/loading.gif" />';
            setTimeout("Do_AddMyWord();", 200); 
        }
    }catch(e){
        HJ$("amw_panel_"+newword_panelID).innerHTML='<img src="images/loading.gif" />';
        setTimeout("Do_AddMyWord();", 200); 
    }
    return false;
} 
function Do_AddMyWord(){ 
	Do_AddMyWord2(newword_title, newword_comment, newword_langs);
}
function Do_AddMyWord2(aword, acomments, alang){ 
	var amw_html="<iframe id='iHJDFrame' name='iHJDFrame' width=0 height=0></iframe><br/>";
	var url = "http://" +SiteHost+ "/client/client_addmyword.aspx?ran="+ Math.random(); 
	amw_html+= "<FORM name='AddMyWord_Form' id='AddMyWord_Form' METHOD='POST' ACTION='"+ url +"' target='iHJDFrame' >";
	amw_html+= "<INPUT TYPE='text' NAME='w' value='"+ aword +"'>";
	amw_html+= "<INPUT TYPE='text' NAME='c' value='"+ acomments +"'>";
	amw_html+= "<INPUT TYPE='text' NAME='langs' value='"+ alang +"'>";
	amw_html+= "<INPUT TYPE='text' NAME='back' value='"+ document.location+".back.htm'>";
	amw_html+= "</FORM>"; 
	HJ$("addword_panel").innerHTML= amw_html;
	HJ$("AddMyWord_Form").submit();
}
function onAddMyWordResult(aResult){ 
    if(aResult=="yes"){
        HJ$("amw_panel_" +newword_panelID).innerHTML='<a href="http://'+  HjDictMyDictUrl  +'/mydict/" title="查看我的生词本" target="_blank" onclick="return true;">添加成功</a>';
    }else if(aResult=="no"){
        HJ$("amw_panel_" +newword_panelID).innerHTML='<a href="http://'+  HjDictMyDictUrl  +'/mydict/" title="查看我的生词本" target="_blank">你添过这个词了</a>';
    }else if(aResult=="error"){
        HJ$("amw_panel_" +newword_panelID).innerHTML='添加失败';
    }else if(aResult=="login"){
        if(confirm("只有登录沪江部落后，才能添加自己的生词，现在是否登录？")){ 
            window.open("http://"+  HjDictMyDictUrl  +"/login.aspx?Reset=1&ReturnUrl="+ escape("http://bulo.hjenglish.com/mydict/"));
        }
		HJ$("amw_panel_" +newword_panelID).innerHTML='<a href="###" onclick="Do_AddMyWord();return false;"><img src="http://' +SiteHost+ '/images/btn_myword_add.gif" alt="添加到我的生词本" align="absmiddle"/></a>';	
    }else{
        alert(result.value);
    }
	setTimeout("onAddMyWordResult_End();", 500);
}
function onAddMyWordResult_End(){ 
	HJ$("addword_panel").innerHTML= "";
}

