﻿
// JScript 文件

function createAjaxObj(){
	var httprequest=false
	if (window.XMLHttpRequest){ // if Mozilla, Safari etc
		httprequest=new XMLHttpRequest()
		if (httprequest.overrideMimeType)
			httprequest.overrideMimeType('text/xml');
	}
	else if (window.ActiveXObject){ // if IE
		try 
		{
			httprequest=new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e)
		{
			try
			{
				httprequest=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){}
		}
	}
	return httprequest;
}


function sendWebEmailtoFriends(type)
{
if(sendWebEmailtoFriendsCnCheck()){
  var emailSubject = document.getElementById("emailSubject").value;
　var friendsEmail = document.getElementById("friendsEmail").value;
　var yourName = document.getElementById("yourName").value;
  var yourEmail = document.getElementById("yourEmail").value;
  var yourMessage = document.getElementById("yourMessage").value;
  var isSendtoSelf = "false";
  var sendUrl=document.location.href;
  if(document.getElementById("isSendtoSelf").checked)
      isSendtoSelf = document.getElementById("isSendtoSelf").value;
　var url = "/en/NewsSendWebEmailtoFriendsAjax.aspx?";
　var wetTitle="";
　if(type==""||type=="news")
　{
     type='news';
     wetTitle = document.getElementById("txttitle").innerText;
  }
  else
    wetTitle = document.getElementById("JobDetailInfo_lblJobName").innerText;
　var postStr = "emailSubject="+escape(emailSubject)+"&friendsEmail="+escape(friendsEmail)+"&yourName="+escape(yourName)+"&yourEmail="+escape(yourEmail)+"&yourMessage="+escape(yourMessage)+"&isSendtoSelf="+escape(isSendtoSelf)+"&sendUrl="+escape(sendUrl)+"&wetTitle="+escape(wetTitle);
　postStr=postStr+"&type="+escape(type);
//　alert(url+postStr);
　//实例化Ajax
　var ajax = createAjaxObj();　
　//通过Post方式打开连接
　ajax.open("POST", url, true); 
　//定义传输的文件HTTP头信息，这一行不能少
　ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");  
　//发送POST数据
　ajax.send(postStr);
　ajax.onreadystatechange = function() { 
　　if (ajax.readyState == 4 && ajax.status == 200) { 
        var content=ajax.responseText;
        alert(content); 
        hideBoxAndShadeDiv("emailTofriendsBigBox");
　　} 
　　else if(ajax.readyState != 1 && ajax.readyState != 2 && ajax.readyState != 3&& ajax.readyState != 0)
　　{
　　 alert("Submit false,Illegal characters are detected in your content!"); 
　　}
　}
}
}

function sendWebEmailtoFriendsCnCheck()
{
var flag=true;
   if(document.getElementById("emailSubject").value==""){alert('input Subject please!');flag=false;}else flag=true;
   if(flag)
   if(document.getElementById("friendsEmail").value=="separate multiple email addresses with semicolon(;)"||document.getElementById("friendsEmail").value==""||document.getElementById("friendsEmail").value.length==0){alert('Input the receiver email please！');flag=false;}else flag=true;
   if(flag)
   if(document.getElementById("friendsEmail").value.indexOf(".")<0||document.getElementById("friendsEmail").value.indexOf("@")<0){alert('email address format error!(example:abc@coship.com)');flag=false;}else flag=true;
   if(flag)
   if(document.getElementById("yourName").value==""||document.getElementById("yourName").value.length==0){alert('Input sender name please！');flag=false;}else flag=true;
   if(flag)
   if(document.getElementById("yourEmail").value==""||document.getElementById("yourEmail").value.length==0){alert('Input sender email please！');flag=false;}else flag=true;
   if(flag)
   if(document.getElementById("yourEmail").value.indexOf(".")<0||document.getElementById("yourEmail").value.indexOf("@")<0){alert('email address format error!(example:abc@coship.com)');flag=false;}else flag=true;
   if(flag)
   if(document.getElementById("yourMessage").value.length>500){alert('Maximum 500 characters.');flag=false;}else flag=true;
   
   return flag;
}


function emailTofriendsForm(type)
{
document.write('<div id="emailTofriendsBigBox">');
document.write('<div class="floatLeftW"><div class="emailTofriendsBoxTitleLeft"><strong>Email to friends</strong></div><div class="emailTofriendsBoxTitleRight"><img src=\"/en/images/en/news2_04.gif\" alt=\"close\" id=\"emailTofriendsBigBoxClose\" />&nbsp;</div></div>');
document.write('      <div class="emailTofriendstable">');
document.write('            <table cellSpacing="0" cellPadding="2" align="center" border="0">');
document.write('		    <tr><td align="right" height="30" ><strong>Subject</strong><font class="colorRed">*</font></td><td align="left"><input id="emailSubject" type="text" style="width:350px;color:#333;"  /></td></tr>');
document.write('		    <tr><td align="right" height="30"  width="110"><strong>Recipient\'s Email</strong><font class="colorRed">*</font></td><td align="left" ><input id="friendsEmail" type="text" style="width:350px;color:#666;font-size:11px;"  value="separate multiple email addresses with semicolon(;)" onClick=\'javascritp:setOnClickText("friendsEmail","separate multiple email addresses with semicolon(;)")\' /></td></tr>');
document.write('		    <tr><td align="right" height="30"  ><strong>Your Name</strong><font class="colorRed">*</font></td><td align="left"><input id="yourName" type="text" style="width:350px;color:#333;"  /></td></tr>');
document.write('		    <tr><td align="right" height="30"  ><strong>Your Email</strong><font class="colorRed">*</font></td><td align="left"><input id="yourEmail" type="text" style="width:350px;color:#333;"  /></td></tr>');
document.write('		    <tr><td align="right" valign="top" height="85"><strong>Comments</strong></td><td align="left"><textarea id="yourMessage"  cols="50" rows="5"  style="color:#999;"  ></textarea></td></tr>');
document.write('		    <tr><td align="right" height="30"  ></td><td align="left" style="text-align:left;line-height:30px;vertical-align:middle"><input id="isSendtoSelf" type="checkbox" value="true" style="color:#999;border:0px;"  /> <label for="isSendtoSelf" id="selectStr"><strong>Send Yourself a Copy</strong></label></td></tr>');
document.write('		    <tr><td ></td><td  height="38" style="text-indent:110px;"><img id="btnSubmitEmailFriend" src="/en/images/en/news2_13.gif" alt="Send" align="AbsMiddle" onClick="sendWebEmailtoFriends(\''+type+'\');"/></td></tr>');
document.write('	        </table>');
document.write('     </div>');
document.write('</div>');
}

function emailInterviewCheck()
{
var flag=true;
   if(document.getElementById("txtName").value==""){alert('Please input your Fist Name!');flag=false;}else flag=true;
   if(flag)
   if(document.getElementById("txtNameLast").value==""){alert('Please input your Last Name!');flag=false;}else flag=true;
   if(flag)
   if(document.getElementById("txtFax").value==""){alert('Please input your Title!');flag=false;}else flag=true;
   if(flag)
   if(document.getElementById("txtcompany").value==""||document.getElementById("txtcompany").value.length==0){alert('Please input your Company!');flag=false;}else flag=true;
   if(flag)
   if(document.getElementById("txtEmail").value==""||document.getElementById("txtEmail").value.length==0){alert('Please input your Email!！');flag=false;}else flag=true;
   if(flag)
   if(document.getElementById("txtEmail").value.indexOf(".")<0||document.getElementById("txtEmail").value.indexOf("@")<0){alert('email address format error!(example:abc@coship.com)');flag=false;}else flag=true;
   if(flag)
   if(document.getElementById("txtPhone").value==""){alert('Please input your Tel!');flag=false;}else flag=true;
   if(flag)
   if(document.getElementById("txtlocation").value==""){alert('Please input your Location!');flag=false;}else flag=true;
   if(flag)
   if(document.getElementById("txtOther").value.length>500){alert('Maximum 500 characters.');flag=false;}else flag=true;
   
   return flag;
}

emailInterview();
function emailInterview()
{
document.write('<div id="emailInterviewBigBox">');
document.write('<div class="floatLeftW"><div class="emailInterviewBoxTitleLeft"><strong>Media Contact</strong></div><div class="emailInterviewBoxTitleRight"><img src=\"/en/images/en/news2_04.gif\" alt=\"close\" id=\"emailInterviewBigBoxClose\" />&nbsp;</div></div>');
document.write('      <div class="emailInterviewexplanation">');
document.write('      For media-related enquiries,please fill out the form below.We will do our best to provide you with an answer promptly.');
document.write('      </div>');
document.write('      <div class="emailInterviewtable">');
document.write('            <table cellSpacing="0" cellPadding="2" align="center" border="0">');
document.write('		    <tr><td align="right" height="23" width="100"><strong>Fist Name</strong><font class="colorRed">*</font></td><td align="left"><input id="txtName" type="text" style="width:350px;color:#333;"  /></td></tr>');
document.write('		    <tr><td align="right" height="23" ><strong>Last Name</strong><font class="colorRed">*</font></td><td align="left" ><input id="txtNameLast" type="text" style="width:350px;color:#333;"   /></td></tr>');
document.write('		    <tr><td align="right" height="23"  ><strong>Company</strong><font class="colorRed">*</font></td><td align="left"><input id="txtcompany" type="text" style="width:350px;color:#333;"  /></td></tr>');
document.write('		    <tr><td align="right" height="23"  ><strong>Title</strong><font class="colorRed">*</font></td><td align="left"><input id="txtFax" type="text" style="width:350px;color:#333;"  /></td></tr>');
document.write('		    <tr><td align="right" height="23"  ><strong>E-mail</strong><font class="colorRed">*</font></td><td align="left"><input id="txtEmail" type="text" style="width:350px;color:#333;"  /></td></tr>');
document.write('		    <tr><td align="right" height="23"  ><strong>Tel</strong><font class="colorRed">*</font></td><td align="left"><input id="txtPhone" type="text" style="width:350px;color:#333;"  /></td></tr>');
document.write('		    <tr><td align="right" height="23"  ><strong>Location</strong><font class="colorRed">*</font></td><td align="left"><input id="txtlocation" type="text" style="width:350px;color:#333;"  /></td></tr>');
document.write('		    <tr><td align="right" valign="top" ><strong>Request</strong></td><td align="left"><textarea id="txtOther" cols="50" rows="2"  style="color:#999;"  ></textarea></td></tr>');
document.write('	        </table>');
document.write('		    <div class="emailInterviewbuttom"><img id="btnInterview" src="/en/images/en/news2_13.gif" alt="Send" align="AbsMiddle" onClick="sendEmailInterview();"/></div>');
document.write('     </div>');
document.write('</div>');
}

function sendEmailInterview()
{
if(emailInterviewCheck()){
  var txtName = document.getElementById("txtName").value;
　var txtNameLast = document.getElementById("txtNameLast").value;
　var txtFax = document.getElementById("txtFax").value;
  var txtcompany = document.getElementById("txtcompany").value;
  var txtEmail = document.getElementById("txtEmail").value;
  var txtPhone = document.getElementById("txtPhone").value;
  var txtlocation = document.getElementById("txtlocation").value;
  var txtOther = document.getElementById("txtOther").value;
　var url = "/en/emailInterviewAjax.aspx?";

　var postStr = "txtName="+escape(txtName)+"&txtNameLast="+escape(txtNameLast)+"&txtFax="+escape(txtFax)+"&txtcompany="+escape(txtcompany)+"&txtEmail="+escape(txtEmail)+"&txtPhone="+escape(txtPhone)+"&txtlocation="+escape(txtlocation)+"&txtOther="+escape(txtOther);
//　alert(url+postStr);
　//实例化Ajax
　var ajax = createAjaxObj();　
　//通过Post方式打开连接
　ajax.open("POST", url, true); 
　//定义传输的文件HTTP头信息，这一行不能少
　ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");  
　//发送POST数据
　ajax.send(postStr);
　ajax.onreadystatechange = function() { 
　　if (ajax.readyState == 4 && ajax.status == 200){
        var content=ajax.responseText;
        alert(content); 
        hideBoxAndShadeDiv("emailInterviewBigBox");
　　} 
　　else if(ajax.readyState != 1 && ajax.readyState != 2 && ajax.readyState != 3&& ajax.readyState != 0)
　　{
　　 alert("Submit failed,Illegal characters are detected in your content,check them please. "); 
　　}
　}
}
}


