// JavaScript Document

//Begin Jquery 
$(document).ready(function(){
	
	 //draw/results table sorting
	/*$('#results1').dataTable( {
		"bInfo": false,
		"iDisplayLength": 50,
		"bLengthChange": false,
		"aaSorting": [[3, 'desc']]
	});
	$('#bullList').dataTable( {
		"bInfo": false,
		"iDisplayLength": 55,
		"bLengthChange": false,
		"asStripClasses": [ 'light', 'dark' ],
		"aaSorting": [[0, 'asc']],
		"bFilter": false
	});*/
	 //var count = document.getElementsByTagName('*').length;
	 //alert(count);
	//Rounded Corners
	//$("#specpolls").corner();
	//$(".pane").corner();
	//$(".panelinks").corner();
	//$("#contacts").corner("cc:#222425")
	//$("#voicecontent").corner();
	//$("#riderswrap").corner();
	//$("#bullswrap").corner();
	//$(".image").corner();
	//$("#riderbullinfo").corner();
	//$(".righthead").corner();
	//$("#bottombanners").corner();
	//$('#countercorner').corner();
	//$('#whContent').corner("7px");
	//$('#nextevent').corner("7px");
	
	
	$('#defaultCountdown').countdown({
    until: new Date("October 20, 2010 19:00:00")}); 
	
	
	/*$("#statslink1").click(function() {
		
		$("#hpstats1").toggle();
		$("#rider2").toggle();
		if($("#statslink1").html() == "Hide Stats") {
			$("#statslink1").html("View Stats");
		} else {
			$("#statslink1").html("Hide Stats");
		}
		
	});*/
	
	$("#nextBFTS").click(function() {
		$("#nxtevent").show();
		$("#wfhpevent").hide();
  	});
	
	$("#wfev").click(function() {
		$("#wfhpevent").show();
		$("#nxtevent").hide();
  	});
	
	/*$("#pbrtvPromo").click(function() {
		$("#pbrtv").show();
		$("#fantasy").hide();
	});
	$("#fantasyPromo").click(function() {
		$("#pbrtv").hide();
		$("#fantasy").show();
	});*/
	
	/*$("#statslink2").click(function() {
		
		$("#hpstats2").toggle();
		$("#rider1").toggle();
		if($("#statslink2").html() == "Hide Stats") {
			$("#statslink2").html("View Stats");
		} else {
			$("#statslink2").html("Hide Stats");
		}
	});
	$("#bullstatslink1").click(function() {
		
		$("#hpbullsstats1").toggle();
		$("#bull2").toggle();
		if($("#bullstatslink1").html() == "Hide Stats") {
			$("#bullstatslink1").html("View Stats");
		} else {
			$("#bullstatslink1").html("Hide Stats");
		}
		
	});
	$("#bullstatslink2").click(function() {
		
		$("#hpbullsstats2").toggle();
		$("#bull1").toggle();
		if($("#bullstatslink2").html() == "Hide Stats") {
			$("#bullstatslink2").html("View Stats");
		} else {
			$("#bullstatslink2").html("Hide Stats");
		}
		
	});
	
*/
	
 	//These Functions handle the VideoPhoto Tabs 
 	$("#videotab").click(function () {
	  $('#pContent').hide();						
      $("#vContent").show();
	  $("#videotab").removeClass("tab_off").addClass("tab_on").end();
	  $("#phototab").removeClass("tab_on").addClass("tab_off").end();
    });
	$("#phototab").click(function () {
	  $('#vContent').hide();
      $("#pContent").show();
	  $("#videotab").removeClass("tab_on").addClass("video_off").end();
	  $("#phototab").removeClass("tab_off").addClass("tab_on").end();
    });
	
	
	$("#resultslabel").click(function () {
	  $('#standings').hide();
      $("#results").show();
	  $("#bftstab").removeClass("tab_off").addClass("tab_on").end();
	  $("#bftsrescontent").show();
    });
	$("#standingslabel").click(function () {
	  $('#results').hide();
      $("#standings").show();
    });
	
	$("#schedulelabel").click(function () {
	  $('#injury').hide();
      $("#schedule").show();
    });
	$("#injurylabel").click(function () {
	  $('#schedule').hide();
      $("#injury").show();
    });
	
	
	
	
	//Standings Area
 	$("#bftstab").click(function () {
	  $('#challengercontent').hide();
	  $('#qualifiercontent').hide();
      $("#bftscontent").show();
	  $("#qualifiertab").removeClass("tab_on").addClass("tab_off").end();
	  $("#challengertab").removeClass("tab_on").addClass("tab_off").end();
	  $("#bftstab").removeClass("tab_off").addClass("tab_on").end();
    });
 	$("#challengertab").click(function () {
	  $('#bftscontent').hide();
	  $('#qualifiercontent').hide();
      $("#challengercontent").show();
	  $("#qualifiertab").removeClass("tab_on").addClass("tab_off").end();
	  $("#bftstab").removeClass("tab_on").addClass("tab_off").end();
	  $("#challengertab").removeClass("tab_off").addClass("tab_on").end();
    });
 	$("#qualifiertab").click(function () {
	  $('#bftscontent').hide();
	  $('#challengercontent').hide();
      $("#qualifiercontent").show();
	  $("#challengertab").removeClass("tab_on").addClass("tab_off").end();
	  $("#bftstab").removeClass("tab_on").addClass("tab_off").end();
	  $("#qualifiertab").removeClass("tab_off").addClass("tab_on").end();
    });
	
 	$("#bftsrtab").click(function () {
	  $('#challengerrescontent').hide();
	  $('#entrescontent').hide();
      $("#bftsrescontent").show();
	  $("#entrtab").removeClass("tab_on").addClass("tab_off").end();
	  $("#challengerrtab").removeClass("tab_on").addClass("tab_off").end();
	  $("#bftsrtab").removeClass("tab_off").addClass("tab_on").end();
    });
 	$("#challengerrtab").click(function () {
	  $('#bftsrescontent').hide();
	  $('#entrescontent').hide();
      $("#challengerrescontent").show();
	  $("#entrtab").removeClass("tab_on").addClass("tab_off").end();
	  $("#bftsrtab").removeClass("tab_on").addClass("tab_off").end();
	  $("#challengerrtab").removeClass("tab_off").addClass("tab_on").end();
    });
 	$("#entrtab").click(function () {
	  $('#bftsrescontent').hide();
	  $('#challengerrescontent').hide();
      $("#entrescontent").show();
	  $("#challengerrtab").removeClass("tab_on").addClass("tab_off").end();
	  $("#bftsrtab").removeClass("tab_on").addClass("tab_off").end();
	  $("#entrtab").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");
	});
	
	$("#rbTabs").tabs();
	$("#vidphoto").tabs();

//End Jquery Document.ready()
 });