﻿
function CheckUserInput()
{var tbOriginName=$(ForeignCompInputClientIDs.tbOriginName);var rbtRename=$(ForeignCompInputClientIDs.rbtRename);if(tbOriginName.value.trim()==ORN_PROMPT)
{tbOriginName.value="";}
if(rbtRename.checked&&tbOriginName.value.trim()=="")
{alert("请输入原有公司名字。");tbOriginName.focus();tbOriginName.select();return;}
var tbEngName=$(ForeignCompInputClientIDs.tbEngName);if(tbEngName.value.trim()=="")
{alert("请输入公司/产品的英文名字。");tbEngName.focus();tbEngName.select();return;}
if(checkIsEnglish(tbEngName.value)==false)
{alert("英文公司/产品名只能由：英文字母，中文汉字，空格，-，和&符号构成，请重新输入。\r\n提示：您只需要输入公司名字的核心部分即可。");tbEngName.focus();tbEngName.select();return;}
var enPattern=/[a-z]/gi;if(enPattern.test(tbEngName.value)==false)
{alert("名字中必须包含英文字符，请重新输入。");tbEngName.focus();tbEngName.select();return;}
var str=tbEngName.value;var cnStart=false;var count=0;var pattern=/([\u4E00-\u9FA5])/gi;for(i=0;i<str.length;++i)
{if(str.charAt(i)!=' '&&str.charAt(i)!='&'&&str.charAt(i)!='-')
{if(pattern.test(str.charAt(i))&&cnStart==false)
{++count;cnStart=true;}
else if(pattern.test(str.charAt(i))==false&&cnStart==true)
{cnStart=false;}}}
if(count>1)
{alert("目前名字中的汉字部分只能出现在一个位置，请重新输入。");tbEngName.focus();tbEngName.select();return;}
if(tbEngName.value.trim().length>20)
{alert("英文公司/产品名目前最多允许20个字符，请重新输入。\r\n提示：您只需要输入公司名字的核心部分即可。");tbEngName.focus();tbEngName.select();return;}
if(tbEngName.value.trim().length<=1)
{alert("英文公司/产品名至少为2个字母构成。");tbEngName.focus();tbEngName.select();return;}
if(CheckAdvancedParams()==false)
{if(window.confirm("您指定了某些音、形、义的值（高级选项的指定信息），但没有指定具体位置。\r\n点击‘确认’指定，点击‘取消’则忽略。"))
{return;}}
var tbWishes=$(ForeignCompInputClientIDs.tbWishes);var tbBiz=$(ForeignCompInputClientIDs.tbBusiness);var tbRaw=$(ForeignCompInputClientIDs.tbRawNames);if(tbWishes.value.trim()==HOPE_PROMPT)
{tbWishes.style.color="#000000";tbWishes.value="";}
if(tbBiz.value.trim()==BIZ_PROMPT)
{tbBiz.style.color="#000000";tbBiz.value="";}
if(tbRaw.value.trim()==RAW_PROMPT)
{tbRaw.style.color="#000000";tbRaw.value="";}
if(IsModification==false)
{ShowProgressBar_1($("btSubmit"),0);}
else
{try
{ShowProgressBar_1($("btSubmit"),0,"true");}
catch(e)
{}}
try
{document.getElementById("imgVisitorStat").src=document.getElementById("imgVisitorStat").src+"?rand="+Math.random();}
catch(e)
{}
var postID;var r=/javascript\:__doPostBack\(["|'](.*)["|'],/g;var re=r.exec($(ForeignCompInputClientIDs.lbtSubmit).href);if(re!=null)
{postID=re[1];}
else
{postID=ForeignCompInputClientIDs.lbtSubmit.replace(/\_/g,"$");}
__doPostBack(postID,"");}
function CheckAdvancedParams()
{var paramsCtrl=$("tableRowSpecifyWord").getElementsByTagName("INPUT");var slot1Ctrl=$(ForeignCompInputClientIDs.ddlSpecIndex1);var slot2Ctrl=$(ForeignCompInputClientIDs.ddlSpecIndex2);var specSlot1=false;var specSlot2=false;for(var i=0;i<paramsCtrl.length;++i)
{if(paramsCtrl[i].type.toLowerCase()=="text")
{if(paramsCtrl[i].value.trim()!="")
{var id=paramsCtrl[i].id;var index=id.indexOf("tb");if(index==-1)
{continue;}
id=id.substring(index);if(id.indexOf("1")!=-1)
{specSlot1=true;window.adValue=true;}
else if(id.indexOf("2")!=-1)
{specSlot2=true;window.adValue=true;}}}}
if((specSlot1==true&&slot1Ctrl.selectedIndex==0)||(specSlot2==true&&slot2Ctrl.selectedIndex==0))
{return false;}
return true;}
function AjustIframParentSize(showDialog)
{try
{var bar=parent.$("modiDialog");var barHolder=parent.$("modiHolder");if(navigator.userAgent.toLowerCase().indexOf("safari")!=-1)
{height=document.documentElement.scrollHeight;width=document.documentElement.scrollWidth;}
else
{height=document.body.scrollHeight;width=document.body.scrollWidth;}
parent.$("iframeModifyParam").height=height+(showDialog!=undefined?40:0);;parent.$("iframeModifyParam").width=width;bar.height=height+(showDialog!=undefined?40:0);bar.width=width;barHolder.height=height+(showDialog!=undefined?40:0);barHolder.width=width;}
catch(e)
{}}
function CloseParentWindow()
{try
{parent.$('modiDialog').style.display='none';parent.$('modiAllbody').style.display='none';}
catch(e)
{}}
var HOPE_PROMPT="请输入表达您愿望的词汇。";var BIZ_PROMPT="请输入您公司的主要业务(50字符以内)";var RAW_PROMPT="请输入您心目中的草稿名。";var ORN_PROMPT="原有名字（中文名）";var specIndex1Sel=0,specIndex2Sel=0;document.body.onkeydown=function(event)
{if(!event)
{event=window.event;}
var isMSIE=(navigator.appName=="Microsoft Internet Explorer");try
{if(!IsModification)
{return;}
if(isMSIE)
{if(event.keyCode==8)
{if(event.srcElement.tagName.toLowerCase()!="input"&&event.srcElement.tagName.toLowerCase()!="textarea")
{return false;}}}
else
{if(event.keyCode==8)
{if(event.target.tagName.toLowerCase()!="input"&&event.target.tagName.toLowerCase()!="textarea")
{event.preventDefault();event.stopPropagation();}}}}
catch(e)
{}}
function OnHopesTextBoxBlur()
{var tbWishes=$(ForeignCompInputClientIDs.tbWishes);if(tbWishes.value.trim()=="")
{tbWishes.style.color="gray";tbWishes.value=HOPE_PROMPT;}}
function OnBizTextBoxBlur()
{var tbBiz=$(ForeignCompInputClientIDs.tbBusiness);if(tbBiz.value.trim()=="")
{tbBiz.style.color="gray";tbBiz.value=BIZ_PROMPT;}}
function OnRawNamesTextBoxBlur()
{var tbRaw=$(ForeignCompInputClientIDs.tbRawNames);if(tbRaw.value.trim()=="")
{tbRaw.style.color="gray";tbRaw.value=RAW_PROMPT;}}
function OnOriginNameTextBoxBlur()
{var tbOriginName=$(ForeignCompInputClientIDs.tbOriginName);if(tbOriginName.value.trim()=="")
{tbOriginName.style.color="gray";tbOriginName.value=ORN_PROMPT;}}
try
{var oldBodyClickFunction=document.body.onclick;document.body.onclick=function(event)
{try
{if(oldBodyClickFunction!=undefined&&oldBodyClickFunction!=null)
{oldBodyClickFunction(event);}}
catch(e)
{}
if(!event)
{event=window.event;}
var isMSIE=(navigator.appName=="Microsoft Internet Explorer");try
{if(isMSIE)
{if(event.srcElement.id!=queryField.id&&IsTheSonOf(event.srcElement,"PickItemDiv")==false&&IsTheSonOf(event.srcElement,'divPickupXing')==false)
{showDiv(false);}}
else
{if(event.target.id!=queryField.id&&IsTheSonOf(event.target,"PickItemDiv")==false&&IsTheSonOf(event.target,'divPickupXing')==false)
{showDiv(false);}}}
catch(e)
{}}}
catch(e)
{}
function ShowAdOptions(control)
{var div=$("divAdOptions");if(div!=undefined&&div.style.display=="none")
{control.innerHTML="隐藏";div.style.display="";SetCookie("divAdOptions"," ");}
else
{control.innerHTML="显示";div.style.display="none";SetCookie("divAdOptions","none");}
if(IsModification)
{AjustIframParentSize();}}
function OnBusinessChanged()
{var rbNewName=$(ForeignCompInputClientIDs.rbtNewName);var tbOriginName=$(ForeignCompInputClientIDs.tbOriginName);}
function OnNameLenChanged()
{var ddlNameLen=$(ForeignCompInputClientIDs.ddlNameLength);var ddlSpecIndex1=$(ForeignCompInputClientIDs.ddlSpecIndex1);var ddlSpecIndex2=$(ForeignCompInputClientIDs.ddlSpecIndex2);var len=parseInt(ddlNameLen.options[ddlNameLen.selectedIndex].value);var specChar2=$(ForeignCompInputClientIDs.tbSpecifiedWord2);if(specIndex1Sel!=5&&len<specIndex1Sel)
{specIndex1Sel=0;}
if(specIndex2Sel!=5&&len<specIndex2Sel)
{specIndex2Sel=0;}
ddlSpecIndex1.selectedIndex=specIndex1Sel;ddlSpecIndex2.selectedIndex=specIndex2Sel;if(ddlNameLen.selectedIndex==0)
{specChar2.disabled=true;specChar2.value="";}
else
{specChar2.disabled=false;}
if(ddlNameLen.selectedIndex==0)
{ddlSpecIndex1.options[3].className="readOnly";ddlSpecIndex1.options[4].className="readOnly";ddlSpecIndex2.options[3].className="readOnly";ddlSpecIndex2.options[4].className="readOnly";ddlSpecIndex1.options[3].style.backgroundColor="#ccc";ddlSpecIndex1.options[3].style.color="#666";ddlSpecIndex1.options[4].style.backgroundColor="#ccc";ddlSpecIndex1.options[4].style.color="#666";ddlSpecIndex2.options[3].style.backgroundColor="#ccc";ddlSpecIndex2.options[3].style.color="#666";ddlSpecIndex2.options[4].style.backgroundColor="#ccc";ddlSpecIndex2.options[4].style.color="#666";}
else if(ddlNameLen.selectedIndex==1)
{ddlSpecIndex1.options[3].className="readWrite";ddlSpecIndex1.options[4].className="readOnly";ddlSpecIndex2.options[3].className="readWrite";ddlSpecIndex2.options[4].className="readOnly";ddlSpecIndex1.options[3].style.backgroundColor="#fff";ddlSpecIndex1.options[3].style.color="#000";ddlSpecIndex1.options[4].style.backgroundColor="#ccc";ddlSpecIndex1.options[4].style.color="#666";ddlSpecIndex2.options[3].style.backgroundColor="#fff";ddlSpecIndex2.options[3].style.color="#000";ddlSpecIndex2.options[4].style.backgroundColor="#ccc";ddlSpecIndex2.options[4].style.color="#666";}
else
{ddlSpecIndex1.options[3].className="readWrite";ddlSpecIndex1.options[4].className="readWrite";ddlSpecIndex2.options[3].className="readWrite";ddlSpecIndex2.options[4].className="readWrite";ddlSpecIndex1.options[3].style.backgroundColor="#fff";ddlSpecIndex1.options[3].style.color="#000";ddlSpecIndex1.options[4].style.backgroundColor="#fff";ddlSpecIndex1.options[4].style.color="#000";ddlSpecIndex2.options[3].style.backgroundColor="#fff";ddlSpecIndex2.options[3].style.color="#000";ddlSpecIndex2.options[4].style.backgroundColor="#fff";ddlSpecIndex2.options[4].style.color="#000";}}
function OnSpecIndex1Changed()
{var me=$(ForeignCompInputClientIDs.ddlSpecIndex1);if(me.options[me.selectedIndex].className=='readOnly')
{ShowMsgInfo("您不能选择该项，因为该项和您指定的名字的长度相矛盾。");me.selectedIndex=specIndex1Sel;return;}
var ddlSpecIndex2=$(ForeignCompInputClientIDs.ddlSpecIndex2);if(ddlSpecIndex2.selectedIndex!=0&&me.selectedIndex!=5&&ddlSpecIndex2.selectedIndex==me.selectedIndex)
{ShowMsgInfo("当前指定位置不能和另外一个指定位置相同。");me.selectedIndex=specIndex1Sel;return;}
specIndex1Sel=me.selectedIndex;}
function OnSpecIndex2Changed()
{var me=$(ForeignCompInputClientIDs.ddlSpecIndex2);if(me.options[me.selectedIndex].className=='readOnly')
{ShowMsgInfo("您不能选择该项，因为该项和您指定的名字的长度相矛盾。");me.selectedIndex=specIndex2Sel;return;}
var ddlSpecIndex1=$(ForeignCompInputClientIDs.ddlSpecIndex1);if(ddlSpecIndex1.selectedIndex!=0&&me.selectedIndex!=5&&ddlSpecIndex1.selectedIndex==me.selectedIndex)
{ShowMsgInfo("当前指定位置不能和另外一个指定位置相同。");me.selectedIndex=specIndex2Sel;return;}
specIndex2Sel=me.selectedIndex;}
var bizSamplesCache=new Array();function GetBizSamples()
{var area=$(ForeignCompInputClientIDs.ddlArea);var selID=area.options[area.selectedIndex].value;if(bizSamplesCache[selID]!=null)
{$("spanBiz").innerHTML=bizSamplesCache[selID];return;}
try
{　　 xmlHttp=GetXmlHttpObject();　　 SendXmlHttpRequest(xmlHttp,GetBizSamplesCallBack,AppPath+"CompanyName/AJAXServices/BizSamples.aspx?AreaID="+escape(selID));}
catch(e)
{}}
function GetBizSamplesCallBack()
{try
{if(xmlHttp.readyState==4||xmlHttp.readyState=='complete')
{if(xmlHttp.status==200)
{var response=xmlHttp.responseText;if(response.length>0)
{var more=response.substring(0,1);response=response.substring(1);if(response=="")
{$("spanBiz").innerHTML="";return;}
var temp=response.split("|");var html="<br /><span style='color:gray'>比如，</span>";for(i=0;i<temp.length;++i)
{html+="<a title='点击加入' href='javascript:void(0);' onclick='PickBizSample(\""+temp[i]+"\")'>"+temp[i]+"</a>　";}
if(more=="1")
{html+="<a href=javascript:void(0) onclick='ShowMoreBizSamples()'>&gt;&gt;更多</a>";}
$("spanBiz").innerHTML=html;var area=$(ForeignCompInputClientIDs.ddlArea);var selID=area.options[area.selectedIndex].value;bizSamplesCache[selID]=html;if(IsModification)
{AjustIframParentSize();}}
else
{$("spanBiz").innerHTML="";}}
else
{$("spanBiz").innerHTML="";}}}
catch(e)
{}}
function PickBizSample(txt)
{var tb=$(ForeignCompInputClientIDs.tbBusiness);if(tb.value.trim()==BIZ_PROMPT)
{tb.style.color="#000000";tb.value="";}
var temp=" "+tb.value+" ";if(temp.indexOf(" "+txt+" ")==-1)
{tb.value=(tb.value.trim()+" "+txt).trim();}}
function ShowMoreBizSamples()
{var control=ForeignCompInputClientIDs.tbBusiness;var area=$(ForeignCompInputClientIDs.ddlArea);var selID=area.options[area.selectedIndex].value;var simpParts=popupDialog(control,AppPath+"CompanyName/SelectBizSamples.aspx?value="+escape($(control).value)+"&AreaID="+escape(selID),620,410);}
var currentAreaIndex=0;var currentAreaChar='';function CharPointItem(evt)
{evt=window.event?window.event:evt;var ddl=$(ForeignCompInputClientIDs.ddlArea);var itemCount=ddl.options.length;var selectStr='';var laseIndex=currentAreaIndex;var pressKey=String.fromCharCode(evt.keyCode).toLowerCase();if(itemCount<=1||IsEnChar(pressKey)==false)
return;if(pressKey!=currentAreaChar)
currentAreaIndex=0;for(var i=currentAreaIndex;i<itemCount;++i)
{if(ddl.options[i].getAttribute("py").toLowerCase()==pressKey)
{currentAreaChar=pressKey;ddl.selectedIndex=i;currentAreaIndex=i+1;break;}}
ddl.onchange();currentAreaIndex=laseIndex==currentAreaIndex?0:currentAreaIndex;}
function IsEnChar(str)
{t=str.charAt(0).toLowerCase();if(t<="z"&&t>="a")
return true;else
return false;}
function OnUnknownArea()
{var tbBiz=$(ForeignCompInputClientIDs.tbBusiness);var bizInfo=tbBiz.value.trim();if(bizInfo==BIZ_PROMPT)
{tbBiz.value="";}
if(tbBiz.value=="")
{alert("请输入您公司的业务介绍。");return;}
try
{　　 xmlHttp=GetXmlHttpObject();　　 SendXmlHttpRequest(xmlHttp,OnUnknownAreaCallback,AppPath+"CompanyName/AJAXServices/AreaClassify.aspx?BizInfo="+escape(bizInfo));}
catch(e)
{}}
function OnUnknownAreaCallback()
{try
{if(xmlHttp.readyState==4||xmlHttp.readyState=='complete')
{if(xmlHttp.status==200)
{var response=xmlHttp.responseText;if(response.length>0)
{var temp=response.split("|");var html="";for(i=0;i<temp.length;++i)
{if(temp[i]=="")
{continue;}
var t=temp[i].split(":");html+="<input type='radio' onclick='SelectArea(\""+t[0]+"\")' name='RD_AREA' id='rdArea"+i+"' /><label for='rdArea"+i+"'>"+t[1]+"</label> 　";}
if(html!="")
{html="<hr />根据您输入的业务介绍，我们为您推荐了几个最相关领域，请选择领域：<br />"+html;}
$("spanArea").innerHTML=html;if(IsModification)
{AjustIframParentSize();}}
else
{$("spanArea").innerHTML="暂无推荐。";}}
else
{$("spanArea").innerHTML="暂无推荐。";}}}
catch(e)
{}}
function SelectArea(areaID)
{var ddl=$(ForeignCompInputClientIDs.ddlArea);for(var i=0;i<ddl.options.length;++i)
{if(ddl.options[i].value==areaID)
{ddl.selectedIndex=i;GetBizSamples();break;}}}
function ShowMsgInfo(msg)
{try
{var msgDialog=$("msgContainer");var msgDialogTxt=$("msgContainerTxt");if(msgDialog.style.visibility=='hidden')
{msgDialog.style.visibility="visible";}
msgDialogTxt.innerHTML=msg.replace("<br>","");msgDialog.style.left=(screen.width-msgDialog.scrollWidth)/2+"px";msgDialog.style.top=document.documentElement.scrollTop+2+"px";msgDialog.style.borderColor="red";setTimeout("HighlightMsgInfo()",200);clearTimeout(autoCloseTimer);autoCloseTimer=setTimeout("AutoCloseMsgInfo()",4*1000);msgDialog.onmouseover=function()
{clearTimeout(autoCloseTimer);}
msgDialog.onmouseout=function()
{autoCloseTimer=setTimeout("AutoCloseMsgInfo()",2*1000);}}
catch(e)
{}}
var autoCloseTimer;function HighlightMsgInfo()
{try
{var msgDialog=$("msgContainer");msgDialog.style.borderColor="green";}
catch(e)
{}}
function AutoCloseMsgInfo()
{try
{var msgDialog=$("msgContainer");msgDialog.style.visibility="hidden";}
catch(e)
{}}
function SetControlStatusByNamingMethod()
{var rbtTrans=$(ForeignCompInputClientIDs.rbtTrans);var ddlNameLen=$("divNameLen");if(rbtTrans.checked)
{ddlNameLen.style.display="none";}
else
{ddlNameLen.style.display="";}}
function SelectSimpParts(control)
{var simpParts=popupDialog(control,AppPath+"Naming/SelectSimpParts.aspx?value="+escape($(control).value),620,400);}
function SelectSpell(control)
{var simpParts=popupDialog(control,AppPath+"Naming/SelectSpell.aspx?value="+escape($(control).value),500,250);}
function SelectYunMu(control)
{var yunmu=popupDialog(control,AppPath+"Naming/SelectYunMu.aspx?value="+escape($(control).value),600,250);}
function SelectStructures(control)
{var structures=popupDialog(control,AppPath+"Naming/SelectStructure.aspx?value="+escape($(control).value),520,200);}
function SelectStrokes(control)
{var strokes=popupDialog(control,AppPath+"Naming/SelectStroke.aspx?value="+escape($(control).value),600,250);}
function SelectTunes(control)
{var tunes=popupDialog(control,AppPath+"Naming/SelectTune.aspx?value="+escape($(control).value),500,200);}
function SetSampleWishes(wish)
{var tbOtherHopes=$(ForeignCompInputClientIDs.tbWishes);tbOtherHopes.style.color="#000000";if(tbOtherHopes.value.trim()==HOPE_PROMPT)
{tbOtherHopes.value="";}
wish=wish.trim();if(tbOtherHopes.value.indexOf(wish)==-1)
{tbOtherHopes.value+=" "+wish;}
tbOtherHopes.value=tbOtherHopes.value.trim();}
function SetControlsStatus()
{CheckAdvancedParams();if(window.adValue)
{var button=$("btAdOption");if(button.innerHTML=="显示")
{ShowAdOptions(button);}}}
function popupDialog(control,url,width,height)
{var x=parseInt(screen.width/2.0)-(width/2.0);var y=parseInt(screen.height/2.0)-(height/2.0);var isMSIE=(navigator.appName=="Microsoft Internet Explorer");if(isMSIE)
{retval=window.showModalDialog(url,window,"dialogWidth:"+width+"px; dialogHeight:"+height+"px; dialogLeft:"+x+"px; dialogTop:"+y+"px; status:no; directories:yes;scrollbars:no;Resizable=no; ");if(retval!=undefined)
{$(control).value=retval;$(control).title=retval;}}
else
{window.myAction=this;var win=window.open(url,"mcePopup","top="+y+",left="+x+",scrollbars=no,dialog=yes,modal=yes,width="+width+",height="+height+",resizable=no");eval('try { win.resizeTo(width, height); } catch(e) { }');win.focus();this.returnAction=function(strResult)
{if(strResult!=undefined)
{$(control).value=strResult;$(control).title=strResult;}}}}
function PickCountry()
{try
{InitQueryCode(ForeignCompInputClientIDs.tbCountry,"PickItemDiv",CountryValueChanged);isXingShi=false;showQueryDiv(locations["国家"],30,1,5);AjustIframParentSize(true);}
catch(e)
{}}
function CountryValueChanged()
{var country=$(ForeignCompInputClientIDs.tbCountry);var pro=$(ForeignCompInputClientIDs.tbProvince);var city=$(ForeignCompInputClientIDs.tbCity);if(country.value.trim()!="中国")
{pro.value="";city.value="";}}
function ProvinceValueChanged()
{var city=$(ForeignCompInputClientIDs.tbCity);city.value="";}
function PickProvince()
{try
{if($(ForeignCompInputClientIDs.tbCountry).value.trim()=="中国")
{InitQueryCode(ForeignCompInputClientIDs.tbProvince,"PickItemDiv",ProvinceValueChanged);isXingShi=false;showQueryDiv(locations["省市"],40,1,8);AjustIframParentSize(true);}}
catch(e)
{}}
function PickCity()
{try
{var country=$(ForeignCompInputClientIDs.tbCountry).value.trim();var pro=$(ForeignCompInputClientIDs.tbProvince).value.trim();var city=locations[pro];if(city!=undefined&&city!=null&&country=="中国")
{InitQueryCode(ForeignCompInputClientIDs.tbCity,"PickItemDiv");isXingShi=false;showQueryDiv(city,40,1,6);AjustIframParentSize(true);}}
catch(e)
{}}