--- phone.cs.inc	2009-08-26 18:06:12.000000000 +0200
+++ phone.cs.new.inc	2009-09-01 21:43:10.000000000 +0200
@@ -37,22 +37,19 @@ function valid_cs_phone_number($phonenum
  * @param $phonenumber must be a valid nine-digit number (with optional international prefix)
  * 
  */
-function format_cs_phone_number($phonenumber) {
+function format_cs_phone_number($phonenumber, $field) {
 
   // define regular expression   
-  $regex = "/^((\+|00)420)? ?(\d{3}) ?(\d{3}) ?(\d{3})$/";
+  $regex = "/^((?:\+|00)420)? ?(\d{3}) ?(\d{3}) ?(\d{3})$/";
 
   // get digits of phone number
   preg_match($regex, $phonenumber, $matches);
   
   if ($field['phone_country_code']) {
-        if ($matches[1] != "+420") {
-    	$phonenumber = "+420" . " " . $matches[2] .' '. $matches[] .' '. $matches[4]; 
-        }
-   }   
-  else { 
+    $phonenumber = '+420 '. $matches[2] .' '. $matches[3] .' '. $matches[4]; 
+  } else { 
   	$phonenumber = $matches[2] .' '. $matches[3] .' '. $matches[4];
   }
  
   return $phonenumber;
-}
\ No newline at end of file
+}
