var linkuri_protejate = "";
var a_to_va = 0;
var a_to_vb = 0;
var a_to_vc = "";

function auto_anonimizare() {
auto_anonimizare();
}

function auto_anonimizare() {
var a_to_vd = window.location.hostname;

if(linkuri_protejate != "" && !linkuri_protejate.match(a_to_vd)) {
linkuri_protejate += ", " + a_to_vd;
} else if(linkuri_protejate == "")
{ linkuri_protejate = a_to_vd;
}

var a_to_ve = "";
var a_to_vf = new Array();
var a_to_vg = 0;

a_to_ve = document.getElementsByTagName("a");
a_to_va = a_to_ve.length; a_to_vf = a_to_fa();
a_to_vg = a_to_vf.length;

var a_to_vh = false;
var j = 0;
var a_to_vi = "";

for(var i = 0; i < a_to_va; i++)
{
a_to_vh = false; j = 0;

while(a_to_vh == false && j < a_to_vg)
{
a_to_vi = a_to_ve[i].href; if(a_to_vi.match(a_to_vf[j]) || !a_to_vi || !a_to_vi.match("http://"))
{ a_to_vh = true;
}
j++;
}

if(a_to_vh == false)
{
a_to_ve[i].href = "http://link.m9.ro/?"+base64_encode('' + a_to_vi);
a_to_vb++; a_to_vc += i + ":::" + a_to_ve[i].href + "\n";
}
}

var a_to_vj = document.getElementById("anonimizat");
var a_to_vk = document.getElementById("linkuri_gasite");

if(a_to_vj)
{
a_to_vj.innerHTML += a_to_vb;
}

if(a_to_vk)
{
a_to_vk.innerHTML += a_to_va;
}
}

function a_to_fa()
{
var a_to_vf = new Array();

linkuri_protejate = linkuri_protejate.replace(" ", "");

a_to_vf = linkuri_protejate.split(","); return a_to_vf;
}

function base64_encode(data) {

var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var o1, o2, o3, h1, h2, h3, h4, bits, i=0, enc='';

do {
o1 = data.charCodeAt(i++);
o2 = data.charCodeAt(i++);
o3 = data.charCodeAt(i++);

bits = o1<<16 | o2<<8 | o3;

h1 = bits>>18 & 0x3f;
h2 = bits>>12 & 0x3f;
h3 = bits>>6 & 0x3f;
h4 = bits & 0x3f;


enc += b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
} while (i < data.length);

switch( data.length % 3 ){
case 1:
enc = enc.slice(0, -2) + '==';
break;
case 2:
enc = enc.slice(0, -1) + '=';
}

return enc;
}
