// JavaScript Document
$(document).ready(function(){
	$("#vote_yes").click(function(){
		votevalue=$("#vote_yes").val();	
  		$.ajax({
  		type:"GET",  
  		url:"vote.php",
		data:"voteid="+votevalue+"&isyes=1",
  		dataType:"json",
  		success:function(msg){
			$("#vote_yes_div").html('');$("#vote_no_div").html('');
  			bar_y="<img src='images/bar_amex_y.gif' width='"+msg.y_p+"%'   height='4'>";
			bar_n="<img src='images/bar_amex_y.gif' width='"+msg.no_p+"%'   height='4'>";
			yes_img="<img src='images/btn_yes_s.gif' border='0'>";
			no_img="<img src='images/btn_no_s.gif' border='0'>";
			re="<a href='vote_list.php'>Step 2: for Archives (view past results).....Click Here</a>";
			$("#yes_image").html(yes_img);
			$("#no_image").html(no_img);
			$("#image_y").html(bar_y);
			$("#image_n").html(bar_n);
			$("#div_y").html(msg.y_p);
			$("#div_n").html(msg.no_p);
			$("#past_r").html(re);
  		}
  	});	
  });	
	$("#vote_no").click(function(){
		votevalue=$("#vote_no").val();	
  		$.ajax({
  		type:"GET",  
  		url:"vote.php",
		data:"voteid="+votevalue+"&isyes=0",
  		dataType:"json",
  		success:function(msg){
			$("#vote_yes_div").html('');$("#vote_no_div").html('');
  			bar_y="<img src='images/bar_amex_y.gif' width='"+msg.y_p+"%'   height='4'>";
			bar_n="<img src='images/bar_amex_n.gif' width='"+msg.no_p+"%'   height='4'>";
			yes_img="<img src='images/btn_yes_s.gif' border='0'>";
			no_img="<img src='images/btn_no_s.gif' border='0'>";
			re="<a href='vote_list.php'>Step 2: for Archives (view past results).....Click Here</a>";
			$("#yes_image").html(yes_img);
			$("#no_image").html(no_img);
			$("#image_y").html(bar_y);
			$("#image_n").html(bar_n);
			$("#div_y").html(msg.y_p);
			$("#div_n").html(msg.no_p);
			$("#past_r").html(re);
  		}
  	});	
  });	 
   if(parseInt(row)>0){
  		votevalue=$("#vote_yes").val();	
  		$.ajax({
  		type:"GET",  
  		url:"vote.php",
		data:"voteid="+votevalue+"&isyes=1",
  		dataType:"json",
  		success:function(msg){
			$("#vote_yes_div").html('');$("#vote_no_div").html('');
  			bar_y="<img src='images/bar_amex_y.gif' width='"+msg.y_p+"%'   height='4'>";
			bar_n="<img src='images/bar_amex_y.gif' width='"+msg.no_p+"%'   height='4'>";
			yes_img="<img src='images/btn_yes_s.gif' border='0'>";
			no_img="<img src='images/btn_no_s.gif' border='0'>";
			re="<a href='vote_list.php'>Step 2: for Archives (view past results).....Click Here</a>";
			$("#yes_image").html(yes_img);
			$("#no_image").html(no_img);
			$("#image_y").html(bar_y);
			$("#image_n").html(bar_n);
			$("#div_y").html(msg.y_p);
			$("#div_n").html(msg.no_p);
			$("#past_r").html(re);


  		}
  	});	
  }
});