function disableSelection (target) 
{
	if ( typeof target.onselectstart != "undefined" ) 
	{	
	  // IE
		target.onselectstart = function() 
		{
			return false
		};
	} 
	else if (typeof target.style.MozUserSelect != "undefined") 
	{ 
	  // Firefox
		target.style.MozUserSelect = "none";
	} 
	else 
	{ 
	  // Other
		target.onmousedown = function() 
		{
			return false;
		}
	}
	target.style.cursor = "default";
}

function trefwoord (showHint) 
{
	if( showHint ) 
	{
		if( $( 'trefwoord' ).value == defHint ) 
		{
			$( 'trefwoord' ).value = '';
		}
	} 
	else 
	{
		if( $( 'trefwoord' ).value == '' ) 
		{
			$( 'trefwoord' ).value = defHint;
		}
	}
}

function playMovie( movieurl ) 
{
	var flashvars = {};
	var params = 
	{
		play              : "true",
		loop              : "true",
		menu              : "false",
		quality           : "high",
		scale             : "showall",
		wmode             : "window",
		allowfullscreen   : "true",
		allowscriptaccess : "sameDomain",
		FlashVars         : "file=" + movieurl + "&autostart=true&width=520&height=310"
	};
	
	var attributes = 
	{
		name : "player"
	};

	swfobject.embedSWF (siteroot + "flash/player.swf", "overlay_content", "520", "310", "9.0.0", "", flashvars, params, attributes);
}

function keyHandler (e) 
{
	if (e.key == 'esc') 
	{
	  closeMoviePopup();
	}
}

function closeMoviePopup() 
{
	$('overlay_container').innerHTML = '<div id="overlay_content"><a style="position : absolute; left : 50%; margin-left : -60px; margin-top : 100px" href="http://get.adobe.com/flashplayer/" target="_blank" title="Get Flash"><img style="border : none" src="' + siteroot + 'img/getflash.png" alt="Get Flash" title="" /></a></div><span style="background-color : white; position : absolute; top : 323px; right : 10px;">&nbsp;[ <a href="#" onclick="return closeMoviePopup();">sluiten</a> ]&nbsp;</span>';
	$('overlay_container').setStyle ('top', -340);
	$('overlay').setStyle ('display', 'none');
	$('overlay_container').setStyle ('display', 'none');
	
	$(document.documentElement).removeEvent ('keydown', keyHandler);
	
	return false;
}

function moviePopup( movieurl ) 
{
	$('overlay').set('opacity', 0 );
	$('overlay').setStyle('display', 'block' );
	$('overlay').set('tween', { duration : 2500 } ).fade ('0.5');
	$('overlay_container').setStyle ('display', 'block');
	
	var mE = new Fx.Morph ($('overlay_container'), { duration : 2500 } );
	mE.start ({ 'top' : 200 });

	playMovie (movieurl);
	
	$(document.documentElement).addEvent ('keyup', keyHandler);
}


// Google maps
function createInfoMarker( point, address ) 
{
   var marker = new GMarker( point );
   GEvent.addListener( marker, "click",
      function() 
      {
         marker.openInfoWindowHtml( address );
      }
   );

  return marker;
}

function showGoogle (address, label, showMarker) 
{
	if (GBrowserIsCompatible ()) 
	{
		var geocoder = new GClientGeocoder ();
		geocoder.getLatLng (address, function (point) 
    {
			if (point) 
			{
				map = new GMap2 ($('vac_googlemaps'));
				map.setCenter (point, 14);
				map.addControl (new GSmallMapControl ());
				
				if (showMarker) 
				{
    			var marker = new GMarker( point, label );
    			map.addOverlay( marker );
    			GEvent.addListener( marker, "click", function() { alert( label ); } );
				}

				var i = 0;
    		$('vac_googlemaps').getChildren ('div').each (function(el) 
    		{
    			i++;
    			if ( i == 2 || i == 3 || el.getStyle ('right') == '3px') 
    			{
    				el.setStyle( 'display', 'none' );
    				el.setStyle( 'visibility', 'hidden' );
    			}
    		});
     	}
	  });
	}
}

function giveNewUpload (row_no) 
{
  return '<input type="file" name="soll_extradoc_' + (row_no - 2) + '" id="soll_extradoc_' + (row_no - 2) + '" value="" onchange="addUpload();"/>';
}

function vValidateVisit (nVisitID) 
{
  var ce = navigator.cookieEnabled || false;
  
  if (typeof navigator.cookieEnabled == 'undefined' && ! ce ) 
  {
    document.cookie = "TestCookie";
    ce = (document.cookie.indexOf ("TestCookie") != -1 ) ? true : false;
  }
  new Request ({
    url     : "/includes/validateVisit.php",
    method  : "post",
    data    : { "id" : nVisitID }
  }).send ();
        
  if (!ce) 
  {
    $('notice').innerHTML  = '<p style="background-color: grey; font-weight: bold; font-size: 14px; padding: 10px 0 10px 0; color: white">';
    $('notice').innerHTML += 'Uw browser ondersteunt geen "Cookies", of deze zijn uitgeschakeld. Deze website vereist "Cookies".';
    $('notice').innerHTML += '</p>';
    $('notice').setStyle ('display', 'block');
  }
}

function validateStats (stats_id) 
{
	var ce = navigator.cookieEnabled || false;
	
	if (typeof navigator.cookieEnabled == 'undefined' && ! ce ) 
	{
		document.cookie = "TestCookie";
		ce = (document.cookie.indexOf ("TestCookie") != -1 ) ? true : false;
	}
	new Request ({
		url		  : "/includes/validateStats.php",
		method	: "post",
		data	  : { "id" : stats_id }
	}).send ();
				
	if (!ce) 
	{
		$('notice').innerHTML = "<p style=\"background-color : grey; font-weight : bold; font-size : 14px;\ padding : 10px 0 10px 0; color : white;\">" + "Uw browser ondersteunt geen \"Cookies\", of deze zijn uitgeschakeld. Deze website vereist \"Cookies\".</p>";
		$('notice').setStyle ('display', 'block');
	}
}

function enterPressed (myfield, e) 
{
  var keycode;
  if (window.event) keycode = window.event.keyCode;
  else if (e) keycode = e.which;
  else return true;

  if (keycode == 13) 
  {
    setTimeout ("vUpdateData ()", 30);
    return false;
  } 
  else 
  {
    return true;
  }
}

function vPopupWindow (URL, nWidth, nHeight) 
{
  dCurrentDate = new Date();
  tCurrentTime = dCurrentDate.getTime();
  
  // Calculate screen resolution and dimensions for popup window
  nLeft   = (screen.width / 2) - (nWidth / 2);
  nTop    = (screen.height / 2) - ((nHeight / 3) * 2);

  // Create popup window
  sOptions  = "toolbar=0, scrollbars=1, location=0, statusbar=0, menubar=0, resizable=0, width=" + nWidth + ", height=" + nHeight + ", left=" + nLeft + ", top=" + nTop;
  sVariable = "Page" + tCurrentTime;
  sTitle    = tCurrentTime;

  // Display popup window  
  sEval = sVariable + " = window.open (URL, '" + sTitle + "','" + sOptions + "');";
  eval (sEval);
  
  // Prevent anchors from following link specified by HREF attribute
  //return false;
}

// Init
window.addEvent ('domready', function() {
	/* initShadowbox(); */
	// makeTooltips
	new Tips ($$('.tips'), {
		timeOut			  : 700,
		maxTitleChars	: 50,
		hideDelay		  : 200,
		className		  : 'tips',
		onShow			  : function (tip) 
		{
			tip.setStyle ('opacity', '0.6');
			tip.setStyle ('z-index', '9999999');
		}
	});

	if (typeof (window['redirect_url']) != "undefined"  && redirect_url.length > 0) 
	{
		location.href = redirect_url;
	}
});