function addsmile(smiley) {
  doc_content = document.forms[0].message.value + smiley
  document.forms[0].message.value = doc_content
  document.forms[0].message.focus()
}

function calcCharLeft()
{
	var theReply = document.forms[0].message.value;
	var availChars = 1000;
	if (theReply.length  > availChars)
		{
			document.forms[0].message.value = theReply.substring(0,availChars);
			alert('Het ingetikte bericht is te lang en zal worden afgebroken. \n\nThe typed message is to long and will be cut off.');
			document.forms[0].message.focus();
		}
}

function checkMessage(obj)
{
	var form = document.getElementById(obj);
	var errors = "";
	var error = 0;

	if(form.message)
	{
		if(form.message.value.length < 1)
		{
			errors = errors + "\n -No message entered.";
		} else if (form.message.value.length < 2)
		{
			errors = errors + "\n -Entered message is to short.";
		}
		
		if (!isEmail(form.email.value) && form.email.value.length != "")
		{
			errors = errors + "\n -No valid e-mail address entered. (not required)";
		}
	}else{
		if (!isEmail(form.email.value))
		{
			errors = errors + "\n -No valid e-mail address entered.";
		}
	}
	
	if(form.name.value.length < 1)
	{
		errors = errors + "\n -No name entered."
	} else if(form.name.value.length < 2)
	{
		errors = errors + "\n -Entered name is to short."
	}
		
	if(errors != "")
	{
		errors = "The following error(s) occured:" + errors;
		alert(errors);
		return false;
	}else
	{
		return true;
	}		
}

function isEmail(str) {
	var supported = 0;
	if (window.RegExp) {
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr)) supported = 1;
	}
	if (!supported)  return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
	
	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	return (!r1.test(str) && r2.test(str));
}

function show(url,windowName,w,h,scroll,resize)
{
	var win;
	winprops = 'height='+h+',width='+w+',top='+((screen.height - h) / 2)+',left='+(screen.width - w) / 2+',scrollbars='+scroll+',resizable='+resize;
	win = window.open(url, windowName, winprops);
	win.focus();
}

function doLinks()
{
	if (!document.getElementsByTagName) return;
	
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++)
	{
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
			anchor.target = "_blank";
	}
}

function mail(naam, domein, ext)
{
	window.location.href = 'mailto:' + naam + '@' + domein + '.' + ext;
}