var albumOverviewLabel = 'overzicht fotoboeken';
var albumSlideshowLabel = 'diashow';
var nextLabel = 'volgende';
var previousLabel = 'vorige';
var installDir = 'website/heemkundige-kring-dronghine/site';
$(document).ready(function() {
/* Navigation slider to showhide subnav */
$(".parentNav").click(function(){
var showHide = $(this).parent().find('ul.subnav').css('display');
if(showHide == 'none'){
$(this).parent().find('ul.subnav').slideDown("fast");
$(this).parent().find('ul.subnav').removeClass("hide");
} else {
$(this).parent().find('ul.subnav').slideUp("fast");
$(this).parent().find('ul.subnav').addClass("hide");
}
return false;
});
initFunctions();
});
/* FUNCTIONS TO BE EXECUTED ON PAGE LOAD */
function initFunctions(){
/* PAGER FUNCTIONS */
var pLength = $('.pages .pager-num').length;
var modulus = pLength % 5;
var maxLPos = (pLength - modulus ) * -24; // items have a width of 24px, minus visible items of last page
var maxRPos = (pLength - modulus ) * 24;
pScrollLength = 120;
if(pLength < 5) pScrollLength = pLength * 24;
$('.pageCont .pager-cont').width(pScrollLength);
if(pLength > 5) {
//check the active page
var pCurrentActive = $('.pages:first .pager-num.active a').html();
if(pCurrentActive > 5){
var lPos = Math.floor(pCurrentActive / 5);
$(".pages").animate({
left: '-='+pScrollLength*lPos
}, 0);
}
$(".pager-next").click(function(){
var currLeft = Math.round($('.pages').position().left);
if((currLeft - 120) >= maxLPos){
$(".pages").animate({
left: '-=120'
}, 500);
}
return false;
});
$(".pager-prev").click(function(){
var currLeft = Math.round($('.pages').position().left);
if((currLeft + 120) <= 0){
$(".pages").animate({
left: '+=120'
}, 500);
}
return false;
});
$(".pager-last").click(function(){
$(".pages").animate({
left: maxLPos
}, 500);
return false;
});
$(".pager-first").click(function(){
$(".pages").animate({
left: 0
}, 500);
return false;
});
}
/* TAB FUNCTIONS */
$('.tabbar').each(function(i,el){
if($('.tabbar-tab',$(el)).length > 1){
$(el).addClass('tabbar-js')
$('.tabbar-title',$(el)).click(function(){
$('.tabbar-tab',$(el)).removeClass('tabbar-active')
$(this).parent('.tabbar-tab').addClass('tabbar-active')
$(el).css('height',$('.tabbar-active .tabbar-field',$(el)).height()+$('.tabbar-active .tabbar-title',$(el)).height())
return false
})
$('.tabbar-active .tabbar-title',$(el)).click()
}
});
/* FAQ FUNCTIONS */
$(".questionTitle").click(function(){
// close all
$(".questionAnswer").each(function(){
$(this).parent().find('.questionTitle').removeClass('active');
$(this).slideUp("fast");
});
var element = $(this).parent().children(".questionAnswer");
var showHide = element.css('display');
if(showHide == 'none'){
$(this).addClass('active');
element.slideDown("fast");
} else {
$(this).removeClass('active');
element.slideUp("fast");
}
return false;
});
/* Example form plugin */
/*if($('#contactform').length > 0){
$('input.ctext, textarea').example(function() {
return $(this).attr('title');
});
}*/
if($('#guestbook').length > 0){
$(".guestbookItemRecordMessage").emoticons();
$('input.ctext, textarea').example(function() {
return $(this).attr('title');
});
}
/* Contact form validation */
$('#contactform').submit(function() {
var hasErrors = false;
$('.optValue').each(function(){
if($(this).hasClass('required')){
// find form element inside this element
var frmEl = $(this).find('.frmField');
var requiredArea = $(this).closest('tr').find('.optRequired:first');
var labelArea = $(this).closest('tr').find('.optRequired:first');
var frmElTag = $(frmEl).get(0).tagName;
$(requiredArea).html(' ');
switch(frmElTag){
case 'INPUT': // check input field type
var frmElType = $(frmEl).attr('type');
switch(frmElType){
case 'text': var frmElValue = $(this).find('input').val();
if(frmElValue === ""){
hasErrors = true;
$(requiredArea).html('Verplicht veld');
} else {
// check for numeric or email
if($(this).find('input').hasClass('email')){
// check for valid email
if(!checkEmail(frmElValue)){
$(requiredArea).html('Ongeldig e-mailadres');
hasErrors = true;
}
} else if($(this).find('input').hasClass('numeric')){
var maxVal = $(this).find('input').attr('maxval');
var minVal = $(this).find('input').attr('minval');
var Exceeded = false;
if(!isNumber(frmElValue)){
Exceeded = true;
hasErrors = true;
$(requiredArea).html('De waarde moet numeriek zijn');
}
if(maxVal && !Exceeded){
if(parseInt(frmElValue) > maxVal){
Exceeded = true;
hasErrors = true;
$(requiredArea).html('De waarde moet kleiner of gelijk zijn aan ' + maxVal + '');
}
}
if(minVal && !Exceeded){
if(parseInt(frmElValue) < minVal){
Exceeded = true;
hasErrors = true;
$(requiredArea).html('De waarde moet groter of gelijk zijn aan ' + minVal + '');
}
}
}
}
break;
case 'checkbox':
case 'radio':
var frmElValue = $(this).find('input[name='+$(frmEl).attr('name')+']:checked').val();
if(frmElValue === undefined){
hasErrors = true;
// add invalid class to label
$(requiredArea).html('Verplicht veld');
}
break;
}
break;
case 'TEXTAREA': var frmElValue = $(this).find('textarea').val();
if(frmElValue === ""){
hasErrors = true;
$(requiredArea).html('Verplicht veld');
}
break;
case 'SELECT': var frmElValue = $(this).find('select').val();
if(frmElValue == ''){
hasErrors = true;
$(requiredArea).html('Verplicht veld');
}
}
}
});
if(hasErrors === false){
return true;
} else {
return false;
}
return false;
});
/* Guestbook form validation */
$('#guestbook').submit(function() {
var hasErrors = false;
$(this).find("p.smaller").html('(* Verplichte velden)');
// check if required fields are filled
$('.ctext, textarea').each(function(){
var formElement=$(this);
if($(this).hasClass('required') && $(this).val() == ''){
hasErrors = true;
$(this).addClass('invalid');
$(this).example(function() {
return $(this).attr('title');
});
$(this).focus(function() {
$(this).removeClass('invalid');
});
} else if($(this).hasClass('required') && $(this).val() != ''){
if($(this).hasClass('email')){
if(checkEmail($(this).val())){
$(this).removeClass('invalid');
} else {
hasErrors = true;
$(this).addClass('invalid');
$('#guestbook').find("p.smaller").html($('#guestbook').find("p.smaller").html()+' - Ongeldig e-mailadres');
$(this).focus(function() {
$(this).removeClass('invalid');
});
}
} else {
$(this).removeClass('invalid');
}
} else if($(this).val() == ''){
$(this).example(function() {
return $(this).attr('title');
});
}
});
if(hasErrors === false){
return true;
} else {
$(this).find("p.smaller").addClass('red');
return false;
}
/*$('input, textarea').example(function() {
return $(this).attr('title');
});*/
return false;
});
$(".signGuestbookLink a").click(function(){
var element = $(this).parent().parent().children(".signGuestbookForm");
var showHide = element.css('display');
if(showHide == 'none'){
$(this).addClass('active');
element.slideDown("fast");
} else {
$(this).removeClass('active');
element.slideUp("fast");
}
return false;
});
}
/* FULL BACKGROUND */
function initBg(){
flexiBackground.initialize();
}
function checkEmail(email) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)){
return (true)
}
return (false)
}
function isNumber(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}