//去掉字符串左边的空格
function lTrim(str)
{
    if (str.charAt(0) == " ")
    {
        str = str.substring(1);
        str = lTrim(str);
    }
    return str;
}

//去掉字符串右边的空格
function rTrim(str)
{
    var iLength;
    iLength = str.length;
    if (str.charAt(iLength - 1) == " ")
    {
        str = str.substring(0, iLength - 1);
        str = rTrim(str);
    }
    return str;
}

//去掉字符串两边的空格
function trim(str)
{
    return lTrim(rTrim(str));
}

//判断邮件的格式
function isEmail(email)
{
    return /\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})/.test(email) && !/www.\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})/.test(email);

}
//建立XMLHttpRequest对像
function createXMLHttpRequest(strUrl) 
	{ 
		var xmlHttp; 
		if(window.ActiveXObject){
			 xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		   }else if(window.XMLHttpRequest){
			 xmlHttp = new XMLHttpRequest();
		   }
		if(!xmlHttp){
			responsetext="...";
		}else{
			var responsetext ="" ; 
			xmlHttp.open("POST", strUrl, false); 
			xmlHttp.onreadystatechange=function(){
				responsetext=getXmlHttpState(xmlHttp)
			};
			xmlHttp.send(); 
		}
		return responsetext; 
	} 
//判断XMLHttpRequest状态
function getXmlHttpState(theXmlHttp){
	   var theState="";
	   if(theXmlHttp.readyState == 0){
		 theState = ".";
		 //alert(theXmlHttp.readyState);
	   }
	   if(theXmlHttp.readyState == 1){
		 theState = "..";
		 //alert(theXmlHttp.readyState);
	   }
	   if(theXmlHttp.readyState == 2){
		 theState = "...";
		 //alert(theXmlHttp.readyState);
	   }
	   if(theXmlHttp.readyState == 3){
		 theState = "....";
		 //alert(theXmlHttp.readyState);
	   }
	   if(theXmlHttp.readyState == 4){
			//alert(theXmlHttp.readyState);
			if(theXmlHttp.status==200){
				theState=theXmlHttp.ResponseText;
			}else{
				theState="";
				theState=theXmlHttp.ResponseText;
			}
	   }
	   
	   return theState;
} 

function addEmail() {
            var email = document.getElementById("emailName").value;
            if (trim(email) != "") {
                if (!isEmail(email)) {
                    alert("email format error");
                    return false;
                } else {
                    return true;
                }
            } else {
                alert("email is not null");
                return false;
            }
        }

function submitSearchForm(){

							if(document.getElementById("mapData(subject)").value==''){

								alert("Please input search keyword!");

								document.getElementById("mapData(subject)").focus();

								return false;

							}else if(document.getElementById("mapData(subject)").value.length<=1){

								alert("The keyword must be more than 2 characters!!");

								document.getElementById("mapData(subject)").focus();

								return false;

							}

							document.searchform.submit();

						}