
function mouseOverTab(p_strTarget) {
    document.getElementById('img'+ p_strTarget).src='/Images/Buttons/MenuMaster/btn' + p_strTarget + 'Active.png';
}

function mouseOutTab(p_strTarget) {
    if(document.images['img' + p_strTarget]) {
        document.images['img' + p_strTarget].src='/Images/Buttons/MenuMaster/btn' + p_strTarget + '.png'
    }
}

function OpenClose(p_objThis) {
    if(p_objThis.style.display=='block'){
        p_objThis.style.display='none';
    } else {
        p_objThis.style.display='block';
    }
}   

function OpenCloseCursor(p_objThis, p_strClass, p_strClassOver) {
    if(p_objThis.className==p_strClass){
        p_objThis.className=p_strClassOver;
    } else {
        p_objThis.className=p_strClass;
    }
}

function findPosX(obj)
{
    var curleft = 0;
    curleft = obj.offsetLeft;
    return curleft;
}


function CheckValueOk(p_objReq, p_intType){
    if(p_intType==1) {
        if(p_objReq.responseText!=''){
        }
    } 
    if(p_intType==2) {
        if(p_objReq.responseText!=''){
        }
    } 
}

function SetFileName(p_strFileName) {
    document.getElementById('FileName').innerHTML= p_strFileName.substring(p_strFileName.lastIndexOf('\\')+1);
    document.FileForm.submit();
}

function CheckfieldText(p_strText, p_strErrorText, p_objThis) {
    if(p_objThis.value==p_strText || p_objThis.value==p_strErrorText) {
        p_objThis.value = '';
    } else if (p_objThis.value=='') {
        p_objThis.value = p_strText;
    }
}

function filterFileType(p_strText, p_strExt) {
    if (p_strText.toLowerCase().indexOf('.' + p_strExt) == -1) {
	    return false;
    } else {
        return true;
    }
}	

function isDate(p_strDate){
    var l_objRegExp=/^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((1[6-9]|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((1[6-9]|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((1[6-9]|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$/
    if(l_objRegExp.test(p_strDate)) {
        return true;
    } else {
        return false ;
    }
}

function isTime(p_strTime){
    var l_objRegExp=/^([0-1][0-9]|[2][0-3]):([0-5][0-9])$/
    if(l_objRegExp.test(p_strTime)) {
        return true;
    } else {
        return false ;
    }
}

function isEmail(p_strEmail) {
    var l_strEmail = p_strEmail.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
	if (l_strEmail){
	    return true;
	} else {
	    return false;
	}
}

function showpopup(p_strId) { 
    document.getElementById(p_strId).style.display='block';
}

function showvideo(p_strVideo, p_strTitle, p_intWidth, p_intHeight) {
    document.getElementById('OverlayVideo').style.display = 'block';
    document.getElementById('PopupVideo').style.display = 'block';
    document.getElementById('divVideoTitle').innerHTML = p_strTitle;
    PlayMovieStart(p_strVideo, 'video', p_intWidth, p_intHeight);
}

function hidevideo() {
    document.getElementById('OverlayVideo').style.display = 'none';
    document.getElementById('PopupVideo').style.display = 'none';
}

function showpopup(p_strId, p_strLinkName, p_intCorrectieHoogte) { 
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var contentElement = document.getElementById(p_strId);
	        var linkObject = document.getElementById(p_strLinkName);
			var contentTargetPosition = getPosition(linkObject);
		}
	}
    document.getElementById(p_strId).style.display='block';
}

function showpopupSend(p_strId, p_strLinkName) { 
	document.getElementById('txtUrl').value = p_strLinkName;
    document.getElementById(p_strId).style.display='block';
}



function CheckInfoSend() {
    ResetLabels();
    var l_intErrorCount = 0;
    var emailadres = document.getElementById('txtEmailadresSend').value;
    var naam = document.getElementById('txtNaamSend').value;
    var emailadresOntvanger = document.getElementById('txtEmailadresOntvanger').value;
    var naamOntvanger = document.getElementById('txtNaamOntvanger').value;   
    var opmerking = document.getElementById('taOpmerkingSend').value;  
    var url = document.getElementById('txtUrl').value;  
    
    if (emailadres == "") {
        document.getElementById('lblErrorEmailadres').innerHTML = "Vul uw emailadres in.";
        l_intErrorCount++;
    } else if (!isEmail(emailadres)){
        document.getElementById('lblErrorEmailadres').innerHTML = "Emailadres onjuist.";
        l_intErrorCount++;
    }
    if (naam == "") {
        document.getElementById('lblErrorNaam').innerHTML = "Vul uw naam in.";
        l_intErrorCount++;
    }
    if (emailadresOntvanger == "") {
        document.getElementById('lblErrorEmailadresOntvanger').innerHTML = "Vul een emailadres in.";
        l_intErrorCount++;
    } else if (!isEmail(emailadresOntvanger)){
        document.getElementById('lblErrorEmailadresOntvanger').innerHTML = "Emailadres onjuist.";
        l_intErrorCount++;
    }
    if (naamOntvanger== "") {
        document.getElementById('lblErrorNaamOntvanger').innerHTML = "Vul een naam in.";
        l_intErrorCount++;
    }    
    if (l_intErrorCount == 0) {
        sendRequest('/Ajax/SendArticle.aspx', InfoSendOk, '&email=' + emailadres + '&naam=' + naam + '&emailontvanger=' + emailadresOntvanger + '&naamontvanger=' + naamOntvanger + '&opmerking=' + opmerking + '&url=' + url);
    }
}

function ResetLabels() {
    document.getElementById('lblErrorEmailadres').innerHTML = "";
    document.getElementById('lblErrorNaam').innerHTML = "";
    document.getElementById('lblErrorEmailadresOntvanger').innerHTML = "";
    document.getElementById('lblErrorNaamOntvanger').innerHTML = "";
}

function InfoSendOk(p_objReq){
    document.getElementById('PopupContainer').style.display='none';
}

function CheckValuesNaam() {
    var naam = document.getElementById('txtNaamNieuwsbrief').value;
    if (naam == 'vul uw naam in.' || naam == 'uw naam..') {
        document.getElementById('txtNaamNieuwsbrief').style.color = "#3f3f3f";
        document.getElementById('txtNaamNieuwsbrief').value = "";
    }
}
function CheckValuesEmail() {
    var email = document.getElementById('txtEmailNieuwsbrief').value;
    if (email == 'vul uw emailadres in.' || email == 'emailadres onjuist.' || email == 'uw emailadres..') {
        document.getElementById('txtEmailNieuwsbrief').style.color = "#3f3f3f";
        document.getElementById('txtEmailNieuwsbrief').value = "";
    }
}


function CheckInputNieuwsbrief() {
    
    document.getElementById('trResultOk').style.display = 'none';
    document.getElementById('trResultAlert').style.display = 'none';
    document.getElementById('txtEmailNieuwsbrief').style.color = "Black";
    document.getElementById('txtNaamNieuwsbrief').style.color = "Black";
    
    var l_intErrorCount = 0;
    var emailadres = document.getElementById('txtEmailNieuwsbrief').value;
    var naam = document.getElementById('txtNaamNieuwsbrief').value;
    if (emailadres == "") {
        document.getElementById('txtEmailNieuwsbrief').style.color = "Red";
        document.getElementById('txtEmailNieuwsbrief').value = "vul uw emailadres in.";
        l_intErrorCount++;
    } else if (!isEmail(emailadres)){
        document.getElementById('txtEmailNieuwsbrief').style.color = "Red";
        document.getElementById('txtEmailNieuwsbrief').value = "emailadres onjuist.";
        l_intErrorCount++;
    }
    if (naam == "") {
        document.getElementById('txtNaamNieuwsbrief').style.color = "Red";
        document.getElementById('txtNaamNieuwsbrief').value = "Vul uw naam in.";
        l_intErrorCount++;
    }
    
    if (l_intErrorCount == 0) {
        sendRequest('/Ajax/AddNewsletterAddress.aspx', SendAddressOk, '&email=' + emailadres + '&naam=' + naam);
    }
}

function SendAddressOk(p_objReq){
    if (p_objReq.responseText == 'Ok') {
        document.getElementById('trResultOk').style.display = 'block';
    } else {
        document.getElementById('trResultAlert').style.display = 'block';
    }
    //document.getElementById('txtNaamNieuwsbrief').value = p_objReq.responseText;
    //document.getElementById('txtEmailNieuwsbrief').value = "";
    //document.getElementById('PopupNieuwsbrief').style.display='none';
}

function CheckTipForm() {
    ResetLabels();
    var l_intErrorCount = 0;
    var emailadres = document.getElementById('txtEmailadresTip').value;
    var naam = document.getElementById('txtNaamTip').value;
    var opmerking = document.getElementById('taOpmerkingTip').value;  
    
    if (emailadres == "") {
        document.getElementById('lblErrorEmailadresTip').innerHTML = "Vul uw emailadres in.";
        l_intErrorCount++;
    } else if (!isEmail(emailadres)){
        document.getElementById('lblErrorEmailadresTip').innerHTML = "Emailadres onjuist.";
        l_intErrorCount++;
    }
    if (naam == "") {
        document.getElementById('lblErrorNaamTip').innerHTML = "Vul uw naam in.";
        l_intErrorCount++;
    }
    if (l_intErrorCount == 0) {
        sendRequest('/Ajax/SendTip.aspx', TipSendOk, '&email=' + emailadres + '&naam=' + naam + '&opmerking=' + opmerking);
    }
}

function TipSendOk(p_objReq){
    document.getElementById('divTipForm').innerHTML = p_objReq.responseText;
    //document.getElementById('PopupTip').style.display='none';
}





function showpopupTop(p_strId) { 
    document.getElementById(p_strId).style.top='0px';
    document.getElementById(p_strId).style.display='block';
}

function hidepopup(p_strId) { 
    document.getElementById(p_strId).style.display='none';
}



function showpopupTop(p_strId) { 
    document.getElementById(p_strId).style.top='0px';
    document.getElementById(p_strId).style.display='block';
}

function hidepopup(p_strId) { 
    document.getElementById(p_strId).style.display='none';
}

function pageRefresh() {
    location.reload(true);
}


function GetAllValues(p_strId) {
    var l_strValues = '';
    var l_objItems = document.getElementById(p_strId).getElementsByTagName('input');
    for (i=0; i<l_objItems.length; i++) {
        if(l_objItems[i].type=='radio') {
            if(l_objItems[i].checked) {
                l_strValues = l_strValues + '&' + l_objItems[i].name + '=' + URLEncode(l_objItems[i].value);
            }
        } else if (l_objItems[i].type=='button' || l_objItems[i].type=='submit'){
            //do not add.
        } else {
            l_strValues = l_strValues + '&' + l_objItems[i].name + '=' + URLEncode(l_objItems[i].value);
        }
    }
    l_objItems = document.getElementById(p_strId).getElementsByTagName('textarea');
    for (i=0; i<l_objItems.length; i++) {
        l_strValues = l_strValues + '&' + l_objItems[i].name + '=' + URLEncode(l_objItems[i].value);
        //l_strValues = l_strValues + '&' + l_objItems[i].name + '=' + l_objItems[i].innerHTML;
    }
    l_objItems = document.getElementById(p_strId).getElementsByTagName('select');
    for (i=0; i<l_objItems.length; i++) {
        l_strValues = l_strValues + '&' + l_objItems[i].name + '=' + URLEncode(l_objItems[i].options[l_objItems[i].selectedIndex].value);
    }
    return l_strValues.replace(/(<([^>]+)>)/ig,"");
}

function changeInputType(p_objOldObject, p_strType, p_strValue) {
  var l_objNewObject = document.createElement('input');
  l_objNewObject.type = p_strType;
  if(p_objOldObject.size) l_objNewObject.size = p_objOldObject.size;
  if(p_objOldObject.value) l_objNewObject.value = p_objOldObject.value;
  if(p_objOldObject.name) l_objNewObject.name = p_objOldObject.name;
  if(p_objOldObject.id) l_objNewObject.id = p_objOldObject.id;
  if(p_objOldObject.className) l_objNewObject.className = p_objOldObject.className;
  if(p_strValue!=null) l_objNewObject.value = p_strValue;
  p_objOldObject.parentNode.replaceChild(l_objNewObject,p_objOldObject);
  //alert(l_objNewObject.id);
  setTimeout('document.getElementById("' + l_objNewObject.id + '").focus()',10);
}

function URLEncode(p_strIn) { 
	var SAFECHARS = "0123456789" +		// Numeric
	"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
	"abcdefghijklmnopqrstuvwxyz" +
	"-_.!~*'()";			// RFC2396 Mark characters
				
	var HEX = "0123456789ABCDEF"; 
	if (p_strIn==null) 
		return p_strIn; 

	var plaintext = p_strIn + ''; 
	var encoded = ""; 

	for (var i = 0; i < plaintext.length; i++ ) { 
		var ch = plaintext.charAt(i); 
		if (ch == " ") { 
			encoded += "+"; // x-www-urlencoded, rather than %20 
		} else if (SAFECHARS.indexOf(ch) != -1) { 
			encoded += ch; 
		} else { 
			var charCode = ch.charCodeAt(0); 
			
			if (charCode > 255) { 
				alert( "Unicode Character '" + ch + "' cannot be encoded using standard URL encoding.\n" + "(URL encoding only supports 8-bit characters.)\n" + "A space (+) will be substituted." ); 
				encoded += "+"; 
			} else {
				encoded += "%"; 
				encoded += HEX.charAt((charCode >> 4) & 0xF); 
				encoded += HEX.charAt(charCode & 0xF);
			} 
		} 
	}
	p_strIn = encoded; 
	return p_strIn; 
}


function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

function getPosition(obj){
    var topValue= 0;
    while(obj){
	    topValue+= obj.offsetTop;
	    obj= obj.offsetParent;
    }
    finalvalue = topValue;
    return finalvalue;
}  


function resetLabels() {
    var x = document.getElementsByTagName('label');
    for (var i=0;i<x.length;i++) {
        x[i].innerHTML = '';
    }
}


function matchHeight(p_intCorr){
    var divs,contDivs,maxHeight,divHeight,d;
    contDivs = new Array();
    contDivs[0]=document.getElementById('divLeft');
    contDivs[1]=document.getElementById('divMiddle');
    contDivs[2]=document.getElementById('divRight');

    maxHeight=0;
    for(var i=0;i<contDivs.length;i++){
            d = contDivs[i];
            if(d.offsetHeight){
                if ( window.ActiveXObject ) {
                    divHeight=d.offsetHeight;
                } else {
                  divHeight=d.offsetHeight + p_intCorr;
                }                        
                 
            } else if(d.style.pixelHeight){
                 divHeight=d.style.pixelHeight;
            }
            maxHeight=Math.max(maxHeight,divHeight);
    }
    for(var i=0;i<contDivs.length;i++){
      contDivs[i].style.height= maxHeight + 'px';
    }
}


///Functions homepage
     function RotateStart(){
            var l_intImagesCount = document.getElementById('divHeaders').childNodes.length;
            for(var i=1;i<=l_intImagesCount;i++) {
                document.getElementById('divHeader' + i).style.display='none'; 
            }
            Rotate(1);
        }
        
        function Rotate(p_intCounter) {
            var l_intImagesCount = document.getElementById('divHeaders').childNodes.length;
            for(var i=1;i<=l_intImagesCount;i++) {
                document.getElementById('divHeader' + i).style.display='none'; 
            }    
            if(p_intCounter==l_intImagesCount+1) {
                RotateStart();
            } else {
                document.getElementById('divHeader' + p_intCounter).style.display='block';
                Fade(document.getElementById('divHeader' + p_intCounter),0);      
                //Rode Balk move
                //alert('divRedStrip' + p_intCounter);
                MoveUp(document.getElementById('divRedStrip' + p_intCounter), 140, 310);  
                setTimeout(
                    function(){
                        Rotate(p_intCounter+1)
                    },10000
                );             
            }
        }
        
        function MoveUp(p_strStripId, p_intEndPos, p_intStartPos) {
             var p_intTopPos = p_intStartPos;
             if(p_intEndPos < p_intTopPos) {
                if (p_strStripId.currentStyle){ 
                    p_strStripId.style.top = p_intTopPos;
                } else {    
                    p_strStripId.style.top = p_intTopPos + "px";
                }    
                setTimeout( function(){MoveUp(p_strStripId, p_intEndPos, p_intTopPos - 2)},10);
            }

        }

        function MoveDown(p_strStripId, p_intEndPos, p_intStartPos) {
            var p_intTopPos = p_intStartPos;
            if (p_intEndPos >= p_intTopPos) {
                if (p_strStripId.currentStyle) {
                    p_strStripId.style.top = p_intTopPos;
                } else {
                    p_strStripId.style.top = p_intTopPos + "px";
                }
                setTimeout(function() { MoveDown(p_strStripId, p_intEndPos, p_intTopPos + 2) }, 10);
            }

        }
        
        function MoveAllDown() {
            if ((document.getElementById('divRedStripVerleden').style.top < '150') || (document.getElementById('divRedStripVerleden').style.top < '150px')) {
                MoveDown(document.getElementById('divRedStripVerleden'), 225, 143);
            }
            if ((document.getElementById('divRedStripHeden').style.top < '150') || (document.getElementById('divRedStripHeden').style.top < '150px')) {
                MoveDown(document.getElementById('divRedStripHeden'), 225, 143);
            }
            if ((document.getElementById('divRedStripToekomst').style.top < '150') || (document.getElementById('divRedStripToekomst').style.top < '150px')) {
                MoveDown(document.getElementById('divRedStripToekomst'), 225, 143);
            }
        }
        
        function al_p(e) { 
            //alert('Element'); 
            if((navigator.userAgent.indexOf("MSIE")>-1 && navigator.userAgent.indexOf("compatible")>1 && !(navigator.userAgent.indexOf("opera")>-1))) { //IE
                if(!e) e = window.event; e.cancelBubble = true;
            } else {
                //Other Browsers
                e.stopPropagation(); 
            }
        }    
        
        function Fade(p_objSet, p_strValue) {
 
            if(p_strValue<10) {
                //IE only
                if(document.all) {
                    var l_objChildren = p_objSet.childNodes;
                     for(var i=0; i < l_objChildren.length; i++) {
                        SetOpacity(l_objChildren[i], p_strValue);
                     }
                }
	            SetOpacity(p_objSet, p_strValue);
	            setTimeout(
                    function(){
                        Fade(p_objSet, p_strValue+1)
                    },100
                );
            } else {
               SetOpacity(p_objSet, 10);
            }
        }
        function SetOpacity(p_objSet, p_strValue) {
            p_objSet.style.opacity = p_strValue/10;
      
            p_objSet.style.filter = 'alpha(opacity=' + p_strValue*10 + ')';
       }
       
       function ShowNews() {
            //namen: divTabsOuterLeft, divTabLeft, divTabMiddle, divTabRight, divTabOuterRight
            // onmouseover=\"this.style.color= '#d11241';\" onmouseout=\"this.style.color='#409bd2';\"
            document.getElementById('divTabsOuterLeft').className = 'divTabsOuterLeft';
            document.getElementById('divTabLeft').className = 'divTab';
            document.getElementById('divTabMiddle').className = 'divTabMiddle';
            document.getElementById('divTabRight').className = 'divTabNotSelectedRight';
            document.getElementById('divTabOuterRight').className = 'divTabOuterRight';
            
            document.getElementById('divContentNews').style.display = 'block';
            document.getElementById('divContentAgenda').style.display = 'none';
       }

       function ShowAgenda() {

            document.getElementById('divTabsOuterLeft').className = 'divTabsOuterLeftNot';
            document.getElementById('divTabLeft').className = 'divTabNotSelected';
            document.getElementById('divTabMiddle').className = 'divTabMiddleRight';
            document.getElementById('divTabRight').className = 'divTabRight';
            document.getElementById('divTabOuterRight').className = 'divTabOuterRightSelected'; 
                  
            document.getElementById('divContentAgenda').style.display = 'block';
            document.getElementById('divContentNews').style.display = 'none';
       }