function trim(s)
{
 var re = /^\s*(\S*)\s*$/;
 return s.replace(re,"$1");
}

function isDigit(s)
{
var patrn=/^[0-9]{1,12}$/;   //1-4位数字
if (!patrn.exec(s)) return false
return true
}

function isemail(s)
{
        // Writen by david, we can delete the before code
        if (s.length > 100)
        {
            window.alert("email地址长度不能超过100位!");
            return false;
        }

         var regu = "^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|NET|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT)$"
         var re = new RegExp(regu);
         if (s.search(re) != -1) {
               return true;
         }
         else
         {
               //window.alert ("请输入有效合法的E-mail地址 ！")
               return false;
         }
}


function Selectfind(s,c)
{
   var theObj = findObj(s);
	var	 CheckedObj;
	if (theObj.length==null)
	{
		if(theObj.checked)
			CheckedObj = theObj;
	}
	else
	{
		var i;
		for(i=0; i<theObj.length; i++)
		{

                    if (theObj[i].checked)
                    {
                            CheckedObj = theObj[i];
                            break;
                    }
		}
	}
	if (CheckedObj==null)
	{
		alert("请选择"+c+"!");
                return false;
	}
        return true;
}

function findObj(theObj, theDoc)
{
  var p, i, foundObj;

  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++)
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++)
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);

  return foundObj;
}

function IsDomainName(str){
 // var ext=(".COM.| .NET.| .GOV.|.ORG.|.EDU.|.IDV.").split("|");
  var ext=(".com.|.net.|.gov.|.org.|.edu.|.idv.").split("|");
 // var province =(".BJ.|.SH.|.TJ.|.CQ.|.HE.|.SX.|.NM.|.JL.|.HL.|.JS.|.ZJ.|.AH.|.FJ.|.JX.|.SD.|.HA.|.HB.|.GD.|.GX.|.HI.|.SC.|.GZ.|.YN.|.XZ.|.SN.|.GS.|.QH.|.XJ.|.TW.|.HK.|.MO.|.LN.|.HN.|.NX.|.AC.").split("|");
  var province=(".bj.|.sh.|.tj.|.cq.|.he.|.sx.|.nm.|.jl.|.hl.|.js.|.zj.|.ah.|.fj.|.jx.|.sd.|.ha.|.hb.|.gd.|.gx.|.hi.|.sc.|.gz.|.yn.|.xz.|.sn.|.gs.|.qh.|.xj.|.tw.|.hk.|.mo.|.ln.|.hn.|.nx.|.ac.").split("|");
  var l=str.indexOf("http://");
  //alert(l);

  if(l>=0){
    str=str.substring((l+7),str.length);
  //  alert(str);
  }
  if(str.length==0){
    //alert("请输入正确的域名！");
    return false;
  }

  var j=0;
  for(var i=0;i<ext.length;i++){

    j=str.indexOf(ext[i]);
    if(j>0){
      j=str.lastIndexOf(".",j);
      if(j>0){
        str=str.substring(j,str.length);
        //alert("1111111111");
        return true;
      }
    }
    else{
      //alert(ext[i].substring(0,4));
      j=str.lastIndexOf(ext[i].substring(0,4));
      if(j>0){
        j=str.lastIndexOf(".",j);
        if(j>0){
          str=str.substring(j,str.length);
           //alert("22222");
          return true;
        }
      }
    }
  }


   //alert("aaaaaaaaaaaaaaaa");
  for(var i=0;i<province.length;i++){
    j=str.indexOf(province[i]);
    if(j>0){
      j=str.lastIndexOf(".",j);
      if(j>0){
        str=str.substring(str.lastIndexOf(".",j),str.length);
         //alert("333333");
        return true;
      }

    }
  }


  return false;
}


function CheckTime(BeginTime,EndTime){
	if(BeginTime==""&&EndTime!=""){
          alert("请选择开始时间!");
          return false;
	}

	if(BeginTime!=""&&EndTime==""){
          alert("请选择结束时间!");
          return false;
	}
	if((BeginTime!=""&&EndTime!="")&&BeginTime>EndTime){
          alert("开始时间比结束时间晚!");
          return false;
	}
        return true;
}

function checkPhone(Mobile){
        var phone=Mobile.value
	var regu = "((^([0-9]{6,15})$)|(^([\(]+([0-9]{3,4})+[\)])+([0-9]{6,9})$)|(^([0-9]{3,4})+[\-]+([0-9]{6,9})$))";
	 var re = new RegExp(regu);
	 if (phone.search(re) != -1) {
		return true;
	 }
         return false;
}

function setStatus() {
	window.status="                                                                   正   在   发   邮   件.............";
}
function ClearStatus() {
	window.status="";
}
