/* 
   Blog functions
   Last Modified: 2005.03.22
   Author: Mark Egge

   These functions may be freely distributed.
   Please leave the header information remain intact.
   Thanks.
   mark [ at ] eateggs.com
*/

function WriteEmailAddress() {
	$mailto="mailto:";
	$first="mark";
	$second="eateggs.com";
	document.writeln("<a href='" + $mailto + $first + "@" + $second + "'>" + $first + "[at]" + $second + "</a>");
}

function pop_win(url, name, attributes) {
  var a = window.open(url, name, attributes);
  if (window.focus) {a.focus()}
}

function comment_toggle_edit(id) {
  swap_visible('edit' + id);
  swap_visible('disp' + id);
}

function comment_save(finished, id) {
  var toSend = escape(finished);

  for(i=0; i < toSend.length; i += 1024) {
    action = "cache_comment";
    if((i + 1024) > toSend.length) { action = "store_comment"; }

    header = "commenthandler.php?" + "action=" + action;
    header += "&id=" + id;
    header += "&data=" + toSend.substring(i, i+1024);
    document.images["fakeimage"].src = header;
  }

  changeinnerhtml('alert' + id, "<i>Comment updated to:</i><br>");
  changeinnerhtml('comment' + id, finished);

  comment_toggle_edit(id);
}

function comment_delete_ban (id, parentId, ipValue) {
  document.images["fakeimage"].src = "commenthandler.php?action=ban&ip_value=" + ipValue;  
//  comment_delete(id, parentId);
}

function comment_delete(id, parentId) {
  changeinnerhtml('comment' + id, '');
  number_comments_current = eval("document.getElementById('numcmts" + parentId + "').innerHTML;");
  number_comments_new = parseInt(number_comments_current) - 1;
  changeinnerhtml('numcmts' + parentId, number_comments_new);
 
  collapse('disp' + id);
  
  document.images["fakeimage"].src = "commenthandler.php?action=delete_comment&comment_id=" + id;
}


function changeinnerhtml(layerid, htmlcode) {
    var statement = '';
    if (document.all) 
	  statement += "document.all['" + layerid + "'].innerHTML = '" + htmlcode + "';";	     
    else if (document.getElementById)           
	  statement += "document.getElementById('" + layerid + "').innerHTML = '" + htmlcode + "';"; 
    eval(statement);    
}

/* 
  Outliner functions -- Visibility Magic
  version: 1.3.6
  last modified 4-Feb-2003
  created by Marc Barrot, with help from Aaron Straup Cope, DJ Adams, Sjoerd Visscher and Danny Goodman
  copyright 2002 by Precision IT Management,Inc.
   You may use and distribute this code freely,
  just keep this header information intact.
*/
var img_expanded  = 'images/aright.gif';
var img_collapsed = 'images/adown.gif';

function ioSwitch(ioNode) {
  if (document.getElementById && document.getElementById(ioNode) !=  null) {
    nodeState = document.getElementById(ioNode).className;
  }
  
  if (nodeState == 'collapsed') { expand(ioNode); }
  else { collapse(ioNode); }
}

function expand(ioNode) {
  if (document.getElementById && document.getElementById(ioNode) != null) {
    document.getElementById(ioNode).className='expanded';
  }
}

function collapse(ioNode) {
  if (document.getElementById && document.getElementById(ioNode) !=  null) {
    document.getElementById(ioNode).className='collapsed';
  }
}

// END Marc Barrot CODE

function swap_visible(myElement) {
  var isNow = document.getElementById(myElement).className;

  if(isNow == 'collapsed') {
    expand(myElement);
  } else {
    collapse(myElement);
  }
}