function setVideo(title, url)
{
	var flash = document.getElementById( "forestsandfish" );
	if ( flash )
	{
		flash.setVideo("&#8220;" + title + "&#8221;", url);
	}
	
	$('#watchCommercial').css("display","block");
}


$(document).ready(function()
{
	//$(".box").hover( over, out );
	
	$(".box").mouseover( function()
	{
		var $description = $(".description", $(this) );
		$description.css("display","block");
	});
	
	$(".box").mouseout( function()
	{
		var $description = $(".description", $(this) );
		$description.css("display","none");
	});
	
	
	// POLL
	$("#poll #buttons input").click(function(){
	  
	  var id = ( this.value.toLowerCase() == "agree") ? 1 : 2;
	  
	  pageTracker._trackPageview("mostnaturalresource.com/poll/public_policy/" + this.value.toLowerCase());
  
	  $.getJSON("poll/poll.php?vote=" + id, poll_results );
	  
	});
	
});

// DB column numbers
var OPT_ID = 0;
var OPT_TITLE = 1;
var OPT_VOTES = 2;
var MAX_BAR_WIDTH = 150;
function poll_results(data) {
  // console.log( data );
  
  $("#buttons").hide();
  $("#results").fadeIn();
  
  
  var total_votes = 0;
  var percent;
  var bar_width;
  var title;
  
  for (id in data) {
    total_votes = total_votes+parseInt(data[id][OPT_VOTES]);
  }
  // console.log("total votes: " + total_votes);
  
  var results_html = "<div id='poll-results'><h3>Poll Results</h3>\n<dl class='graph'>\n";
  for (id in data) {
    percent = (parseInt(data[id][OPT_VOTES])/parseInt(total_votes));
    title = data[id][OPT_TITLE];

    
    bar_width = percent * MAX_BAR_WIDTH;
  
    $("#results ." + title).animate({ borderLeftWidth: bar_width + "px" }, 'slow');
    
    $("#results ." + title + " .percent").text( Math.round(percent * 100) + "%" );
    
  }
  
  // $("#results .agree").animate({ borderLeftWidth: "100px" }, 600);
  // $("#results .disagree").animate({ borderLeftWidth: "150px" }, 600);
  
}


function over(e)
{
	alert(e.target.className)
	$(e.target).children("div").css("display","block");
		
	//$(this).children(".description div").hide();
	
}
function out(e)
{
	$(e.target).children("div").css("display","none");
	
	//var thisId = ($(this).children("a").attr('id'));
	//if (thisId != currentLinkId) $(this).removeClass("active");
}


/*function over(e)
{
	$(e.target).children("div").animate({ bottom: 0 }, 100 );
		
	//$(this).children(".description div").hide();
	
	console.log( $(e.target).children("div.description") );


}
function out(e)
{
	$(e.target).children("div").animate({ bottom: -118 }, 100 );
	//var thisId = ($(this).children("a").attr('id'));
	//if (thisId != currentLinkId) $(this).removeClass("active");
}*/
