function format_PhoneNumber(ph,standard,parens,ext){
  y = ph;
  x = "";
  for(i=0;i<y.length;i++){
    if(!isNaN(y.substr(i,1)) && y.substr(i,1) != " "){
	   x = x + y.substr(i,1);
	}
  }
  nph = "";
 if(x.length !=0){
  if(x.length >= 3){
  	 if(parens == 1){
	     nph = "(" + x.substr(0,3) + ")";
	 }else{
	 	 nph = x.substr(0,3);
	 }	
	 if(x.length >=6){
	   if(standard == 1){
		   nph = nph + " " + x.substr(3,3);	   
	   }else{
		   nph = nph + "." + x.substr(3,3);	   
	   }
	   if(x.length >= 10){
	     if(standard == 1){
		     nph = nph + "-" + x.substr(6,4);		 
		 }else{
		     nph = nph + "." + x.substr(6,4);		 
		 }
		 if(x.length > 10 && ext == 1){
		   nph = nph + " ext:" + x.substr(10,x.length - 10);
		 }
	   }else{
	     if(standard == 1){
		     nph = nph + "-" + x.substr(6,x.length -7);		 
		 }else{
		     nph = nph + "." + x.substr(6,x.length -7);		 
		 }
	   }
	 }else{
		if(standard == 1){
	   		 nph = nph + " " + x.substr(3,x.length - 3);		 
		 }else{
	   		 nph = nph + "." + x.substr(3,x.length - 3);		 
		 }
	 }
  }else{
	if(parens == 1){
     	nph = "(" + x.substr(0,x.length) + ")";
	}else{
     	nph = x.substr(0,x.length);
	}
  }
  }
  return  nph;
}
