var nm=navigator.appName;
NS=((nm.indexOf("Netscape")>-1||nm.indexOf("Netscape")>-1)?1:0);
var IE4 = (document.all);

//设为Browser Home Page
function Homepage(th) {
  th.style.behavior="url(#default#homepage)"; 
  th.setHomePage("http://tssi-smtp-component.trisunsoft.com") 
  }

//添加到"我的最爱"
function addfavorite() {
  if (IE4) {window.external.AddFavorite(location.href, document.title);}
  if (NS) {alert("For Netscape users, please press <Ctrl + D> to add this page to your bookmarks.");}
  }

//去空格函数
function trim(str, type) {
//Description: str - 目标串, type - 类型. 0 - 去除前后空格; 1 - 去前导空格; 2 - 去尾部空格

  var sTmpStr = ' '
  var i = -1

  if(type == 0 || type == 1) {
	 while(sTmpStr == ' ') {
		++i
		sTmpStr = str.substr(i,1)
	 }
	 str = str.substring(i)
  }

  if(type == 0 || type == 2) {
	 sTmpStr = ' '
	 i = str.length
	 while(sTmpStr == ' ') {
		--i
		sTmpStr = str.substr(i,1)
	 }
	 str = str.substring(0,i+1)
  }
  return str
}


function checkAddress() {
   var strAddress = trim(document.sendmail.address.value, 0);
	if(strAddress.length != 0) {
	   if(strAddress.charAt(0) == "." ||        
		   strAddress.charAt(0) == "@" ||       
		   strAddress.indexOf('@', 0) == -1 || 
		   strAddress.indexOf('.', 0) == -1 || 
		   strAddress.lastIndexOf("@") == strAddress.length - 1 || 
		   strAddress.lastIndexOf(".") == strAddress.length - 1) {
         alert("Please input a VALID EMAIL ADDRESS.") 
         document.sendmail.address.value = ""
         document.sendmail.address.focus()   
         return false  
      }
	}
	else {
	   alert("Please input the EMAIL ADDRESS.");
   	document.sendmail.address.focus();
	   return false;
	}
	return true;
} 

function doCopy(id)
{
	id.select();
	rgn = id.createTextRange();
	rgn.execCommand("Copy");
}

// 实作mailto协议链接 (使用 js 是为了处理正文之换行符).
function mailTo() {  
  var url = "?subject=Recommend software - TSSI SMTP Component - from your friend YOUR NAME.&body=Hello:" +		escape('\n') + escape('\n') + "I'm using TSSI SMTP Component, it's a powerful SMTP component, and you can use it to develop the SMTP/ESMTP mailing applications conveniently." + escape('\n') + escape('\n') + "You should have a test!" + escape('\n') + escape('\n') + "Official website: http://tssi-smtp-component.TriSunSoft.com" + escape('\n') + "Direct download URL: http://tssi-smtp-component.TriSunSoft.com/tssi-smtp-component.exe" + escape('\n') + escape('\n') + "Yours: your name"
  window.location.href = "mailto:" + url
}