--- pollfield.module.orig	2009-09-14 14:51:16.000000000 -0500
+++ pollfield.module	2009-09-14 16:37:31.000000000 -0500
@@ -84,224 +84,233 @@
  * @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'];
-	//adding up the results
-	$show_form = true;
-	$choices= unserialize($items['choice']);
-	
-	$votes=array();$choices_array=array();
+    global $user;
+    $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
+    $show_form = false;
+    $choices= unserialize($items['choice']);
+
+    $votes=array();$choices_array=array();
     if (!empty($choices)){
-		foreach ($choices as $delta => $choice) {
+	foreach ($choices as $delta => $choice) {
 		
-			if (!empty($choice['choice'])){
-				$choices_array[] = check_plain($choice['choice']);
-				$count = db_result(db_query("SELECT count(*) FROM {pollfield_votes} WHERE nid = %d AND delta=%d 
+	    if (!empty($choice['choice'])){
+		$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 
 				AND field_table='%s' AND field_name='%s' AND field_name_delta=%d",
-				$node->nid, $delta,$type,$field,$field_name_delta));
-				$votes[]=$count+$choice['votes'];
-				$sum=$sum+$count+$choice['votes'];//countig all votes
+					    $node->nid, $delta,$type,$field,$field_name_delta));
+		$votes[]=$count+$choice['votes'];
+		$sum=$sum+$count+$choice['votes'];//countig all votes
 			
-			}
-		}
+	    }
 	}
-	//dpm($votes);dpm($coices_array);
-	//geting results
-	$i=0;
-	$poll_result="<div id='pollfield' class='pollfiedl_results'>";
-	//print_r($choices_array);
-	while (!empty($choices_array[$i]) && $sum>0){
-		$percent=floatval(($votes[$i]*100.0)/$sum);
-		$percent=round($percent,1);
-		//$votes[$i]=$percent;
-		$percent_string=$percent."% (".$votes[$i]." ".t('votes').")";
-		$poll_result.="<div class='pollfield-row'><div class='text'>".$choices_array[$i]."</div><div class='barcell'>
+    }
+    //dpm($votes);dpm($coices_array);
+    //geting results
+    $i=0;
+    $poll_result="<div id='pollfield' class='pollfield_results'>";
+    //print_r($choices_array);
+    while (!empty($choices_array[$i]) && $sum>0){
+	$percent=floatval(($votes[$i]*100.0)/$sum);
+	$percent=round($percent,1);
+	//$votes[$i]=$percent;
+	$percent_string=$percent."% (".$votes[$i]." ".t('votes').")";
+	$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>";
-		$i++;
-	}
-	
-	$poll_result.="</div>";	
-	if ($show_form) {
-		$form = pollfield_voting_form($element);
-		$out = '<div class="pollfield-form">';
+	    $percent_string."</div></div>";
+	$i++;
+    }
+	
+    $poll_result.="</div>";	
+    if ($show_form) {
+	$form = pollfield_voting_form($element);
+	$out = '<div class="pollfield-form">';
         
         if ($element['#item']['question']!="' '")
-			$out .= '<div class="pollfield-title">'.$element['#item']['question'].'</div>';
+	    $out .= '<div class="pollfield-title">'.$element['#item']['question'].'</div>';
 	
-		$out .= $form;
-		$out .= $poll_result;
-		$out .= '</div>';
-		return $out;
-  } 
+	$out .= $form;
+	$out .= $poll_result;
+	$out .= '</div>';
+	return $out;
+    } 
   
 }
 
 
 function theme_pollfield_formatter_results($element) {
-  // todo and other formattings
+    // todo and other formattings
  
-  global $user;
-	$items      = $element['#item'];
-	$node       = $element['#node'];
-	$type=$element['#type_name'];
-	$field=$element['#field_name'];
-	//adding up the results
-	$show_form = true;
-	$choices= unserialize($items['choice']);
+    global $user;
+    $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 
+    // at least one choice configured
+    $show_form = false;
+    $choices= unserialize($items['choice']);
 	
 	
-	$votes=array();$choices_array=array();
+    $votes=array();$choices_array=array();
     if (!empty($choices)){
-		foreach ($choices as $delta => $choice) {
-		
-			if (!empty($choice['choice'])){
-				$choices_array[] = check_plain($choice['choice']);
-				$count = db_result(db_query("SELECT count(*) FROM {pollfield_votes} WHERE nid = %d AND delta=%d 
+	foreach ($choices as $delta => $choice) {
+	    if (!empty($choice['choice'])){
+		$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 
 				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'];
+		$sum=$sum+$count+$choice['votes'];//countig all votes
+	    }
 	}
+    }
 	
-	//geting results
-	$i=0;
-	$poll_result="<div id='pollfield' class='pollfiedl_results'>";
-	
-	while (!empty($choices_array[$i]) && $sum>0){
-		$percent=floatval(($votes[$i]*100.0)/$sum);
-		$percent=round($percent,1);
-		//$votes[$i]=$percent;
-		$percent_string=$percent."% (".$votes[$i]." ".t('votes').")";
-		$poll_result.="<div class='pollfield-row'><div class='text'>".$choices_array[$i]."</div><div class='barcell'>
+    //geting results
+    $i=0;
+    $poll_result="<div id='pollfield' class='pollfield_results'>";
+	
+    while (!empty($choices_array[$i]) && $sum>0){
+	$percent=floatval(($votes[$i]*100.0)/$sum);
+	$percent=round($percent,1);
+	//$votes[$i]=$percent;
+	$percent_string=$percent."% (".$votes[$i]." ".t('votes').")";
+	$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>";
-		$i++;
-	}
-
-	$poll_result.="</div>";	
-	if ($show_form) {
-		$form = pollfield_voting_form($element);
-		$out = '<div class="pollfield-form">';
-		$out .= $poll_result;
-		$out .= '</div>';
-		
-		return $out;
-  } 
+	    $percent_string."</div></div>";
+	$i++;
+    }
+
+    $poll_result.="</div>";	
+    if ($show_form) {
+	$form = pollfield_voting_form($element);
+	$out = '<div class="pollfield-form">';
+	$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'];
-	$field=$element['#field_name'];
-	//adding up the results
-	$show_form = true;
-	$choices= unserialize($items['choice']);
+    $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 
+    // at least one choice configured
+    $show_form = false;
+    $choices= unserialize($items['choice']);
 	
 	
-	$votes=array();$choices_array=array();
+    $votes=array();$choices_array=array();
     if (!empty($choices)){
-		foreach ($choices as $delta => $choice) {
+	foreach ($choices as $delta => $choice) {
 		
-			if (!empty($choice['choice'])){
-				$choices_array[] = check_plain($choice['choice']);
-				$count = db_result(db_query("SELECT count(*) FROM {pollfield_votes} WHERE nid = %d AND delta=%d 
+	    if (!empty($choice['choice'])){
+		$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 
 				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'];
+		$sum=$sum+$count+$choice['votes'];//countig all votes
 			
-			}
-		}
+	    }
 	}
+    }
 	
-	//geting results
-	$i=0;
-	$poll_result="<div id='pollfield' class='pollfiedl_results'>";
-	
-	while (!empty($choices_array[$i]) && $sum>0){
-		$percent=floatval(($votes[$i]*100.0)/$sum);
-		$percent=round($percent,1);
-		//$votes[$i]=$percent;
-		$percent_string=$percent."% (".$votes[$i]." ".t('votes').")";
-		$poll_result.="<div class='pollfield-row'><div class='text'>".$choices_array[$i]."</div>";
-		$i++;
-	}
-
-	$poll_result.="</div>";	
-	if ($show_form) {
-		$form = pollfield_voting_form($element);
-		$out = '<div class="pollfield-form">';
-		$out .= $poll_result;
-		$out .= '</div>';
+    //geting results
+    $i=0;
+    $poll_result="<div id='pollfield' class='pollfield_results'>";
+	
+    while (!empty($choices_array[$i]) && $sum>0){
+	$percent=floatval(($votes[$i]*100.0)/$sum);
+	$percent=round($percent,1);
+	//$votes[$i]=$percent;
+	$percent_string=$percent."% (".$votes[$i]." ".t('votes').")";
+	$poll_result.="<div class='pollfield-row'><div class='text'>".$choices_array[$i]."</div>";
+	$i++;
+    }
+
+    $poll_result.="</div>";	
+    if ($show_form) {
+	$form = pollfield_voting_form($element);
+	$out = '<div class="pollfield-form">';
+	$out .= $poll_result;
+	$out .= '</div>';
 		
-		return $out;
-  } 
+	return $out;
+    } 
   
   
 }
 
 function theme_pollfield_formatter_question($element) {
-  	// todo and other formattings
+    // todo and other formattings
 
-	global $user;
-	$items      = $element['#item'];
-	$node       = $element['#node'];
-	$type=$element['#type_name'];
-	$field=$element['#field_name'];
-	//adding up the results
-	$show_form = true;
-	$choices= unserialize($items['choice']);
+    global $user;
+    $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 
+    // at least one choice configured
+    $show_form = false;
+    $choices= unserialize($items['choice']);
 	
 	
-	$votes=array();$choices_array=array();
+    $votes=array();$choices_array=array();
     if (!empty($choices)){
-		foreach ($choices as $delta => $choice) {
-		
-			if (!empty($choice['choice'])){
-				$choices_array[] = check_plain($choice['choice']);
-				$count = db_result(db_query("SELECT count(*) FROM {pollfield_votes} WHERE nid = %d AND delta=%d 
+	foreach ($choices as $delta => $choice) {
+	    if (!empty($choice['choice'])){
+		$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 
 				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'];
+		$sum=$sum+$count+$choice['votes'];//countig all votes
 			
-			}
-		}
+	    }
 	}
+    }
 	
-	//geting results
-	$i=0;
-	$poll_result="<div id='pollfield' class='pollfiedl_results'>";
-	
-	while (!empty($choices_array[$i]) && $sum>0){
-		$percent=floatval(($votes[$i]*100.0)/$sum);
-		$percent=round($percent,1);
-		//$votes[$i]=$percent;
-		$percent_string=$percent."% (".$votes[$i]." ".t('votes').")";
-		$poll_result.="<div class='pollfield-row'><div class='text'>".$choices_array[$i]."</div><div class='barcell'>
+    //geting results
+    $i=0;
+    $poll_result="<div id='pollfield' class='pollfield_results'>";
+	
+    while (!empty($choices_array[$i]) && $sum>0){
+	$percent=floatval(($votes[$i]*100.0)/$sum);
+	$percent=round($percent,1);
+	//$votes[$i]=$percent;
+	$percent_string=$percent."% (".$votes[$i]." ".t('votes').")";
+	$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>";
-		$i++;
-	}
-
-	$poll_result.="</div>";	
-	if ($show_form) {
-		$out = '<div class="pollfield-form">';
+	    $percent_string."</div></div>";
+	$i++;
+    }
+
+    $poll_result.="</div>";	
+    if ($show_form) {
+	$out = '<div class="pollfield-form">';
         
         if ($element['#item']['question']!="' '")
-			$out .= '<div class="pollfield-title">'.$element['#item']['question'].'</div>';
-		$out .= '</div>';
+	    $out .= '<div class="pollfield-title">'.$element['#item']['question'].'</div>';
+	$out .= '</div>';
 		
-		return $out;
-  } 
+	return $out;
+    } 
   
 }
 
@@ -309,54 +318,54 @@
     // todo and other formattings
     
     global $user;
-	$items      = $element['#item'];
-	$node       = $element['#node'];
-	$type=$element['#type_name'];
-	$field=$element['#field_name'];
-	//adding up the results
-	$show_form = true;
-	$choices= unserialize($items['choice']);
+    $items      = $element['#item'];
+    $node       = $element['#node'];
+    $type=$element['#type_name'];
+    $field=$element['#field_name'];
+    //adding up the results
+    $show_form = false;
+    $choices= unserialize($items['choice']);
 	
 	
-	$votes=array();$choices_array=array();
+    $votes=array();$choices_array=array();
     if (!empty($choices)){
-		foreach ($choices as $delta => $choice) {
-		
-			if (!empty($choice['choice'])){
-				$choices_array[] = check_plain($choice['choice']);
-				$count = db_result(db_query("SELECT count(*) FROM {pollfield_votes} WHERE nid = %d AND delta=%d 
+	foreach ($choices as $delta => $choice) {
+	    if (!empty($choice['choice'])){
+		$show_form = false;
+		$choices_array[] = check_plain($choice['choice']);
+		$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'];
+		$sum=$sum+$count+$choice['votes'];//countig all votes
 			
-			}
-		}
+	    }
 	}
-	//dpm($votes);dpm($coices_array);
-	//geting results
-	$i=0;
-	$poll_result="<div id='pollfield' class='pollfiedl_results'>";
-	
-	while (!empty($choices_array[$i]) && $sum>0){
-		$percent=floatval(($votes[$i]*100.0)/$sum);
-		$percent=round($percent,1);
-		//$votes[$i]=$percent;
-		$percent_string=$percent."% (".$votes[$i]." ".t('votes')." )";
-		$poll_result.="<div class='pollfield-row'><div class='text'>".$choices_array[$i]."</div><div class='barcell'>
+    }
+    //dpm($votes);dpm($coices_array);
+    //geting results
+    $i=0;
+    $poll_result="<div id='pollfield' class='pollfield_results'>";
+	
+    while (!empty($choices_array[$i]) && $sum>0){
+	$percent=floatval(($votes[$i]*100.0)/$sum);
+	$percent=round($percent,1);
+	//$votes[$i]=$percent;
+	$percent_string=$percent."% (".$votes[$i]." ".t('votes')." )";
+	$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>";
-		$i++;
-	}
-
-	$poll_result.="</div>";	
-	if ($show_form) {
-		
-		$out = '<div class="pollfield-form">';
-		$out .= '<div class="pollfield-title">'.$element['#item']['runtime'].'</div>';
-		$out .= '</div>';
+	    $percent_string."</div></div>";
+	$i++;
+    }
+
+    $poll_result.="</div>";	
+    if ($show_form) {
+		
+	$out = '<div class="pollfield-form">';
+	$out .= '<div class="pollfield-title">'.$element['#item']['runtime'].'</div>';
+	$out .= '</div>';
 		
-		return $out;
-  } 
+	return $out;
+    } 
   
 }
 
@@ -673,11 +682,10 @@
 * Implementation of hook_content_is_empty().
 */
 function pollfield_content_is_empty($item, $field) {
- 
   if(empty($item['question'])) {
-	
     return TRUE;
   }
+
   return FALSE;
 }
 
@@ -1034,7 +1042,7 @@
 			drupal_set_message(t('Your vote was recorded.'));
 		  }
 		  else {
-			drupal_set_message(t("You allready voted or your are not allowed to vote"), 'error');
+			drupal_set_message(t("You already voted or your are not allowed to vote"), 'error');
 		  }
 	}
 	
