
/*<!--
Hieronder de code voor de XMLHTTP unit
--> */

var xmlhttp
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
  try {
  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
} catch (e) {
  try {
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  } catch (E) {
   xmlhttp=false
  }
}
@else
xmlhttp=false
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
try {
  xmlhttp = new XMLHttpRequest();
} catch (e) {
  xmlhttp=false
}
} 

tryEmail	= false;
function submitEmail()
{
	var emailString = document.getElementById( 'nieuwsbrief' ).value;
	filter			= /^[A-z0-9][\w.-]*@[A-z0-9][\w\-\.]+\.[A-z0-9]{2,6}$/i;
	if ( filter.test( emailString ) )
	{
		xmlhttp.open( "GET", "/submitEmail.php?email=" + emailString + "", true );
		xmlhttp.onreadystatechange = function() 
		{
			if ( xmlhttp.readyState == 4 ) 
			{
				if ( xmlhttp.responseText == 'error' )
					alert( 'Unable to submit your email address.' );
				else
				{
					alert( 'Thank you for submitting your email adress.' );
					document.getElementById( 'nieuwsbrief' ).value = 'email address submitted';
					document.getElementById( 'nieuwsbrief' ).blur();
		
					tryEmail	= false;
					blurring();
				}
			}
		}
		xmlhttp.send("");
		return;
	}
	else if ( tryEmail )
	{
		alert( 'please specify a valid email adress' );
	}
	else
	{
		focusMe 	= true;
		tryEmail	= true;
		if ( isProperBrowser() ) 
		{
			document.getElementById('nieuwsbrief').setSelectionRange( 0, document.getElementById('nieuwsbrief').value.length );
		}
	}
	mouseOver();
	focussing();
	document.getElementById('nieuwsbrief').focus();
}
function blurring()
{
	document.getElementById( 'm1' ).className = 'huh';
	document.getElementById( 'nieuwsbrief' ).style.visibility = 'hidden';
	focusMe = false;
}
function focussing()
{
	tryEmail	= true;
	document.getElementById('m1').className += ' focus'; 
	focusMe = true; 
	if ( isProperBrowser() ) 
		document.getElementById( 'nieuwsbrief' ).setSelectionRange( 0,  document.getElementById( 'nieuwsbrief' ).value.length );
}
function mouseOver()
{
	document.getElementById( 'nieuwsbrief' ).style.visibility = 'visible';
	document.getElementById( 'm1' ).className += ' over1';
}
function mouseOut()
{
	if ( !focusMe ) 
	{ 
		document.getElementById( 'm1' ).className=document.getElementById( 'm1' ).className.replace( new RegExp(' over1\\b'), '' );
		document.getElementById( 'nieuwsbrief' ).style.visibility = 'hidden'; 
	}
	if ( !focusMe ) document.getElementById('nieuwsbrief').style.visibility = 'hidden';
}
function isProperBrowser()
{
	return ( typeof( document.all ) == 'undefined' );
}

function externalLinks() {
 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";
 }
}
window.onload = externalLinks;