var window1;

function popwin(myurl, strWindowTarget, leftInt, topInt, widthInt, heightInt, resizableBit, statusBit, menubarBit, scrollbarsBit, toolbarBit, directoriesBit) {
  s="" +"location=0" +",left=" +leftInt + ",top=" + topInt + ",width=" + widthInt + ",height=" + heightInt + ",resizable=" +resizableBit + ",status=" + statusBit + ",menubar=" + menubarBit + ",scrollbars=" + scrollbarsBit + ",toolbar=" + toolbarBit + ",directories=" + directoriesBit + "";
    
  window1=window.open(myurl, strWindowTarget, s);
  
  if (window.focus) 
  {
    window1.focus();
  }
}

function convert(text) {
  var newText = "";
  var i;

  for (i=0; i<text.length; i++)
  {
    newText += "&#" + text.charCodeAt(i) + ";";
  }

  return newText;
}

function mail2(twot,iurl,alttext,onet) {
  var alt;
  var one;
  var two;
  one = convert(onet);
  two = convert(twot);
  alt = convert(alttext);  
  var mailto = convert('mailto:');
   
  if (iurl !== '')
  {
    document.write('<a href="' + mailto + one + '@' + two + '">' + '<img src="' + iurl + '/email.gif" class="border" width="16" height="12" alt="' + one + '@' + two + '" title="' + one + '@' + two + '" />' + '</a>');
  } else {
    if (alttext == 'whole')
    {
      document.write('<a href="' + mailto + one + '@' + two + '">' + one + '@' + two + '</a>');
    } else if (alttext !== '') {
      document.write('<a href="' + mailto + one + '@' + two + '">' + alt + '</a>');
    } else {
      document.write('<a href="' + mailto + one + '@' + two + '">' + '@' + '</a>');
    }
  }
}

var THIS_SITE="http://self-injury.net";

function openlink(_checked)
{
  where = _checked?"_blank":"_self";

  for (var i=0; i<=(document.links.length-1); i++)
  {
    if(document.links[i].href.indexOf(THIS_SITE)<0)
    {
      document.links[i].target=where;
    }
  }
}

function maxforcookie(element, maxchars) {

  if(element.value.length > maxchars) 
  {
    return '1'; 
  } else {
    return '0'; 
  }
  
}


function setCookie(name,value,expires,domain,path,secure) 
{
  var today = new Date();
  today.setTime( today.getTime() );

  if ( expires )
  {
    expires = expires * 1000 * 60 * 60 * 24;
  }

  var expires_date = new Date( today.getTime() + (expires) );

  document.cookie = name + "=" +escape( value ) + ((expires) ? ";expires=" + expires_date.toGMTString() : "" ) + (( path) ? ";path=" + path : "" ) + ((domain) ? ";domain=" + domain : "" ) + ((secure) ? ";secure" : "" );
}

function readCookie(name)
{
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');

  for(var i=0;i < ca.length;i++)
  {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0)
    {
      return unescape(c.substring(nameEQ.length,c.length));
    }
  }
  return null;
}

function DeleteCookie(name,path,domain) 
{
  var exp = new Date();
  exp.setTime (exp.getTime() - 10000); 
  var getval = readCookie(name)

  if (getval) 
  {
    document.cookie = name + "=" + "test" + ";expires=" + exp.toGMTString() + ((path) ? ";path=" + path : "") + ((domain) ? ";domain=" + domain : "") + ";secure";
  }
}

function setSizes() {
  body_fs = fs
  h1_fs = body_fs+6;
  h2_fs = body_fs+5;
  h3_fs = body_fs+4;
  h4_fs = body_fs+3;
  h5_fs = body_fs+1;
  h6_fs = body_fs+1;
}

function changeType() {
  if (!document.getElementsByTagName)
  {
    return false;
  }

  setStyleByTag('td','fontSize',body_fs+'px');
  setStyleByTag('div','fontFamily',ff);
  setStyleByTag('div','fontSize',body_fs+'px');
  setStyleByTag('p','fontSize',body_fs+'px');

  setStyleByTag('h1','fontSize',h6_fs+'px');
  setStyleByTag('h2','fontSize',h5_fs+'px');
  setStyleByTag('h3','fontSize',h3_fs+'px');
  setStyleByTag('h4','fontSize',h4_fs+'px');
  setStyleByTag('h5','fontSize',h5_fs+'px');
  setStyleByTag('h6','fontSize',h6_fs+'px');

  setCookie('fontSize',fs,'3000','self-injury.net','/','');
  setCookie('fontFamily',ff,'3000','self-injury.net','/','');
  return null;
}

function increaseSize() {
  fs+=1;
  setSizes();
  changeType();
}

// this function is called from the A- button
function decreaseSize() {
  if (body_fs>1) 
  {
    fs-=1;
    setSizes();
    changeType();
  }
}


// These 2 setstyle functions were modified from code by Steven Champeon found at
// http://developer.apple.com/internet/_javascript/styles.html

function setStyleByTag(e, p, v) {
  var elements = document.getElementsByTagName(e);
  for(var i = 0; i < elements.length; i++)
  {
    elements.item(i).style[p] = v;
  }
}

function setStyleById(i, p, v)
{
  var n = document.getElementById(i);
  n.style[p] = v;
}

function CheckMaxLength(Object, MaxLen)
{
  if(Object.value.length > MaxLen)
  {     
    Object.value = Object.value.substring(0, MaxLen);
  }
}

/*
  Unless otherwise indicated, all code below was written by Eric Costello,
  and you are free to use, modify and distribute it. Please leave this 
  comment block intact so that people can find the original unmodified
  version at: http://www.glish.com/css/blogger/

  Also see:
  http://www.schwa.com
  http://www.glish.com
*/

if (document.getElementById) {
  ff = readCookie('fontFamily');
  if (ff=='') ff='Verdana, Arial, Helvetica, sans-serif';

  fs = parseInt(readCookie('fontSize'));
  if (!fs>0) fs=12;

  var body_fs, h1_fs, h2_fs, h3_fs, h4_fs, h5_fs, h6_fs;

  setSizes();

  document.writeln('<style>');
  document.writeln('body{font-size:'+body_fs+'px;}');
  document.writeln('body{font-family:'+ff+';}');
  document.writeln('.pad2007{font-size:'+body_fs+'px;}');
          
  document.writeln('.pad2007{font-family:'+ff+';}');
  document.writeln('h1{font-size:'+h1_fs+'px;}');
  document.writeln('h2{font-size:'+h2_fs+'px;}');
  document.writeln('h3{font-size:'+h3_fs+'px;}');
  document.writeln('h4{font-size:'+h4_fs+'px;}');
  document.writeln('h5{font-size:'+h5_fs+'px;}');
  document.writeln('h6{font-size:'+h6_fs+'px;}');
  document.writeln('</style>');
}

function init() 
{
  changeType();
}