﻿function GetPosTop(ctrlId) 
{ 
	var t,l,a,b; 
	a = document.all(ctrlId); 
	t = a.offsetTop; 
	while(a.tagName != "BODY") 
	{ 
		a = a.offsetParent; 
		t = t + a.offsetTop; 
	} 
	return t+98; 
} 
function GetPosLeft(ctrlId) 
{ 
	var t,l,a,b; 
	a = document.all(ctrlId); 
	t = a.offsetTop; 
	l = a.offsetLeft; 
	while(a.tagName != "BODY") 
	{ 
		a = a.offsetParent; 
		l = l + a.offsetLeft; 
	} 
	return l+226; 
} 

function ShowReworkDefine(number,ischinese,keyword,ID,filename,tablename)
{
	//var vId = CheckSoftCount("checkName") ;
	var shield = document.createElement("DIV");
	shield.id = "shield";
	shield.style.position = "absolute";
	shield.style.left = "0px";
	shield.style.top = "0px";
	shield.style.width = "100%";
	shield.style.height = document.body.scrollHeight+"px";
	shield.style.background = "#333";
	shield.style.textAlign = "center";
	shield.style.zIndex = "10000";
	shield.style.filter = "alpha(opacity=0)";
	
	var alertFram = document.createElement("DIV");
	alertFram.id="alertFram";
	alertFram.style.position = "absolute";
	alertFram.style.left = GetPosLeft("a"+number)+"px";
	alertFram.style.top = GetPosTop("a"+number)+"px";		
	alertFram.style.marginLeft = "-225px";
	alertFram.style.marginTop = "-75px";
	alertFram.style.width = "400px";
	alertFram.style.height = "160px";
	alertFram.style.background = "#ccc";
	alertFram.style.textAlign = "center";
	alertFram.style.lineHeight = "150px";
	alertFram.style.zIndex = "10001";
	

	strHtml = "<ul style=\"list-style:none;margin:2px;padding:0px;width:100%\">\n";
	strHtml += " <li style=\"background:#ebf2f8;text-align:left;padding-left:30px;font-size:14px;font-weight:bold;height:25px;line-height:25px;border:1px solid #F9CADE;\">[添加词对到词典]</li>\n";
	strHtml += " <li style=\"background:#fff;text-align:center;font-size:12px;height:60px;line-height:60px;border-left:1px solid #F9CADE;border-right:1px solid #F9CADE;\">";
	 var judui = document.getElementById("judui"+number).value;
	 var index = judui.indexOf('|');
	 var zhongwen = judui.substr(0,index);
	 var yingwen = judui.substr(index+1);
	strHtml += "<table>";
	strHtml += "<tr><td align='left' colspan=2>&nbsp;&nbsp;&nbsp;&nbsp;说明:如果您发现本句对中存在上面的词典未显示的词条或其译词，您可以在此添加。添加完成后，您可以刷新页面或查询您所添加的词条，便可在“显示用户修正”中看到您提交的结果。</td></tr>";
	strHtml += "<tr><td align='left'colspan=2>您选择的当前句对:</td></tr><tr><td align='left'colspan=2 class=\"heicu\">&nbsp;&nbsp;"+zhongwen+"</td></tr>";
	strHtml += "<tr><td align='left'colspan=2 class=\"heicu\">&nbsp;&nbsp;"+yingwen+"</td></tr>";
	if(ischinese=="True")
	{
	strHtml += "<tr><td align='center'>中文词条：&nbsp;&nbsp;</td><td><input readonly=true id='chineseword' type='text' value="+keyword+"></td></tr>";
	strHtml += "<tr><td align='center'>英文词条：&nbsp;&nbsp;</td><td><input  id='englishword' type='text'></td></tr>";
	}
	else
	{
	strHtml += "<tr><td align='center'>中文词条：&nbsp;&nbsp;</td><td><input  id='englishword' type='text' ></td></tr>";
	strHtml += "<tr><td align='center'>英文词条：&nbsp;&nbsp;</td><td><input  id='chineseword' type='text' value="+keyword+"></td></tr>";
	}
	strHtml += "<tr><td align='center'>用户名：&nbsp;&nbsp;</td><td><input  id='username' type='text'></td></tr>";
	strHtml += "<tr><td align='center'>用户Email：&nbsp;&nbsp;</td><td><input  id='useremail' type='text'></td></tr>";
	strHtml += "</table></li>\n"
	//<tr><td align='center'>&nbsp;修改后定义：&nbsp;&nbsp;</td><td><TEXTAREA id='nowContent' rows='3' cols='31' style='WIDTH: 272px; HEIGHT: 56px'></TEXTAREA></td></tr><tr><td align='center'>&nbsp;备注：&nbsp;&nbsp;</td><td><select name='remark'><option id='hao' value='好' selected>好</option><option id='huai' value='坏' selected>坏</option><option id='yiban' value='一般' selected>一般</option></select></td></tr>
	strHtml += " <li style=\"background:#ebf2f8;text-align:center;font-weight:bold;height:25px;line-height:25px; border:1px solid #F9CADE;\"><input id=\"btn\" type=\"button\" value=\"确 定\" onclick=\"doRework('"+ischinese+"','"+keyword+"','"+ID+"','"+filename+"','"+tablename+"')\" style=\"BACKGROUND-COLOR: #ebf2f8\" />&nbsp;&nbsp;&nbsp;<input id=\"btn\" type=\"button\" value=\"关 闭\" onclick=\"doClose()\" style=\"BACKGROUND-COLOR: #ebf2f8\" /></li>\n";
	strHtml += "</ul>\n";
	alertFram.innerHTML = strHtml;
	document.body.appendChild(alertFram);
	document.body.appendChild(shield);
	alertFram.focus();
	//document.body.onselectstart = function(){return false;};
}

function doClose()
  {
		alertFram.removeNode(true) ;
		shield.removeNode(true) ;
		//document.getElementById("checkbox"+vId).checked = false ;
	}
function Show(number,ischinese, keyword,ID,filename,tablename){
ShowReworkDefine(number,ischinese, keyword,ID,filename,tablename) ;
	
}
function GetJuDui()
{
  
}

function showMoreWords(divName,e)
		{//debugger;
			if(document.getElementById(divName).style.display=='none')
			{
				document.getElementById(divName).style.display= 'block';
				e.src="images/hide_more.gif";
			}
			else
			{
				document.getElementById(divName).style.display='none'
				e.src="images/show_more.gif";
			}
		}
		function showMoreWordsEn(divName,e)
		{//debugger;
			if(document.getElementById(divName).style.display=='none')
			{
				document.getElementById(divName).style.display= 'block';
				e.src="images/hide_more_en.gif";
			}
			else
			{
				document.getElementById(divName).style.display='none'
				e.src="images/show_more_en.gif";
			}
		}
		function showUser(e,divName)
		{
			if(document.getElementById(divName).style.display=='none')
			{
				document.getElementById(divName).style.display='block';
				e.src="images/hide_correct.gif";
			}
			else
			{
				document.getElementById(divName).style.display='none';
				e.src="images/show_correct.gif";

			}
		}
		function showUserEn(e,divName)
		{
			if(document.getElementById(divName).style.display=='none')
			{
				document.getElementById(divName).style.display='block';
				e.src="images/hide_correct_en.gif";
			}
			else
			{
				document.getElementById(divName).style.display='none';
				e.src="images/show_correct_en.gif";

			}
		}
		function tjCustom(keyword)//用户自定义据对
		{//debugger;
			var customWord = document.getElementById('custom').value;
			customWord = unescape(customWord);
			//document.getElementById('tjType').value = "sentence";
			if(customWord.length == 0)
			{
				alert("输入词为空！");
				return;
			}
			keyword = escape(keyword);
			customWord = escape(customWord);
			window.location.href = "dict_result.aspx?custom="+customWord+"&tjType=sentence&searchword="+keyword;
		}
		function hide_err(flag,n)//显示 隐藏
		{//debugger;
			if(flag == '1')
			{
				document.getElementById(n).style.display='none';
			}
			else
			{
				document.getElementById(n).style.display='block';
			}
		}
		function getResult(result,divid)
		{
		    document.getElementById(divid).style.display = 'block';
			document.getElementById(divid).innerHTML = result;
		}
		function checkPingjia(divid,fname,tname,keyword,sentid,tranWord,flag,cn)//显示评价
		{//debugger;
		    if(document.getElementById(divid).style.display != 'none')
		    {
	            document.getElementById(divid).style.display = 'none';
	            return;
		    }
		    var d = "";
		    fname = unescape(fname);
		    tname = unescape(tname);
		    keyword = unescape(keyword);
		    tranWord = unescape(tranWord);

		    if(document.getElementById(divid).innerHTML != "")
		    {
	            document.getElementById(divid).style.display = 'block';
	            return;
		    }
			if(flag == '1')
			{
				//d = CNKIDICT.dict_result.pj(divid,fname,tname,keyword,sentid,tranWord,'1',cn).value;
				PageMethods.pj(divid,fname,tname,keyword,sentid,tranWord,'1',cn,getResult,null,divid);
			}
			else
			{
				PageMethods.pj(divid,fname,tname,keyword,sentid,tranWord,'0',cn,getResult,null,divid);
			}
//			document.getElementById(divid).style.display = 'block';
//			document.getElementById(divid).innerHTML = d;
		}
		function tjError(showWord,n,divid)//纠错
		{//
			var selErrorWord = document.getElementById('selErrorWord_'+n).value;
			if(selErrorWord.length <= 0)
			{
				alert('请选择译词！');
				return;
			}
			var chenghu = document.getElementById('chenghu_'+n).value;
			if(chenghu.length <= 0)
			{
				chenghu = "";
			}
			var email = document.getElementById('email_'+n).value;
			if(email.indexOf('.')==-1||email.indexOf('@')==-1)
			{
				alert('Email格式不对，请输入正确的Email');
				return;
			}
			
			var s1 = document.getElementById('checkbox1_'+n);
			var s2 = document.getElementById('checkbox2_'+n);
			var s3 = document.getElementById('checkbox3_'+n);
			var s4 = document.getElementById('checkbox4_'+n);
			
			var str = "";
			if(s1.checked)
			{
				str += "译义不准;";
			}
			if(s2.checked)
			{
				str += "拼写错误;";
			}
			if(s3.checked)
			{
				str += "译词重复;";
			}
			if(s4.checked)
			{
				if(document.getElementById('reason_'+n).value.length > 0)
				{
					str += document.getElementById('reason_'+n).value + ";";
				}
			}
			var right = document.getElementById('right_'+n).value;
			var according = document.getElementById('according_'+n).value;
			
			//var d = CNKIDICT.dict_result.errorW(selErrorWord,chenghu,email,str,right,according,showWord).value;
			PageMethods.errorW(selErrorWord,chenghu,email,str,right,according,showWord,tjerror,null,divid);
//			if( d != '1' )
//			{
//				alert('提交失败！');
//				return;
//			}
//			else
//			{
//				alert('提交成功， 谢谢您的参与！');
//				hide_err('1',divid);
//			}
		}
		function tjerror(d,divid)//纠错
		{
		    if( d != '1' )
			{
				alert('提交失败！');
			}
			else
			{
				alert('提交成功， 谢谢您的参与！');
				hide_err('1',divid);
			}
		}
		function showohter(n)//纠错中显示其他
		{
			var s = document.getElementById('checkbox4_'+n);
			if(s.checked == true)
			{
				document.getElementById('other_'+n).style.display = 'block';
			}
			else
			{
				document.getElementById('other_'+n).style.display = 'none';
			}
		}
		function addsen(ischn,sentid,tableName,fileName,div_id)//添加据对
		{//debugger;
		    tableName = unescape(tableName);
		    fileName = unescape(fileName);
		    var ori;
		    var tran;
		    if(ischn == "True")
		    {
		        ori = document.getElementById('chn_citiao_'+div_id).value;
			    tran = document.getElementById('eng_citiao_'+div_id).value;
		    }
		    else
		    {
		        tran = document.getElementById('chn_citiao_'+div_id).value;
			    ori = document.getElementById('eng_citiao_'+div_id).value;
		    }
			
			var uid = document.getElementById('name_citiao_'+div_id).value;
			var email = document.getElementById('email_citiao_'+div_id).value;
			if(email.indexOf('.')==-1||email.indexOf('@')==-1)
			{
				alert('Email格式不对，请输入正确的Email');
				return;
			}
			
			PageMethods.addjd(ori,tran,sentid,tableName,fileName,uid,email,addonejd,null,div_id);
			
		}
		function addonejd(d,div_id)//句对添加
		{
		    if( d != '1' )
			{
				alert('提交失败！');
			}
			else
			{
				alert('提交成功， 谢谢您的参与！');
				hide_err('1',div_id);
			}
		}
		function app(divid,sentid,keyword,tranWord,zhuanticode,tname,fname,values)
		{//debugger;
		    keyword = unescape(keyword);
		    tranWord = unescape(tranWord);
		    tname = unescape(tname);
		    fname = unescape(fname);
			//var d = CNKIDICT.dict_result.addapp(divid,sentid,keyword,tranWord,zhuanticode,tname,fname,values).value;
			PageMethods.addapp(divid,sentid,keyword,tranWord,zhuanticode,tname,fname,values,getAdd);
			
			function getAdd(d)
		    {
		        if( d != 1 )
		        {
			        alert('提交失败！');
		        }
		        else
		        {
    //			    keyword = escape(keyword);
    //		        tranWord = escape(tranWord);
    //		        tname = escape(tname);
    //		        fname = escape(fname);
                    //var d2 = CNKIDICT.dict_result.pj(divid,fname,tname,keyword,sentid,tranWord,'1',zhuanticode).value;
                    PageMethods.pj(divid,fname,tname,keyword,sentid,tranWord,'1',zhuanticode,getResult,null,divid);//显示评价
                    //document.getElementById(divid).style.display = 'block';
		            //document.getElementById(divid).innerHTML = d2;
		        }
		    }
			
		}
		
		function record(keyword, adname, openurl)
		{
		    PageMethods.recordA(keyword, adname, openurl);
		}
		function showjds(divName,e)//显示隐藏句对
		{//debugger;
			if(document.getElementById(divName).style.display=='none')
			{
				document.getElementById(divName).style.display= 'block';
				e.src="images/jian.gif";
			}
			else
			{
				document.getElementById(divName).style.display='none'
				e.src="images/jia.gif";
			}
		}
		function showjdsw(divName,imgid)//显示隐藏句对
		{
		//debugger;
			if(document.getElementById(divName).style.display=='none')
			{
				document.getElementById(divName).style.display= 'block';
				document.getElementById(imgid).src="images/jian.gif";
			}
			else
			{
				document.getElementById(divName).style.display='none'
				document.getElementById(imgid).src="images/jia.gif";
			}
		}
		
		//获取QuetyString
        function getRequestQuerystring(strName)
        {
            var strHref = window.document.location.href;
            var intPos = strHref.indexOf("?");
            var strRight = strHref.substr(intPos + 1);

            var arrTmp = strRight.split("&");
            for(var i = 0; i < arrTmp.length; i++)
            {
                var arrTemp = arrTmp[i].split("=");

                if(arrTemp[0].toUpperCase() == strName.toUpperCase()) return arrTemp[1];
            }
            return "";
}
