// JavaScript Document
function CryptMailto() {
	shift = parseInt(document.forms[0].shiftField.value);
	var n=0;
	var r="";
	var s="mailto:"+document.forms[0].emailField.value;
	for(var i=0;i<s.length;i++) { 
		n=s.charCodeAt(i); 
		if (n>=8364) {n = 128;}
		r += String.fromCharCode(n+shift); 
	}
	document.forms[0].cyptedEmailField.value = r;
	document.forms[0].HTMLCyptedEmailField.value = "<a href=\"javascript:linkTo_UnCryptMailto('"+r+"', "+shift+");\">eMail-Link</a>";
}

function UnCryptMailto(s, shift) {
	var n=0;
	var r="";
	for(var i=0;i<s.length;i++) { 
		n=s.charCodeAt(i); 
		if (n>=8364) {n = 128;}
		r += String.fromCharCode(n-(shift)); 
	}
	return r;
}

function linkTo_UnCryptMailto(s, shift)	{
	location.href=UnCryptMailto(s, shift);
}

function showLogin (){
	loginbox = document.getElementById("loginScreen");
	loginbox.style.display = "block";
}

function hideLogin (){
	loginbox = document.getElementById("loginScreen");
	loginbox.style.display = "none";
}

function toggle_loginLink(loggedin) {
	if (loggedin) {
		loginlink = document.getElementById("logout_link");
		loginlink.style.display = "none";
		logoutlink = document.getElementById("logout_link");
		logoutlink.style.display = "block";
	}
	else {
		loginlink = document.getElementById("login_link");
		loginlink.style.display = "block";
		logoutlink = document.getElementById("logout_link");
		logoutlink.style.display = "none";
	}
}

function insertContact (name, sld, tld) {
		document.write('<a href="mailto:'+name+'@'+sld+'.'+tld+'">'+name+'@'+sld+'.'+tld+'</a>');
	}
	
function openWindow (url) {
	 window1 = window.open(url, "image", "dependent=yes, location=no, menubar=no, scrollbars=no, status=no, toolbar=no");
	 window1.focus();
}
	
function openWin(url, w, h) {
	var windowName = "popupDialog";
	var properties = "dependent=yes, status=no, menubar=yes, scrollbars=yes, height="+h+", width="+w+", left=0, top=0, location=no";
	popupWindow = window.open(url, windowName, properties);
	popupWindow.focus();
}