// Submenu opening and closing
function openmenu(p_intNumber) {
    l_objSubmenu = document.getElementById('submenu' + p_intNumber)
    l_objSubmenu.style.display = (l_objSubmenu.style.display=='block') ? 'none' : 'block';
} 

// Stylesheet text size changer
function setActiveStyleSheet(l_strTitle) {
  var l_intCount, l_objTag, main, l_blnShown;
  l_blnShown = false;
  
  document.getElementById('default').style.color='#003C69';
  document.getElementById('large').style.color='#003C69';
  document.getElementById('big').style.color='#003C69';
  
  document.getElementById(l_strTitle).style.color='#009FDA';
  
  for(l_intCount=0; (l_objTag = document.getElementsByTagName("link")[l_intCount]); l_intCount++) {
    if(l_objTag.getAttribute("rel").indexOf("style") != -1 && l_objTag.getAttribute("title")) {
      l_objTag.disabled = true;
      if(l_objTag.getAttribute("title") == l_strTitle)
      {
        l_objTag.disabled = false;
        l_blnShown = true;
      }
    }
  }
  if (!l_blnShown) { setActiveStyleSheet("default") }
}

//Imagefader
var fadearray=new Array() //array to cache fadeshow instances
var fadeclear=new Array() //array to cache corresponding clearinterval pointers
var dom=(document.getElementById) //modern dom browsers
var iebrowser=document.all
 
function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, displayorder){
	this.pausecheck=pause
	this.mouseovercheck=0
	this.delay=delay
	this.degree=10 //initial opacity degree (10%)
	this.curimageindex=0
	this.nextimageindex=1
	fadearray[fadearray.length]=this
	this.slideshowid=fadearray.length-1
	this.canvasbase="canvas"+this.slideshowid
	this.curcanvas=this.canvasbase+"_0"
	if (typeof displayorder!="undefined")
		theimages.sort(function() {
			return 0.5 - Math.random();
		}) 
	this.theimages=theimages
	this.imageborder=parseInt(borderwidth)
	this.postimages=new Array() //preload images
	for (p=0;p<theimages.length;p++){
		this.postimages[p]=new Image()
		this.postimages[p].src=theimages[p][0]
	}
 	var fadewidth=fadewidth+this.imageborder*2
	var fadeheight=fadeheight+this.imageborder*2
	if (iebrowser&&dom||dom) //if IE5+ or modern browsers (ie: Firefox)
		document.write('<div id="master'+this.slideshowid+'" style="position:relative;width:'+fadewidth+'px;height:'+fadeheight+'px;overflow:hidden;"><div id="'+this.canvasbase+'_0" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);-moz-opacity:10;-khtml-opacity:10;background-color:'+fadebgcolor+'"></div><div id="'+this.canvasbase+'_1" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);-moz-opacity:10;background-color:'+fadebgcolor+'"></div></div>')
	else
		document.write('<div><img name="defaultslide'+this.slideshowid+'" src="'+this.postimages[0].src+'"></div>')
 
	if (iebrowser&&dom||dom) //if IE5+ or modern browsers such as Firefox
		this.startit()
	else{
		this.curimageindex++
		setInterval("fadearray["+this.slideshowid+"].rotateimage()", this.delay)
	}
}
function fadepic(obj){
	if (obj.degree<100){
		obj.degree+=10
		if (obj.tempobj.filters&&obj.tempobj.filters[0]){
			if (typeof obj.tempobj.filters[0].opacity=="number") //if IE6+
				obj.tempobj.filters[0].opacity=obj.degree
			else //else if IE5.5-
				obj.tempobj.style.filter="alpha(opacity="+obj.degree+")"
		}
		else if (obj.tempobj.style.MozOpacity)
			obj.tempobj.style.MozOpacity=obj.degree/101
		else if (obj.tempobj.style.KhtmlOpacity)
			obj.tempobj.style.KhtmlOpacity=obj.degree/100
	}
	else{
		clearInterval(fadeclear[obj.slideshowid])
		obj.nextcanvas=(obj.curcanvas==obj.canvasbase+"_0")? obj.canvasbase+"_0" : obj.canvasbase+"_1"
		obj.tempobj=iebrowser? iebrowser[obj.nextcanvas] : document.getElementById(obj.nextcanvas)
		obj.populateslide(obj.tempobj, obj.nextimageindex)
		obj.nextimageindex=(obj.nextimageindex<obj.postimages.length-1)? obj.nextimageindex+1 : 0
		setTimeout("fadearray["+obj.slideshowid+"].rotateimage()", obj.delay)
	}
}
 
fadeshow.prototype.populateslide=function(picobj, picindex){
	var slideHTML=""
	slideHTML+='<div style="text-align:center;width:250px;">'
	if (this.theimages[picindex][1]!="") //if associated link exists for image
		slideHTML+='<a href="'+this.theimages[picindex][1]+'" target="'+this.theimages[picindex][2]+'">'
	slideHTML+='<img src="'+this.postimages[picindex].src+'" border="'+this.imageborder+'px">'
	if (this.theimages[picindex][1]!="") //if associated link exists for image
		slideHTML+='</a>'
	slideHTML+='</div>'
	picobj.innerHTML=slideHTML
}
 
 
fadeshow.prototype.rotateimage=function(){
	if (this.pausecheck==1) //if pause onMouseover enabled, cache object
		var cacheobj=this
	if (this.mouseovercheck==1)
		setTimeout(function(){cacheobj.rotateimage()}, 100)
	else if (iebrowser&&dom||dom){
		this.resetit()
		var crossobj=this.tempobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
		crossobj.style.zIndex++
		fadeclear[this.slideshowid]=setInterval("fadepic(fadearray["+this.slideshowid+"])",50)
		this.curcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_1" : this.canvasbase+"_0"
	}
	else{
		var ns4imgobj=document.images['defaultslide'+this.slideshowid]
		ns4imgobj.src=this.postimages[this.curimageindex].src
	}
	this.curimageindex=(this.curimageindex<this.postimages.length-1)? this.curimageindex+1 : 0
}
 
fadeshow.prototype.resetit=function(){
	this.degree=10
	var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
	if (crossobj.filters&&crossobj.filters[0]){
		if (typeof crossobj.filters[0].opacity=="number") //if IE6+
			crossobj.filters(0).opacity=this.degree
		else //else if IE5.5-
			crossobj.style.filter="alpha(opacity="+this.degree+")"
	}
	else if (crossobj.style.MozOpacity)
		crossobj.style.MozOpacity=this.degree/101
	else if (crossobj.style.KhtmlOpacity)
		crossobj.style.KhtmlOpacity=this.degree/100
}
 
fadeshow.prototype.startit=function(){
	var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
	this.populateslide(crossobj, this.curimageindex)
	if (this.pausecheck==1){ //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
		var cacheobj=this
		var crossobjcontainer=iebrowser? iebrowser["master"+this.slideshowid] : document.getElementById("master"+this.slideshowid)
		crossobjcontainer.onmouseover=function(){
			cacheobj.mouseovercheck=1
		}
		crossobjcontainer.onmouseout=function(){
			cacheobj.mouseovercheck=0
		}
	}
	this.rotateimage()
}

function formValidate2() {
    if(document.getElementById('Email').value == '' || !document.getElementById('Email').value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi)) {
        alert('Vul een geldig e-mailadres in');
        return false;
    }
    if(document.getElementById('UwMail').value != '' && !document.getElementById('UwMail').value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi)) {
        alert('Vul een geldig e-mailadres in');
        return false;
    }
}

function formValidate()
{
    var fieldName = '';
    for(i = 0; i < document.forms.length; i++)
    {
        for(j = 0; j < document.forms[i].elements.length; j++)
        {
            fieldName = document.forms[i].elements[j].name;
            if(fieldName.indexOf('_Required') > -1)
            {
                if(document.getElementById(fieldName).value == '')
                {
                    fieldName = fieldName.replace(/_Required/, '');
                    fieldName = fieldName.replace(/_/, ' ');
                    alert(fieldName + ' mag niet leeg zijn');
                    return false;
                }
                else if(!document.getElementById('E-mailadres_ontvanger_Required').value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi))
                {
                    alert('Vul een geldig e-mailadres in');
                    return false;
                }
            }
            else if(document.getElementById('E-mail').value != '' && !document.getElementById('E-mail').value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi))
            {
                alert('Vul een geldig emailadres in');
                return false;
            }
        }
    }
}

function Search()
{
    if(document.getElementById('SearchTerm').value == '')
    {
        alert('Zoekveld mag niet leeg zijn');
        return false;
    }else if(document.getElementById('SearchTerm').value == 'Zoek in gehele site' && document.getElementById('search') == null)
    {
        alert('Voer een trefwoord in');
        return false;
    }else if(document.getElementById('SearchTerm').value.length < 2)
    {
        alert('Voer minimaal 2 karakters in');
        return false;
    }
}

function Searching() {
    if(document.getElementById('search2') != null) {
        if(document.getElementById('search2').value == '') {
            alert('Zoekveld mag niet leeg zijn');
            return false;
        } else if(document.getElementById('search2').value.length < 2) {
            alert('Voer minimaal 2 karakters in');
            return false;
        }
    } else {
        if(document.getElementById('Search2').value == '') {
            alert('Zoekveld mag niet leeg zijn');
            return false;
        } else if(document.getElementById('Search2').value.length < 2) {
            alert('Voer minimaal 2 karakters in');
            return false;
        }
    }
}

function showHide(divId)
{
    if(document.getElementById(divId).style.display == 'block' || document.getElementById(divId).style.display == '')
    {
        document.getElementById(divId).style.display = 'none';
        document.getElementById(divId+'img').style.listStyleImage = "url('/images/3hoek_rechts.gif')";
    }
    else
    {
        document.getElementById(divId).style.display = 'block';
        document.getElementById(divId+'img').style.listStyleImage = "url('/images/3hoek_onder.gif')";
    }
}

var lastOpened;
function show(vraag)
{
    var elm = document.getElementById(vraag);
    if(elm.style.display == 'none')
    {
        if (lastOpened) lastOpened.style.display='none'; 
        lastOpened = elm; 
    }
    elm.style.display = (elm.style.display=='none'?'block':'none');
}

function changeContentWidth()
{
    var UA = navigator.userAgent;
    if(UA.indexOf('Firefox') > -1 || UA.indexOf('Safari') > -1)
    {
        if(document.getElementById('right').innerHTML.length <= '40')
        {
            document.getElementById('middle').style.width = '775px';
        }
        else
        {
            document.getElementById('middle').style.width = '520px';
        }
    }else{
        if(document.getElementById('right').innerHTML.length == '0')
        {
            if(UA.indexOf('MSIE 6.0') > -1)
                document.getElementById('middle').style.width = '775px';
            else
                document.getElementById('middle').style.width = '775px';

        }
        else
        {
            document.getElementById('middle').style.width = '520px';
        }
    }
}


function AskApothekerCheck(p_objForm)
{
    if(p_objForm.vraag.value == '')
    {
        alert('Vraag mag niet leeg zijn');
        p_objForm.vraag.focus();
        return false;
    }
    
    if(p_objForm.gewicht.value.length > 0 && isNaN(p_objForm.gewicht.value)) {
        window.alert('Vul alleen hele getallen in.');
        p_objForm.gewicht.focus();
        return false;
    }
    if(p_objForm.leeftijd.value.length > 0 && isNaN(p_objForm.leeftijd.value)) {
        window.alert('Vul alleen hele getallen in.');
        p_objForm.leeftijd.focus();
        return false;
    }
    
    if(p_objForm.email.value=='')
    {
        window.alert('Email is verplicht.');
        p_objForm.email.focus();
        return false;
    }
    else
	{
		var goodEmailA = p_objForm.email.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
		if (goodEmailA){
		}else{
			window.alert('Dit emailadres is niet valide.');
			p_objForm.email.focus();
			return false;
		}
	}
}

function  ChangeBGForward(p_strD, p_intI)
{
    var Image = 'url(/images/icon'+p_intI+'.gif)';
    var Id = 'cta'+p_strD;
    ChangeBackgroundImage(Id, Image);
    document.getElementById(Id).style.backgroundColor='#f3f4f8';
}

function  ChangeBGBack(p_strD, p_intI)
{
    var Image = 'url(/images/icon'+p_intI+'.jpg)';
    var Id = 'cta'+p_strD;
    ChangeBackgroundImage(Id, Image);
    document.getElementById(Id).style.backgroundColor='#e5ebf0';
}

function ChangeBackgroundImage(p_strId, p_strImage)
{
    document.getElementById(p_strId).style.backgroundPosition='bottom right';
    document.getElementById(p_strId).style.backgroundRepeat='No-repeat';
    document.getElementById(p_strId).style.backgroundImage=p_strImage;
}

function SwitchFAQ(p_strName)
{
if(document.getElementById('Groep_' + p_strName).style.display=='none')
    document.getElementById('Groep_' + p_strName).style.display='block';
else
    document.getElementById('Groep_' + p_strName).style.display='none'

}

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 printObject(p_strCode){ document.write(p_strCode);}

function ShowFreq() {
    if(document.getElementById('FreqDiv') != null)
    {
        var Elm = document.getElementById('FreqDiv');
        if(Elm.style.display == '')
            Elm.style.display = 'none';
        Elm.style.display = (Elm.style.display=='none'?'block':'none');
    }
}

function CreateCookie(p_strCookie) {
    document.cookie = p_strCookie + '=visited;expires=' + new Date(new Date().getTime() + (3600 * 24 * 7 * 52)).toGMTString();
}