var MyTextArea = 0

function OpenWindow(url, width, height, windowname)
  {
  window.open(url, windowname, 'dependent=0,width='+width+',height='+height+',menubar=0,resizable=0,status=0,toolbar=0,scrollbars=1');
  }
  
function ShowComments(section, id)
  {
  window.open('/comments/' + section + '/' + id, '_blank', 'dependent=0,width=520,height=400,menubar=0,resizable=0,status=0,toolbar=0,scrollbars=1');
  }
   
    
function AddStuff(id, object)
  {
  if (object == 'Friend') { subject = 'Member'; list = 'Friends'; }
  else { subject = object; list = 'Favorites'; }
  alert(subject + ' has beed added to your ' + list.toLowerCase() + ' list.')
  document.getElementById('add_' + object.toLowerCase()).innerHTML = '<a href="/' + subject.toLowerCase() + '/' + id + '/remove" onclick="RemoveStuff(' + id + ', \'' + object + '\')">Remove from ' + list + '</a>'    
  }
  
function RemoveStuff(id, object)
  {
  if (confirm('Are you sure?'))
    {
    if (object == 'Friend') { subject = 'Member'; list = 'Friends'; }
    else { subject = object; list = 'Favorites'; }
    alert(subject + ' has beed removed from your ' + list.toLowerCase() + ' list.')
    document.getElementById('add_' + object.toLowerCase()).innerHTML = '<a href="/' + subject.toLowerCase() + '/' + id + '/add" onclick="AddStuff(' + id + ', \'' + object + '\')">Add to ' + list + '</a>'    
    }
  else { return false; }
  }
  
function RecommendStuff(id, object)
  {
  ojbect = object.toLowerCase();
  if (confirm('Are you sure you want to recommend this for the following award?\n"' + award_poll_name + '"'))
    {
    alert('You have recommended this ' + object + ' for an award.');
    document.getElementById('recommend_' + object).innerHTML = '';
    return true;
    }
  else { return false; }
  }
  
function SelectAll(formname, fieldname, truefalse, min, max)
  {
  for (var i = min; i <= max; i++) 
    {
    if (typeof(document.forms[formname].elements[fieldname + i]) != 'undefined') 
      {
      document.forms[formname].elements[fieldname + i].checked = truefalse;
      }
    }
  }
  
function InsertStuff(text)
  {
  if (MyTextArea == 0) { for (x = 0; x < document.forms[0].elements.length; x++) { if (document.forms[0].elements[x].type == 'textarea') { MyTextArea = document.forms[0].elements[x]; } } }
  if (MyTextArea == 0) { for (x = 0; x < document.forms[0].elements.length; x++) { if (document.forms[1].elements[x].type == 'textarea') { MyTextArea = document.forms[1].elements[x]; } } }
  MyTextArea.value += text;
  }
  
function ShowAddress(messenger, text)
  {
  prompt('To add this member in your ' + messenger + ', just copy and paste this address:', text);
  return false;
  }
