function CheckROFormZoek()
{
 var l_strAlert = 'Het volgende verplichte veld is niet ingevuld: ';

    if(document.getElementById('ZoekForm').value =='Zoekwoord' || document.getElementById('ZoekForm').value =='')
    {
        //document.getElementById('reactieIcoon').style.backgroundColor = '#FF4747';
        document.getElementById('reactieIcoon').focus();
        window.alert('U dient wel een zoekwoord op te geven');
        return false;
    }
    document.CanonZoekForm.submit();
}

function isChild(l_objParent, l_objChild) {
      if(l_objChild != null ) {                 
            while( l_objChild.parentNode ) {
                  if( (l_objChild = l_objChild.parentNode) == l_objParent ) {
                        return true;
                  }
            }
      }
      return false;
}

function fixOnMouseOut(l_objElement, event, p_strCode) {
      var l_objCurrentTarget = null;
      if(event.toElement) {                     
            l_objCurrentTarget = event.toElement;
      } else if(event.relatedTarget) {                      
            l_objCurrentTarget = event.relatedTarget;
      }
      if(!isChild(l_objElement, l_objCurrentTarget) && l_objElement != l_objCurrentTarget) {
            eval(p_strCode);
      }
}

function GetXmlHttpObject()
{ 
    var objXMLHttp=null
    if (window.XMLHttpRequest)
    {
       objXMLHttp=new XMLHttpRequest()
    }
    else if (window.ActiveXObject)
    {
       objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
    }
    return objXMLHttp
} 
var XMLHttpRequestObject = false;



function IconsOphalen(p_strLocatie,p_strFeatureId,p_strTag)
{
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
       {
          alert ("Browser does not support HTTP Request")
          return
        } 
       
    var url="/templates/stemverwerken.aspx?locatie="+p_strLocatie+"&FeatureId="+p_strFeatureId+"&tag="+p_strTag
    xmlHttp.open("GET",url,true)
    xmlHttp.onreadystatechange = function()
        {
            if (xmlHttp.readyState == 4 && xmlHttp.status == 200) 
            {
                document.getElementById('KOI'+p_strLocatie).style.display='block';
                document.getElementById('KOI'+p_strLocatie).innerHTML = xmlHttp.responseText;
                document.getElementById('KOI'+p_strLocatie).style.zIndex='2001';
            }
       }
    xmlHttp.send(null)
}


//kaart

var actiefMouseOver = false;
function kaartplaatsen(p_strX,p_strY,p_strKleur)
{
    document.getElementById('IA'+p_strX+'_'+p_strY).innerHTML='<img class=\"BlokIcoonkaart\" src="/images/kaart/'+p_strKleur+'.gif"/>';
    document.getElementById('IA'+p_strX+'_'+p_strY).style.top=(20*p_strX)-20+'px';
    document.getElementById('IA'+p_strX+'_'+p_strY).style.left=(20*p_strY)-20+'px';
    document.getElementById('IA'+p_strX+'_'+p_strY).style.position='absolute';
    document.getElementById('IA'+p_strX+'_'+p_strY).style.zIndex ='999';
}


function kaartvullen(p_strX,p_strY,p_strKleur,p_strAantal,p_strFeatureId,p_strTag)
{
    if(actiefMouseOver==false )
    {
        document.getElementById('IA'+p_strX+'_'+p_strY).innerHTML='<img class=\"BlokIcoonkaartActief\" src="/images/kaart/blok_'+p_strKleur+'_click.gif"  />';
        document.getElementById('IA'+p_strX+'_'+p_strY).style.top=(20*p_strX)-20+'px';
        document.getElementById('IA'+p_strX+'_'+p_strY).style.left=(20*p_strY)-55+'px';
        document.getElementById('IA'+p_strX+'_'+p_strY).style.position='absolute';
        document.getElementById('IA'+p_strX+'_'+p_strY).style.zIndex ='2001';
        
            window.setTimeout("kaartOverlayIcoon("+p_strX+","+p_strY+","+p_strAantal+","+p_strFeatureId+",'"+p_strTag+"')",200);
            
           
        actiefMouseOver=true;
    }
}

function kaartOut(p_strX,p_strY,p_strKleur)
{
    document.getElementById('IA'+p_strX+'_'+p_strY).innerHTML='<img class=\"BlokIcoonkaart\" src="/images/kaart/'+p_strKleur+'.gif"/>';
    document.getElementById('IA'+p_strX+'_'+p_strY).style.top=(20*p_strX)-20+'px';
    document.getElementById('IA'+p_strX+'_'+p_strY).style.left=(20*p_strY)-20+'px';
    document.getElementById('IA'+p_strX+'_'+p_strY).style.position='absolute';
    document.getElementById('IA'+p_strX+'_'+p_strY).style.zIndex ='999';
    document.getElementById('KOI'+p_strX+'_'+p_strY).style.display='none';
    actiefMouseOver=false;
}


function kaartOverlayIcoon(p_strX,p_strY,p_strAantal,p_strFeatureId,p_strTag)
{
    IconsOphalen(p_strX+'_'+p_strY,p_strFeatureId,p_strTag);
    document.getElementById('KOI'+p_strX+'_'+p_strY).style.display='block';
    if(p_strAantal>=5)//midden uitlijnen, verticaal groter dan 5
    {
        if(((20*p_strX)-20)>240)
        {
            document.getElementById('KOI'+p_strX+'_'+p_strY).style.bottom=0+'px';//onderste
        }
        else
        {
            if((20*p_strX)-135 <0)
            {
            //alert('2:'+((20*p_strX)-135));
                document.getElementById('KOI'+p_strX+'_'+p_strY).style.top=0+'px';//bovenste 
            }
            else
            {
                if(((20*p_strX)-70))
                {
                    document.getElementById('KOI'+p_strX+'_'+p_strY).style.bottom=0+'px';//bovenste 
                }
                else
                {
                //alert('6:'+((20*p_strX)-70));
                    document.getElementById('KOI'+p_strX+'_'+p_strY).style.bottom=0+'px';//bovenste 
                }
            }
        }

    }
    else//kleiner dan 5
    {
        if(((20*p_strX)-20)>=240)
        {
        //alert('7:'+(((p_strAantal-5)*70)+14));
            if((((p_strAantal-5)*70)+14)<-50)
            {
            //alert('3:'+(((p_strAantal-5)*70)+14));
                document.getElementById('KOI'+p_strX+'_'+p_strY).style.top=((20*p_strX)+36)-(p_strAantal*70)+'px';//bovenste op 0
                }
            else
            {
            //alert('5:'+p_strAantal+':: '+(((p_strAantal-5)*70)+14));
                document.getElementById('KOI'+p_strX+'_'+p_strY).style.bottom=((p_strAantal-5)*70)-56+'px';//onderste
            }
        }
        else
        {
        //alert('4:'+((20*p_strX)-34));
        if(((20*p_strX)-34)<0)
            document.getElementById('KOI'+p_strX+'_'+p_strY).style.top=0+'px';//bovenste 
        else
            document.getElementById('KOI'+p_strX+'_'+p_strY).style.top=(20*p_strX)-34+'px';//bovenste 
        }
    }
    
    if(p_strAantal>5)//midden uitlijnen, horizontaal
    {
    //alert((20*p_strY)-265)
        if((20*p_strY)-265 < -30)//links afvangen
        {
            document.getElementById('KOI'+p_strX+'_'+p_strY).style.left=-50+'px';
        }
        else if((20*p_strY)-265 >0)//rechts afvangen
        {
            document.getElementById('KOI'+p_strX+'_'+p_strY).style.left=-50+'px';
        }
         else 
        {
            document.getElementById('KOI'+p_strX+'_'+p_strY).style.left=(20*p_strY)-285+'px';
        }
    }
    else
    {
    // alles moet rechts van blokje getoond worden ivm mouseout op icoon
        //if(((20*p_strY)-20)>=240)//links van blokje
          //  document.getElementById('KOI'+p_strX+'_'+p_strY).style.left=(20*p_strY)-285+'px';
        //else//rechts van blokje
            document.getElementById('KOI'+p_strX+'_'+p_strY).style.left=(20*p_strY)-35+'px';
    }
}

function ShowFormButton()
{
    document.getElementById('formButtonOut').style.display='none';
    document.getElementById('formButtonIn').style.display='block';
}

function ShowFormButtonOut()
{
    document.getElementById('formButtonOut').style.display='block';
    document.getElementById('formButtonIn').style.display='none';
}

function CheckROForm()
{
    document.CanonForm.submit();
}


function CheckROFormReactie()
{
    
    var l_strAlert = 'Het volgende verplichte veld is niet ingevuld: ';

    if(document.getElementById('reactieIcoon').value =='Uw reactie' || document.getElementById('reactieIcoon').value =='')
    {
        document.getElementById('reactieIcoon').style.backgroundColor = '#FF4747';
        document.getElementById('reactieIcoon').focus();
       l_strAlert = l_strAlert + 'Uw reactie';
    }
    if(l_strAlert != 'Het volgende verplichte veld is niet ingevuld: ')
    {
       window.alert(l_strAlert);
    }
    else
    {
        document.CanonFormReactie.submit();
    }
}

function ShowLarge(p_strPath, p_blnIsVideo) {
    if(p_blnIsVideo) {
       // document.getElementById('icon_media_large').style.paddingBottom = ((navigator.appName == "Microsoft Internet Explorer") ? 25 : 20) + 'px';
    } else {
        if(document.getElementById('large') == null) {
            document.getElementById('icon_media_large').innerHTML = '<img id="large" src="' + p_strPath + '" alt="" />';
        } else {
            document.getElementById('large').src = p_strPath;
        }
        //document.getElementById('icon_media_large').style.paddingBottom = ((navigator.appName == "Microsoft Internet Explorer") ? 25 : 20) + 'px';
    }
}

function CheckForm(p_objForm) {
    if(!p_objForm.Aanhef[0].checked && !p_objForm.Aanhef[1].checked) {
        alert('Vul uw aanhef in');
        return false;
    }
    if(p_objForm.Voorletters.value.length <= 0) {
        alert('Vul uw voorletter(s) in');
        p_objForm.Voorletters.focus();
        return false;
    }
    if(p_objForm.Naam.value.length <= 0) {
        alert('Vul uw naam in');
        p_objForm.Naam.focus();
        return false;
    }
    if(p_objForm.Organisatie.value.length <= 0) {
        alert('Vul uw organisatie in');
        p_objForm.Organisatie.focus();
        return false;
    }
    if(p_objForm.Telefoon.value.length <= 9 || p_objForm.Telefoon.value.length > 10) {
        alert('Vul een geldig telefoonnummer in');
        p_objForm.Telefoon.focus();
        return false;
    }
    if(p_objForm.E_mail.value.length <= 0) {
        alert('Vul uw e-mailadres in');
        p_objForm.E_mail.focus();
        return false;
    }
    if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(p_objForm.E_mail.value))) {
        alert('Vul een geldig e-mailadres in');
        p_objForm.E_mail.focus();
        return false;
    }
    if(!p_objForm.Thema[0].checked && !p_objForm.Thema[1].checked) {
        alert('Vul in welk thema u wenst bij te wonen');
        return false;
    }
    p_objForm.submit();
}
