function OnLoadAdd(p_strFunction) {
    var l_objOldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = p_strFunction;
    } else {
        window.onload = function() {
            if (l_objOldonload) {
                l_objOldonload();
            }
            p_strFunction();
        }
    }
}
function CloseTabs(p_strId){
    try {
        var l_arrObjects = document.getElementById('Tabvulling' + p_strId).getElementsByTagName('Div');
        for(i=0;i<l_arrObjects.length;i++){
            if(l_arrObjects[i].className=='TabShow') {
                l_arrObjects[i].className='TabHide';
            }
        }
        var l_arrObjects = document.getElementById('Tabbladen' + p_strId).getElementsByTagName('Div');
        for(i=0;i<l_arrObjects.length;i++){
            if(l_arrObjects[i].className=='TabbladChosen') {
                l_arrObjects[i].className='Tabblad';
            }
        }
    } catch(err) {}
}

function OpenTab(p_strAnchor) {
    document.location='#' + p_strAnchor;
    
    CloseTabs(p_strAnchor.split('|')[0])
    document.getElementById('Tab' + p_strAnchor).className='TabShow';
    document.getElementById('Tabblad' + p_strAnchor).className='TabbladChosen';
}

function OpenAnchor() {
    var l_strAnchor = document.location.hash.substring(1);
    if(l_strAnchor!='') {
        try {
            CloseTabs(l_strAnchor.split('|')[0]);
            document.getElementById('Tab' + l_strAnchor).className='TabShow';
            document.getElementById('Tabblad' + l_strAnchor).className='TabbladChosen';
        } catch(err) {}
        try {
            OpenItem(l_strAnchor);
        } catch(err) {}
    }
}

OnLoadAdd(OpenAnchor);


function OpenItem(p_intId, p_objThis) {
    var l_objItem = document.getElementById(p_intId);
    if(l_objItem.style.display=='block') {
        l_objItem.style.display='none';
        if(p_objThis) {
            p_objThis.className='';
        } else {
            document.getElementById(p_intId + 'Link').className='';
        }
    } else {
        l_objItem.style.display='block';
        if(p_objThis) {
            p_objThis.className='Selected';
        } else {
            document.getElementById(p_intId + 'Link').className='Selected';
        }
    }
}

var m_blnMove = false;
 
function Slide(p_strId, p_intWidth, p_blnLeft) {	
    if(!m_blnMove) {
        var l_intStartPosition = parseInt(document.getElementById('Slide' + p_strId).style.left.replace('px',''));
        if(!l_intStartPosition) {
            l_intStartPosition = 0;
        }
        m_blnMove = true;
        SlideMove(l_intStartPosition, l_intStartPosition, p_blnLeft, p_intWidth, p_strId);
    }
}

function SlideMove(p_intPosition, p_intStartPosition, p_blnLeft, p_intWidth, p_strId) {		
	document.getElementById('Slide' + p_strId).style.left=p_intPosition+'px';
	document.getElementById('SlideNext' + p_strId).style.display='block';
	document.getElementById('SlidePrevious' + p_strId).style.display='block';

	if(p_blnLeft) {
		if(p_intPosition<(p_intStartPosition+p_intWidth)){
			setTimeout(
				function() { 						
					SlideMove(p_intPosition+10, p_intStartPosition, p_blnLeft, p_intWidth, p_strId);		
				},
			1); 
		} else {
			if(p_intPosition==0) {
				document.getElementById('SlideNext' + p_strId).style.display='none';
			}
			m_blnMove = false;
		} 
	} else {
		if(p_intPosition>(p_intStartPosition-p_intWidth)){
			setTimeout(
				function() { 						
					SlideMove(p_intPosition-10, p_intStartPosition, p_blnLeft, p_intWidth, p_strId);		
				},
			1); 
		} else {
			if((p_intPosition+(-p_intWidth))==-(document.getElementById('Slide' + p_strId).offsetWidth)) {
				document.getElementById('SlidePrevious' + p_strId).style.display='none';
			}
			m_blnMove = false;
		} 
	}
}

function SlideUp(p_strId, p_intHeight, p_blnUp) {	
    if(!m_blnMove) {
        var l_intStartPosition = parseInt(document.getElementById('Slide' + p_strId).style.top.replace('px',''));
        if(!l_intStartPosition) {
            l_intStartPosition = 0;
        }
        m_blnMove = true;
        SlideUpMove(l_intStartPosition, l_intStartPosition, p_blnUp, p_intHeight, p_strId);
    }
}

function SlideUpMove(p_intPosition, p_intStartPosition, p_blnUp, p_intHeight, p_strId) {		
	document.getElementById('Slide' + p_strId).style.top=p_intPosition+'px';
	document.getElementById('SlideDown' + p_strId).style.display='block';
	document.getElementById('SlideUp' + p_strId).style.display='block';

	if(p_blnUp) {
		if(p_intPosition<(p_intStartPosition+p_intHeight)){
			setTimeout(
				function() { 						
					SlideUpMove(p_intPosition+10, p_intStartPosition, p_blnUp, p_intHeight, p_strId);		
				},
			1); 
		} else {
			if(p_intPosition==0) {
				document.getElementById('SlideUp' + p_strId).style.display='none';
			}
			m_blnMove = false;
		} 
	} else {
		if(p_intPosition>(p_intStartPosition-p_intHeight)){
			setTimeout(
				function() { 						
					SlideUpMove(p_intPosition-10, p_intStartPosition, p_blnUp, p_intHeight, p_strId);		
				},
			1); 
		} else {
			if((p_intPosition+(-p_intHeight))<-(document.getElementById('Slide' + p_strId).offsetHeight)) {
				document.getElementById('SlideDown' + p_strId).style.display='none';
			}
			m_blnMove = false;
		} 
	}
}


function VerzendVraag(p_strId) {
    var l_blnOk = true;
    
    if (document.getElementById('Naam' + p_strId).value == '' || document.getElementById('Naam' + p_strId).value == 'Naam') {
        alert('Vul uw naam in!');
        l_blnOk = false;
    }
    
    if (!isEmail(document.getElementById('Email' + p_strId).value)) {
        alert('Vul uw e-mailadres in!');
        l_blnOk = false;
    }
    
    if(l_blnOk) {
        document.getElementById('VraagFormulier' + p_strId).submit()
    }
}


function VerzendNieuwsbrief(p_strId) {
    var l_blnOk = true;
    
    if (document.getElementById('Naam' + p_strId).value == '' || document.getElementById('Naam' + p_strId).value == 'Naam') {
        alert('Vul uw naam in!');
        l_blnOk = false;
    }
    
    if (!isEmail(document.getElementById('Email' + p_strId).value)) {
        alert('Vul uw e-mailadres in!');
        l_blnOk = false;
    }
    
    if(l_blnOk) {
        document.getElementById('VerzendNieuwsbrief' + p_strId).submit()
    }
}


function isEmail(p_strEmail) {
    var l_strEmail = p_strEmail.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.info)|(\..{2,2}))$)\b/gi);
	if (l_strEmail){
	    return true;
	} else {
	    return false;
	}
}
