// JavaScript Document


//Begin Jquery 
$(document).ready(function(){

	$("#fancontent").corner();
	$("#social").corner("bottom");
	$("#pbrtv").corner("bottom");
	$("#insidefeatures").corner("bottom");
	$("#pbrtvContent").corner("bottom");
	$("#centerContentTwo").corner();
	
	$("#bftstab").click(function () {
	  $('#wfcontent').hide();
      $("#bftscontent").show();
	  $("#wftab").removeClass("tab_on").addClass("tab_off").end();
	  $("#bftstab").removeClass("tab_off").addClass("tab_on").end();
    });
 	$("#wftab").click(function () {
	  $('#bftscontent').hide();
      $("#wfcontent").show();
	  $("#bftstab").removeClass("tab_on").addClass("tab_off").end();
	  $("#wftab").removeClass("tab_off").addClass("tab_on").end();
    });
 
 	$(".thumbnails").click(function () {
		$("#timer").stopTime();
	 // Gets the ID attribute of the item that was clicked						
	 var clicked_id = $(this).attr('id');
	 // Gets the ID attribute of the item that is the currently selected item
	 var current_id = $('#moreheadlines').find('.current').parent('div').attr('id');
	 //Hide the current content
	 $('#'+current_id+'-lead').hide();
	 $('#'+current_id+'-summary').hide();
	 $('#'+current_id+'-shadow').hide();
	 $('#'+current_id+'-image').hide();
	 // Changes the current class to other on the current img
	 $('#moreheadlines').find('.current').removeClass("current").addClass("other").end();
	 // Changes the other class to current on the clicked img
	 $("#"+clicked_id+' img').removeClass("other").addClass("current").end();
	 $('#'+clicked_id+'-lead').show();
	 $('#'+clicked_id+'-summary').show();
	 $('#'+clicked_id+'-shadow').show();
	 $('#'+clicked_id+'-image').show();
	 
    });
	
	 
	 $("#timer").everyTime("5s",function () {
										   
	
	// Gets the ID attribute of the item that was clicked						
	 var clicked_id = $('#timer').attr('class');
	 var current = clicked_id.replace('head','');
	  // Gets the ID attribute of the item that is the currently selected item
	 var current_id = (parseInt(current-1));
	 if(current_id ==0) {
	 	current_id=4;
	 }
	 
	 
	 var next = (parseInt(current)+1);
	 if(next > 4) {
		next=1; 
	 }

	 //Hide the current content
	 // Changes the current class to other on the current img
	 $('#head'+current_id+' img').removeClass("current").addClass("other")
	 $('#head'+current_id+'-lead').hide();
	 $('#head'+current_id+'-summary').hide();
	 $('#head'+current_id+'-shadow').hide();
	 $('#head'+current_id+'-image').hide();
	 // Changes the other class to current on the clicked img
	 $("#"+clicked_id+' img').removeClass("other").addClass("current").end();
	 $('#'+clicked_id+'-lead').show();
	 $('#'+clicked_id+'-summary').show();
	 $('#'+clicked_id+'-shadow').show();
	 $('#'+clicked_id+'-image').show();

	 $("#timer").removeClass("head"+current).addClass("head"+next).end();
	});

	$(".pollresults").click(function(){
		$("#blogs").hide();
		$("#polls").css("border", "none");

		var id = $(this).attr('id');
		var poll = id.replace('poll','');
		$.post("/ajax/poll.cfm", {pollid:poll},
		function(data){
			$("#polls ul").html(data);
  		}, "html");

	});
	$(".vote").click(function() {
		$("#blogs").hide();
		$("#polls").css("border", "none");
		var id = $(this).attr('id');
		var poll = id.replace('pollvote','');
		var answer = $(".answer:checked").val();
		$.post("/ajax/vote.cfm", {pollid:poll,answerid:answer},
		function(data){
			$("#polls ul").html(data);
  		}, "html");
	});
	$(".specvote").click(function() {
		var id = $(this).attr('id');
		var poll = id.replace('pollvote','');
		var answer = $(".answer:checked").val();
		$.post("/ajax/vote.cfm", {pollid:poll,answerid:answer},
		function(data){
			$("#specpolls ul").html(data);
  		}, "html");
	});
	

 //End Jquery Document.ready()
 });