var securitygraphic_number = 0;

// website startup
function OnLoad()
{
	ServerTime();
	SetMails();
}

// sets server time
function ServerTime()
{
	var Hours = Servertime.getHours();
	var Minutes = Servertime.getMinutes();
	var Seconds = Servertime.getSeconds();
	Servertime.setSeconds(Seconds + 1);
	
	if(Hours < 10) Hours = "0" + Hours;
	if(Minutes < 10) Minutes = "0" + Minutes;
	if(Seconds < 10) Seconds = "0" + Seconds;
	
	TimeString = " | Serverzeit: " + Hours + ":" + Minutes + ":" + Seconds;
	
	document.getElementById("servertime").innerHTML = TimeString;
	
	setTimeout("ServerTime()", 1000);
}

// sets email strings
function SetMails()
{
	var InfoMail = "lqirCfrqqdu0duwv1gh";
	var AdminMail = "lqirCfrqqdu0duwv1gh";
	if(document.getElementById("InfoMail"))
	{
		document.getElementById("InfoMail").innerHTML = "<a href=\"javascript:CreateMailLink('" + InfoMail + "');\">" + StringDecryption(InfoMail) + "</a>";
	}
	if(document.getElementById("AdminMail"))
	{
		document.getElementById("AdminMail").innerHTML = "<a href=\"javascript:CreateMailLink('" + AdminMail + "');\">Administrator</a>";
	}
}

// sets email links
function CreateMailLink(EncryptedString)
{
	location.href = "mailto:" + StringDecryption(EncryptedString);
}

// encrypts strings
function StringDecryption(EncryptedString)
{
	var DecryptedString = "";
	var Length = EncryptedString.length;
	for(var i = 0; i < Length; i++)
	{
		var CharCode = EncryptedString.charCodeAt(i);
		DecryptedString += DecryptChar(CharCode);
	}
	
	return DecryptedString;
}

// encrypts single chars
function DecryptChar(CharCode)
{
	CharCode = CharCode - 3;
	
	return String.fromCharCode(CharCode);
}

function securitygraphic_reload()
{
	document.getElementById("securitygraphic").src = "captcha.php?i=" + securitygraphic_number + "&sid=" + sessionid;
	securitygraphic_number++;
}

/*function email()
{
	NewString = "";
	Mail = "info@connar-arts.de";
	for(var i = 0; i < Mail.length; i++)
	{
		NewString += String.fromCharCode(Mail.charCodeAt(i) + 3);
	}
	location.href = NewString;
}*/
