
function getCurDate(){
    var date="";
    var CurDate=new Date;
    var iYear = CurDate.getFullYear();
    var iMonth = CurDate.getMonth()+1;
    var iDay =CurDate.getDate();
  	iMonth = iMonth + 100 + "";
  	iMonth = iMonth.substring(1);
  	iDay   = iDay + 100 + "";
  	iDay   = iDay.substring(1);
  	date = iYear+"-"+iMonth+"-"+iDay;
    return  date;

}

//this function is used to compare two date,author:rautinee

function compareDate(DateOne,DateTwo)
{

var OneMonth = DateOne.substring(5,DateOne.lastIndexOf ("-"));
var OneDay = DateOne.substring(DateOne.length,DateOne.lastIndexOf ("-")+1);
var OneYear = DateOne.substring(0,DateOne.indexOf ("-"));

var TwoMonth = DateTwo.substring(5,DateTwo.lastIndexOf ("-"));
var TwoDay = DateTwo.substring(DateTwo.length,DateTwo.lastIndexOf ("-")+1);
var TwoYear = DateTwo.substring(0,DateTwo.indexOf ("-"));

if (Date.parse(OneMonth+"/"+OneDay+"/"+OneYear) >
Date.parse(TwoMonth+"/"+TwoDay+"/"+TwoYear))
{
return true;
}
else
{
return false;
}
}
function JHshLTrim(sString)
{
var sStr,i,iStart,sResult = "";

sStr = sString.split("");
iStart = -1 ;
for (i = 0 ; i < sStr.length ; i++)
{
if (sStr[i] != " ")
{
iStart = i;
break;
}
}
if (iStart == -1) { return "" ;}    //¡À¨ª¨º?sString?D¦Ì??¨´¨®D¡Á?¡¤??¨´¨º?????,?¨°¡¤¦Ì????¡ä?
else { return sString.substring(iStart) ;}
}


function isNull(arr){
  with(mainForm.document){
     for(var i=0;i<arr.length;i++){
        var obj=document.getElementById(arr[i]);
        if(obj.value==""){
          var preObj=obj.parentNode.previousSibling.innerText;
          if(null!=preObj)   preObj=preObj.substring(0,preObj.indexOf("(**)"));
          alert(preObj+"2??¨¹?a??!!!");
          return false;
         }
      }
   }
   return true;

  }


//add by zoutao

String.prototype.trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
}
String.prototype.replaceAll=function(rgExp,replaceText)
{
	  if(rgExp==replaceText || rgExp=="") return this;
	  var l1=rgExp.length;
	  var l2=replaceText.length

	  var str=this;
	  var retStr="";
	  var startIndex=0;
	  var index=str.indexOf(rgExp,startIndex);
	  while(index!=-1){
	  	str=str.substr(0,startIndex)+str.substr(startIndex,index-startIndex)+replaceText+str.substr(index+l1);
	  	startIndex=index+l2;
	  	index=str.indexOf(rgExp,startIndex);
	  }
    return str;
}
String.prototype.lengthEx=function(){
	return this.replace(/[^\x00-\xff]/g,"xx").length;
}

function checkIsNum(val){
  return !isNaN(val);
}




function getAncestorByTagName(el, pTagName) {
	if (el == null) return null;
	else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase())
		return el;
	else
		return getAncestorByTagName(el.parentNode, pTagName);
}

function  getCurDate(){
	dayObj=new Date();

	if(dayObj.getYear()<99)year2000=2000+dayObj.getYear();
	else year2000=dayObj.getYear();
	monthStr=dayObj.getMonth()+1;
	dayStr=dayObj.getDate();
	return year2000+"-"+monthStr+"-"+dayStr;

}

function compareDate(DateOne,DateTwo)
{

var OneMonth = DateOne.substring(5,DateOne.lastIndexOf ("-"));
var OneDay = DateOne.substring(DateOne.length,DateOne.lastIndexOf ("-")+1);
var OneYear = DateOne.substring(0,DateOne.indexOf ("-"));

var TwoMonth = DateTwo.substring(5,DateTwo.lastIndexOf ("-"));
var TwoDay = DateTwo.substring(DateTwo.length,DateTwo.lastIndexOf ("-")+1);
var TwoYear = DateTwo.substring(0,DateTwo.indexOf ("-"));

if (Date.parse(OneMonth+"/"+OneDay+"/"+OneYear) >
Date.parse(TwoMonth+"/"+TwoDay+"/"+TwoYear))
{
return true;
}
else
{
return false;
}

}

function fucCheckTEL(TEL)
{
	var i,j,strTemp;
	strTemp="0123456789-()#*";
	for (i=0;i<TEL.length;i++)
	{
		j=strTemp.indexOf(TEL.charAt(i));
		if (j==-1)
		{
			return 0;
		}
	}
	return 1;
}

//fo?a¨ºy¡Á¨¦?a??0:¡À¨ª¨º???¨°a¡ä??¨¦?¨´¦Ì?id¦Ì?field¦Ì?id?¦Ì
//            1:¡À¨ª¨º???¨°a¡ä??¨¦?¨´¦Ì?certificate_code¦Ì?id?¦Ì
//            2:¡À¨ª¨º???¨°a¡ä??¨¦?¨´¦Ì?name¦Ì?id?¦Ì
//            3:¡À¨ª¨º???¨°a¡ä??¨¦?¨´¦Ì?ename¦Ì?id?¦Ì
function selectFLoHQ(fo){
	f="dialogHeight: 520px; dialogWidth: 700px;  edge: Raised; center: Yes; help: No; resizable: No; status: No;";
	if(fo.length==undefined){
		alert("selectFLoHQ¡¤?¡¤¡§¦Ì?2?¨ºy¡À?D??a¨ºy¡Á¨¦,??o¨ª1¨¹¨¤¨ª?¡À¨¢a?¦Ì");
	}
	ret=openModalWindow("/permit/eo/fLoHQAction.do?method=selectFLoHQ",'????¡Á¡è???¡ä¨°¦Ì?¨²11',f); 
	if(ret==null) return;
        with(document.forms(0)){
          for(var i=0;i<ret.length;i++){
          try{
          if(fo[i]!=undefined && fo[i]!=null && fo[i]!="null" ){
          if(typeof(fo[i])=="string"){
            if(elements(fo[i]).length>1) alert("??3??a"+fo[i]+"2??1¨°???");
            elements(fo[i]).value=ret[i];
          }else{
            fo[i].value=ret[i];
          }

          }
          }catch(e){}
        }
  }
}
function selectDeputy(fo){
	f="dialogHeight: 520px; dialogWidth: 700px;  edge: Raised; center: Yes; help: No; resizable: No; status: No;";
	if(fo.length==undefined){
		alert("selectFLoDeputy¡¤?¡¤¡§¦Ì?2?¨ºy¡À?D??a¨ºy¡Á¨¦,??o¨ª1¨¹¨¤¨ª?¡À¨¢a?¦Ì");
	}
	var str="";
	if(fo[0]!=null&fo[0].value!=null)
	{
                 str = "&lo_id="+fo[0].value;  
  	}
	
	ret=openModalWindow("/permit/eo/fLoHQAction.do?method=selectFLoDeputy"+str,'????¡Á¡è???¡ä¨°¦Ì?¨²11',f);  
	if(ret==null) return;
        with(document.forms(0)){
          for(var i=0;i<ret.length;i++){
          try{
          if(fo[i]!=undefined && fo[i]!=null && fo[i]!="null" ){
          if(typeof(fo[i])=="string"){
            if(elements(fo[i]).length>1) alert("??3??a"+fo[i]+"2??1¨°???");
            elements(fo[i]).value=ret[i];
          }else{
            fo[i].value=ret[i];
          }

          }
          }catch(e){}
        }
  }
}
//fo?a¨ºy¡Á¨¦?a?? 0:¡À¨ª¨º???¨°a¡ä??¨¦¨º|¦Ì?id¦Ì??¦Ì
//            1:¡À¨ª¨º???¨°a¡ä??¨¦¨º|¦Ì?certificate_code?¦Ì
//            2:¡À¨ª¨º???¨°a¡ä??¨¦¨º|¦Ì?name?¦Ì
//            3:¡À¨ª¨º???¨°a¡ä??¨¦¨º|¦Ì?iscopartner?¦Ì 
//            4:¡À¨ª¨º??¨¦?¨´¦Ì?id?¦Ì
//            5:¡À¨ª¨º??¨¦?¨´¦Ì?name?¦Ì 
 function selectEmployee(fo){
	f="dialogHeight: 500px; dialogWidth: 700px;  edge: Raised; center: Yes; help: No; resizable: No; status: No;";
	if(fo.length==undefined){
		alert("selectFlo¡¤?¡¤¡§¦Ì?2?¨ºy¡À?D??a¨ºy¡Á¨¦,??o¨ª1¨¹¨¤¨ª?¡À¨¢a?¦Ì");
	}
	var str = "";
	if(fo[4]!=null&&fo[4].value!=null){
	    str += "&lo_id="+fo[3].value;
	}
	ret=openModalWindow("/permit/eo/employeeAction.do?method=selectEmployee",'????¡Á¡è???¡ä¨°¦Ì?¨²11',f);
	if(ret==null) return;
        with(document.forms(0)){
          //for(var i=0;i<ret.length;i++){
          for(var i=0;i<4;i++){
          try{
          if(fo[i]!=undefined && fo[i]!=null && fo[i]!="null" ){
          if(typeof(fo[i])=="string"){
            if(elements(fo[i]).length>1) alert("??3??a"+fo[i]+"2??1¨°???");
            elements(fo[i]).value=ret[i];
          }else{
            fo[i].value=ret[i];
          }

          }
          }catch(e){}
        }
  }
}
// lo.js
//fo?a¨ºy¡Á¨¦?a?? 0:¡À¨ª¨º???¨°a¡ä??¨¦¨º|¦Ì?id¦Ì??¦Ì
//            1:¡À¨ª¨º???¨°a¡ä??¨¦¨º|¦Ì?certificate_code?¦Ì
//            2:¡À¨ª¨º???¨°a¡ä??¨¦¨º|¦Ì?name?¦Ì
//            3:¡À¨ª¨º???¨°a¡ä??¨¦¨º|¦Ì?iscopartner?¦Ì 
//            4:¡À¨ª¨º??¨¦?¨´¦Ì?id?¦Ì
//            5:¡À¨ª¨º??¨¦?¨´¦Ì?name?¦Ì 
 function selectMultiLawyer(fo){
	f="dialogHeight: 500px; dialogWidth: 700px;  edge: Raised; center: Yes; help: No; resizable: No; status: No;";
	if(fo.length==undefined){
		alert("selectFlo¡¤?¡¤¡§¦Ì?2?¨ºy¡À?D??a¨ºy¡Á¨¦,??o¨ª1¨¹¨¤¨ª?¡À¨¢a?¦Ì");
	}
	var str = "";
	
	ret=openModalWindow("/permit/eo/lawyerAction.do?method=selectMultiLawyer"+str,'????¡Á¡è???¡ä¨°¦Ì?¨²11',f);
	var tempids;
	var tempnames;

	if(ret==null) return;
        with(document.forms(0)){
	    
          for(var i=0;i<ret.length;i++){
		  var temp=ret[i].split(",");
		  if(i==0){
		  tempids=temp[0];
		  tempnames=temp[1];
		  }else{
		  tempids+=","+temp[0];
		  tempnames+=","+temp[1];
		   }   
          }
		  elements("lawyers").value=tempnames;
		  elements("lawyer_ids").value=tempids;
    }
    
}

function go_msg(){   
    var f;
    if (window.screen.availWidth<=800){
         f="dialogHeight: 600px; dialogWidth: 800px;  edge: Raised; center: Yes; help: No; resizable: No; status: No;";
    }else{
	 f="dialogHeight: 738px; dialogWidth: 1024px;  edge: Raised; center: Yes; help: No; resizable: No; status: No;";
	 }
     var theUrl="/communion/instantMsgAction.do?method=read&msg_id="+mainForm.user_id.value+"&user_name="+mainForm.user_name.value;
     window.open(theUrl,"","toolbar=no,location=no,scrollbars=no,menubar=no,width=800,height=600");
} 