	// Open External Links as Blank Targets via Unobtrusive JavaScript
// http://perishablepress.com/press/2007/11/20/open-external-links-as-blank-targets-via-unobtrusive-javascript/

jQuery(document).ready(function(){
	
	var pageHeight = jQuery('#container_content')[0].offsetHeight + 405;
	//alert(pageHeight);
	jQuery('#viewport').each(function () {
		jQuery(this).hide();
		jQuery(this).css('height', pageHeight + 'px');
		jQuery(this).fadeIn(1);
	});
	
	setTimeout('DrukBalkNaarBeneden();',600);
	
	jQuery('div.subitem').each(function (position) {
		var w = jQuery(this)[0].offsetWidth;
		var marginLeft = -1 * ((w / 2) - 8);
		jQuery(this).css('margin-left', String(marginLeft) + 'px');
		
		var thisLeft = jQuery(this)[0].offsetLeft;
		var menuHolderLeft = jQuery('#menu_holder')[0].offsetLeft;
		
		while (jQuery(this)[0].offsetLeft < menuHolderLeft) {
			marginLeft++;
			jQuery(this).css('margin-left', String(marginLeft) + 'px');
		}
	});
	
	jQuery('.subitemFloat').hide();
	
	jQuery('a.menu_item').live('mouseover', function () {
		var arrowContainer = jQuery('div.arrow_bottom');
		arrowContainer.replaceWith(arrowContainer.html());
		jQuery('a.menu_item.active').removeClass('active');
		
		// Hide alle andere submenu's
		jQuery('.subitemFloat').hide();
		
		// Toon het juiste submenu
		var itemId = jQuery(this)[0].id.replace(/\D/g, '');
		jQuery('#subitem' + itemId).show();
		
		jQuery(this).addClass('active');
		
		// Verplaats de pijl
		VerplaatsPijl(jQuery(this));
	});
	
	VerplaatsPijl(jQuery('a.menu_item.active'));
	
	if (jQuery('a.menu_item.active').length > 0) {
		var menuItemId = jQuery('a.menu_item.active')[0].id.replace(/\D/g, '');
		jQuery('#subitem' + menuItemId).show();
	}
	
});

function DrukBalkNaarBeneden() {
	while (jQuery('#container_submenu_bottom')[0].offsetTop < document.body.offsetHeight - 27) {
		jQuery('#viewport').css('height', (parseInt(jQuery('#viewport').css('height')) + 1) + 'px');
	}
}

function VerplaatsPijl(naarDiv) {
	if (naarDiv.length == 0) { return false; }
	
	var arrow = jQuery('#testarrow');
	arrow.show();
	arrow.css('left', naarDiv[0].offsetLeft + 'px');
}

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.getAttribute("rel") == "external nofollow" || 
			anchor.getAttribute("rel") == "nofollow external" )
			)
		anchor.target = "_blank";
	}
}
window.onload = function() {
	externalLinks();
}



function sendform(contactform)
{
    if(Validate(contactform)){eval('document.' + contactform + '.submit();' )} 

}


var formfunctions = new function()
{
    this.onfocus = function(Element)
    {
        if (Element.value.length == 0 || Element.value == Element.title || Element.title == "")
        {
        Element.title = Element.value;
        Element.alt = Element.value;
        Element.value = "";
        }
    }
    
    
    this.onblur = function(Element)
    {
        if (Element.value.length == 0 || Element.value == Element.title)
        {
            Element.value = Element.title
            Element.alt = ""
            Element.title = ""
        }
    }
}
