String.prototype.trim = function() {  
  var m = this.match(/^\s*(\S+(\s+\S+)*)\s*$/);  
  return (m == null) ? "" : m[1];  
} 

String.prototype.isMobile = function() {  
  return (/^(?:13\d|15[0123456789])-?\d{5}(\d{3}|\*{3})$/.test(this.trim()));  
} 

function isNum(value){
	var numtype="0123456789";
	for(i=0;i<value.length;i++){
		if(numtype.indexOf(value.substring(i,i+1))<0)
			return false; 
	}
	return true;
} 

function frameFitSelfHeightOld(frameId){
	myFrameId=frameId;
	var frameHeight=document.getElementById(frameId).contentWindow.document.body.scrollHeight;
	if(frameHeight==0){
		setTimeout('frameFitSelfHeight(myFrameId)',100);
	}else{
		document.getElementById(frameId).height = frameHeight;
}
}

function frameFitSelfHeight(frameId,countNum){
	myFrameId=frameId;
	myCountNum=countNum;
	
	if(myCountNum==null || myCountNum==undefined || myCountNum<0){
		myCountNum=0;
	}
	
	myCountNum++;
	
	if(myCountNum<=20){
		document.getElementById(myFrameId).height = document.getElementById(myFrameId).contentWindow.document.body.scrollHeight;
		setTimeout('frameFitSelfHeight(myFrameId,myCountNum)',500);
	}
}

//function parentframeFitSelfHeight(frameId){
//	myFrameId=frameId;
//	var frameHeight=parent.document.getElementById(frameId).contentWindow.document.body.scrollHeight;
//	if(frameHeight==0){
//		setTimeout('parentframeFitSelfHeight(myFrameId)',100);
//	}else{
//		parent.document.getElementById(frameId).height = frameHeight;
//	}
//}

function parentframeFitSelfHeight(frameId,countNum){
	myFrameId=frameId;
	myCountNum=countNum;
	
	if(myCountNum==null || myCountNum==undefined || myCountNum<0){
		myCountNum=0;
	}
	
	myCountNum++;
	
	if(myCountNum<=20){
		parent.document.getElementById(myFrameId).height = parent.document.getElementById(myFrameId).contentWindow.document.body.scrollHeight;
		setTimeout('parentframeFitSelfHeight(myFrameId,myCountNum)',500);
	}
}



/**去掉空格函数****/
function trim(s) {
  var count = s.length;
  var st    = 0;       // start
  var end   = count-1; // end

  if (s == "") return s;
  while (st < count) {
    if (s.charAt(st) == " ")
      st ++;
    else
      break;
  }
  while (end > st) {
    if (s.charAt(end) == " ")
      end --;
    else
      break;
  }
  return s.substring(st,end + 1);
}
/*******身份证号码校验函数*****************/
function isSFZ(str){ 
		if(""==str){ 
		return false; 
		} 
		if(str.length!=15&&str.length!=18){//身份证长度不正确 
		return false; 
		} 
		if(str.length==15){ 
		if(!isNumber(str)){ 
		return false; 
		} 
		}else{ 
		str1 = str.substring(0,17); 
		str2 = str.substring(17,18); 
		alpha = "X0123456789"; 
		if(!isNumber(str1)||alpha.indexOf(str2)==-1){ 
		return false; 
		} 
		} 
		return true; 
		} 
function isNumber(str){ 
		if(""==str){ 
		return false; 
		} 
		var reg = /\D/; 
		return str.match(reg)==null; 
		} 