﻿var serverPath="http://www.etwinternational.com/";var serveraddress="http://usa1.etwun.com/getuserip.php";var msg1="'Title' is required";var msg2="'Email' is required";var msg3="'Message' is required";var msg4="Invalid 'E-mail'";var etw_url_2009_str=window.location.href.indexOf("&etwurl=");
var wait="Wait for 10 Seconds Please";
var emailmsg="请输入您的邮箱地址";
var resetinfo="发送";
var success="成功";
var timerLast="数据正在处理中...请等待15秒";
var guestshowText="我们会在24小时内回复您的信息.您可以继续浏览其它页面.";
function checkmailempty(){document.getElementById("email").value=emailmsg;}checkmailempty();
if(etw_url_2009_str>0){etw_url_2009=window.location.href.substr(etw_url_2009_str+8);var etw_post_url=etw_url_2009;}
function trim(str){return str.replace(/(^\s*)|(\s*$)/g,"")}
function borderstyle(ob){ob.style.cssText="border:2px solid #80FF00;"}
var title;var message;var email;var address;var substate=true;
function formcheck(){var company=document.getElementById("company");var tempinfo;tempinfo="";title=document.getElementById("title");message=document.getElementById("message"); email=document.getElementById("email");address=document.getElementById("address");if(title.value==""){tempinfo=tempinfo+msg1;title.style.cssText="border:1px solid #ff0000;"}if(email.value==""){tempinfo=tempinfo+"\n\r"+msg2;email.style.cssText="border:1px solid #ff0000;";}else{var getob=document.getElementById("email").value;var reg=/^[a-zA-Z0-9_-]+[-_\.]*[a-zA-Z0-9]*@[a-zA-Z0-9_-]+[-_\.]*[a-zA-Z0-9]*\.([a-zA-Z0-9_-]+[-_\.]*[a-zA-Z0-9]*)$/;if(!reg.test(getob)){tempinfo=tempinfo+"\n\r"+msg4;email.style.cssText="border:1px solid #ff0000;";}}contentlen=message.value.replace(/ /g,"");contentlen=contentlen.replace(/\n/g,"");contentlen=contentlen.replace(/\r/g,"");if(contentlen.length<1){tempinfo=tempinfo+"\n\r"+msg3;message.style.cssText="border:1px solid #ff0000;"}if(tempinfo!=""){alert(tempinfo);substate=false;}else{substate=true;}if(substate==true){document.getElementById("content").value="";document.getElementById("content").value=message.value+"\n\r"+"Company:"+company.value+"\n\r"; var myform=document.getElementsByTagName("form");var guestshow=document.getElementById("showresultmsg");myform[0].submit();document.getElementById("sendmessagebutton").setAttribute("disabled","disabled");/*show time out*/var sendmessagebutton=document.getElementById("sendmessagebutton");var showseond=new Object();showseond.count=15;function lastsecond(){if(showseond.count>=0){timerLast=timerLast.replace(/[0-9]+/,(showseond.count-5));sendmessagebutton.value=timerLast;showseond.count=showseond.count-1;if(showseond.count<5){sendmessagebutton.value=success;guestshow.innerHTML=guestshowText;}}else{clearInterval(showseond.timer);sendmessagebutton.removeAttribute("disabled");myform[0].reset();sendmessagebutton.value=resetinfo;}}showseond.timer=setInterval(lastsecond,1000);showseond.timer;/*show time out*/}}

function getparastr(){var mylocation=window.location.href;var pos=mylocation.indexOf("?");var myvalue=mylocation.substring(pos+1);myvalue_re=myvalue.indexOf("&etwurl=");myvalue=myvalue.substr(0,myvalue_re);if(myvalue.indexOf("undefined")>=0){}else{myvalue=myvalue.replace(/%20/g," ");myvalue=myvalue.replace("inquireform"," ");document.getElementById("title").value=myvalue;}}
//getparastr()

var idscript=document.createElement("script");var reetw_url_2009=etw_url_2009;urlStart=reetw_url_2009.indexOf("http://")+7;if(reetw_url_2009.indexOf("www.")>1){urlStart=urlStart+4;}
//以下代码用于获取网址下chatid的ID
reetw_url_2009=reetw_url_2009.substr(urlStart);urlEnd=reetw_url_2009.indexOf("/")+urlStart;if(urlEnd>urlStart){etw_url_2009=etw_url_2009.substring(urlStart,urlEnd);}else{etw_url_2009=etw_url_2009.substr(urlStart)}
//以上代码用于获取网址下chatid的ID
document.getElementById("url").value=reetw_url_2009;idscript.setAttribute("src","http://www."+etw_url_2009+"/chatId.js");idscript.setAttribute("type","text/javascript");document.body.appendChild(idscript);

var addscript=document.createElement("script");addscript.setAttribute("src",serveraddress);document.body.appendChild(addscript);
/*清除邮件地址-2009-11-19*/
document.getElementById("email").style.cssText="font-weight:normal; color:#999999;";
function clearemail(){var email=document.getElementById("email");if((email.value).indexOf("@")<1){email.value="";email.style.cssText="font-weight:bold; color:#990000;";}}
function recheckemail(){var email=document.getElementById("email");if((email.value).indexOf("@")<1){email.value=emailmsg;}}
document.getElementById("resetmessage").onclick=function(){document.getElementById("sendmessagebutton").value=resetinfo;document.getElementById("sendmessagebutton").removeAttribute("disabled");}
