 
  function toggleModule(modid,callback)
  {
    var temp = document.getElementById(modid+"body");
    var pic = document.getElementById(modid+"pic");
    if(temp.style.display == 'none')
    {
      pic.src = "/images/minus.gif";
    }
    else
    {
      pic.src = "/images/plus.gif";
    }
  }
  
  function saveEditedComment(id)
  {
    $("#edit_comment").attr("disabled",true);
    $("#edit_comment_button").attr("value","Saving Comment");
    xajax_saveEditedComment(id,$("#edit_comment").attr("value"));
    $(function() {
        $('.lightbox').lightBox();
    });
  }
  
  var fetch_comment = 0;
  var editing_comment = false;
  var old_edit_id = 0;
  
  function editComment(id)
  {
    if($('#edit_comment_id').val() > 0)
    {
      old_edit_id = $('#edit_comment_id').val();
      xajax_fetchComment(old_edit_id,0,"replace");
    }
    
    if(fetch_comment == 0)
    {
      fetch_comment = id;
      xajax_fetchComment(id,1);
    }
    editing_comment = true;
  }
  
  var quote_comment = 0;
  function quoteComment(comment_id)
  {
    if(quote_comment == 0)
    {
      quote_comment = comment_id;
      xajax_fetchComment(comment_id,1,"quote");
    }
  }
 
 var users_timer;
 var content_timer;
 var manage_timer;
 var characters_entered = 0;
 var saving_comment = 0;

  
  var got_emoticions = false;
  function showEmoticons()
  {
    if(!got_emoticions)
    {
      $('#emotebody').html("<img src='/images/loading.gif'> Fetching Emoticons....");
      xajax_getEmoticons();
    }
  }
  
  
  function insertAtCursor(myField, myValue) {
    myField = document.getElementById(myField);
    //IE support
    if (document.selection) {
    myField.focus();
    sel = document.selection.createRange();
    sel.text = myValue;
    }
    //MOZILLA/NETSCAPE support
    else if (myField.selectionStart || myField.selectionStart == '0') {
    var startPos = myField.selectionStart;
    var endPos = myField.selectionEnd;
    myField.value = myField.value.substring(0, startPos)
    + myValue
    + myField.value.substring(endPos, myField.value.length);
    } else {
    myField.value += myValue;
    }
  }
  
  function isdefined(variable)
  {
    return(typeof( window[ variable ] ) != "undefined");
  }
  
  var page_update_time = 30;
       
  function update_page()
	{
	   if(!isdefined("external_id") || editing_comment == true)
	   {
	     var external_id = '';
	   }
	   else
	   {
	     external_id = window[ "external_id" ];
	   }
     $('#index_archived_articles').fadeTo('fast',0);
     xajax_update_page(location.href,'2008-07-25 02:10:10',external_id);
     clearTimeout(users_timer);
	   users_timer = setTimeout("update_page()",page_update_time * 1000);
	}
  setTimeout("update_page()",page_update_time * 1000);
  
  
  function entering_comment(page)
	{
	   characters_entered++;
	   if(characters_entered%50==1)
	   {
	     xajax_entering_comment(page);
	   }
	}
	
	var at_a_glance = false;
	var myspace_picture_height = 0;
  $(document).ready(function(){
   $("div.moduletitle").toggle(function(){
     $(this).siblings().animate({ height: 'toggle', opacity: 'hide' }, 'slow');
   },function(){ 
     $(this).siblings().animate({ height: 'toggle', opacity: 'show' }, 'slow');
   });
      $("#emotetitle").click(function(){
		  showEmoticons();
	 });
   $("#glancetitle").click(function(){
      if(!at_a_glance)
      {
		    xajax_AtAGlanceModuleOnClick();
		  }
	 });
 });
 
 
 
function show_my_file()
{
  if($("#my_files").val() != '')
  {
    xajax_fetch_my_file($("#my_files").val());
  }
  else
  {
    $("#show_my_file").html("Choose a file you've uploaded to see a preview.");
  }
}
 
function addFile()
{
  if($("#my_files").val() != '')
  {
    insertAtCursor('comment_box', "[file id='"+$("#my_files").val()+"']");
  }
}
    
function refresh_files()
{
  xajax_files_dropdown()
}

function makePick(game,team)
{
  xajax_savepick(game,team);
}

function keypressed(comment)
{
  	$('#comment_' + comment + '_status').html("<button onclick=\"saveNFLPickComment('" +comment+ "')\">Save Changes</button>");
}

function saveNFLPickComment(comment)
{
  xajax_saveNFLPickComment(comment, document.getElementById('comment_' + comment).value);
  $('#comment_' + comment + '_status').html("&nbsp;");
}

function get_help(week,game_id)
{
  $('#help_week_'+week).html('Fetching Team Data...');
  xajax_get_game_help(game_id);
}

function fetch_graphs()
{
  xajax_fetch_graphs($('#displaydate').val());
}


function ratings_over(name,number)
{
  var temp = "";
  for(var i = 0; i<=5; i++)
  {
    temp = "";
    
    if(i == 0)
    {
      temp += "zero";
      
      if(number==0)
      {
        temp += "full";
      } 
      else
      {
        temp += "empty";
      } 
      
    }
    else
    {
      if(i <= number)
      {      
        temp += "full";
      }
      else
      {
        temp += "empty";
      }
    }
    $('#rating_'+name+'_'+i).attr('src','/themes/default/ratings/'+temp+'.gif');
  }
}

var rating_saving = 0;    
function save_rating(name,rating)
{
  if(rating_saving == 0)
  {
    rating_saving = 1;
    xajax_saveRating(name,rating);
  }
}

function ratings_out(name, old)
{
  var temp;
  var type;
  //alert(name + ' ' + old);
  if(old=='')
  {
    old="0";
  }
  else
  {
    old++;
  }
  
  for(var i = 0; i<=5; i++)
  {
    temp = '';
    if(i==0)
    {
      temp = 'zero';
      
      if(old==1)
      {
        type = "full";
      } 
      else
      {
        type = "empty";
      } 
    }
    else
    {
      if(old>=1)
      {
        type='full';
      }
      else if(old==.5)
      {
        type='half';
      }
      else
      {
        type='empty';
      }
    }
    $('#rating_'+name+'_'+i).attr('src','/themes/default/ratings/'+temp+type+'.gif');
    old--;
  }
}

$(function() {
    $('.lightbox').lightBox();
});
   
