diff -urp pollfield/pollfield.css pollfield_new/pollfield.css
--- pollfield/pollfield.css	2009-10-23 01:45:29.000000000 +0200
+++ pollfield_new/pollfield.css	2010-08-08 10:14:27.073314238 +0200
@@ -30,66 +30,66 @@
 .node-form .poll-form fieldset {
   display: block;
 }
-
 .pollfield-form{
 
 }
 .pollfield-form fieldset legend + .form-item{
-width:70%;
+  width: 70%;
 }
 .pollfield-form fieldset .form-item{
-float:left;
-width:25%;
+  float: left;
+  width: 25%;
 }
 /*style pollfield*/
 #pollfield{
-max-width:800px;
-display:table;
+  max-width: 800px;
+  display: table;
 }
 .pollfield-row{
-margin:10px 0;
-padding:0;
-overflow:visible;
-display:table-row;
-width:100%;
+  margin: 10px 0;
+  padding: 0;
+  overflow: visible;
+  display: table-row;
+  width: 100%;
 }
 .pollfield-row .text{
-display:table-cell;
-vertical-align:middle;
-padding:0.2em 3px 0.2em 0;
-min-width:4em;
-overflow:visible;
-text-align:right;
+  display: table-cell;
+  vertical-align: middle;
+  padding: 0.2em 3px 0.2em 0;
+  min-width: 4em;
+  overflow: visible;
+  text-align: right;
 }
-
 .barcell{
-display:table-cell;
-width:240px;
-vertical-align:middle;
+  display: table-cell;
+  width: 240px;
+  vertical-align: middle;
 }
 /*.pollfield-bar-holder{
-position:relative;
-background:olive;
-width:100%;
-height:100%;
+  position: relative;
+  background: olive;
+  width: 100%;
+  height: 100%;
 }*/
 .barcell .bar{
-height:1em;
-border:#F0F0F0 solid 1px;
-background:#FFFFFF url(../../../../themes/garland/images/bg-bar-white.png) repeat-x scroll 0 0;
-width:240px;
+  height: 1em;
+  border: #F0F0F0 solid 1px;
+  background: #FFFFFF url(../../../../themes/garland/images/bg-bar-white.png) repeat-x scroll 0 0;
+  width: 240px;
 }
 .barcell .bar .pollfield-foreground{
-background:#71A7CC url(../../../../themes/garland/images/bg-bar.png) repeat-x scroll 0 100%;
-height:1em;
+  background: #71A7CC url(../../../../themes/garland/images/bg-bar.png) repeat-x scroll 0 100%;
+  height: 1em;
 }
 .pollfield-percent{
-display:table-cell;
-vertical-align:middle;
-padding:0.2em;
-min-width:20em;
-overflow:visible;
+  display: table-cell;
+  vertical-align: middle;
+  padding: 0.2em;
+  min-width: 20em;
+  overflow: visible;
 }
 /* this class is used to show what is user choice in the poll*/
-.pollfield-chosen{font-weight:bold;font-style:italic;}
-
+.pollfield-chosen{
+  font-weight: bold;
+  font-style: italic;
+}
diff -urp pollfield/pollfield.module pollfield_new/pollfield.module
--- pollfield/pollfield.module	2010-06-26 16:05:06.000000000 +0200
+++ pollfield_new/pollfield.module	2010-08-08 10:18:58.848376925 +0200
@@ -1,11 +1,13 @@
 <?php
 // $Id: pollfield.module,v 1.2.4.11.2.68 2010/06/26 14:05:06 marioprkos Exp $
 
+
 /**
-* views api init
-*/
+ * views api init
+ */
 function pollfield_views_api() {
-  return array('api' => 2.0,);
+  return array('api' => 2.0,
+  );
 }
 
 /**
@@ -31,9 +33,9 @@ function pollfield_perm() {
   //get table
   $fields = content_fields();
   foreach ($fields as $i => $key) {
-    if ($fields[$i]['module']=='pollfield') {
-      $permission[]='view pollfield results '. $i;
-			$permission[]='admin pollfield '. $i;
+    if ($fields[$i]['module'] == 'pollfield') {
+      $permission[] = 'view pollfield results '. $i;
+      $permission[] = 'admin pollfield '. $i;
     }
   }
 
@@ -57,8 +59,8 @@ function pollfield_init() {
 function pollfield_help($path, $arg) {
   switch ($path) {
     case 'admin/help#pollfield':
-      $output = '<p>'. t('The Pollfield module adds a poll widget that enables you to create a CCK field designed to hold a simple poll. This poll is a simple multiple choice questionnaire which displays the cumulative results of the answers to the poll. ') .'</p>';
-      $output .= '<p>'. t('The field created this way can be added to any content type enabling users to have simple polls inside node types other than Poll. It is possible to add more than one Pollfield in the same content type, it means you can have more than one poll in one node. ') .'</p>';
+      $output = '<p>'. t('The Pollfield module adds a poll widget that enables you to create a CCK field designed to hold a simple poll. This poll is a simple multiple choice questionnaire which displays the cumulative results of the answers to the poll.') .'</p>';
+      $output .= '<p>'. t('The field created this way can be added to any content type enabling users to have simple polls inside node types other than Poll. It is possible to add more than one Pollfield in the same content type, it means you can have more than one poll in one node.') .'</p>';
       $output .= '<p>'. t('Add the field to a content type of your choice. When creating new content of that content type Poll settings option will be available as one of the fieldsets. Create a question, then enter the responses and the starting vote counts. You can also choose the time period over which the vote will run.') .'</p>';
       return $output;
   }
@@ -93,7 +95,6 @@ function pollfield_theme() {
     'user_vote' => array(
       'arguments' => array('node', 'comment'),
     ),
-		
   );
 }
 
@@ -101,37 +102,39 @@ function pollfield_theme() {
  * What you see in the edit node
  *
  * @param unknown_type $element
+ *
  * @return unknown
  */
 function theme_pollfield($element) {
- 
- $element['#attributes']['class'] .= 'pollfield-form';
- $fieldset = array(
+
+  $element['#attributes']['class'] .= 'pollfield-form';
+  $fieldset = array(
     '#type' => 'fieldset',
-    '#title' => "Pollfield ",//.$element['#title'],
+    //.$element['#title'],
+    '#title' => "Pollfield ",
     '#collapsible' => isset($element['#collapsible']) ? $element['#collapsible'] : TRUE,
-    '#collapsed' =>  isset($element['#collapsed']) ? $element['#collapsed'] : TRUE,
+    '#collapsed' => isset($element['#collapsed']) ? $element['#collapsed'] : TRUE,
     '#attributes' => $element['#attributes'],
     '#children' => $element['#children'],
   );
-  
-  return theme('fieldset', $fieldset);
 
+  return theme('fieldset', $fieldset);
 }
 
 /**
  * what you see in the node view
  *
  * @param unknown_type $element
+ *
  * @return unknown
  */
 function theme_pollfield_formatter_default($element) {
   global $user;
-  $items      = $element['#item'];
-  $node       = $element['#node'];
-  $type = $element['#type_name'];
-  $field = $element['#field_name'];
-  $field_name_delta=$element['#item']['#delta'];
+  $items            = $element['#item'];
+  $node             = $element['#node'];
+  $type             = $element['#type_name'];
+  $field            = $element['#field_name'];
+  $field_name_delta = $element['#item']['#delta'];
   //adding up the results
   // kjh: default to showing form as FALSE and enable it when we have an
   // at least one choice configured
@@ -140,97 +143,99 @@ function theme_pollfield_formatter_defau
     $choices = $items['group'];
     $poll_features = $items['poll_features'];
   }
-  else{
+  else {
     $choices = unserialize($items['choice']);
     $poll_features = unserialize($items['poll_features']);
   }
 
   //is user voted
-  $field_table=$node->type;$field_name=$field;
-  $is_vote = pollfield_user_voted($node, $field_table, $field_name, $field_name_delta);
-  $user_votes = pollfield_user_votes($node, $field_table, $field_name, $field_name_delta);
-  $is_results_allow=$poll_features['ResultsAllow'];
-	//*********    aggragate translation votes ****************
-	$tnid=db_result(db_query("SELECT tnid FROM {node} WHERE nid = %d",$node->nid));
-	$t_nodes_results=db_query("SELECT nid FROM {node} WHERE tnid = %d",$tnid);
- 
+  $field_table      = $node->type;
+  $field_name       = $field;
+  $is_vote          = pollfield_user_voted($node, $field_table, $field_name, $field_name_delta);
+  $user_votes       = pollfield_user_votes($node, $field_table, $field_name, $field_name_delta);
+  $is_results_allow = $poll_features['ResultsAllow'];
+  //*********    aggragate translation votes ****************
+  $tnid = db_result(db_query("SELECT tnid FROM {node} WHERE nid = %d", $node->nid));
+  $t_nodes_results = db_query("SELECT nid FROM {node} WHERE tnid = %d", $tnid);
+
   while ($t_nodes = db_fetch_object($t_nodes_results)) {
-	 
-		if ($node->nid<>$t_nodes->nid){
-			$t_nodes_nid[]=$t_nodes->nid;
-			//find start value choices
-			//get table name
-			$fields = content_fields();
-			$db_info = content_database_info($fields[$field_name]);
-			$table_content = $db_info['table'];
-			$column_choice = $field_name ."_choice";
-			$column_question = $field_name ."_question";
-			$column = 'delta';
-			$is_delta_exist = db_column_exists($table_content, $column);
-			if ($is_delta_exist) {
-				//get choices
-				$choices_start_unser = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d AND delta=%d", $column_choice, $table_content,$t_nodes->nid, $field_name_delta));
-
-			}
-			else {
-				//get choices
-				$choices_start_unser = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d", $column_choice, $table_content, $t_nodes->nid));
-			}		 
-			$choices_start=unserialize($choices_start_unser);
-			if (is_array($choices_start)){
-			  foreach($choices_start as $value){
-				  $count_translate_votes[]=$value['votes'];
-			  }
-			}
-		}		
-
-	}
-	
-	
-	//************* end of aggregate translated votes ********************
 
+    if ($node->nid <> $t_nodes->nid) {
+      $t_nodes_nid[] = $t_nodes->nid;
+      //find start value choices
+      //get table name
+      $fields          = content_fields();
+      $db_info         = content_database_info($fields[$field_name]);
+      $table_content   = $db_info['table'];
+      $column_choice   = $field_name ."_choice";
+      $column_question = $field_name ."_question";
+      $column          = 'delta';
+      $is_delta_exist  = db_column_exists($table_content, $column);
+      if ($is_delta_exist) {
+        //get choices
+        $choices_start_unser = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d AND delta=%d", $column_choice, $table_content, $t_nodes->nid, $field_name_delta));
+      }
+      else {
+        //get choices
+        $choices_start_unser = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d", $column_choice, $table_content, $t_nodes->nid));
+      }
+      $choices_start = unserialize($choices_start_unser);
+      if (is_array($choices_start)) {
+        foreach ($choices_start as $value) {
+          $count_translate_votes[] = $value['votes'];
+        }
+      }
+    }
+  }
+
+
+  //************* end of aggregate translated votes ********************
 
-  $votes=array();$choices_array=array();
+
+  $votes = array();
+  $choices_array = array();
   if (!empty($choices)) {
     foreach ($choices as $delta => $choice) {
 
       if (!empty($choice['choice'])) {
-        $show_form = TRUE;
+        $show_form       = TRUE;
         $choices_array[] = check_plain($choice['choice']);
-				$count_node = db_result(db_query("SELECT count(*) FROM {pollfield_votes} WHERE nid = %d AND delta=%d
-		          AND field_table='%s' AND field_name='%s' AND field_name_delta=%d",$node->nid, $delta, $type, $field, $field_name_delta));		
-				$count_translate=0;
-			  foreach($t_nodes_nid as $tnode){
-					
-		      $count_temp = db_result(db_query("SELECT count(*) FROM {pollfield_votes} WHERE nid= %d AND delta=%d
+        $count_node      = db_result(db_query("SELECT count(*) FROM {pollfield_votes} WHERE nid = %d AND delta=%d
+		          AND field_table='%s' AND field_name='%s' AND field_name_delta=%d", $node->nid, $delta, $type, $field, $field_name_delta));
+        $count_translate = 0;
+        foreach ($t_nodes_nid as $tnode) {
+
+          $count_temp = db_result(db_query("SELECT count(*) FROM {pollfield_votes} WHERE nid= %d AND delta=%d
 		          AND field_table='%s' AND field_name='%s' AND field_name_delta=%d",
-		          $tnode,$node->nid, $delta, $type, $field, $field_name_delta));
-					$count_translate=$count_translate+$count_temp;				
-				}
-				$count=$count_node+$count_translate;
-        $votes[] = $count+$choice['votes']+$count_translate_votes[$delta];
-        $sum = $sum+$count+$choice['votes']+$count_translate_votes[$delta];//countig all votes
+              $tnode, $node->nid, $delta, $type, $field, $field_name_delta
+            ));
+          $count_translate = $count_translate + $count_temp;
+        }
+        $count = $count_node + $count_translate;
+        $votes[] = $count + $choice['votes'] + $count_translate_votes[$delta];
+        // countig all votes
+        $sum = $sum + $count + $choice['votes'] + $count_translate_votes[$delta];
       }
     }
   }
-	
+
   //geting results
-  $i=0;
-  $poll_result='<div id="pollfield">';
+  $i = 0;
+  $poll_result = '<div id="pollfield">';
 
-  while (!empty($choices_array[$i]) && $sum>0) {
-    $percent = floatval(($votes[$i]*100.0)/$sum);
+  while (!empty($choices_array[$i]) && $sum > 0) {
+    $percent = floatval(($votes[$i] * 100.0) / $sum);
     $percent = round($percent, 1);
     //$votes[$i]=$percent;
     //$percent_string = $percent .'% ('.format_plural($votes[$i],'1 vote','@count votes').')';
-		$percent_string = $percent .'% ('.format_plural($votes[$i],'1 vote','@count votes').')';
-		
+    $percent_string = $percent .'% ('. format_plural($votes[$i], '1 vote', '@count votes') .')';
+
     //check user voted
     $is_this_user_vote = FALSE;
     if (is_array($user_votes)) {
       //get if user voted on this choice
       foreach ($user_votes as $value) {
-        if ($value==$i) {
+        if ($value == $i) {
           $is_this_user_vote = TRUE;
         }
       }
@@ -238,54 +243,52 @@ function theme_pollfield_formatter_defau
     //marked chosen answer
     if ($is_this_user_vote) {
       $poll_result .= "<div class='pollfield-row pollfield-chosen'><div class='text'>". $choices_array[$i] ."</div><div class='barcell'><div
-      class='bar'><div class='pollfield-foreground' style='width: ". $percent ."%;'></div></div></div><div class='pollfield-percent'>".
-      $percent_string ."</div></div>";
+      class='bar'><div class='pollfield-foreground' style='width: ". $percent ."%;'></div></div></div><div class='pollfield-percent'>". $percent_string ."</div></div>";
     }
     else {
       $poll_result .= "<div class='pollfield-row'><div class='text'>". $choices_array[$i] ."</div><div class='barcell'>
-      <div class='bar'><div class='pollfield-foreground' style='width: ". $percent ."%;'></div></div></div><div class='pollfield-percent'>".
-      $percent_string ."</div></div>";
-
+      <div class='bar'><div class='pollfield-foreground' style='width: ". $percent ."%;'></div></div></div><div class='pollfield-percent'>". $percent_string ."</div></div>";
     }
     $i++;
   }
   $poll_result .= "</div>";
 
-  
+
   if ($show_form) {
-    
+
     $form = pollfield_build_voting_form($element);
-    $out = '<div id="pollfield-'.$node->nid.'-'.$field_name_delta.'" class="pollfield-form">';
+    $out = '<div id="pollfield-'. $node->nid .'-'. $field_name_delta .'" class="pollfield-form">';
 
-    if ($element['#item']['question']!="' '") {
+    if ($element['#item']['question'] != "' '") {
       $out .= '<div class="pollfield-title">'. check_plain($element['#item']['question']) .'</div>';
     }
 
     $out .= $form;
-    $permission='view pollfield results '. $field_name;
+    $permission = 'view pollfield results '. $field_name;
     if (user_access($permission)) {
-      if ( $is_vote || $is_results_allow) {
+      if ($is_vote || $is_results_allow) {
         $out .= $poll_result;
       }
     }
     $out .= '</div>';
     return $out;
   }
-
 }
+
 /**
  * what you see in the node view
  *
  * @param unknown_type $element
+ *
  * @return unknown
  */
 function theme_pollfield_formatter_block_default($element) {
   global $user;
-  $items      = $element['#item'];
-  $node       = $element['#node'];
-  $type = $element['#type_name'];
-  $field = $element['#field_name'];
-  $field_name_delta=$element['#item']['#delta'];
+  $items            = $element['#item'];
+  $node             = $element['#node'];
+  $type             = $element['#type_name'];
+  $field            = $element['#field_name'];
+  $field_name_delta = $element['#item']['#delta'];
   //adding up the results
   // kjh: default to showing form as FALSE and enable it when we have an
   // at least one choice configured
@@ -294,97 +297,99 @@ function theme_pollfield_formatter_block
     $choices = $items['group'];
     $poll_features = $items['poll_features'];
   }
-  else{
+  else {
     $choices = unserialize($items['choice']);
     $poll_features = unserialize($items['poll_features']);
   }
 
   //is user voted
-  $field_table=$node->type;$field_name=$field;
-  $is_vote = pollfield_user_voted($node, $field_table, $field_name, $field_name_delta);
-  $user_votes = pollfield_user_votes($node, $field_table, $field_name, $field_name_delta);
-  $is_results_allow=$poll_features['ResultsAllow'];
-	//*********    aggragate translation votes ****************
-	$tnid=db_result(db_query("SELECT tnid FROM {node} WHERE nid = %d",$node->nid));
-	$t_nodes_results=db_query("SELECT nid FROM {node} WHERE tnid = %d",$tnid);
- 
+  $field_table      = $node->type;
+  $field_name       = $field;
+  $is_vote          = pollfield_user_voted($node, $field_table, $field_name, $field_name_delta);
+  $user_votes       = pollfield_user_votes($node, $field_table, $field_name, $field_name_delta);
+  $is_results_allow = $poll_features['ResultsAllow'];
+  //*********    aggragate translation votes ****************
+  $tnid = db_result(db_query("SELECT tnid FROM {node} WHERE nid = %d", $node->nid));
+  $t_nodes_results = db_query("SELECT nid FROM {node} WHERE tnid = %d", $tnid);
+
   while ($t_nodes = db_fetch_object($t_nodes_results)) {
-	 
-		if ($node->nid<>$t_nodes->nid){
-			$t_nodes_nid[]=$t_nodes->nid;
-			//find start value choices
-			//get table name
-			$fields = content_fields();
-			$db_info = content_database_info($fields[$field_name]);
-			$table_content = $db_info['table'];
-			$column_choice = $field_name ."_choice";
-			$column_question = $field_name ."_question";
-			$column = 'delta';
-			$is_delta_exist = db_column_exists($table_content, $column);
-			if ($is_delta_exist) {
-				//get choices
-				$choices_start_unser = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d AND delta=%d", $column_choice, $table_content,$t_nodes->nid, $field_name_delta));
-
-			}
-			else {
-				//get choices
-				$choices_start_unser = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d", $column_choice, $table_content, $t_nodes->nid));
-			}		 
-			$choices_start=unserialize($choices_start_unser);
-			if (is_array($choices_start)){
-			  foreach($choices_start as $value){
-				  $count_translate_votes[]=$value['votes'];
-			  }
-			}
-		}		
-
-	}
-	
-	
-	//************* end of aggregate translated votes ********************
+
+    if ($node->nid <> $t_nodes->nid) {
+      $t_nodes_nid[] = $t_nodes->nid;
+      //find start value choices
+      //get table name
+      $fields          = content_fields();
+      $db_info         = content_database_info($fields[$field_name]);
+      $table_content   = $db_info['table'];
+      $column_choice   = $field_name ."_choice";
+      $column_question = $field_name ."_question";
+      $column          = 'delta';
+      $is_delta_exist  = db_column_exists($table_content, $column);
+      if ($is_delta_exist) {
+        //get choices
+        $choices_start_unser = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d AND delta=%d", $column_choice, $table_content, $t_nodes->nid, $field_name_delta));
+      }
+      else {
+        //get choices
+        $choices_start_unser = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d", $column_choice, $table_content, $t_nodes->nid));
+      }
+      $choices_start = unserialize($choices_start_unser);
+      if (is_array($choices_start)) {
+        foreach ($choices_start as $value) {
+          $count_translate_votes[] = $value['votes'];
+        }
+      }
+    }
+  }
+
+
+  //************* end of aggregate translated votes ********************
 
 
-  $votes=array();$choices_array=array();
+  $votes = array();
+  $choices_array = array();
   if (!empty($choices)) {
     foreach ($choices as $delta => $choice) {
 
       if (!empty($choice['choice'])) {
-        $show_form = TRUE;
+        $show_form       = TRUE;
         $choices_array[] = check_plain($choice['choice']);
-				$count_node = db_result(db_query("SELECT count(*) FROM {pollfield_votes} WHERE nid = %d AND delta=%d
-		          AND field_table='%s' AND field_name='%s' AND field_name_delta=%d",$node->nid, $delta, $type, $field, $field_name_delta));		
-				$count_translate=0;
-			  foreach($t_nodes_nid as $tnode){
-					
-		      $count_temp = db_result(db_query("SELECT count(*) FROM {pollfield_votes} WHERE nid= %d AND delta=%d
+        $count_node      = db_result(db_query("SELECT count(*) FROM {pollfield_votes} WHERE nid = %d AND delta=%d
+		          AND field_table='%s' AND field_name='%s' AND field_name_delta=%d", $node->nid, $delta, $type, $field, $field_name_delta));
+        $count_translate = 0;
+        foreach ($t_nodes_nid as $tnode) {
+
+          $count_temp = db_result(db_query("SELECT count(*) FROM {pollfield_votes} WHERE nid= %d AND delta=%d
 		          AND field_table='%s' AND field_name='%s' AND field_name_delta=%d",
-		          $tnode,$node->nid, $delta, $type, $field, $field_name_delta));
-					$count_translate=$count_translate+$count_temp;				
-				}
-				$count=$count_node+$count_translate;
-        $votes[] = $count+$choice['votes']+$count_translate_votes[$delta];
-        $sum = $sum+$count+$choice['votes']+$count_translate_votes[$delta];//countig all votes
+              $tnode, $node->nid, $delta, $type, $field, $field_name_delta
+            ));
+          $count_translate = $count_translate + $count_temp;
+        }
+        $count = $count_node + $count_translate;
+        $votes[] = $count + $choice['votes'] + $count_translate_votes[$delta];
+        // countig all votes
+        $sum = $sum + $count + $choice['votes'] + $count_translate_votes[$delta];
       }
     }
   }
-	
+
   //geting results
-  $i=0;
-  $poll_result='<div id="pollfield">';
+  $i = 0;
+  $poll_result = '<div id="pollfield">';
 
-  while (!empty($choices_array[$i]) && $sum>0) {
-    $percent = floatval(($votes[$i]*100.0)/$sum);
+  while (!empty($choices_array[$i]) && $sum > 0) {
+    $percent = floatval(($votes[$i] * 100.0) / $sum);
     $percent = round($percent, 1);
     //$votes[$i]=$percent;
     //$percent_string = $percent .'% ('.format_plural($votes[$i],'1 vote','@count votes').')';
-		$percent_string = $percent .'% ('.format_plural($votes[$i],'1 vote','@count votes').')';
-		
+    $percent_string = $percent .'% ('. format_plural($votes[$i], '1 vote', '@count votes') .')';
+
     //check user voted
     $is_this_user_vote = FALSE;
     if (is_array($user_votes)) {
       //get if user voted on this choice
       foreach ($user_votes as $value) {
-        if ($value==$i) {
+        if ($value == $i) {
           $is_this_user_vote = TRUE;
         }
       }
@@ -392,54 +397,51 @@ function theme_pollfield_formatter_block
     //marked chosen answer
     if ($is_this_user_vote) {
       $poll_result .= "<div class='pollfield-row pollfield-chosen'><div class='text'>". $choices_array[$i] ."</div><div class='barcell'><div
-      class='bar'><div class='pollfield-foreground' style='width: ". $percent ."%;'></div></div></div><div class='pollfield-percent'>".
-      $percent_string ."</div></div>";
+      class='bar'><div class='pollfield-foreground' style='width: ". $percent ."%;'></div></div></div><div class='pollfield-percent'>". $percent_string ."</div></div>";
     }
     else {
       $poll_result .= "<div class='pollfield-row'><div class='text'>". $choices_array[$i] ."</div><div class='barcell'>
-      <div class='bar'><div class='pollfield-foreground' style='width: ". $percent ."%;'></div></div></div><div class='pollfield-percent'>".
-      $percent_string ."</div></div>";
-
+      <div class='bar'><div class='pollfield-foreground' style='width: ". $percent ."%;'></div></div></div><div class='pollfield-percent'>". $percent_string ."</div></div>";
     }
     $i++;
   }
   $poll_result .= "</div>";
 
-  
+
   if ($show_form) {
-    
+
     $form = pollfield_build_voting_form($element);
-    $out = '<div id="pollfield-'.$node->nid.'-'.$field_name_delta.'" class="pollfield-form">';
+    $out = '<div id="pollfield-'. $node->nid .'-'. $field_name_delta .'" class="pollfield-form">';
 
-    if ($element['#item']['question']!="' '") {
+    if ($element['#item']['question'] != "' '") {
       $out .= '<div class="pollfield-title">'. check_plain($element['#item']['question']) .'</div>';
     }
-    else{
-      $node_title=db_result(db_query("SELECT title FROM {node} WHERE nid= %d",$node->nid));
-      $nid=$node->nid;
-      $node_link=l($node_title,"node/".$nid);
+    else {
+      $node_title = db_result(db_query("SELECT title FROM {node} WHERE nid= %d", $node->nid));
+      $nid        = $node->nid;
+      $node_link  = l($node_title, "node/". $nid);
       $out .= '<div class="pollfield-title">'. $node_link .'</div>';
     }
-    
+
     $out .= $form;
-    $permission='view pollfield results '. $field_name;
+    $permission = 'view pollfield results '. $field_name;
     if (user_access($permission)) {
-      if ( $is_vote || $is_results_allow) {
+      if ($is_vote || $is_results_allow) {
         $out .= $poll_result;
       }
     }
     $out .= '</div>';
     return $out;
   }
-
 }
+
 function theme_pollfield_formatter_results($element) {
   global $user;
-  $items      = $element['#item'];
-  $node       = $element['#node'];
-  $type = $element['#type_name'];
-  $field = $element['#field_name'];
-  $field_name_delta=$element['#item']['#delta'];
+  $items            = $element['#item'];
+  $node             = $element['#node'];
+  $type             = $element['#type_name'];
+  $field            = $element['#field_name'];
+  $field_name_delta = $element['#item']['#delta'];
   //adding up the results
   // kjh: default to showing form as FALSE and enable it when we have an
   // at least one choice configured
@@ -448,97 +450,99 @@ function theme_pollfield_formatter_resul
     $choices = $items['group'];
     $poll_features = $items['poll_features'];
   }
-  else{
+  else {
     $choices = unserialize($items['choice']);
     $poll_features = unserialize($items['poll_features']);
   }
 
   //is user voted
-  $field_table=$node->type;$field_name=$field;
-  $is_vote = pollfield_user_voted($node, $field_table, $field_name, $field_name_delta);
-  $user_votes = pollfield_user_votes($node, $field_table, $field_name, $field_name_delta);
-  $is_results_allow=$poll_features['ResultsAllow'];
-	//*********    aggragate translation votes ****************
-	$tnid=db_result(db_query("SELECT tnid FROM {node} WHERE nid = %d",$node->nid));
-	$t_nodes_results=db_query("SELECT nid FROM {node} WHERE tnid = %d",$tnid);
- 
+  $field_table      = $node->type;
+  $field_name       = $field;
+  $is_vote          = pollfield_user_voted($node, $field_table, $field_name, $field_name_delta);
+  $user_votes       = pollfield_user_votes($node, $field_table, $field_name, $field_name_delta);
+  $is_results_allow = $poll_features['ResultsAllow'];
+  //*********    aggragate translation votes ****************
+  $tnid = db_result(db_query("SELECT tnid FROM {node} WHERE nid = %d", $node->nid));
+  $t_nodes_results = db_query("SELECT nid FROM {node} WHERE tnid = %d", $tnid);
+
   while ($t_nodes = db_fetch_object($t_nodes_results)) {
-	 
-		if ($node->nid<>$t_nodes->nid){
-			$t_nodes_nid[]=$t_nodes->nid;
-			//find start value choices
-			//get table name
-			$fields = content_fields();
-			$db_info = content_database_info($fields[$field_name]);
-			$table_content = $db_info['table'];
-			$column_choice = $field_name ."_choice";
-			$column_question = $field_name ."_question";
-			$column = 'delta';
-			$is_delta_exist = db_column_exists($table_content, $column);
-			if ($is_delta_exist) {
-				//get choices
-				$choices_start_unser = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d AND delta=%d", $column_choice, $table_content,$t_nodes->nid, $field_name_delta));
-
-			}
-			else {
-				//get choices
-				$choices_start_unser = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d", $column_choice, $table_content, $t_nodes->nid));
-			}		 
-			$choices_start=unserialize($choices_start_unser);
-			if (is_array($choices_start)){
-			  foreach($choices_start as $value){
-				  $count_translate_votes[]=$value['votes'];
-			  }
-			}
-		}		
-
-	}
-	
-	
-	//************* end of aggregate translated votes ********************
 
+    if ($node->nid <> $t_nodes->nid) {
+      $t_nodes_nid[] = $t_nodes->nid;
+      //find start value choices
+      //get table name
+      $fields          = content_fields();
+      $db_info         = content_database_info($fields[$field_name]);
+      $table_content   = $db_info['table'];
+      $column_choice   = $field_name ."_choice";
+      $column_question = $field_name ."_question";
+      $column          = 'delta';
+      $is_delta_exist  = db_column_exists($table_content, $column);
+      if ($is_delta_exist) {
+        //get choices
+        $choices_start_unser = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d AND delta=%d", $column_choice, $table_content, $t_nodes->nid, $field_name_delta));
+      }
+      else {
+        //get choices
+        $choices_start_unser = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d", $column_choice, $table_content, $t_nodes->nid));
+      }
+      $choices_start = unserialize($choices_start_unser);
+      if (is_array($choices_start)) {
+        foreach ($choices_start as $value) {
+          $count_translate_votes[] = $value['votes'];
+        }
+      }
+    }
+  }
+
+
+  //************* end of aggregate translated votes ********************
 
-  $votes=array();$choices_array=array();
+
+  $votes = array();
+  $choices_array = array();
   if (!empty($choices)) {
     foreach ($choices as $delta => $choice) {
 
       if (!empty($choice['choice'])) {
-        $show_form = TRUE;
+        $show_form       = TRUE;
         $choices_array[] = check_plain($choice['choice']);
-				$count_node = db_result(db_query("SELECT count(*) FROM {pollfield_votes} WHERE nid = %d AND delta=%d
-		          AND field_table='%s' AND field_name='%s' AND field_name_delta=%d",$node->nid, $delta, $type, $field, $field_name_delta));		
-				$count_translate=0;
-			  foreach($t_nodes_nid as $tnode){
-					
-		      $count_temp = db_result(db_query("SELECT count(*) FROM {pollfield_votes} WHERE nid= %d AND delta=%d
+        $count_node      = db_result(db_query("SELECT count(*) FROM {pollfield_votes} WHERE nid = %d AND delta=%d
+		          AND field_table='%s' AND field_name='%s' AND field_name_delta=%d", $node->nid, $delta, $type, $field, $field_name_delta));
+        $count_translate = 0;
+        foreach ($t_nodes_nid as $tnode) {
+
+          $count_temp = db_result(db_query("SELECT count(*) FROM {pollfield_votes} WHERE nid= %d AND delta=%d
 		          AND field_table='%s' AND field_name='%s' AND field_name_delta=%d",
-		          $tnode,$node->nid, $delta, $type, $field, $field_name_delta));
-					$count_translate=$count_translate+$count_temp;				
-				}
-				$count=$count_node+$count_translate;
-        $votes[] = $count+$choice['votes']+$count_translate_votes[$delta];
-        $sum = $sum+$count+$choice['votes']+$count_translate_votes[$delta];//countig all votes
+              $tnode, $node->nid, $delta, $type, $field, $field_name_delta
+            ));
+          $count_translate = $count_translate + $count_temp;
+        }
+        $count = $count_node + $count_translate;
+        $votes[] = $count + $choice['votes'] + $count_translate_votes[$delta];
+        // countig all votes
+        $sum = $sum + $count + $choice['votes'] + $count_translate_votes[$delta];
       }
     }
   }
-	
+
   //geting results
-  $i=0;
-  $poll_result='<div id="pollfield">';
+  $i = 0;
+  $poll_result = '<div id="pollfield">';
 
-  while (!empty($choices_array[$i]) && $sum>0) {
-    $percent = floatval(($votes[$i]*100.0)/$sum);
+  while (!empty($choices_array[$i]) && $sum > 0) {
+    $percent = floatval(($votes[$i] * 100.0) / $sum);
     $percent = round($percent, 1);
     //$votes[$i]=$percent;
     //$percent_string = $percent .'% ('.format_plural($votes[$i],'1 vote','@count votes').')';
-		$percent_string = $percent .'% ('.format_plural($votes[$i],'1 vote','@count votes').')';
-		
+    $percent_string = $percent .'% ('. format_plural($votes[$i], '1 vote', '@count votes') .')';
+
     //check user voted
     $is_this_user_vote = FALSE;
     if (is_array($user_votes)) {
       //get if user voted on this choice
       foreach ($user_votes as $value) {
-        if ($value==$i) {
+        if ($value == $i) {
           $is_this_user_vote = TRUE;
         }
       }
@@ -546,48 +550,44 @@ function theme_pollfield_formatter_resul
     //marked chosen answer
     if ($is_this_user_vote) {
       $poll_result .= "<div class='pollfield-row pollfield-chosen'><div class='text'>". $choices_array[$i] ."</div><div class='barcell'><div
-      class='bar'><div class='pollfield-foreground' style='width: ". $percent ."%;'></div></div></div><div class='pollfield-percent'>".
-      $percent_string ."</div></div>";
+      class='bar'><div class='pollfield-foreground' style='width: ". $percent ."%;'></div></div></div><div class='pollfield-percent'>". $percent_string ."</div></div>";
     }
     else {
       $poll_result .= "<div class='pollfield-row'><div class='text'>". $choices_array[$i] ."</div><div class='barcell'>
-      <div class='bar'><div class='pollfield-foreground' style='width: ". $percent ."%;'></div></div></div><div class='pollfield-percent'>".
-      $percent_string ."</div></div>";
-
+      <div class='bar'><div class='pollfield-foreground' style='width: ". $percent ."%;'></div></div></div><div class='pollfield-percent'>". $percent_string ."</div></div>";
     }
     $i++;
   }
   $poll_result .= "</div>";
 
-  
+
   if ($show_form) {
-    
+
     $form = pollfield_build_voting_form($element);
-    $out = '<div id="pollfield-'.$node->nid.'-'.$field_name_delta.'" class="pollfield-form">';
+    $out = '<div id="pollfield-'. $node->nid .'-'. $field_name_delta .'" class="pollfield-form">';
 
-    if ($element['#item']['question']!="' '") {
+    if ($element['#item']['question'] != "' '") {
       $out .= '<div class="pollfield-title">'. check_plain($element['#item']['question']) .'</div>';
     }
 
     $out .= $form;
-    $permission='view pollfield results '. $field_name;
+    $permission = 'view pollfield results '. $field_name;
     if (user_access($permission)) {
-      if ( $is_vote || $is_results_allow) {
+      if ($is_vote || $is_results_allow) {
         $out .= $poll_result;
       }
     }
     $out .= '</div>';
     return $out;
   }
-
 }
 
 function theme_pollfield_formatter_choices($element) {
 
   global $user;
-  $items      = $element['#item'];
-  $node       = $element['#node'];
-  $type = $element['#type_name'];
+  $items = $element['#item'];
+  $node  = $element['#node'];
+  $type  = $element['#type_name'];
   $field = $element['#field_name'];
   //adding up the results
   // kjh: default to showing form as FALSE and enable it when we have an
@@ -597,22 +597,23 @@ function theme_pollfield_formatter_choic
     $choices = $items['group'];
     $poll_features = $items['poll_features'];
   }
-  else{
+  else {
     $choices = unserialize($items['choice']);
     $poll_features = unserialize($items['poll_features']);
   }
 
-  $votes=array();$choices_array=array();
+  $votes = array();
+  $choices_array = array();
   if (!empty($choices)) {
     foreach ($choices as $delta => $choice) {
       if (!empty($choice['choice'])) {
-        $show_form = TRUE;
+        $show_form       = TRUE;
         $choices_array[] = check_plain($choice['choice']);
-        $count = db_result(db_query("SELECT count(*) FROM {pollfield_votes} WHERE nid = %d AND delta=%d
+        $count           = db_result(db_query("SELECT count(*) FROM {pollfield_votes} WHERE nid = %d AND delta=%d
             AND field_table='%s' AND field_name='%s'", $node->nid, $delta, $type, $field));
-        $votes[]=$count+$choice['votes'];
-        $sum=$sum+$count+$choice['votes'];//countig all votes
-
+        $votes[] = $count + $choice['votes'];
+        // countig all votes
+        $sum = $sum + $count + $choice['votes'];
       }
     }
   }
@@ -621,11 +622,11 @@ function theme_pollfield_formatter_choic
   $i = 0;
   $poll_result = " ";
 
-  while (!empty($choices_array[$i]) && $sum>0) {
-    $percent = floatval(($votes[$i]*100.0)/$sum);
+  while (!empty($choices_array[$i]) && $sum > 0) {
+    $percent = floatval(($votes[$i] * 100.0) / $sum);
     $percent = round($percent, 1);
     //$votes[$i]=$percent;
-    $percent_string = $percent ."% (". format_plural($votes[$i],'1 vote','@count votes') .")";
+    $percent_string = $percent ."% (". format_plural($votes[$i], '1 vote', '@count votes') .")";
     $poll_result .= "<div class='pollfield-row'>". check_plain($choices_array[$i]) ."</div>";
     $i++;
   }
@@ -637,16 +638,14 @@ function theme_pollfield_formatter_choic
 
     return $out;
   }
-
-
 }
 
 function theme_pollfield_formatter_question($element) {
   // todo and other formattings
   global $user;
-  $items      = $element['#item'];
-  $node       = $element['#node'];
-  $type = $element['#type_name'];
+  $items = $element['#item'];
+  $node  = $element['#node'];
+  $type  = $element['#type_name'];
   $field = $element['#field_name'];
   //adding up the results
   // kjh: default to showing form as FALSE and enable it when we have an
@@ -656,22 +655,23 @@ function theme_pollfield_formatter_quest
     $choices = $items['group'];
     $poll_features = $items['poll_features'];
   }
-  else{
+  else {
     $choices = unserialize($items['choice']);
     $poll_features = unserialize($items['poll_features']);
   }
 
-  $votes=array();$choices_array=array();
+  $votes = array();
+  $choices_array = array();
   if (!empty($choices)) {
     foreach ($choices as $delta => $choice) {
       if (!empty($choice['choice'])) {
-        $show_form = TRUE;
+        $show_form       = TRUE;
         $choices_array[] = check_plain($choice['choice']);
-        $count = db_result(db_query("SELECT count(*) FROM {pollfield_votes} WHERE nid = %d AND delta=%d
+        $count           = db_result(db_query("SELECT count(*) FROM {pollfield_votes} WHERE nid = %d AND delta=%d
             AND field_table='%s' AND field_name='%s'", $node->nid, $delta, $type, $field));
-        $votes[]=$count+$choice['votes'];
-        $sum = $sum+$count+$choice['votes'];//countig all votes
-
+        $votes[] = $count + $choice['votes'];
+        // countig all votes
+        $sum = $sum + $count + $choice['votes'];
       }
     }
   }
@@ -681,23 +681,22 @@ function theme_pollfield_formatter_quest
   if ($show_form) {
     $out = '<div class="pollfield-questions">';
 
-    if ($element['#item']['question']!="' '") {
+    if ($element['#item']['question'] != "' '") {
       $out .= '<div class="pollfield-row">'. check_plain($element['#item']['question']) .'</div>';
     }
     $out .= '</div>';
 
     return $out;
   }
-
 }
 
 function theme_pollfield_formatter_runtime($element) {
-    // todo and other formattings
+  // todo and other formattings
 
   global $user;
-  $items      = $element['#item'];
-  $node       = $element['#node'];
-  $type = $element['#type_name'];
+  $items = $element['#item'];
+  $node  = $element['#node'];
+  $type  = $element['#type_name'];
   $field = $element['#field_name'];
   //adding up the results
   $show_form = FALSE;
@@ -705,22 +704,23 @@ function theme_pollfield_formatter_runti
     $choices = $items['group'];
     $poll_features = $items['poll_features'];
   }
-  else{
+  else {
     $choices = unserialize($items['choice']);
     $poll_features = unserialize($items['poll_features']);
   }
 
-  $votes=array();$choices_array=array();
+  $votes = array();
+  $choices_array = array();
   if (!empty($choices)) {
     foreach ($choices as $delta => $choice) {
       if (!empty($choice['choice'])) {
-        $show_form = TRUE;
+        $show_form       = TRUE;
         $choices_array[] = check_plain($choice['choice']);
-        $count = db_result(db_query("SELECT count(*) FROM {pollfield_votes} WHERE nid = %d AND delta=%d
+        $count           = db_result(db_query("SELECT count(*) FROM {pollfield_votes} WHERE nid = %d AND delta=%d
             AND field_table='%s' AND field_name='%s'", $node->nid, $delta, $type, $field));
-        $votes[]=$count+$choice['votes'];
-        $sum = $sum+$count+$choice['votes'];//countig all votes
-
+        $votes[] = $count + $choice['votes'];
+        // countig all votes
+        $sum = $sum + $count + $choice['votes'];
       }
     }
   }
@@ -728,16 +728,15 @@ function theme_pollfield_formatter_runti
   //geting results
 
   if ($show_form) {
-    if ($element['#item']['runtime']>0) {
+    if ($element['#item']['runtime'] > 0) {
       $runtime = t('!duration duration of poll in seconds', array('!duration' => $element['#item']['runtime']));
     }
-    else{
+    else {
       $runtime = t('Unlimited poll duration.');
     }
     $out = '<div class="pollfield-runtime">'. check_plain($runtime) .'</div>';
     return $out;
   }
-
 }
 
 
@@ -748,53 +747,58 @@ function theme_user_vote($node, $comment
   $poll_output = "<div id='pollfield' class='pollfield_results'>";
   foreach ($node as $key => $value) {
     //get field name
-    if (strncmp($key, 'field_', 6)==0) {
+    if (strncmp($key, 'field_', 6) == 0) {
       //get table name
-      $fields = content_fields();
-      $db_info = content_database_info($fields[$key]);
-      $table_content = $db_info['table'];
-      $column_choice = $key ."_choice";
+      $fields          = content_fields();
+      $db_info         = content_database_info($fields[$key]);
+      $table_content   = $db_info['table'];
+      $column_choice   = $key ."_choice";
       $column_question = $key ."_question";
-      $column = 'delta';
-      $is_delta_exist = db_column_exists($table_content, $column);
-      $poll_result = db_query("SELECT * FROM {%s} INNER JOIN `node` ON {%s}.nid = node.nid WHERE {%s}.nid = %d AND {%s}.vid = node.vid", 	
-															$table_content, $table_content, $table_content, $node->nid, $table_content);
+      $column          = 'delta';
+      $is_delta_exist  = db_column_exists($table_content, $column);
+      $poll_result     = db_query("SELECT * FROM {%s} INNER JOIN `node` ON {%s}.nid = node.nid WHERE {%s}.nid = %d AND {%s}.vid = node.vid",
+        $table_content, $table_content, $table_content, $node->nid, $table_content
+      );
 
       while ($pollfield = db_fetch_object($poll_result)) {
 
         if ($is_delta_exist) {
-          $field_name_delta=$pollfield->delta;
+          $field_name_delta = $pollfield->delta;
         }
         else {
-          $field_name_delta=0;
+          $field_name_delta = 0;
         }
         $choices = unserialize($pollfield->$column_choice);
         //is user vote
         $is_vote = 0;
         $is_vote = db_result(db_query("SELECT count(*) FROM {pollfield_votes} WHERE nid = %d AND field_name_delta=%d
               AND field_table='%s' AND field_name='%s' AND uid=%d",
-              $node->nid, $field_name_delta, $node->type, $key, $comment->uid));
+            $node->nid, $field_name_delta, $node->type, $key, $comment->uid
+          ));
 
         //get user vote
-				
+
         $user_choice_result = db_query("SELECT delta FROM {pollfield_votes} WHERE nid = %d AND field_name_delta=%d
               AND field_table='%s' AND field_name='%s' AND uid=%d",
-              $node->nid, $field_name_delta, $node->type, $key, $comment->uid);
-				while ($user_choice = db_fetch_object($user_choice_result)) {
-						
-	
-		      $user_choice_response=$choices[$user_choice->delta]['choice'];
-
-		      if ($is_vote>0) {
-		        if ($pollfield->$column_question=="' '") {
-		          $poll_output .= "<p>". $node->title .": ". check_plain($user_choice_response) ."</p>";
-		        }
-		        else{
-		          $poll_output .= "<p>". $pollfield->$column_question .": ". check_plain($user_choice_response) ."</p>";
-		        }
-		        $out = $poll_output;
-		      }//if
-				}//while
+          $node->nid, $field_name_delta, $node->type, $key, $comment->uid
+        );
+        while ($user_choice = db_fetch_object($user_choice_result)) {
+
+
+          $user_choice_response = $choices[$user_choice->delta]['choice'];
+
+          if ($is_vote > 0) {
+            if ($pollfield->$column_question == "' '") {
+              $poll_output .= "<p>". $node->title .": ". check_plain($user_choice_response) ."</p>";
+            }
+            else {
+              $poll_output .= "<p>". $pollfield->$column_question .": ". check_plain($user_choice_response) ."</p>";
+            }
+            $out = $poll_output;
+          }
+          //if
+        }
+        //while
       }
     }
   }
@@ -805,35 +809,34 @@ function theme_user_vote($node, $comment
 function pollfield_voting_form($element) {
   global $user;
 
-  $form = array();
-  $form_state = array();
-  $table = $element['#type_name'];
-  $field_name = $element['#field_name'];
+  $form             = array();
+  $form_state       = array();
+  $table            = $element['#type_name'];
+  $field_name       = $element['#field_name'];
   $field_name_delta = $element['#item']['#delta'];
-  $items = $element['#item'];
-  $node = $element['#node'];
-  $hostname = $_SERVER['REMOTE_ADDR'];
+  $items            = $element['#item'];
+  $node             = $element['#node'];
+  $hostname         = $_SERVER['REMOTE_ADDR'];
   if (is_array($element['#item']['poll_features'])) {
-    $poll_features=$element['#item']['poll_features'];
+    $poll_features = $element['#item']['poll_features'];
   }
-  else{
+  else {
     $poll_features = unserialize($element['#item']['poll_features']);
   }
 
-  $nid=$node->nid;
+  $nid = $node->nid;
 
   //get table
-  $fields = content_fields();
-  $db_info = content_database_info($fields[$field_name]);
-  $table_content = $db_info['table'];
-  $column = 'delta';
+  $fields         = content_fields();
+  $db_info        = content_database_info($fields[$field_name]);
+  $table_content  = $db_info['table'];
+  $column         = 'delta';
   $is_delta_exist = db_column_exists($table_content, $column);
 
   if ($is_delta_exist) {
     //get anonymous voting politics
     $field_anon = $field_name .'_anonymous';
     $anonymous = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d AND delta=%d", $field_anon, $table_content, $nid, $field_name_delta));
-
   }
   else {
     //get anonymous voting politics
@@ -841,48 +844,50 @@ function pollfield_voting_form($element)
     $anonymous = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d", $field_anon, $table_content, $nid));
   }
 
-    //check if user has voted
+  //check if user has voted
   $field_table = $table;
   $voted = pollfield_user_voted($node, $field_table, $field_name, $field_name_delta);
 
 
   if ($voted) {
     if ($user->uid) {
-      if ($poll_features['CancelVote_Allow']) {//allow cancel vote
-        $cancel=1;
+      // allow cancel vote
+      if ($poll_features['CancelVote_Allow']) {
+        $cancel = 1;
         $form['field_name_delta'] = array('#type' => 'hidden', '#value' => $field_name_delta);
         $form['field_name'] = array('#type' => 'hidden', '#value' => $field_name);
         $form['nid'] = array('#type' => 'hidden', '#value' => $node->nid);
-        $form['vote'] = array('#type' => 'submit', '#value' => t('Cancel Vote'),'#submit'=>array('pollfield_voting_function_form_submit'));
+        $form['vote'] = array('#type' => 'submit', '#value' => t('Cancel Vote'), '#submit' => array('pollfield_voting_function_form_submit'));
         $form['table'] = array('#type' => 'hidden', '#value' => $table);
         $form['cancel'] = array('#type' => 'hidden', '#value' => $cancel);
         $form['#type'] = 'form';
-       
       }
     }
-    else{
-      if ($anonymous=='anon_non')
+    else {
+      if ($anonymous == 'anon_non') {
         return $output;
+      }
       else {
-        if ($poll_features['CancelVote_Allow']) {//allow cancel vote
+        // allow cancel vote
+        if ($poll_features['CancelVote_Allow']) {
           $cancel = 1;
           $form['field_name_delta'] = array('#type' => 'hidden', '#value' => $field_name_delta);
           $form['field_name'] = array('#type' => 'hidden', '#value' => $field_name);
           $form['nid'] = array('#type' => 'hidden', '#value' => $node->nid);
-          $form['vote'] = array('#type' => 'submit', '#value' => t('Cancel Vote'),'#submit'=>array('pollfield_voting_function_form_submit'));
+          $form['vote'] = array('#type' => 'submit', '#value' => t('Cancel Vote'), '#submit' => array('pollfield_voting_function_form_submit'));
           $form['table'] = array('#type' => 'hidden', '#value' => $table);
           $form['cancel'] = array('#type' => 'hidden', '#value' => $cancel);
           $form['#type'] = 'form';
-         
         }
       }
     }
   }
   //if user not voted
   else {
-    if ($user->uid==0) {
-      if ($anonymous=='anon_non')
+    if ($user->uid == 0) {
+      if ($anonymous == 'anon_non') {
         return $output;
+      }
     }
 
     if ($items) {
@@ -890,76 +895,78 @@ function pollfield_voting_form($element)
       $choices = unserialize($items['choice']);
 
       if (!empty($choices)) {
-          foreach ($choices as $delta => $choice) {
-            if (!empty($choice['choice'])) {
-              $list[$delta] = check_plain($choice['choice']);
-            }
-          }
-
-          //choose form for specific type of poll
-          if ($poll_features['PollType']=='0') {//single choice
-            $form['choice'] = array('#type' => 'radios', '#title' => $question, '#default_value' => -1, '#options' => $list);
-          }
-          if ($poll_features['PollType']=='1') {//multi choice
-            $form['choice'] = array('#type' => 'checkboxes', '#title' => $question, '#options' => $list);
+        foreach ($choices as $delta => $choice) {
+          if (!empty($choice['choice'])) {
+            $list[$delta] = check_plain($choice['choice']);
           }
+        }
 
+        //choose form for specific type of poll
+        // single choice
+        if ($poll_features['PollType'] == '0') {
+          $form['choice'] = array('#type' => 'radios', '#title' => $question, '#default_value' => -1, '#options' => $list);
+        }
+        // multi choice
+        if ($poll_features['PollType'] == '1') {
+          $form['choice'] = array('#type' => 'checkboxes', '#title' => $question, '#options' => $list);
+        }
       }
-
     }
 
-    
+
     $cancel = 0;
     $form['field_name_delta'] = array('#type' => 'hidden', '#value' => $field_name_delta);
     $form['field_name'] = array('#type' => 'hidden', '#value' => $field_name);
     $form['nid'] = array('#type' => 'hidden', '#value' => $node->nid);
-    $form['vote'] = array('#type' => 'submit', '#value' => t('Vote'),'#submit'=>array('pollfield_voting_function_form_submit'));
+    $form['vote'] = array('#type' => 'submit', '#value' => t('Vote'), '#submit' => array('pollfield_voting_function_form_submit'));
     $form['table'] = array('#type' => 'hidden', '#value' => $table);
     $form['cancel'] = array('#type' => 'hidden', '#value' => $cancel);
     $form['#type'] = 'form';
-
-
   }
 
   //enable and disable vote form
 
 
   $result = db_query("SELECT active FROM {pollfield} WHERE field_table='%s' AND field_name='%s' AND nid=%d AND field_name_delta=%d",
-      $table, $field_name, $node->nid, $field_name_delta);
+    $table, $field_name, $node->nid, $field_name_delta
+  );
   while ($pollfield = db_fetch_object($result)) {
-    $is_active=$pollfield->active;
+    $is_active = $pollfield->active;
   }
-  if ($is_active==1) {
-   
-		return $form;
+  if ($is_active == 1) {
+
+    return $form;
   }
 
 
   return NULL;
 }
+
 /**
-*build form function
-*/
-function pollfield_build_voting_form($element){
-	
-	return drupal_get_form('pollfield_voting_function_form',$element);
-}
-/**
-*form function
-*/
-function pollfield_voting_function_form(&$form_sate,$element){
-	 
-   $form_1 = pollfield_voting_form($element);
-   return $form_1;
-}
-/**
-*submit function for voting form
-*/
-function pollfield_voting_function_form_submit(&$form_values,$element){
- 
-	pollfield_vote();
-	
+ * build form function
+ */
+function pollfield_build_voting_form($element) {
+
+  return drupal_get_form('pollfield_voting_function_form', $element);
 }
+
+/**
+ * form function
+ */
+function pollfield_voting_function_form(&$form_sate, $element) {
+
+  $form_1 = pollfield_voting_form($element);
+  return $form_1;
+}
+
+/**
+ * submit function for voting form
+ */
+function pollfield_voting_function_form_submit(&$form_values, $element) {
+
+  pollfield_vote();
+}
+
 /**
  * Implementation of hook_field_info().
  *
@@ -1001,6 +1008,7 @@ function pollfield_field_settings($op, $
       return $columns;
   }
 }
+
 /**
  * Implementation of hook_cron().
  * Closes pollfields that have exceeded their allowed runtime.
@@ -1010,21 +1018,24 @@ function pollfield_cron() {
   $result = db_query('SELECT p.nid, p.field_name, p.field_table, p.field_name_delta FROM {pollfield} p INNER JOIN {node} n ON p.nid = n.nid WHERE (n.created + p.runtime) < '. $time .' AND p.active = 1 AND p.runtime <> 0');
   while ($pollfield = db_fetch_object($result)) {
     db_query("UPDATE {pollfield} SET active = 0 WHERE nid = %d AND field_table = '%s' AND field_name = '%s' AND field_name_delta=%d",
-      $pollfield->nid, $pollfield->field_table, $pollfield->field_name, $pollfield->field_name_delta);
+      $pollfield->nid, $pollfield->field_table, $pollfield->field_name, $pollfield->field_name_delta
+    );
     // get where is table
     // get table
-    $fields = content_fields();
-    $db_info = content_database_info($fields[$field_name]);
-    $table_content = $db_info['table'];
-    $column = 'delta';
+    $fields         = content_fields();
+    $db_info        = content_database_info($fields[$field_name]);
+    $table_content  = $db_info['table'];
+    $column         = 'delta';
     $is_delta_exist = db_column_exists($table_content, $column);
     if ($is_delta_exist) {
       db_query("UPDATE {%s} set ". $pollfield->field_name ."_active = 0 WHERE nid = %d AND delta=%d", $table_content,
-        $pollfield->nid, $pollfield->field_name_delta);
+        $pollfield->nid, $pollfield->field_name_delta
+      );
     }
     else {
       db_query("UPDATE {%s} set ". $pollfield->field_name ."_active = 0 WHERE nid = %d", $table_content,
-        $pollfield->nid);
+        $pollfield->nid
+      );
     }
   }
 }
@@ -1044,92 +1055,101 @@ function pollfield_user($op, &$edit, &$u
 function pollfield_field($op, &$node, $field, &$items, $teaser, $page) {
   switch ($op) {
     case 'validate':
-    break;
-  case 'delete':
-    pollfield_delete($node);
-    break;
-  case 'validate':
-    break;
-  case 'update':
-    $field_table = $node->type;
-    $field_name = $field['field_name'];
-    $total_votes = 0;
-    foreach ($items as $key => $item) {
-      $choices = array();
-      db_query("DELETE  from {pollfield} WHERE nid=%d AND field_name='%s' AND field_table='%s' AND field_name_delta=%d",
-        $node->nid, $field_name, $field_table, $key);
-      db_query("INSERT INTO {pollfield} (nid, field_table, field_name, runtime, active, field_name_delta) VALUES (%d, '%s', '%s', %d, %d, %d)",
-        $node->nid, $field_table, $field_name, $item['runtime'], $item['active'], $key);
-      // handling publishing option
-      // it is publising
-      if (!isset($items['group'])) {
-        $coices = $items;
-      }
-      else {
-        $coices = $items['group'];
-      }
+      break;
 
-      foreach ($coices as $delta => $group) {
-        $total_votes = $total_votes+$items[$key]['group'][$delta]['votes'];
-      }
-			//delete votes if it set in edit field
-      if ($item['delete_votes']==1){
-				db_query("DELETE FROM {pollfield_votes} WHERE nid = %d
-        AND field_table='%s' AND field_name='%s' AND field_name_delta=%d", $node->nid, $field_table, $field_name,$key);
-			}
-			
-      // get total votes
-      $total_votes = $total_votes+db_result(db_query("SELECT count(*) FROM {pollfield_votes} WHERE nid = %d
+    case 'delete':
+      pollfield_delete($node);
+      break;
+
+    case 'validate':
+      break;
+
+    case 'update':
+      $field_table = $node->type;
+      $field_name  = $field['field_name'];
+      $total_votes = 0;
+      foreach ($items as $key => $item) {
+        $choices = array();
+        db_query("DELETE  from {pollfield} WHERE nid=%d AND field_name='%s' AND field_table='%s' AND field_name_delta=%d",
+          $node->nid, $field_name, $field_table, $key
+        );
+        db_query("INSERT INTO {pollfield} (nid, field_table, field_name, runtime, active, field_name_delta) VALUES (%d, '%s', '%s', %d, %d, %d)",
+          $node->nid, $field_table, $field_name, $item['runtime'], $item['active'], $key
+        );
+        // handling publishing option
+        // it is publising
+        if (!isset($items['group'])) {
+          $coices = $items;
+        }
+        else {
+          $coices = $items['group'];
+        }
+
+        foreach ($coices as $delta => $group) {
+          $total_votes = $total_votes + $items[$key]['group'][$delta]['votes'];
+        }
+        //delete votes if it set in edit field
+        if ($item['delete_votes'] == 1) {
+          db_query("DELETE FROM {pollfield_votes} WHERE nid = %d
+        AND field_table='%s' AND field_name='%s' AND field_name_delta=%d", $node->nid, $field_table, $field_name, $key);
+        }
+
+        // get total votes
+        $total_votes = $total_votes + db_result(db_query("SELECT count(*) FROM {pollfield_votes} WHERE nid = %d
         AND field_table='%s' AND field_name='%s'", $node->nid, $field_table, $field_name));
 
-      // serialize
-      // for publishing and not publishing
-      if (isset($items[$key]['group'])) {
-        $s = serialize($items[$key]['group']);
-        $poll_fetures = serialize($items[$key]['poll_features']);
-      }
-      else {
-        $s = $items[$key]['choice'];
-        $poll_fetures = $items[$key]['poll_features'];
-      }
-      $node->{$field['field_name']}[$key]['choice'] = $s;
-      $items[$key]['choice'] = $s;
-      $items[$key]['votes'] = $total_votes;
-      // adding poll features
-      $items[$key]['poll_features'] = $poll_fetures;
-      $item['nid_poll'] = $node->nid;
-    }
-    break;
-  // poll choices
-  case 'insert':
-    $field_table = $node->type;
-    $field_name = $field['field_name'];
-    $total_votes = 0;
-    foreach ($items as $key => $item) {
-      $choices = array();
-      db_query("DELETE  from {pollfield} WHERE nid=%d AND field_name='%s' AND field_table='%s' AND field_name_delta=%d",
-        $node->nid, $field_name, $field_table, $key);
-      db_query("INSERT INTO {pollfield} (nid, field_table, field_name, runtime, active, field_name_delta) VALUES (%d, '%s', '%s', %d, %d, %d)",
-        $node->nid, $field_table, $field_name, $item['runtime'], $item['active'], $key);
-      if (!empty($item['group'])) {
-        foreach ($item['group'] as $delta => $group) {
-          if (empty($group['choice'])) {
-            unset($items[$key]['group'][$delta]);
+        // serialize
+        // for publishing and not publishing
+        if (isset($items[$key]['group'])) {
+          $s = serialize($items[$key]['group']);
+          $poll_fetures = serialize($items[$key]['poll_features']);
+        }
+        else {
+          $s = $items[$key]['choice'];
+          $poll_fetures = $items[$key]['poll_features'];
+        }
+        $node->{$field['field_name']}[$key]['choice'] = $s;
+        $items[$key]['choice'] = $s;
+        $items[$key]['votes'] = $total_votes;
+        // adding poll features
+        $items[$key]['poll_features'] = $poll_fetures;
+        $item['nid_poll'] = $node->nid;
+      }
+      break;
+    // poll choices
+
+    case 'insert':
+      $field_table = $node->type;
+      $field_name  = $field['field_name'];
+      $total_votes = 0;
+      foreach ($items as $key => $item) {
+        $choices = array();
+        db_query("DELETE  from {pollfield} WHERE nid=%d AND field_name='%s' AND field_table='%s' AND field_name_delta=%d",
+          $node->nid, $field_name, $field_table, $key
+        );
+        db_query("INSERT INTO {pollfield} (nid, field_table, field_name, runtime, active, field_name_delta) VALUES (%d, '%s', '%s', %d, %d, %d)",
+          $node->nid, $field_table, $field_name, $item['runtime'], $item['active'], $key
+        );
+        if (!empty($item['group'])) {
+          foreach ($item['group'] as $delta => $group) {
+            if (empty($group['choice'])) {
+              unset($items[$key]['group'][$delta]);
+            }
+            $total_votes = $total_votes + $items[$key]['group'][$delta]['votes'];
           }
-          $total_votes = $total_votes+$items[$key]['group'][$delta]['votes'];
         }
+        $s = serialize($items[$key]['group']);
+        $poll_fetures = serialize($items[$key]['poll_features']);
+        $node->{$field['field_name']}[$key]['choice'] = $s;
+        $items[$key]['choice'] = $s;
+        $items[$key]['votes'] = $total_votes;
+        // adding poll features
+        $items[$key]['poll_features'] = $poll_fetures;
+        $item['nid_poll'] = $node->nid;
       }
-      $s = serialize($items[$key]['group']);
-      $poll_fetures = serialize($items[$key]['poll_features']);
-      $node->{$field['field_name']}[$key]['choice'] = $s;
-      $items[$key]['choice'] = $s;
-      $items[$key]['votes'] = $total_votes;
-      // adding poll features
-      $items[$key]['poll_features'] = $poll_fetures;
-      $item['nid_poll'] = $node->nid;
-    }
-    break;
-  }// switch
+      break;
+  }
+  // switch
 }
 
 /**
@@ -1166,7 +1186,6 @@ function pollfield_field_formatter_info(
       'field types' => array('pollfield'),
       'multiple values' => CONTENT_HANDLE_CORE,
     ),
-    
     'choices' => array(
       'label' => 'All choices',
       'field types' => array('pollfield'),
@@ -1211,26 +1230,27 @@ function pollfield_elements() {
  * The $fields array is in $form['#field_info'][$element['#field_name']].
  */
 function pollfield_pollfield_process($element, $edit, $form_state, $form) {
-  $field1 = $form['#field_info'][$element['#field_name']];
-  $delta = $element['#delta'];
-  $cols = $element['#columns'];
-  $type_name = $field1['type_name'];
+  $field1     = $form['#field_info'][$element['#field_name']];
+  $delta      = $element['#delta'];
+  $cols       = $element['#columns'];
+  $type_name  = $field1['type_name'];
   $field_name = $field1['field_name'];
   // geting number of blanks spot for questions
   $result = db_result(db_query("SELECT widget_settings FROM {content_node_field_instance} WHERE field_name='%s' AND type_name='%s'",
-    $field_name, $type_name));
+      $field_name, $type_name
+    ));
   $settings = unserialize($result);
   // $blank_fields = $field['widget']['blanks'];
-  $blank_fields = $settings['blanks']-1;
+  $blank_fields = $settings['blanks'] - 1;
 
-	//access to edit pollfield
+  //access to edit pollfield
   $permission = 'admin pollfield '. $field_name;
-  $access = false;
+  $access = FALSE;
   if (user_access($permission)) {
-		$access= true;
+    $access = TRUE;
   }
   //*********************************
-	
+
   $field = $cols[0];
   $element[$field] = array(
     '#type' => 'textfield',
@@ -1246,61 +1266,60 @@ function pollfield_pollfield_process($el
   $field = $cols[1];
   $element[$field] = array(
     '#type' => 'radios',
-		'#access'=> $access,
+    '#access' => $access,
     '#title' => t('Status'),
     '#default_value' => isset($element['#value'][$field]) ? $element['#value'][$field] : 1,
     '#options' => $_active,
-    '#description' => t('When a pollfield is closed, visitors can no longer vote for it.')
+    '#description' => t('When a pollfield is closed, visitors can no longer vote for it.'),
   );
 
   $field = $cols[2];
   $element[$field] = array(
     '#type' => 'select',
-		'#access'=> $access,
+    '#access' => $access,
     '#title' => t('Duration'),
     '#default_value' => isset($element['#value'][$field]) ? $element['#value'][$field] : 1,
     '#options' => $_duration,
-    '#description' => t('After this period, the pollfield will be closed automatically.')
+    '#description' => t('After this period, the pollfield will be closed automatically.'),
   );
 
   // anonymous voting
   $element[$cols[5]] = array(
     '#type' => 'select',
-		'#access'=> $access,
+    '#access' => $access,
     '#title' => t('Anonymous voting'),
     '#default_value' => isset($element['#value']['anonymous']) ? $element['#value']['anonymous'] : 1,
     '#options' => array(
       'anon_non' => t('Not allowed'),
       'anon_by_ip' => t('Allowed, filtered by user IP'),
       'anon_by_cookie' => t('Allowed filtered by user cookie'),
-      'anon_all' => t('Allowed')
+      'anon_all' => t('Allowed'),
     ),
-    '#description' => t('Allow or disallow anonymous users to vote on this poll. Filtering by user IP or cookie ensures only one vote is allowed per user IP.')
+    '#description' => t('Allow or disallow anonymous users to vote on this poll. Filtering by user IP or cookie ensures only one vote is allowed per user IP.'),
   );
 
   // poll_features - additional pollfield settings *******************************
   // we can put this as many features as we want and it is all saved in one field poll_features
   // if we are on edit node and get previous value
   if (!is_array($element['#value'][$cols[6]])) {
-    $poll_features = unserialize($element['#value'][$cols[6]]);
+    $poll_features     = unserialize($element['#value'][$cols[6]]);
     $cancel_vote_allow = $poll_features['CancelVote_Allow'];
-    $result_allow = $poll_features['ResultsAllow'];
-    $poll_type = $poll_features['PollType'];
-   
+    $result_allow      = $poll_features['ResultsAllow'];
+    $poll_type         = $poll_features['PollType'];
   }
   // we are on default value mode and we use default mode value
-  else{
+  else {
     $cancel_vote_allow = $element['#value'][$cols[6]]['CancelVote_Allow'];
     $result_allow = $element['#value'][$cols[6]]['ResultsAllow'];
-    $poll_type = $element['#value'][$cols[6]]['PollType'];// add poll type
-		
+    // add poll type
+    $poll_type = $element['#value'][$cols[6]]['PollType'];
   }
 
   // allow or disallow cancel voting
   $_cancelvote = array(0 => t('Disallow'), 1 => t('Allow'));
   $element['poll_features']['CancelVote_Allow'] = array(
     '#type' => 'radios',
-		'#access'=> $access,
+    '#access' => $access,
     '#title' => t('Cancel Vote'),
     '#default_value' => isset($cancel_vote_allow) ? $cancel_vote_allow : 1,
     '#options' => $_cancelvote,
@@ -1311,7 +1330,7 @@ function pollfield_pollfield_process($el
   $_cancelvote = array(0 => t('Disallow'), 1 => t('Allow'));
   $element['poll_features']['ResultsAllow'] = array(
     '#type' => 'radios',
-		'#access'=> $access,
+    '#access' => $access,
     '#title' => t('Show results before voting'),
     '#default_value' => isset($result_allow) ? $result_allow : 0,
     '#options' => $_cancelvote,
@@ -1324,16 +1343,16 @@ function pollfield_pollfield_process($el
     '#title' => t('Poll type'),
     '#default_value' => isset($poll_type) ? $poll_type : 1,
     '#options' => $_poll_type,
-    '#description' => t('In a Single choice poll only one of the responses can be voted for while in a Multiple choice poll it is possible to choose more than one at the same time. '),
+    '#description' => t('In a Single choice poll only one of the responses can be voted for while in a Multiple choice poll it is possible to choose more than one at the same time.'),
   );
-	//check if we are on default values
-	if (stripos($element['#id'],"default-value-widge")>0){
-		$is_default_values=TRUE;
-	}
-	else{
-		$is_default_values=FALSE;
-	}
-	$_delete_votes = array(0 => t('Not delete'), 1 => t('Delete'));
+  //check if we are on default values
+  if (stripos($element['#id'], "default-value-widge") > 0) {
+    $is_default_values = TRUE;
+  }
+  else {
+    $is_default_values = FALSE;
+  }
+  $_delete_votes = array(0 => t('Not delete'), 1 => t('Delete'));
   $element['delete_votes'] = array(
     '#type' => 'radios',
     '#title' => t('Delet votes'),
@@ -1344,175 +1363,174 @@ function pollfield_pollfield_process($el
 
 
   // ***********************************************************************************
-  $path="pollfield/add_choice/".$type_name."/".$field_name."/".$delta;
-  $name="pollfield_more_".$type_name."_".$field_name."_".$delta;
-  $wrapper="pollfield-choice-wrapper-".$type_name."-".$field_name."-".$delta;
+  $path    = "pollfield/add_choice/". $type_name ."/". $field_name ."/". $delta;
+  $name    = "pollfield_more_". $type_name ."_". $field_name ."_". $delta;
+  $wrapper = "pollfield-choice-wrapper-". $type_name ."-". $field_name ."-". $delta;
   //**********************************************************************
 
-	
 
 
-	$answers = unserialize($element['#value']['choice']);
- 	$value_choice = $answers[$delta]['choice'];
-	if ($value_choice) {
-		//$max = max($blank_fields, intval(sizeof($answers)-1));
-		$max=intval(sizeof($answers)-1);
-		
-	}
-	else {//default 
-		if (isset($element['#value']['group'])) {
-		  // choices is not serialzed in default value settings
-		  $value_choice = $element['#value']['group'][$delta]['choice'];
-		  $value_vote = $element['#value']['group'][$delta]['votes'];
-			//$max = max($blank_fields, intval(sizeof($value_choice)-1));
-      $max=intval(sizeof($element['#value']['group'])-1);
-		}
-	}	
-	//not using ahah for default values
-	if ($is_default_values){
-		$max = max($blank_fields, intval(sizeof($value_choice)-1));
-	}
-	else{
-		$no_fields=FALSE;
-		if ($max==NULL){
-		  $max = 0;
-		  $no_fields=TRUE;
-		}
-	
-	}
-  
+
+  $answers = unserialize($element['#value']['choice']);
+  $value_choice = $answers[$delta]['choice'];
+  if ($value_choice) {
+    //$max = max($blank_fields, intval(sizeof($answers)-1));
+    $max = intval(sizeof($answers) - 1);
+  }
+  // default
+  else {
+    if (isset($element['#value']['group'])) {
+      // choices is not serialzed in default value settings
+      $value_choice = $element['#value']['group'][$delta]['choice'];
+      $value_vote = $element['#value']['group'][$delta]['votes'];
+      //$max = max($blank_fields, intval(sizeof($value_choice)-1));
+      $max = intval(sizeof($element['#value']['group']) - 1);
+    }
+  }
+  //not using ahah for default values
+  if ($is_default_values) {
+    $max = max($blank_fields, intval(sizeof($value_choice) - 1));
+  }
+  else {
+    $no_fields = FALSE;
+    if ($max == NULL) {
+      $max = 0;
+      $no_fields = TRUE;
+    }
+  }
+
   // Container for just the poll choices.
   $element['group'] = array(
-    '#prefix' => '<div id="'.$wrapper.'">',
+    '#prefix' => '<div id="'. $wrapper .'">',
     '#suffix' => '</div>',
   );
-  
-	$nid=$form_state['values']['nid'];$max_number=0;
- 
-  foreach (range(0, $max+$max_number) as $delta) {
-    
+
+  $nid = $form_state['values']['nid'];
+  $max_number = 0;
+
+  foreach (range(0, $max + $max_number) as $delta) {
+
     $value_choice = $answers[$delta]['choice'];
     $value_vote = $answers[$delta]['votes'];
-    if ($value_choice) {
-    }
-    else {
+    if (!$value_choice) {
       if (isset($element['#value']['group'])) {
         // choices is not serialzed in default value settings
         $value_choice = $element['#value']['group'][$delta]['choice'];
         $value_vote = $element['#value']['group'][$delta]['votes'];
       }
     }
-    
-    $first_empty=FALSE;
-    if ($delta==0 && $first_empty=strlen($value_choice)<1)
-       $first_empty=TRUE;
-    
-    if (strlen($value_choice)>1 || $no_fields || $is_default_values || $first_empty){
-		  $element['group'][$delta] = array(
-		    '#type' => 'fieldset',
-		    '#title' => t('Choice #%delta', array('%delta' => intval($number + 1))),
-		    '#tree' => TRUE,
-		  );
-		  $element['group'][$delta]['choice'] = array(
-		    '#title' => t('Response'),
-		    '#type' => 'textfield',
-		    '#default_value' => isset($value_choice) ? $value_choice : '',
-		    '#rows' => 2,
-		    '#weight' => floatval($field1['widget']['weight'] + ($delta / 10)),
-		  );
-		  $element['group'][$delta]['votes'] = array(
-		    '#title' => t('Starting votes count (optional)'),
-				'#access'=> $access,
-		    '#type' => 'textfield',
-		    '#default_value' => isset($value_vote) ? $value_vote : '',
-		    '#size' => 10,
-		    '#weight' => floatval($field1['widget']['weight'] + ($delta / 10) + .1),
-		  );
-		  $number++;
+
+    $first_empty = FALSE;
+    if ($delta == 0 && $first_empty = drupal_strlen($value_choice) < 1) {
+      $first_empty = TRUE;
+    }
+
+    if (drupal_strlen($value_choice) > 1 || $no_fields || $is_default_values || $first_empty) {
+      $element['group'][$delta] = array(
+        '#type' => 'fieldset',
+        '#title' => t('Choice #%delta', array('%delta' => intval($number + 1))),
+        '#tree' => TRUE,
+      );
+      $element['group'][$delta]['choice'] = array(
+        '#title' => t('Response'),
+        '#type' => 'textfield',
+        '#default_value' => isset($value_choice) ? $value_choice : '',
+        '#rows' => 2,
+        '#weight' => floatval($field1['widget']['weight'] + ($delta / 10)),
+      );
+      $element['group'][$delta]['votes'] = array(
+        '#title' => t('Starting votes count (optional)'),
+        '#access' => $access,
+        '#type' => 'textfield',
+        '#default_value' => isset($value_vote) ? $value_vote : '',
+        '#size' => 10,
+        '#weight' => floatval($field1['widget']['weight'] + ($delta / 10) + .1),
+      );
+      $number++;
     }
   }
-	
+
   //check if more choice button submit
-  if (strcmp($form_state['clicked_button']['#name'],$nid."-".$path)==0){
-    if (strlen($element['group'][$number-1]['choice'])>1){
-        $element['group'][$number] = array(
-				  '#type' => 'fieldset',
-				  '#title' => t('Choice #%delta', array('%delta' => intval($number + 1))),
-				  '#tree' => TRUE,
-				);
-				$element['group'][$number]['choice'] = array(
-				  '#title' => t('Response'),
-				  '#type' => 'textfield',
-				  '#default_value' => '',
-				  '#rows' => 2,
-				  '#weight' => floatval($field1['widget']['weight'] + ($delta / 10)),
-				);
-				$element['group'][$number]['votes'] = array(
-				  '#title' => t('Starting votes count (optional)'),
-					'#access'=> $access,
-				  '#type' => 'textfield',
-				  '#default_value' => '',
-				  '#size' => 10,
-				  '#weight' => floatval($field1['widget']['weight'] + ($delta / 10) + .1),
-				);
-				$number++;
-		}
-		else{
-				
-		}
-	}
-	if (!$is_default_values){
-		$element[$name] = array(
-		  '#type' => 'submit',
-		  '#value' => t('More choices'),
-		  '#description' => t("If the amount of boxes above isn't enough, click here to add more choices."),
-		  '#weight' => 1,
-		  '#name'=>$nid."-".$path,
-		  '#submit' => array('pollfield_more_choices_submit'), // If no javascript action.
-		  '#ahah' => array(
-		    'path' => $path,
-		    'wrapper' => $wrapper,
-		    'method' => 'replace',
-		    'effect' => 'fade',
-		  ),
-		);
-	}
+  if (strcmp($form_state['clicked_button']['#name'], $nid ."-". $path) == 0) {
+    if (drupal_strlen($element['group'][$number - 1]['choice']) > 1) {
+      $element['group'][$number] = array(
+        '#type' => 'fieldset',
+        '#title' => t('Choice #%delta', array('%delta' => intval($number + 1))),
+        '#tree' => TRUE,
+      );
+      $element['group'][$number]['choice'] = array(
+        '#title' => t('Response'),
+        '#type' => 'textfield',
+        '#default_value' => '',
+        '#rows' => 2,
+        '#weight' => floatval($field1['widget']['weight'] + ($delta / 10)),
+      );
+      $element['group'][$number]['votes'] = array(
+        '#title' => t('Starting votes count (optional)'),
+        '#access' => $access,
+        '#type' => 'textfield',
+        '#default_value' => '',
+        '#size' => 10,
+        '#weight' => floatval($field1['widget']['weight'] + ($delta / 10) + .1),
+      );
+      $number++;
+    }
+    else {}
+  }
+  if (!$is_default_values) {
+    $element[$name] = array(
+      '#type' => 'submit',
+      '#value' => t('More choices'),
+      '#description' => t("If the amount of boxes above isn't enough, click here to add more choices."),
+      '#weight' => 1,
+      '#name' => $nid ."-". $path,
+      // If no javascript action.
+      '#submit' => array('pollfield_more_choices_submit'),
+      '#ahah' => array(
+        'path' => $path,
+        'wrapper' => $wrapper,
+        'method' => 'replace',
+        'effect' => 'fade',
+      ),
+    );
+  }
   unset($form_state['storage']);
   return $element;
 }
-/**
-*
-*/
-function pollfield_delete_votes($form,&$form_state){
-	dpm($form);dpm($form_state);
 
+/**
+ *
+ */
+function pollfield_delete_votes($form, &$form_state) {
+  dpm($form);
+  dpm($form_state);
 }
 
 /**
-*add more choices using ahah formu
-*/
-function pollfield_add_choice(){
-  
-  $splits_get=$nid_parse=preg_split('/\//',$_GET['q']);
-  $field_name=$splits_get[3];
-	$field_name_delta=$splits_get[4];
-	
-	include_once 'modules/node/node.pages.inc';
+ * add more choices using ahah formu
+ */
+function pollfield_add_choice() {
+
+  $splits_get       = $nid_parse = preg_split('/\//', $_GET['q']);
+  $field_name       = $splits_get[3];
+  $field_name_delta = $splits_get[4];
+
+  include_once 'modules/node/node.pages.inc';
   $form_state = array('storage' => NULL, 'submitted' => FALSE);
   $form_build_id = $_POST['form_build_id'];
   // Get the form from the cache.
   $form = form_get_cache($form_build_id, $form_state);
   $args = $form['#parameters'];
-	
-  
+
+
   $form_id = array_shift($args);
   // We will run some of the submit handlers so we need to disable redirecting.
   $form['#redirect'] = FALSE;
   // We need to process the form, prepare for that by setting a few internals
   // variables.
-  $form['#post'] = $_POST;
+  $form['#post']       = $_POST;
   $form['#programmed'] = FALSE;
-  $form_state['post'] = $_POST;
+  $form_state['post']  = $_POST;
   // Build, validate and if possible, submit the form.
   drupal_process_form($form_id, $form, $form_state);
   // This call recreates the form relying solely on the form_state that the
@@ -1520,71 +1538,70 @@ function pollfield_add_choice(){
   $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);
 
   // Render the new output.
-  $form_choices=$form[$field_name][$field_name_delta]['group'];
-	if (is_array($form_choices)){
-		$delta=0;
-		while (!empty($form_choices[$delta])){
-			$delta++;
-		}
-		$is_choice_set=strlen($form_choices[$delta-1]['choice']['#value'])>1;
-	}
-	
+  $form_choices = $form[$field_name][$field_name_delta]['group'];
+  if (is_array($form_choices)) {
+    $delta = 0;
+    while (!empty($form_choices[$delta])) {
+      $delta++;
+    }
+    $is_choice_set = drupal_strlen($form_choices[$delta - 1]['choice']['#value']) > 1;
+  }
 
-  $_delta=$delta-1;
+
+  $_delta = $delta - 1;
   //genereting new ids and names
-  $name_choice=$form_choices[$_delta]['choice']['#name'];
-  $id_choice=$form_choices[$_delta]['choice']['#id'];
-	$name_votes=$form_choices[$_delta]['votes']['#name'];
-  $id_votes=$form_choices[$_delta]['votes']['#id'];
-  $name_choice=str_replace('['.$_delta.'][choice]','['.$delta.'][choice]',$name_choice);
-  $id_choice=str_replace($_delta.'-choice',$delta.'-choice',$id_choice);
-	$name_votes=str_replace('['.$_delta.'][votes]','['.$delta.'][votes]',$name_votes);
-  $id_votes=str_replace($_delta.'-votes',$delta.'-votes',$id_votes);
-  
-  if ($is_choice_set){
-  	$element = array(
+  $name_choice = $form_choices[$_delta]['choice']['#name'];
+  $id_choice   = $form_choices[$_delta]['choice']['#id'];
+  $name_votes  = $form_choices[$_delta]['votes']['#name'];
+  $id_votes    = $form_choices[$_delta]['votes']['#id'];
+  $name_choice = str_replace('['. $_delta .'][choice]', '['. $delta .'][choice]', $name_choice);
+  $id_choice   = str_replace($_delta .'-choice', $delta .'-choice', $id_choice);
+  $name_votes  = str_replace('['. $_delta .'][votes]', '['. $delta .'][votes]', $name_votes);
+  $id_votes    = str_replace($_delta .'-votes', $delta .'-votes', $id_votes);
+
+  if ($is_choice_set) {
+    $element = array(
       '#type' => 'fieldset',
-      '#title' => t('Choice #%delta', array('%delta' => intval($delta+1))),
+      '#title' => t('Choice #%delta', array('%delta' => intval($delta + 1))),
       '#tree' => TRUE,
     );
     $element['choice'] = array(
       '#title' => t('Response'),
       '#type' => 'textfield',
-			'#name'=>$name_choice,
-			'#id'=>$id_choice,
+      '#name' => $name_choice,
+      '#id' => $id_choice,
       '#default_value' => isset($value_choice) ? $value_choice : '',
       '#rows' => 2,
       '#weight' => floatval($field1['widget']['weight'] + ($delta / 10)),
     );
     $element['votes'] = array(
       '#title' => t('Starting votes count (optional)'),
-			'#name'=>$name_votes,
-			'#id'=>$id_votes,
-			'#access'=> $access,
+      '#name' => $name_votes,
+      '#id' => $id_votes,
+      '#access' => $access,
       '#type' => 'textfield',
       '#default_value' => isset($value_vote) ? $value_vote : '',
       '#size' => 10,
       '#weight' => floatval($field1['widget']['weight'] + ($delta / 10) + .1),
     );
-  
-	
-  	$form_choices[$delta]=$element;
+
+
+    $form_choices[$delta] = $element;
   }
- 
-  unset($form_choices['#prefix'], $form_choices['#suffix']); // Prevent duplicate wrappers.
+
+  // Prevent duplicate wrappers.
+  unset($form_choices['#prefix'], $form_choices['#suffix']);
   $output = drupal_render($form_choices);
-  
+
   drupal_json(array('status' => TRUE, 'data' => $output));
-  	
 }
 
-/*
-*add more choices without using ahah using
-*/
-function pollfield_more_choices_submit($form, &$form_state){
+/**
+ * add more choices without using ahah using
+ */
+function pollfield_more_choices_submit($form, &$form_state) {
   // Set the form to rebuild and run submit handlers.
-   node_form_submit_build_node($form, $form_state);
-	
+  node_form_submit_build_node($form, $form_state);
 }
 
 /**
@@ -1622,10 +1639,11 @@ function pollfield_widget_settings($op, 
         '#type' => 'textfield',
         '#title' => t('Number of default "Response" fields'),
         '#default_value' => isset($widget['blanks']) ? $widget['blanks'] : 3,
-        '#description' => t('This number of fields will always be displayed on defualt value page but fields left blank will not be displayed when viewing content. '),
+        '#description' => t('This number of fields will always be displayed on defualt value page but fields left blank will not be displayed when viewing content.'),
         '#element_validate' => array('_pollfield_widget_settings_blank_questions_validate'),
       );
       return $form;
+
     case 'save':
       return array('blanks');
   }
@@ -1655,24 +1673,24 @@ function pollfield_cancel_multiple_choic
  */
 function pollfield_save_multiple_choice($form_values, $cookie_db) {
   global $user;
-  $form_values = $_POST;
-  $nid = $form_values['nid'];
-  $field_name = $form_values['field_name'];
+  $form_values      = $_POST;
+  $nid              = $form_values['nid'];
+  $field_name       = $form_values['field_name'];
   $field_name_delta = $form_values['field_name_delta'];
-  $field_table = $form_values['table'];
-  $cancel = $form_values['cancel'];
-  $node = node_load($nid);
-  $choice = $form_values['choice'];
-  $nid = $node->nid;
-  $uid = $user->uid;
-  $hostname = $_SERVER['REMOTE_ADDR'];
-  $voted = FALSE;
+  $field_table      = $form_values['table'];
+  $cancel           = $form_values['cancel'];
+  $node             = node_load($nid);
+  $choice           = $form_values['choice'];
+  $nid              = $node->nid;
+  $uid              = $user->uid;
+  $hostname         = $_SERVER['REMOTE_ADDR'];
+  $voted            = FALSE;
 
   // get table
-  $fields = content_fields();
-  $db_info = content_database_info($fields[$field_name]);
-  $table_content = $db_info['table'];
-  $column = 'delta';
+  $fields         = content_fields();
+  $db_info        = content_database_info($fields[$field_name]);
+  $table_content  = $db_info['table'];
+  $column         = 'delta';
   $is_delta_exist = db_column_exists($table_content, $column);
 
   if ($is_delta_exist) {
@@ -1691,22 +1709,23 @@ function pollfield_save_multiple_choice(
   // is user voted
   $voted = pollfield_user_voted($node, $field_table, $field_name, $field_name_delta);
   $number_of_coices = count($form_values['choice']);
-  if ($number_of_coices==0){
-		drupal_set_message(t('Choice is not selected. Select your answer and vote.'));
-		return 0;
-	}
+  if ($number_of_coices == 0) {
+    drupal_set_message(t('Choice is not selected. Select your answer and vote.'));
+    return 0;
+  }
   if ($voted == 0) {
     $uid = $user->uid;
     foreach ($form_values['choice'] as $value) {
       $choice = $value;
-      if ($user->uid>0) {
+      if ($user->uid > 0) {
         db_query("INSERT INTO {pollfield_votes} (nid, field_table, field_name, uid, delta, field_name_delta)
         VALUES (%d, '%s', '%s' , %d, %d, %d)", $nid, $field_table, $field_name, $uid, $choice, $field_name_delta);
         // increment total votes
         if ($existing_field == 1) {
           $total_votes++;
           db_query('UPDATE {%s} SET %s = %d WHERE nid = %d AND delta=%d',
-              $table_content, $field_votes, $total_votes, $nid, $field_name_delta);
+            $table_content, $field_votes, $total_votes, $nid, $field_name_delta
+          );
         }
         else {
           $total_votes++;
@@ -1716,7 +1735,8 @@ function pollfield_save_multiple_choice(
       else {
         db_query("INSERT INTO {pollfield_votes} (nid, field_table, field_name, delta, hostname, field_name_delta, cookie)
           VALUES (%d, '%s', '%s', %d, '%s', %d, '%s')",
-          $nid, $field_table, $field_name, $choice, $hostname, $field_name_delta, $cookie_db);
+          $nid, $field_table, $field_name, $choice, $hostname, $field_name_delta, $cookie_db
+        );
       }
     }
     // Any time a vote is recorded, clear the CCK cache so the votes can be updated.
@@ -1734,24 +1754,24 @@ function pollfield_save_multiple_choice(
  */
 function pollfield_save_single_choice($form_values, $cookie_db) {
   global $user;
-  $form_values = $_POST;
-  $nid = $form_values['nid'];
-  $field_name = $form_values['field_name'];
+  $form_values      = $_POST;
+  $nid              = $form_values['nid'];
+  $field_name       = $form_values['field_name'];
   $field_name_delta = $form_values['field_name_delta'];
-  $field_table = $form_values['table'];
-  $cancel = $form_values['cancel'];
-  $node = node_load($nid);
-  $choice = $form_values['choice'];
-  $nid = $node->nid;
-  $uid = $user->uid;
-  $hostname = $_SERVER['REMOTE_ADDR'];
-  $voted = FALSE;
+  $field_table      = $form_values['table'];
+  $cancel           = $form_values['cancel'];
+  $node             = node_load($nid);
+  $choice           = $form_values['choice'];
+  $nid              = $node->nid;
+  $uid              = $user->uid;
+  $hostname         = $_SERVER['REMOTE_ADDR'];
+  $voted            = FALSE;
 
   // get table
-  $fields = content_fields();
-  $db_info = content_database_info($fields[$field_name]);
-  $table_content = $db_info['table'];
-  $column = 'delta';
+  $fields         = content_fields();
+  $db_info        = content_database_info($fields[$field_name]);
+  $table_content  = $db_info['table'];
+  $column         = 'delta';
   $is_delta_exist = db_column_exists($table_content, $column);
 
   if ($is_delta_exist) {
@@ -1769,23 +1789,24 @@ function pollfield_save_single_choice($f
 
   // is user voted
   $voted = pollfield_user_voted($node, $field_table, $field_name, $field_name_delta);
-	
-	if (!isset($choice)){
-		drupal_set_message(t('Choice is not selected. Select your answer and vote.'));
-		return 0;
-	}
+
+  if (!isset($choice)) {
+    drupal_set_message(t('Choice is not selected. Select your answer and vote.'));
+    return 0;
+  }
 
 
   if ($voted == 0) {
     $uid = $user->uid;
-    if ($user->uid>0) {
+    if ($user->uid > 0) {
       db_query("INSERT INTO {pollfield_votes} (nid, field_table, field_name, uid, delta, field_name_delta)
         VALUES (%d, '%s', '%s' , %d, %d, %d)", $nid, $field_table, $field_name, $uid, $choice, $field_name_delta);
       // increment total votes
       if ($existing_field == 1) {
         $total_votes++;
         db_query('UPDATE {%s} SET %s = %d WHERE nid = %d AND delta=%d',
-          $table_content, $field_votes, $total_votes, $nid, $field_name_delta);
+          $table_content, $field_votes, $total_votes, $nid, $field_name_delta
+        );
       }
       else {
         $total_votes++;
@@ -1795,7 +1816,8 @@ function pollfield_save_single_choice($f
     else {
       db_query("INSERT INTO {pollfield_votes} (nid, field_table, field_name, delta, hostname, field_name_delta, cookie)
         VALUES (%d, '%s', '%s', %d, '%s', %d, '%s')",
-        $nid, $field_table, $field_name, $choice, $hostname, $field_name_delta, $cookie_db);
+        $nid, $field_table, $field_name, $choice, $hostname, $field_name_delta, $cookie_db
+      );
     }
 
     // Any time a vote is recorded, clear the CCK cache so the votes can be updated.
@@ -1813,70 +1835,80 @@ function pollfield_save_single_choice($f
  */
 function pollfield_cancel_single_choice($form_values, $cookie_db) {
   global $user;
-  $nid = $form_values['nid'];
-  $field_name = $form_values['field_name'];
+  $nid              = $form_values['nid'];
+  $field_name       = $form_values['field_name'];
   $field_name_delta = $form_values['field_name_delta'];
-  $field_table = $form_values['table'];
-  $cancel = $form_values['cancel'];
-  $node = node_load($nid);
-  $hostname = $_SERVER['REMOTE_ADDR'];
+  $field_table      = $form_values['table'];
+  $cancel           = $form_values['cancel'];
+  $node             = node_load($nid);
+  $hostname         = $_SERVER['REMOTE_ADDR'];
 
   // get where is table
   // get table
-  $fields = content_fields();
-  $db_info = content_database_info($fields[$field_name]);
-  $table_content = $db_info['table'];
-  $column = 'delta';
+  $fields         = content_fields();
+  $db_info        = content_database_info($fields[$field_name]);
+  $table_content  = $db_info['table'];
+  $column         = 'delta';
   $is_delta_exist = db_column_exists($table_content, $column);
-	$tnid = db_result(db_query("SELECT tnid FROM {node} WHERE nid=%d",$nid));
-	if ($tnid==0){//there is no translation
-	  $t_nodes_results=db_query("SELECT nid FROM {node} WHERE nid = %d",$nid);
-	}else{//there is translation
-	  $t_nodes_results=db_query("SELECT nid FROM {node} WHERE tnid = %d",$tnid);
-	}
-	while ($t_nodes = db_fetch_object($t_nodes_results)) {//check all translations
-		
-		if ($is_delta_exist) {
-		  $field_votes = $field_name .'_votes';
-		  $total_votes = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d AND delta=%d", $field_votes, $table_content, $t_nodes->nid, $field_name_delta));
-		  // get anonymous voting politics
-		  $field_anon = $field_name .'_anonymous';
-		  $anonymous = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d AND delta=%d", $field_anon, $table_content, $t_nodes->nid, $field_name_delta));
-		  // dencrement total votes
-		  $total_votes--;
-		  db_query('UPDATE {%s} SET %s = %d WHERE nid = %d AND delta=%d', $table_content, $field_votes, $total_votes, $t_nodes->nid, $field_name_delta);
-		}
-		else {
-		  $field_votes = $field_name .'_votes';
-		  $total_votes = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d", $field_votes, $table_content, $t_nodes->nid));
-		  // get anonymous voting politics
-		  $field_anon = $field_name .'_anonymous';
-		  $anonymous = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d", $field_anon, $table_content, $t_nodes->nid));
-		}
-		// dencrement total votes
-		$total_votes--;
-		db_query('UPDATE {%s} SET %s = %d WHERE nid = %d', $table_content, $field_votes, $total_votes, $t_nodes->nid);
+  $tnid           = db_result(db_query("SELECT tnid FROM {node} WHERE nid=%d", $nid));
+  // there is no translation
+  if ($tnid == 0) {
+    $t_nodes_results = db_query("SELECT nid FROM {node} WHERE nid = %d", $nid);
+    // there is translation
+  }
+  else {
+    $t_nodes_results = db_query("SELECT nid FROM {node} WHERE tnid = %d", $tnid);
+  }
+  // check all translations
+  while ($t_nodes = db_fetch_object($t_nodes_results)) {
 
-		// ************************
+    if ($is_delta_exist) {
+      $field_votes = $field_name .'_votes';
+      $total_votes = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d AND delta=%d", $field_votes, $table_content, $t_nodes->nid, $field_name_delta));
+      // get anonymous voting politics
+      $field_anon = $field_name .'_anonymous';
+      $anonymous = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d AND delta=%d", $field_anon, $table_content, $t_nodes->nid, $field_name_delta));
+      // dencrement total votes
+      $total_votes--;
+      db_query('UPDATE {%s} SET %s = %d WHERE nid = %d AND delta=%d', $table_content, $field_votes, $total_votes, $t_nodes->nid, $field_name_delta);
+    }
+    else {
+      $field_votes = $field_name .'_votes';
+      $total_votes = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d", $field_votes, $table_content, $t_nodes->nid));
+      // get anonymous voting politics
+      $field_anon = $field_name .'_anonymous';
+      $anonymous = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d", $field_anon, $table_content, $t_nodes->nid));
+    }
+    // dencrement total votes
+    $total_votes--;
+    db_query('UPDATE {%s} SET %s = %d WHERE nid = %d', $table_content, $field_votes, $total_votes, $t_nodes->nid);
+
+    // ************************
 
-		if ($user->uid) {
-		  db_query("DELETE from {pollfield_votes}
+    if ($user->uid) {
+      db_query("DELETE from {pollfield_votes}
 		    WHERE nid = %d AND field_table='%s' AND field_name='%s'AND uid = %d AND field_name_delta=%d",
-		    $t_nodes->nid, $field_table, $field_name, $user->uid, $field_name_delta);// delta is number of choice
-		}
-		else {
-		  if ($anonymous == 'anon_by_ip') {
-		    db_query("DELETE from {pollfield_votes}
+        // delta is number of choice
+        $t_nodes->nid, $field_table, $field_name, $user->uid, $field_name_delta
+      );
+    }
+    else {
+      if ($anonymous == 'anon_by_ip') {
+        db_query("DELETE from {pollfield_votes}
 		      WHERE nid = %d AND field_table='%s' AND field_name='%s'AND hostname = '%s' AND field_name_delta=%d",
-		      $t_nodes->nid, $field_table, $field_name, $hostname, $field_name_delta);// delta is number of choice
-		  }
-		  if ($anonymous == 'anon_by_cookie') {
-		    db_query("DELETE from {pollfield_votes}
+          // delta is number of choice
+          $t_nodes->nid, $field_table, $field_name, $hostname, $field_name_delta
+        );
+      }
+      if ($anonymous == 'anon_by_cookie') {
+        db_query("DELETE from {pollfield_votes}
 		      WHERE nid = %d AND field_table='%s' AND field_name='%s'AND cookie = '%s' AND field_name_delta=%d",
-		      $t_nodes->nid, $field_table, $field_name, $cookie_db, $field_name_delta);// delta is number of choice
-		  }
-		}
-	}
+          // delta is number of choice
+          $t_nodes->nid, $field_table, $field_name, $cookie_db, $field_name_delta
+        );
+      }
+    }
+  }
   return 0;
 }
 
@@ -1885,14 +1917,14 @@ function pollfield_cancel_single_choice(
  */
 function pollfield_vote() {
   global $user;
-  $form_values = $_POST;
-  $nid = $form_values['nid'];
-  $field_name = $form_values['field_name'];
+  $form_values      = $_POST;
+  $nid              = $form_values['nid'];
+  $field_name       = $form_values['field_name'];
   $field_name_delta = $form_values['field_name_delta'];
-  $field_table = $form_values['table'];
-  $cancel = $form_values['cancel'];
-  $node = node_load($nid);
-  
+  $field_table      = $form_values['table'];
+  $cancel           = $form_values['cancel'];
+  $node             = node_load($nid);
+
   // set add cookie**************************
   $cookie = pollfield_cookie_id_generator();
   if ($cookie != 0) {
@@ -1903,8 +1935,8 @@ function pollfield_vote() {
   }
   // *******************************************
 
-  $fields = content_fields();
-  $db_info = content_database_info($fields[$field_name]);
+  $fields        = content_fields();
+  $db_info       = content_database_info($fields[$field_name]);
   $table_content = $db_info['table'];
 
   $column = 'delta';
@@ -1944,36 +1976,35 @@ function pollfield_vote() {
     }
   }
 
-  $query=$_GET['q'];
-  if (isset($_GET['page']))
-		$page='page='.$_GET['page'];
-	
-  drupal_goto($query,$page,'pollfield-'.$nid.'-'.$field_name_delta);
-  pollfield_clear($node);
+  $query = $_GET['q'];
+  if (isset($_GET['page'])) {
+    $page = 'page='. $_GET['page'];
+  }
 
+  drupal_goto($query, $page, 'pollfield-'. $nid .'-'. $field_name_delta);
+  pollfield_clear($node);
 }
 
-
 /**
  * Cookie generator for anonymous voting.
  */
 function pollfield_cookie_id_generator() {
   global $user;
-  $form_values = $_POST;
-  $nid = $form_values['nid'];
-  $field_name = $form_values['field_name'];
+  $form_values      = $_POST;
+  $nid              = $form_values['nid'];
+  $field_name       = $form_values['field_name'];
   $field_name_delta = $form_values['field_name_delta'];
-  $field_table = $form_values['table'];
+  $field_table      = $form_values['table'];
 
-  $node = node_load($nid);
+  $node           = node_load($nid);
   $user_id_cookie = rand(0, 100000);
-  $user_id_cookie = $user_id_cookie+time();
+  $user_id_cookie = $user_id_cookie + time();
   $user_id_cookie = 'id'. $user_id_cookie;
   // /cookie add***************************************
-  $cookie_name = $field_table .'_'. $field_name .'_'. $field_name_delta;
+  $cookie_name  = $field_table .'_'. $field_name .'_'. $field_name_delta;
   $cookie_value = $user_id_cookie;
-  $field = $node->$field_name;
-  $duration = $field[$field_name_delta]['runtime'];
+  $field        = $node->$field_name;
+  $duration     = $field[$field_name_delta]['runtime'];
 
 
   $anonymous = $field[$field_name_delta]['anonymous'];
@@ -1984,10 +2015,11 @@ function pollfield_cookie_id_generator()
 
   if (!isset($_COOKIE[$cookie_name])) {
     if ($duratione == 0) {
-      $expire = time()+60*60*24*30;// if poll is unlimited set expire one month
+      // if poll is unlimited set expire one month
+      $expire = time() + 60 * 60 * 24 * 30;
     }
     else {
-      $expire = time()+$duration;
+      $expire = time() + $duration;
     }
     setcookie($cookie_name, $cookie_value, $expire, '/');
     $cookie = array('cookie_name' => $cookie_name, 'cookie_value' => $cookie_value);
@@ -2006,163 +2038,184 @@ function pollfield_cookie_id_generator()
 function pollfield_user_voted($node, $field_table, $field_name, $field_name_delta) {
   global $user;
 
-  $nid = $node->nid;
-  $uid = $user->uid;
+  $nid      = $node->nid;
+  $uid      = $user->uid;
   $hostname = $_SERVER['REMOTE_ADDR'];
-  $voted = FALSE;
+  $voted    = FALSE;
 
   // get table
-  $fields = content_fields();
-  $db_info = content_database_info($fields[$field_name]);
-  $table_content = $db_info['table'];
-  $column = 'delta';
+  $fields         = content_fields();
+  $db_info        = content_database_info($fields[$field_name]);
+  $table_content  = $db_info['table'];
+  $column         = 'delta';
   $is_delta_exist = db_column_exists($table_content, $column);
-	
-	$tnid = db_result(db_query("SELECT tnid FROM {node} WHERE nid=%d",$nid));
-	if ($tnid==0){//there is no translation
-	  $t_nodes_results=db_query("SELECT nid FROM {node} WHERE nid = %d",$nid);
-	}else{//there is translation
-	  $t_nodes_results=db_query("SELECT nid FROM {node} WHERE tnid = %d",$tnid);
-	}
-	while ($t_nodes = db_fetch_object($t_nodes_results)) {//check all translations
-		$t_nid=$t_nodes->nid;
-		if ($is_delta_exist) {
-		  $existing_field = 1;
-		  // get anonymous voting politics
-		  $field_anon = $field_name .'_anonymous';
-		  $anonymous = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d AND delta=%d", $field_anon, $table_content, $t_nid, $field_name_delta));
-		}
-		else {
-		  // get anonymous voting politics
-		  $field_anon = $field_name .'_anonymous';
-		  $anonymous = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d", $field_anon, $table_content, $t_nid));
-		}
-
-		// check if user has voted
-		if ($user->uid) {
-		  $voted = db_result(db_query("SELECT count(*) from {pollfield_votes}
+
+  $tnid = db_result(db_query("SELECT tnid FROM {node} WHERE nid=%d", $nid));
+  // there is no translation
+  if ($tnid == 0) {
+    $t_nodes_results = db_query("SELECT nid FROM {node} WHERE nid = %d", $nid);
+    // there is translation
+  }
+  else {
+    $t_nodes_results = db_query("SELECT nid FROM {node} WHERE tnid = %d", $tnid);
+  }
+  // check all translations
+  while ($t_nodes = db_fetch_object($t_nodes_results)) {
+    $t_nid = $t_nodes->nid;
+    if ($is_delta_exist) {
+      $existing_field = 1;
+      // get anonymous voting politics
+      $field_anon = $field_name .'_anonymous';
+      $anonymous = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d AND delta=%d", $field_anon, $table_content, $t_nid, $field_name_delta));
+    }
+    else {
+      // get anonymous voting politics
+      $field_anon = $field_name .'_anonymous';
+      $anonymous = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d", $field_anon, $table_content, $t_nid));
+    }
+
+    // check if user has voted
+    if ($user->uid) {
+      $voted = db_result(db_query("SELECT count(*) from {pollfield_votes}
 		    WHERE nid = %d AND field_table='%s' AND field_name='%s'AND uid = %d AND field_name_delta=%d",
-		    $t_nid, $field_table, $field_name, $user->uid, $field_name_delta));// delta is number of choice
-		}
-		else {// user is anonymous
-		  if ($anonymous == 'anon_by_ip') {
-		    $voted = db_result(db_query("SELECT count(*) from {pollfield_votes}
+          // delta is number of choice
+          $t_nid, $field_table, $field_name, $user->uid, $field_name_delta
+        ));
+    }
+    // user is anonymous
+    else {
+      if ($anonymous == 'anon_by_ip') {
+        $voted = db_result(db_query("SELECT count(*) from {pollfield_votes}
 		      WHERE nid = %d AND field_table='%s' AND field_name='%s' AND hostname = '%s' AND field_name_delta=%d",
-		      $t_nid, $field_table, $field_name, $hostname, $field_name_delta));// delta is number of choice
-		  }
-		  if ($anonymous == 'anon_non') {
-		    // $voted = 0;
-		  }
-		  if ($anonymous == 'anon_all') {
-		    // $voted = 1;
-		  }
-		  if ($anonymous == 'anon_by_cookie') {
-		    // add cookie
-		    $cookie_name = $field_table .'_'. $field_name .'_'. $field_name_delta;
-		    $cookie_collected_value = $_COOKIE[$cookie_name];
+            // delta is number of choice
+            $t_nid, $field_table, $field_name, $hostname, $field_name_delta
+          ));
+      }
+      if ($anonymous == 'anon_non') {
+        // $voted = 0;
+      }
+      if ($anonymous == 'anon_all') {
+        // $voted = 1;
+      }
+      if ($anonymous == 'anon_by_cookie') {
+        // add cookie
+        $cookie_name = $field_table .'_'. $field_name .'_'. $field_name_delta;
+        $cookie_collected_value = $_COOKIE[$cookie_name];
 
-		    $cookie_compare = array('cookie_name' => $cookie_name, 'cookie_value' => $cookie_collected_value);
+        $cookie_compare = array('cookie_name' => $cookie_name, 'cookie_value' => $cookie_collected_value);
 
-		    $cookie_compare_db = serialize($cookie_compare);
+        $cookie_compare_db = serialize($cookie_compare);
 
-		    $voted = db_result(db_query("SELECT count(*) from {pollfield_votes}
+        $voted = db_result(db_query("SELECT count(*) from {pollfield_votes}
 		      WHERE nid = %d AND field_table='%s' AND field_name='%s' AND cookie = '%s' AND field_name_delta=%d",
-		      $t_nid, $field_table, $field_name, $cookie_compare_db, $field_name_delta));
-		  }
-		}
-		$is_voted=$is_voted+$voted;
-	}
+            $t_nid, $field_table, $field_name, $cookie_compare_db, $field_name_delta
+          ));
+      }
+    }
+    $is_voted = $is_voted + $voted;
+  }
+
 
 
- 
   return $is_voted;
 }
+
 /**
  * Get is user votes.
  */
 function pollfield_user_votes($node, $field_table, $field_name, $field_name_delta) {
   global $user;
-  
-  $nid = $node->nid;
-  $uid = $user->uid;
+
+  $nid      = $node->nid;
+  $uid      = $user->uid;
   $hostname = $_SERVER['REMOTE_ADDR'];
-  $voted = FALSE;
+  $voted    = FALSE;
 
   // get table
-  $fields = content_fields();
-  $db_info = content_database_info($fields[$field_name]);
-  $table_content = $db_info['table'];
-  $column = 'delta';
+  $fields         = content_fields();
+  $db_info        = content_database_info($fields[$field_name]);
+  $table_content  = $db_info['table'];
+  $column         = 'delta';
   $is_delta_exist = db_column_exists($table_content, $column);
-	$tnid = db_result(db_query("SELECT tnid FROM {node} WHERE nid=%d",$nid));
-	if ($tnid==0){//there is no translation
-	  $t_nodes_results=db_query("SELECT nid FROM {node} WHERE nid = %d",$nid);
-	}else{//there is translation
-	  $t_nodes_results=db_query("SELECT nid FROM {node} WHERE tnid = %d",$tnid);
-	}
-	
-	while ($t_nodes = db_fetch_object($t_nodes_results)) {//check all translations
-		$t_nid=$t_nodes->nid;
-		if ($is_delta_exist) {
-		  $existing_field = 1;
-		  // get anonymous voting politics
-		  $field_anon = $field_name .'_anonymous';
-		  $anonymous = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d AND delta=%d", $field_anon, $table_content,$t_nid, $field_name_delta));
-		}
-		else {
-		  // get anonymous voting politics
-		  $field_anon = $field_name .'_anonymous';
-		  $anonymous = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d", $field_anon, $table_content, $t_nid));
-		}
-
-		// get user votes
-		if ($user->uid) {
-		  $result = db_query("SELECT delta from {pollfield_votes}
+  $tnid           = db_result(db_query("SELECT tnid FROM {node} WHERE nid=%d", $nid));
+  // there is no translation
+  if ($tnid == 0) {
+    $t_nodes_results = db_query("SELECT nid FROM {node} WHERE nid = %d", $nid);
+    // there is translation
+  }
+  else {
+    $t_nodes_results = db_query("SELECT nid FROM {node} WHERE tnid = %d", $tnid);
+  }
+
+  // check all translations
+  while ($t_nodes = db_fetch_object($t_nodes_results)) {
+    $t_nid = $t_nodes->nid;
+    if ($is_delta_exist) {
+      $existing_field = 1;
+      // get anonymous voting politics
+      $field_anon = $field_name .'_anonymous';
+      $anonymous = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d AND delta=%d", $field_anon, $table_content, $t_nid, $field_name_delta));
+    }
+    else {
+      // get anonymous voting politics
+      $field_anon = $field_name .'_anonymous';
+      $anonymous = db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d", $field_anon, $table_content, $t_nid));
+    }
+
+    // get user votes
+    if ($user->uid) {
+      $result = db_query("SELECT delta from {pollfield_votes}
 		    WHERE nid = %d AND field_table='%s' AND field_name='%s'AND uid = %d AND field_name_delta=%d",
-		    $t_nid, $field_table, $field_name, $user->uid, $field_name_delta);// delta is number of choice
-		  while ($db_votes = db_fetch_object($result)) {
-		    $votes[] = $db_votes->delta;
-		  }
-		}
-		// user is anonymous
-		else {
-		  if ($anonymous == 'anon_by_ip') {
-		    $result = db_query("SELECT delta from {pollfield_votes}
+        // delta is number of choice
+        $t_nid, $field_table, $field_name, $user->uid, $field_name_delta
+      );
+      while ($db_votes = db_fetch_object($result)) {
+        $votes[] = $db_votes->delta;
+      }
+    }
+    // user is anonymous
+    else {
+      if ($anonymous == 'anon_by_ip') {
+        $result = db_query("SELECT delta from {pollfield_votes}
 		      WHERE nid = %d AND field_table='%s' AND field_name='%s' AND hostname = '%s' AND field_name_delta=%d",
-		      $t_nid, $field_table, $field_name, $hostname, $field_name_delta);// delta is number of choice
-		    while ($db_votes = db_fetch_object($result)) {
-		      $votes[] = $db_votes->delta;
-		    }
-		  }
-		  if ($anonymous == 'anon_non') {
-		    // $voted = 0;
-		  }
-		  if ($anonymous == 'anon_all') {
-		    // $voted = 1;
-		  }
-		  if ($anonymous == 'anon_by_cookie') {
-		    // add cookie
-		    $cookie_name = $field_table .'_'. $field_name .'_'. $field_name_delta;
-		    $cookie_collected_value = $_COOKIE[$cookie_name];
+          // delta is number of choice
+          $t_nid, $field_table, $field_name, $hostname, $field_name_delta
+        );
+        while ($db_votes = db_fetch_object($result)) {
+          $votes[] = $db_votes->delta;
+        }
+      }
+      if ($anonymous == 'anon_non') {
+        // $voted = 0;
+      }
+      if ($anonymous == 'anon_all') {
+        // $voted = 1;
+      }
+      if ($anonymous == 'anon_by_cookie') {
+        // add cookie
+        $cookie_name = $field_table .'_'. $field_name .'_'. $field_name_delta;
+        $cookie_collected_value = $_COOKIE[$cookie_name];
 
-		    $cookie_compare = array('cookie_name' => $cookie_name, 'cookie_value' => $cookie_collected_value);
+        $cookie_compare = array('cookie_name' => $cookie_name, 'cookie_value' => $cookie_collected_value);
 
-		    $cookie_compare_db = serialize($cookie_compare);
+        $cookie_compare_db = serialize($cookie_compare);
 
-		    $result = db_query("SELECT delta from {pollfield_votes}
+        $result = db_query("SELECT delta from {pollfield_votes}
 		      WHERE nid = %d AND field_table='%s' AND field_name='%s' AND cookie = '%s' AND field_name_delta=%d",
-		      $t_nid, $field_table, $field_name, $cookie_compare_db, $field_name_delta);
-		    while ($db_votes = db_fetch_object($result)) {
-		      $votes[] = $db_votes->delta;
-		    }
-		  }
-		}
-	}
+          $t_nid, $field_table, $field_name, $cookie_compare_db, $field_name_delta
+        );
+        while ($db_votes = db_fetch_object($result)) {
+          $votes[] = $db_votes->delta;
+        }
+      }
+    }
+  }
   return $votes;
 }
+
 /**
-* clear cache function after vote is done
-*/
+ * clear cache function after vote is done
+ */
 function pollfield_clear($node) {
   $cid = 'content:'. $node->nid .':'. $node->vid;
   cache_clear_all($cid, db_table_exists('cache_content') ? 'cache_content' : 'cache', TRUE);
@@ -2170,18 +2223,15 @@ function pollfield_clear($node) {
 }
 
 /**
-* views query substition hook
-*/
-function pollfield_views_query_substitutions($view){
-
-	if (is_array($view->query->tables['node'])){
-	  if (array_key_exists('pollfield_votes',$view->query->tables['node'])){
-		   $replace['INNER JOIN {users} users ON node.uid = users.uid']="INNER JOIN {users} users ON pollfield_votes.uid = users.uid";
-	  }
+ * views query substition hook
+ */
+function pollfield_views_query_substitutions($view) {
+
+  if (is_array($view->query->tables['node'])) {
+    if (array_key_exists('pollfield_votes', $view->query->tables['node'])) {
+      $replace['INNER JOIN {users} users ON node.uid = users.uid'] = "INNER JOIN {users} users ON pollfield_votes.uid = users.uid";
+    }
   }
   return $replace;
 }
 
-
-
-
diff -urp pollfield/pollfield.views_default.inc pollfield_new/pollfield.views_default.inc
--- pollfield/pollfield.views_default.inc	2010-03-01 14:41:27.000000000 +0100
+++ pollfield_new/pollfield.views_default.inc	2010-08-08 10:14:27.085347962 +0200
@@ -1,4 +1,6 @@
 <?php
+// $Id$
+
 /**
  * @file
  * Contains default views on behalf of the node module.
@@ -7,9 +9,7 @@
 /**
  * Implementation of hook_default_view_views().
  */
-
 function pollfield_views_default_views() {
-	
   $view = new view;
   $view->name = 'pollfield_votes';
   $view->description = 'A list of all content, by letter.';
@@ -18,7 +18,7 @@ function pollfield_views_default_views()
   $view->base_table = 'node';
   $view->is_cacheable = '0';
   $view->api_version = 2;
-  $view->disabled = TRUE; // Edit this to true to make a default view disabled initially 
+  $view->disabled = TRUE; // Edit this to true to make a default view disabled initially
   $handler = $view->new_display('default', 'Defaults', 'default');
   $handler->override_option('fields', array(
     'delta' => array(
@@ -29,7 +29,7 @@ function pollfield_views_default_views()
       'field' => 'delta',
       'relationship' => 'none',
     ),
-		'nid' => array(
+    'nid' => array(
       'label' => 'Node ID',
       'exclude' => 1,
       'id' => 'nid',
@@ -37,7 +37,7 @@ function pollfield_views_default_views()
       'field' => 'nid',
       'relationship' => 'none',
     ),
-		'field_name_delta' => array(
+    'field_name_delta' => array(
       'label' => 'Pollfield ID',
       'exclude' => 1,
       'id' => 'field_name_delta',
@@ -53,7 +53,7 @@ function pollfield_views_default_views()
       'field' => 'question',
       'relationship' => 'none',
     ),
-		'field_table' => array(
+    'field_table' => array(
       'label' => 'Table',
       'exclude' => 1,
       'id' => 'field_table',
@@ -61,7 +61,7 @@ function pollfield_views_default_views()
       'field' => 'field_table',
       'relationship' => 'none',
     ),
-		'field_name' => array(
+    'field_name' => array(
       'label' => 'Field',
       'exclude' => 1,
       'id' => 'field_name',
@@ -69,7 +69,7 @@ function pollfield_views_default_views()
       'field' => 'field_name',
       'relationship' => 'none',
     ),
-		'name' => array(
+    'name' => array(
       'label' => 'Name',
       'exclude' => 0,
       'id' => 'name',
@@ -77,13 +77,11 @@ function pollfield_views_default_views()
       'field' => 'name',
       'relationship' => 'none',
     ),
-
   ));
-  
   $handler->override_option('access', array(
     'type' => 'none',
   ));
-	$handler = $view->new_display('page', 'Page', 'page');
+  $handler = $view->new_display('page', 'Page', 'page');
   $handler->override_option('path', 'pollfield_votes');
   $handler->override_option('menu', array(
     'type' => 'none',
@@ -103,9 +101,9 @@ function pollfield_views_default_views()
       'delta' => 'delta',
       'nid' => 'nid',
       'field_name_delta' => 'field_name_delta',
-			'question' => 'question',
-			'field_table' => 'field_table',
-			'name' => 'name',
+      'question' => 'question',
+      'field_table' => 'field_table',
+      'name' => 'name',
     ),
     'info' => array(
       'delta' => array(
@@ -120,7 +118,7 @@ function pollfield_views_default_views()
         'sortable' => 1,
         'separator' => '',
       ),
-			'question' => array(
+      'question' => array(
         'sortable' => 0,
         'separator' => '',
       ),
@@ -135,7 +133,7 @@ function pollfield_views_default_views()
     ),
     'default' => 'name',
   ));
-  
+
   $views[$view->name] = $view;
-	return $views;
+  return $views;
 }
diff -urp pollfield/pollfield.views.inc pollfield_new/pollfield.views.inc
--- pollfield/pollfield.views.inc	2010-03-01 14:41:27.000000000 +0100
+++ pollfield_new/pollfield.views.inc	2010-08-08 10:14:27.089347843 +0200
@@ -1,19 +1,22 @@
 <?php
+// $Id$
+
 /**
-*implementation hook_views_data
-*it takes form uid and join it with uid in user table 
-*/
+ * @file
+ * This file presents the implementation of hooks defined by Views module
+ */
 
-function pollfield_views_data(){
+/**
+ * Implementation of hook_views_data().
+ */
+function pollfield_views_data() {
   $data['pollfield_votes']['table']['group']  = t('Pollfield');
-  
   $data['pollfield_votes']['table']['join'] = array(
-   'node' => array(
-      'type' => 'INNER',      
+    'node' => array(
+      'type' => 'INNER',
       'left_field' => 'nid',
       'field' => 'nid',
-     ),
-    
+    ),
   );
   $data['pollfield_votes']['uid'] = array(
     'title' => t('User ID'),
@@ -21,7 +24,7 @@ function pollfield_views_data(){
     'field' => array(
       'handler' => 'views_handler_field_numeric',
       'click sortable' => TRUE,
-     ),
+    ),
     'filter' => array(
       'handler' => 'views_handler_filter_numeric',
     ),
@@ -29,13 +32,13 @@ function pollfield_views_data(){
       'handler' => 'views_handler_sort',
     ),
   );
-	$data['pollfield_votes']['nid'] = array(
+  $data['pollfield_votes']['nid'] = array(
     'title' => t('Node ID'),
     'help' => t('Node id of node where pollfield is placed.'),
     'field' => array(
       'handler' => 'views_handler_field_numeric',
       'click sortable' => TRUE,
-     ),
+    ),
     'filter' => array(
       'handler' => 'views_handler_filter_numeric',
     ),
@@ -49,7 +52,7 @@ function pollfield_views_data(){
     'field' => array(
       'handler' => 'views_handler_field_numeric',
       'click sortable' => TRUE,
-     ),
+    ),
     'filter' => array(
       'handler' => 'views_handler_filter_numeric',
     ),
@@ -57,95 +60,88 @@ function pollfield_views_data(){
       'handler' => 'views_handler_sort',
     ),
   );
-
-   $data['pollfield_votes']['field_name'] = array(
+  $data['pollfield_votes']['field_name'] = array(
     'title' => t('Field'),
     'help' => t('Name of field.'),
-
     'field' => array(
       'handler' => 'views_handler_field',
       'click sortable' => TRUE,
-     ),
-     'filter' => array(
+    ),
+    'filter' => array(
       'handler' => 'views_handler_filter_string',
-     ),
-     'argument' => array(
-       'handler' => 'views_handler_argument_string',
-     ),
-     'sort' => array(
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_string',
+    ),
+    'sort' => array(
       'handler' => 'views_handler_sort',
-     ),
+    ),
   );
-	$data['pollfield_votes']['field_table'] = array(
+  $data['pollfield_votes']['field_table'] = array(
     'title' => t('Content type'),
     'help' => t('Content type where pollfield is stored.'),
-
     'field' => array(
       'handler' => 'views_handler_field',
       'click sortable' => TRUE,
-     ),
-     'filter' => array(
+    ),
+    'filter' => array(
       'handler' => 'views_handler_filter_string',
-     ),
-     'argument' => array(
-       'handler' => 'views_handler_argument_string',
-     ),
-     'sort' => array(
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_string',
+    ),
+    'sort' => array(
       'handler' => 'views_handler_sort',
-     ),
+    ),
   );
-	$data['pollfield_votes']['question'] = array(
+$data['pollfield_votes']['question'] = array(
     'title' => t('Question'),
     'help' => t('Question of poll.'),
-
     'field' => array(
       'handler' => 'views_handler_field_pollfield_question',
       'click sortable' => TRUE,
-     ),
-     'filter' => array(
+    ),
+    'filter' => array(
       'handler' => 'views_handler_filter_string',
-     ),
-     'argument' => array(
-       'handler' => 'views_handler_argument_string',
-     ),
-     'sort' => array(
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_string',
+    ),
+    'sort' => array(
       'handler' => 'views_handler_sort',
-     ),
+    ),
   );
-  
   $data['pollfield_votes']['delta'] = array(
     'title' => t('Choice'),
     'help' => t('User choice.'),
-
     'field' => array(
       'handler' => 'views_handler_field_pollfield_delta',
       'click sortable' => TRUE,
-     ),
-     'filter' => array(
+    ),
+    'filter' => array(
       'handler' => 'views_handler_filter_string',
-     ),
-     'argument' => array(
-       'handler' => 'views_handler_argument_string',
-     ),
-     'sort' => array(
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_string',
+    ),
+    'sort' => array(
       'handler' => 'views_handler_sort',
-     ),
+    ),
   );
- 
-  
   return $data;
 }
+
 /**
-* hook alter data 
-*/
-function pollfield_views_data_alter(&$data){
-  
+ * Implementation of hook_views_data_alter().
+ */
+function pollfield_views_data_alter(&$data) {
+
 }
+
 /**
-* hook regsister handlers to views
-*/
+ * Implementation of hook_views_handlers().
+ */
 function pollfield_views_handlers() {
-  
   return array(
      'handlers' => array(
       'views_handler_field_pollfield_delta' => array(
@@ -157,5 +153,3 @@ function pollfield_views_handlers() {
     ),
   );
 }
-
-
diff -urp pollfield/views_handler_field_pollfield_delta.inc pollfield_new/views_handler_field_pollfield_delta.inc
--- pollfield/views_handler_field_pollfield_delta.inc	2010-02-06 02:12:40.000000000 +0100
+++ pollfield_new/views_handler_field_pollfield_delta.inc	2010-08-08 10:14:27.089347843 +0200
@@ -2,39 +2,33 @@
 // $Id: views_handler_field_pollfield_delta.inc,v 1.1.2.1 2010/02/06 01:12:40 marioprkos Exp $
 
 /**
+ * @file
  * Field handler to translate a node type into its readable form.
  */
-
 class views_handler_field_pollfield_delta extends views_handler_field {
   function render($values) {
-   
-    $number=$values->pollfield_votes_delta;
-		$nid=$values->pollfield_votes_nid;
-    $field_name_delta=$values->pollfield_votes_field_name_delta;
-    $field_name=$values->pollfield_votes_field_name;
+    $number = $values->pollfield_votes_delta;
+    $nid = $values->pollfield_votes_nid;
+    $field_name_delta = $values->pollfield_votes_field_name_delta;
+    $field_name = $values->pollfield_votes_field_name;
 
-		//get table information
-		$fields = content_fields();
+    // Get table information
+    $fields = content_fields();
     $db_info = content_database_info($fields[$field_name]);
     $table_content = $db_info['table'];
     $column_choice = $field_name ."_choice";
     $column_question = $field_name ."_question";
     $column = 'delta';
     $is_delta_exist = db_column_exists($table_content, $column);
-		//get question and choices
+
+    // Get question and choices
     if (!$is_delta_exist) {
-       
-			 $poll_choices=db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d",
-															$column_choice,$table_content,$nid));
+      $poll_choices = db_result(db_query("SELECT %s FROM {%s} WHERE nid = %d", $column_choice, $table_content, $nid));
+    }
+    else {
+      $poll_choices = db_result(db_query("SELECT %s FROM {%s} WHERE nid = %d AND delta = %d", $column_choice, $table_content, $nid, $field_name_delta));
     }
-		else{
-			 $poll_choices=db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d AND delta=%d",
-															$column_choice,$table_content,$nid,$field_name_delta));
-			
-		}
-		$choices=unserialize($poll_choices);
-		
-    
+    $choices=unserialize($poll_choices);
     return $choices[$number]['choice'];
   }
 }
diff -urp pollfield/views_handler_field_pollfield_question.inc pollfield_new/views_handler_field_pollfield_question.inc
--- pollfield/views_handler_field_pollfield_question.inc	2010-02-06 02:12:40.000000000 +0100
+++ pollfield_new/views_handler_field_pollfield_question.inc	2010-08-08 10:14:27.093350727 +0200
@@ -2,43 +2,36 @@
 // $Id: views_handler_field_pollfield_question.inc,v 1.1.2.1 2010/02/06 01:12:40 marioprkos Exp $
 
 /**
+ * @file
  * Field handler to translate a node type into its readable form.
  */
-
 class views_handler_field_pollfield_question extends views_handler_field {
   function query() {
-    
-    
+
   }
 
   function render($values) {
-    
-    $number=$values->pollfield_votes_delta;
-    $nid=$values->pollfield_votes_nid;
-    $field_name_delta=$values->pollfield_votes_field_name_delta;
-    $field_name=$values->pollfield_votes_field_name;
+    $number = $values->pollfield_votes_delta;
+    $nid = $values->pollfield_votes_nid;
+    $field_name_delta = $values->pollfield_votes_field_name_delta;
+    $field_name = $values->pollfield_votes_field_name;
 
-		//get table information
-		$fields = content_fields();
+    // Get table information
+    $fields = content_fields();
     $db_info = content_database_info($fields[$field_name]);
     $table_content = $db_info['table'];
     $column_choice = $field_name ."_choice";
     $column_question = $field_name ."_question";
     $column = 'delta';
     $is_delta_exist = db_column_exists($table_content, $column);
-		//get question and choices
+
+    // Get question and choices
     if (!$is_delta_exist) {
-       
-			 $poll_question=db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d",
-															$column_question,$table_content,$nid));
+      $poll_question=db_result(db_query("SELECT %s FROM {%s} WHERE nid = %d", $column_question, $table_content, $nid));
+    }
+    else {
+      $poll_question=db_result(db_query("SELECT %s FROM {%s} WHERE nid = %d AND delta = %d", $column_question, $table_content, $nid, $field_name_delta));
     }
-		else{
-			 $poll_question=db_result(db_query("SELECT %s FROM {%s} WHERE nid=%d AND delta=%d",
-															$column_question,$table_content,$nid,$field_name_delta));
-			
-		}
-	
     return $poll_question;
   }
 }
-
