﻿// JScript File
var g_intHeight = 40;

var bo_ns_id = 0;

function startIeFix()
{
    if(isIE())
        document.write('<noscript id="bo_ns_id_' + bo_ns_id + '">');
}


function endIeFix()
{
    if(isIE())
    {
        var theObject = document.getElementById("bo_ns_id_" + bo_ns_id++);
        var theNoScript = theObject.innerHTML;
        document.write(theNoScript);
    }
}


function isIE()
{
    var strBrowser = navigator.userAgent.toLowerCase();

    if(strBrowser.indexOf("msie") > -1 && strBrowser.indexOf("mac") < 0)
        return true;
    else
        return false;
}

function Display(p_strId, p_strDisplay)
{
    document.getElementById(p_strId).style.display = p_strDisplay;
}

function KinderScrollSize()
{
    var windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowHeight = document.body.clientHeight;
	}         
	                   
    var yScroll;
    if (window.innerHeight && window.scrollMaxY) {	
	    yScroll = document.body.scrollHeight;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
	    yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
	    yScroll = document.body.offsetHeight;
    }
    
    var l_objOverlay = document.getElementById('KinderOverLay')
    if(yScroll > windowHeight)
        l_objOverlay.style.height = yScroll - 247 + 'px';
    else
        l_objOverlay.style.height = windowHeight - 247 + 'px';
    l_objOverlay.style.display = 'block';
}

function ScrollSize()
{
    
    var windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowHeight = document.body.clientHeight;
	}                            
 
    g_intHeight = windowHeight - 240;
    if(g_intHeight < 40){ 
        g_intHeight = 40; 
    }
    document.getElementById('MainContent').style.height =  g_intHeight+'px';
    
    timer=setTimeout("ScrollSize2()", 40);
}

function ScrollSize2()
{
    var yScroll;
    if (window.innerHeight && window.scrollMaxY) {	
	    yScroll = document.body.scrollHeight;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
	    yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
	    yScroll = document.body.offsetHeight;
    }
    document.body.parentNode.scrollHeight
    var l_intHeight2 = yScroll - 240;
    //document.getElementById('SubMenuContainer2').innerHTML = g_intHeight+'px - '+l_intHeight2+'px';
    if(l_intHeight2 > g_intHeight){
        document.getElementById('MainContent').style.height =  l_intHeight2+'px';
    }
}

var g_blnAnother = false;
var g_blnType = false;

function CheckFAQForm()
{
    var l_strValue = "";
    var l_strChecked = false;
    if(document.getElementById('Vraag').value == ""){
        alert('U bent uw vraag vergeten in te vullen');
        document.getElementById('Vraag').focus();
        return false;
    }else if(document.getElementById('Naam').value == ""){
        alert('U bent uw naam vergeten in te vullen');
        document.getElementById('Naam').focus();
        return false;
    }else if(CheckEmail('Email') != ""){
        alert('U bent uw e-mail vergeten in te vullen of uw e-mail is incorrect');
        document.getElementById('Email').focus();
        return false;
    }
    var a = 0;
    while(a < document.FAQ.Type.length){
        if(document.FAQ.Type[a].checked == true){
            l_strChecked = true;
            l_strValue = document.FAQ.Type[a].value;
        }
        a++;
    }
    if(l_strChecked == false || (l_strValue == "anders, namelijk" && document.getElementById('AndersText').value == "")){
        alert('U bent alternatief vergeten in te vullen');
        document.getElementById('AndersText').focus();
        return false;
    }
}

function CheckFormOpinion()
{
    if(document.getElementById('Naam').value == ""){
        alert('U bent uw naam vergeten in te vullen');
        document.getElementById('Naam').focus();
        return false;
    }else if(CheckEmail('Email') != ""){
        alert('U bent uw e-mail vergeten in te vullen of uw e-mail is incorrect');
        document.getElementById('Email').focus();
        return false;
    }else if(document.getElementById('Telefoon').value == ""){
        alert('U bent uw telefoon vergeten');
        document.getElementById('Telefoon').focus();
        return false;
    }else if(document.getElementById('Opmerking').value == ""){
        alert('U bent uw mening vergeten');
        document.getElementById('Opmerking').focus();
        return false;
    }
}

function CheckForm()
{
    var l_strValue = "";
    var l_strChecked = false;
    if(document.getElementById('Naam').value == ""){
        alert('U bent uw naam vergeten in te vullen');
        document.getElementById('Naam').focus();
        return false;
    }else if(document.getElementById('Adres').value == ""){
        alert('U bent uw adres vergeten in te vullen');
        document.getElementById('Adres').focus();
        return false;   
    }else if(CheckEmail('Email') != ""){
        alert('U bent uw e-mail vergeten in te vullen of uw e-mail is incorrect');
        document.getElementById('Email').focus();
        return false;
    }
    var a = 0; 
    while(a < document.NewsLetter.Type.length){
        if(document.NewsLetter.Type[a].checked == true){
            l_strChecked = true;
            l_strValue = document.NewsLetter.Type[a].value;
        }
        a++;
    }
    if(l_strChecked == false || (l_strValue == "anders, namelijk" && document.getElementById('AndersText').value == "")){
        alert('U bent alternatief vergeten in te vullen');
        document.getElementById('AndersText').focus();
        return false;
    }
   
   
    
}

function CheckEmail(p_strEmail)
{
    if (/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i.test(document.getElementById(p_strEmail).value))
        return '';
    else
        return 'Wrong Email';
}

function SetFalse()
{
    g_blnAnother = false;
    g_blnType = true;
}

function SetTrue()
{
    g_blnAnother = true;
    g_blnType = true;
}

function Show(p_strId)
{
    if(document.getElementById(p_strId).style.display == 'none')
        document.getElementById(p_strId).style.display = 'block';
    else
        document.getElementById(p_strId).style.display = 'none'
}

function Hide(p_strId)
{
    if(document.getElementById('KinderOverLay'))
        document.getElementById('KinderOverLay').style.display = 'none';
    document.getElementById(p_strId).style.display = 'none';
}

function ShowDiv(p_strPre, p_intId)
{
    HideAll(p_strPre);
    if(document.getElementById(p_strPre+p_intId).style.display == 'block')
        document.getElementById(p_strPre+p_intId).style.display = 'none';
    else
        document.getElementById(p_strPre+p_intId).style.display = 'block';
}

function ShowKinderDiv(p_strId)
{
    //HideAll(p_strPre);
//    if(document.getElementById(p_strPre+p_intId).style.display == 'block')
//        document.getElementById(p_strPre+p_intId).style.display = 'none';
//    else
//        document.getElementById(p_strPre+p_intId).style.display = 'block';
    var l_objDiv = document.getElementById('KinderPopup');
    l_objDiv.innerHTML = document.getElementById(p_strId).innerHTML;
    KinderScrollSize();
    l_objDiv.style.display = 'block';
}

function HideAll(p_strPre)
{
    if(document.getElementById('KinderOverLay'))
        document.getElementById('KinderOverLay').style.display = 'none';
    var l_intCounter = 0;
    while (document.getElementById(p_strPre+l_intCounter) != null)
    {
        document.getElementById(p_strPre+l_intCounter).style.display = 'none';
        l_intCounter++;
    }
}

function CheckBijeenkomstenForm()
{
    //l_strFormValues[2] = new Array('Id','Alerttext','Type', NextArray);
    var l_strFormValues = new Array();
    l_strFormValues[0] = new Array('Bijeenkomst.Locatie','U bent vergeten locatie aan te geven','radio');
    l_strFormValues[1] = new Array('Naam','U bent uw naam vergeten in te vullen','text');
    l_strFormValues[2] = new Array('Functie','U bent uw functie vergeten in te vullen','text');
    l_strFormValues[3] = new Array('Organisatie','U bent uw organisatie vergeten in te vullen','text');
    l_strFormValues[4] = new Array('Adres','U bent uw adres vergeten in te vullen','text');
    l_strFormValues[5] = new Array('Plaats','U bent uw plaats vergeten in te vullen','text');
    l_strFormValues[6] = new Array('Telefoonnummer','U bent uw telefoonnummer vergeten in te vullen','text');
    l_strFormValues[7] = new Array('Email','U bent uw e-mail vergeten in te vullen','text');
    l_strFormValues[8] = new Array('Email','Door u ingevulde e-mail is niet correct','email');
    var l_blnCheck = false;
    var l_intCounter = 0;
    while(l_intCounter < l_strFormValues.length)
    {
        l_blnCheck = CheckElement(l_strFormValues[l_intCounter], '');
        if(!l_blnCheck)
            return l_blnCheck;
        l_intCounter++;
    }
}


function CheckElement(p_strValues, p_strExt)
{
    var l_objElement = document.getElementById(p_strValues[0] + p_strExt);
    if(p_strValues[2] == 'radio')
         l_objElement = eval("document." + p_strValues[0] + p_strExt);
    if(l_objElement)
    {
        switch(p_strValues[2])
        {
            case 'text':
                if(l_objElement.value == '')
                {
                    l_objElement.style.borderColor='#FF0000';
                    l_objElement.focus();
                    alert(p_strValues[1]);
                    return false;
                }
                else
                {
                    l_objElement.style.borderColor='#F7C2DC';
                    return true;
                }
                break;
            case 'radio':
                var l_intCounter = 0;
                while(l_objElement[l_intCounter])
                {
                    if(l_objElement[l_intCounter].checked)
                        return true;
                    l_intCounter++
                }
                alert(p_strValues[1]);
                return false;
                break;
            case 'pass':
                if(l_objElement.value == '')
                {
                    l_objElement.style.borderColor='#FF0000';
                    l_objElement.focus();
                    alert(p_strValues[1]);
                    return false;
                }
                else if(l_objElement.value.length < p_strValues[3])
                {
                    l_objElement.style.borderColor='#FF0000';
                    l_objElement.focus();
                    alert(p_strValues[4]);
                    return false;
                }
                else
                {
                    l_objElement.style.borderColor='#F7C2DC';
                    return true;
                }
                break;
            case 'email':
                if(EmailCheck(p_strValues[0]))
                {
                    l_objElement.style.borderColor='#FF0000';
                    l_objElement.focus();
                    alert(p_strValues[1]);
                    return false;
                }
                else
                {
                    l_objElement.style.borderColor='#F7C2DC';
                    return true;
                }
                break;
            case 'datetext':
                if(l_objElement.value == '' || l_objElement.value == 'dd-mm-jjjj')
                {
                    l_objElement.style.borderColor='#FF0000';
                    l_objElement.focus();
                    alert(p_strValues[1]);
                    return false;
                }
                else
                {
                    l_objElement.style.borderColor='#F7C2DC';
                    return true;
                }
                break;
            case 'date':
                if(!IsDatum(p_strValues[0] + p_strExt))
                {
                    l_objElement.style.borderColor='#FF0000';
                    l_objElement.focus();
                    alert(p_strValues[1]);
                    return false;
                }
                else
                {
                    l_objElement.style.borderColor='#F7C2DC';
                    return true;
                }
                break;
            case 'int': 
                if(!IsInt(l_objElement))
                {
                    l_objElement.style.borderColor='#FF0000';
                    l_objElement.focus();
                    alert(p_strValues[1]);
                    return false;
                }
                else
                {
                    l_objElement.style.borderColor='#F7C2DC';
                    return true;
                }
                break;
            case 'pulldown': 
                if(l_objElement.value < 0)
                {
                    l_objElement.style.borderColor='#FF0000';
                    l_objElement.focus();
                    alert(p_strValues[1]);
                    return false;
                }
                else if(l_objElement.value == 0)
                {
                    l_objElement.style.borderColor='#F7C2DC';
                    if(p_strValues[3])
                    {
                        if(document.getElementById(p_strValues[3][0] + 'Container'))
                            document.getElementById(p_strValues[3][0] + 'Container').style.display = 'block'
                        var l_blnCheck = CheckElement(p_strValues[3], '');
                        if(!l_blnCheck)
                            return l_blnCheck;
                    }
                    return true;
                }
                else
                {
                    l_objElement.style.borderColor='#F7C2DC';
                    return true;
                }
                break;
        }
    }
}

function EmailCheck(p_strId)
{
    if (/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i.test(document.getElementById(p_strId).value))
        return false;
    else
        return true
}

function IsDatum(p_strId)
{
    var l_strDate = document.getElementById(p_strId).value;
    var l_objRegExp = new RegExp("^(\\d{1,2})[/-](\\d{1,2})[/-](\\d{4})$");
    var l_objDate;
    var l_intDay;
    var l_intMonth;
    var l_intYear;
    var l_blnOutput = true;
    if(l_objRegExp.test(l_strDate))
    {
        var l_intDaysInMonth = new Array (31,0,31,30,31,30,31,31,30,31,30,31);
        
        l_objRegExp.exec(l_strDate);
        l_intYear =  new Number(RegExp.$3);
        l_intDaysInMonth[1]= ((l_intYear%4==0)&&((l_intYear%100!=0)||(l_intYear%400==0)))?29:28;
        l_intDay =  new Number(RegExp.$1);
        l_intMonth =  new Number(RegExp.$2);
        
        if(l_intYear < 1900)
            l_blnOutput = false;
        if(l_intMonth > 12)
            l_blnOutput = false;
        if(l_intDay > l_intDaysInMonth[l_intMonth-1])
            l_blnOutput = false;

    }
    else
    {
        l_blnOutput = false;
    }
    if(l_blnOutput)
        if(document.getElementById(p_strId+'_Sub'))
            document.getElementById(p_strId+'_Sub').value = l_intMonth+'-'+l_intDay+'-'+l_intYear;
    
    return l_blnOutput;
}

function PlaySound(p_strSoundfile)
{
    if(isIE())
    {
        document.getElementById("SoundEffect2").src = ''; //reset first in case of problems
        document.getElementById("SoundEffect2").src = p_strSoundfile;
        document.getElementById("SoundEffect2").setAttribute('autostart', true);
    }
    else
    {
        document.getElementById("SoundEffect").src = ''; //reset first in case of problems
        document.getElementById("SoundEffect").src = p_strSoundfile;
        document.getElementById("SoundEffect").setAttribute('autostart', true);
   } 
    //document.getElementById(p_strSoundfile).play();
}

function StopSound(p_strSoundfile)
{
    if(isIE())
    {
        document.getElementById("SoundEffect2").setAttribute('autostart', false);
        document.getElementById("SoundEffect2").src = '';
    }
    else
    {
        document.getElementById("SoundEffect").setAttribute('autostart', false);
        document.getElementById("SoundEffect").src = '';
    }
    //document.getElementById(p_strSoundfile).stop();
}

function bindsound(tag, soundfile, masterElement)
{
    if (!window.event) return
    var source=event.srcElement
    while (source!=masterElement && source.tagName!="HTML")
    {
        if (source.tagName==tag.toUpperCase())
        {
            playsound(soundfile)
            break
        }
        source=source.parentElement
    }
}

function DrawCircle(p_intDegree)
{
    p_intDegree++;
    var l_intDegree = p_intDegree;
    if(l_intDegree < 361)
    {
        Rotate((l_intDegree), 'circle');
        setTimeout("DrawCircle("+l_intDegree+")",10);
    }
}

function Rotate(p_intDegree, p_strId) {
    var l_intDegree = p_intDegree;
    if(l_intDegree > 359)
        l_intDegree = p_intDegree - 360;
    var l_objDiv = document.createElement('div');
    l_objDiv.setAttribute('id', 'Degree'+p_intDegree);
    l_objDiv.style.position = 'absolute';
    l_objDiv.style.width = '2px';
    l_objDiv.style.height = '2px';
    
    var l_intRadius = Math.round(100);
    var l_intPosition = Math.round(1);
    var x = l_intRadius*Math.cos(p_intDegree*Math.PI/180);
    var y = l_intRadius*Math.sin(p_intDegree*Math.PI/180);
    var l_intLeft = x +100 + l_intPosition;
    var l_intRight = y + 100;
    var l_intCounter = 0;
    var l_intSubLeft = Math.round(((l_intLeft - Math.floor(l_intLeft)) * 100));
    var l_intSubRight = Math.round(((l_intRight - Math.floor(l_intRight)) * 100));
    while(l_intCounter < 4)
    {
        var l_objDiv2 = document.createElement('div');
        l_objDiv2.style.position = 'absolute';
        l_objDiv2.style.width = '1px';
        l_objDiv2.style.height = '1px';
        l_objDiv2.style.backgroundColor = 'Black';
        
        if(l_intCounter == 0)
        {
            l_objDiv2.style.opacity = ((l_intSubLeft + l_intSubRight)/2)/100;
            l_objDiv2.style.filter = 'alpha(opacity='+(l_intSubLeft + l_intSubRight)/2+')';
            l_objDiv2.style.left = '0px';
            l_objDiv2.style.top = '0px'; 
        }
        else if(l_intCounter == 1)
        {
            l_objDiv2.style.opacity = (((100 - l_intSubLeft) + l_intSubRight)/2)/100;
            l_objDiv2.style.filter = 'alpha(opacity='+((100 - l_intSubLeft) + l_intSubRight)/2+')';
            l_objDiv2.style.left = '1px';
            l_objDiv2.style.top = '0px';  
        }
        else if(l_intCounter == 2)
        {
            l_objDiv2.style.opacity = ((l_intSubLeft + (100 - l_intSubRight))/2)/100;
            l_objDiv2.style.filter = 'alpha(opacity='+(l_intSubLeft + l_intSubRight)/2+')';
            l_objDiv2.style.left = '0px';
            l_objDiv2.style.top = '1px'; 
        }
        else if(l_intCounter == 3)
        {
            l_objDiv2.style.opacity = (((100 - l_intSubLeft) + (100 - l_intSubRight))/2)/100;
            l_objDiv2.style.filter = 'alpha(opacity='+(l_intSubLeft + l_intSubRight)/2+')';
            l_objDiv2.style.left = '1px';
            l_objDiv2.style.top = '1px'; 
        }
        l_objDiv.appendChild(l_objDiv2);
        l_intCounter++;
    }
    l_objDiv.style.left = Math.floor(l_intLeft)+'px';
    l_objDiv.style.top = Math.floor(y+170)+'px';
    document.getElementById('circle').appendChild(l_objDiv);
    
}