

function isIE () {
    return (navigator.userAgent.indexOf("MSIE")!=-1) ? true : false;
}
function isFF () {
    return (navigator.userAgent.indexOf("Firefox")!=-1) ? true : false;
}

function isdefined( variable) {
    return (typeof(window[variable]) == "undefined")?  false: true;
}

function checkContactOblicatory (f, fieldsPrefix) {
    var error = 0;
    var emailerror = 0;


    if(!f[fieldsPrefix+'_tav'][0].checked && !f[fieldsPrefix+'_tav'][1].checked) {
        changeBg (f[fieldsPrefix+'_tav'][0]);
        changeBg (f[fieldsPrefix+'_tav'][1]);
        error = 1;
    } else {
        changeBgTr (f[fieldsPrefix+'_tav'][0]);
        changeBgTr (f[fieldsPrefix+'_tav'][1]);
    }

    if(f[fieldsPrefix+'_voornaam'].value == '') {
        changeBg (f[fieldsPrefix+'_voornaam']);
        error = 1;
    } else changeBgTr (f[fieldsPrefix+'_voornaam'])
    if(f[fieldsPrefix+'_achternaam'].value == '') {
        changeBg (f[fieldsPrefix+'_achternaam']);
        error = 1;
    } else changeBgTr (f[fieldsPrefix+'_achternaam'])
    if(f[fieldsPrefix+'_voorletters_1'].value == '') {
        changeBg (f[fieldsPrefix+'_voorletters_1']);
        error = 1;
    } else changeBgTr (f[fieldsPrefix+'_voorletters_1'])



    if(f[fieldsPrefix+'_emailadres'].value == '' || !checkEmailAddress(f[fieldsPrefix+'_emailadres'])) {
        changeBg (f[fieldsPrefix+'_emailadres']);
        emailerror = 1;
    } else changeBgTr (f[fieldsPrefix+'_emailadres'])

    if(f[fieldsPrefix+'_uw_vraag_of_reactie'].value == '') {
        changeBg (f[fieldsPrefix+'_uw_vraag_of_reactie']);
        error = 1;
    } else changeBgTr (f[fieldsPrefix+'_uw_vraag_of_reactie'])


    if(error || emailerror) {
        if(error && emailerror) {
            //alert(al + ' ' +emailal);
        }
        if(error && !emailerror) {
            //alert(al);
        }
        if(!error && emailerror) {
            //alert(emailal);
        }
        return;
    } else {
        f.submit();
    }
}

function checkNewsletterOblicatory(f,action,fieldsPrefix) {

    var error = 0;
    var emailerror = 0;

    if(f.melden[0].checked) {
        if(f[fieldsPrefix+'_email'].value == '' || !checkEmailAddress(f[fieldsPrefix+'_email'])) {
            changeBg (f[fieldsPrefix+'_email']);
            emailerror = 1;
        } else changeBgTr (f[fieldsPrefix+'_email'])

        if(f[fieldsPrefix+'_name'].value == '') {
            changeBg (f[fieldsPrefix+'_name']);
            error = 1;
        } else changeBgTr (f[fieldsPrefix+'_name'])

        if(f[fieldsPrefix+'_surname'].value == '') {
            changeBg (f[fieldsPrefix+'_surname']);
            error = 1;
        } else changeBgTr (f[fieldsPrefix+'_surname'])

        if(!f[fieldsPrefix+'_sex'][0].checked && !f[fieldsPrefix+'_sex'][1].checked) {
            changeBg (f[fieldsPrefix+'_sex'][0]);
            changeBg (f[fieldsPrefix+'_sex'][1]);
            error = 1;
        } else {
            changeBgTr (f[fieldsPrefix+'_sex'][0]);
            changeBgTr (f[fieldsPrefix+'_sex'][1]);
        }
    }
    if(f.melden[1].checked) {
        if(f[fieldsPrefix+'_email'].value == '' || !checkEmailAddress(f[fieldsPrefix+'_email'])) {
            changeBg (f[fieldsPrefix+'_email']);
            emailerror = 1;
        } else changeBgTr (f[fieldsPrefix+'_email'])
    }

    if(error || emailerror) {
        if(error && emailerror) {
            //alert(al + ' ' +emailal);
        }
        if(error && !emailerror) {
            //alert(al);
        }
        if(!error && emailerror) {
            //alert(emailal);
        }
        return;
    } else {
        f.nbaction.value = action
        f.submit();
    }

}

function checkNewsletterForm(f) {
    var anDiv = document.getElementById ('Aanmelden');
    var afDiv = document.getElementById ('Afmelden');
    if(f.melden[0].checked) {
        anDiv.style.display = 'block';
        afDiv.style.display = 'none';
    } else if (f.melden[1].checked) {
        anDiv.style.display = 'none';
        afDiv.style.display = 'block';
    } else {
        anDiv.style.display = 'none';
        afDiv.style.display = 'none';
    }
    if(f.melden[0].checked) {
        anDiv.style.visibility = 'visible';
        afDiv.style.visibility = 'hidden';
    } else if (f.melden[1].checked) {
        anDiv.style.visibility = 'hidden';
        afDiv.style.visibility = 'visible';
    } else {
        anDiv.style.visibility = 'hidden';
        afDiv.style.visibility = 'hidden';
    }

}

function goTo (l) {
    location.href=l;
}

function changeBg (el) {
    el.style.backgroundColor = '#FFD5D5';
}
function changeBgTr (el) {
    el.style.backgroundColor = 'white';
}

function movieWindow(urlImg, title, width, height) {
    var width = parseInt(width);
    var height = parseInt(height);
    var width = (isNaN(width) ? 420 : width+20);
    var height = (isNaN(height) ? 420 : height+20);

    var Win = window.open('',"",'width=' + width + ',height=' + height + ',resizable=0,scrollbars=no, menubar=no, left=350, top=100' );
    Win.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>'+title+'</title></head><body style="background-color:navy" leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">');

    Win.document.write('<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0"><tr><td align=center><table bgcolor="white" style="padding:4px;border:silver 1px solid"><tr><td><embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" SRC="'+urlImg+'" name="wmp" SHOWCONTROLS="1" SHOWDISPLAY="0" AutoStart="true"></embed></td></tr></table></td></tr></table>');
    Win.document.write('</body></html>');

};


function imageWindow(urlImg, title, width, height) {
    var width = parseInt(width);
    var height = parseInt(height);
    var width = (isNaN(width) ? 420 : width+20);
    var height = (isNaN(height) ? 420 : height+20);

    var Win = window.open('',"",'width=' + width + ',height=' + height + ',resizable=0,scrollbars=no, menubar=no, left=350, top=100' );
    Win.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>'+title+'</title></head><body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">');

    Win.document.write('<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0"><tr><td align=center><table style="padding:4px;border:silver 1px solid"><tr><td><a href="javascript:self.close();"><img src="'+urlImg+'" alt="" border="0"></a></td></tr></table></td></tr></table>');
    Win.document.write('</body></html>');

};

function win(url, title, width, height) {
    var width = parseInt(width);
    var height = parseInt(height);
    var width = (isNaN(width) ? 420 : width+20);
    var height = (isNaN(height) ? 420 : height+20);

    var Win = window.open(url,"",'width=' + width + ',height=' + height + ',resizable=0,scrollbars=no, menubar=no, left=350, top=100' );

};

function checkEmailAddress(field) {
    var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,4}))$)\b/gi);

    if (goodEmail){
      return true
    } else {
    field.focus()
    field.select()
    return false
  }
}