function fixPng(A)
{
  if(arguments.length==0)
  {
    A=this
  }
  if(navigator.platform=="Win32"&&navigator.appName=="Microsoft Internet Explorer"&&typeof A.style.filter=="string"&&A.src.match(/\.png$/i)!=null)
  {
    var B=A.src;
    if(A.width)
    {
      A.style.width=A.width+"px"
    }
    if(A.height)
    {
      A.style.height=A.height+"px"
    }
    A.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+B+"', sizingMethod='scale')";
    A.onload=function()
    {
      A.className=A.className.replace(/\bfixPng\b/g,"")};
      A.src="http://unrefer.com/images/blank.gif"
  }
  else
  {
    A.className=A.className.replace(/\bfixPng\b/g,"")
  }
}
if(navigator.platform=="Win32"&&navigator.appName=="Microsoft Internet Explorer")
{
  document.write('<style type="text/css"> .fixPng { visibility: hidden; } </style>')
}

function go()
{
  x = document.unreferform.userurl.value;

  if(x.length == 0)
  {
    document.unreferform.urldirect.value = "";
    document.unreferform.htmllink.value = "";
    document.unreferform.boardlink.value = "";
    return 0;
  }

  if(x.length < 11)
  {
    return 0;
  }

  /*
  if (!x.match("http://") && !x.match("https://"))
  {
    x = "http://" + x;
    document.unreferform.userurl.value = x;
  }
  */

  var displayURL = x.replace("http://", "");

  y = document.location.search.substring(1,11);
  y = "";

  document.unreferform.urldirect.value = "http://unrefer.com/?" + x + "" + y;
  document.unreferform.htmllink.value = "<a href=\"http://unrefer.com/?" + x + "" + y + "\">unRefer " + displayURL + "</a>";
  document.unreferform.boardlink.value = "[url=http://unrefer.com/?" + x  + "" + y + "]unRefer " + displayURL + "[/url]";

  return false;
}
function goToUrl()
{
  url = document.unreferform.urldirect.value;

  if(url.length == 0)
  {
    return false;
  }
  document.location = document.unreferform.urldirect.value;

  return false;
}
function generateCode(formName, displayIn)
{
  var script_path = "http://unrefer.com/js/anonymize.js";
  var keywords = document.forms[formName].elements["keywords"].value;
  keywords = keywords.replace(" ", "");
  var keywords_array = new Array();

  var the_code = "";

  keyword_array = keywords.split(",");

  // check -> do some checks here, if wanted
  // ...

  // build the code
  the_code += "<script src=\"" +  script_path + "\" type=\"text/javascript\"></script>\n\n";

  // debug only
  //the_code += "&lt;!-- display stats (if you don't want stats the_code, just kick this and the next line) --&gt;\n";
  //the_code += "&lt;div&gt;anonyminized by anonym.to: &lt;span id=\"found_links\"&gt;&lt;/span&gt; links found; &lt;span id=\"anonyminized\"&gt;&lt;/span&gt; anonyminized&lt;/div&gt;\n\n";

  the_code += "<script type=\"text/javascript\"><!--\n";
  the_code += "protected_links = \"" + keyword_array.join(", ") + "\";\n\n";
  the_code += "auto_anonymize();\n";
  the_code += "//--></script>\n";

  // spit it out
  displayCode(displayIn, the_code);
}
function displayCode(displayIn, the_code)
{
  var the_element = document.getElementById(displayIn);

  the_element.value = "";
  the_element.value = the_code;
}
