<!--

function desencripta(Str_Message)
{
	Len_Str_Message=Str_Message.length;
	Str_Encrypted_Message="";
	for (Position = 0 ; Position<Len_Str_Message ; Position+=3)
	{
		cadena_num = Str_Message.substring(Position, Position+3);
		Ascii_Num_Byte = 999-cadena_num;
	        caracter=String.fromCharCode(Ascii_Num_Byte);
		Str_Encrypted_Message=Str_Encrypted_Message+caracter;
	} 
	return(Str_Encrypted_Message);
}

function nomes_variables(str)
{
	if (str.indexOf('?')==-1) { return(""); }
	theleft = str.indexOf("?") + 3;
	newstr=str.substring(theleft);
	return(newstr);
}


function troba_email(str)
{
	theleft = str.indexOf("e=") + 2;
	theright = str.indexOf("&f=");
	return(str.substring(theleft, theright));
}

function troba_emailamigo(str)
{
	theleft = str.indexOf("f=") + 2;
	theright = str.indexOf("&g=");
	return(str.substring(theleft, theright));
}

function troba_nombre(str)
{
	theleft = str.indexOf("g=") + 2;
	theright = str.indexOf("&h=");
	return(str.substring(theleft, theright));
}

function troba_nombreamigo(str)
{
	theleft = str.indexOf("h=") + 2;
	theright = str.indexOf("&i=");
	return(str.substring(theleft, theright));
}

function troba_focus(str)
{
	theleft = str.indexOf("i=") + 2;
	theright = str.indexOf("&error=");
	return(str.substring(theleft, theright));
}

function troba_error(str)
{
	theleft = str.indexOf("error=") + 6;
	theright = str.lastIndexOf("&");
	return(str.substring(theleft, theright));
}

var desencriptat="";
var email="";
var emailamigo="";
var nombre="";
var nombreamigo="";
var missatge_error="";
var focus="";
var text = document.URL

variables=nomes_variables(text);

if (variables!="") 
{

	desencriptat=desencripta(variables);

	email=troba_email(desencriptat)
	emailamigo=troba_emailamigo(desencriptat)
	nombre=troba_nombre(desencriptat)
	nombreamigo=troba_nombreamigo(desencriptat)
	focus=troba_focus(desencriptat)
	missatge_error=troba_error(desencriptat)

}
else
{
	email="";
	emailamigo="";
	nombre="";
	nombreamigo="";
	missatge_error="";
}
// document.MyForm.NombreAmigo.focus();
//window.onload=document.MyForm.EmailAmigo.focus;

function addEvent(obj, evType, fn)
{
	if (obj.addEventListener)
	{
	      obj.addEventListener(evType, fn, true);
	      return true;
	}
	else if (obj.attachEvent)
	{
	      var r = obj.attachEvent('on'+evType, fn);
	      return r;
	}
	else
	{
	      return false;
	}
}

if (focus==1)
{
	addEvent(window, 'load', function() {document.MyForm.Nombre.focus()});
}
else
{
	if (focus==2)
	{
		addEvent(window, 'load', function() {document.MyForm.Email.focus()});
	}
	else
	{
		if (focus==3)
		{
			addEvent(window, 'load', function() {document.MyForm.NombreAmigo.focus()});
		}
		else
		{
			if (focus==4)
			{
				addEvent(window, 'load', function() {document.MyForm.EmailAmigo.focus()});
			} 
		}
	}
}
-->

