﻿// JavaScript Document
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// + this function includes all necessary js files for the application             +
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function includeJS(file)
{
	var script  = document.createElement('script');
	script.src  = file;
	script.type = 'text/javascript';
	script.defer = true;

	document.getElementsByTagName('head').item(0).appendChild(script);

	// include any js files here
	// includeJS('js/myFile1.js');
	// includeJS('js/myFile2.js');
}



// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// + Last update date creation for use in top of page                              +
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function lastUpdate(preText,last) { // aanroepen met lastUpdate(document.lastModified)

	function makeArray0() {
		 for (i = 0; i<makeArray0.arguments.length; i++)
			  this[i] = makeArray0.arguments[i];
	}
	
// 	var days = new makeArray0("zondag","maandag","dinsdag","woensdag",
// 		"donderdag","vrijdag","zaterdag");
	
	var months = new makeArray0('January','February','Maart',
		'April','Mei','Juni','July','Augustus','September',
		'Oktober','November','December');
	
	// function getCorrectedYear(year) {
	// 	year = year - 0;
	// 	if (year < 70) return (2000 + year);
	// 	if (year < 1900) return (1900 + year);
	// 	return year;
	// }
	
	function y2k(number) { return (number < 1000) ? number + 1900 : number; }
	
	var date    = new Date(last);
	var dateY2K = new Date(date.getFullYear(),date.getMonth(),date.getDate());
	// var dateY2K = new Date(getCorrectedYear(date.getFullYear()),date.getMonth(),date.getDate());
	
		return (preText + 
//			days[dateY2K.getDay()] + " " +
			dateY2K.getDate() + 
			" " + months[dateY2K.getMonth()] + " " +
			(y2k(dateY2K.getFullYear())) + "");
};

/***************************************************/
function createLastUpdateText(divID) {
	var htmlText = "&nbsp;";
	var     text = "Laatst gewijzigd op ";
	
	if (divID) { htmlText = lastUpdate(text,document.lastModified); }
	
	$(divID).html(htmlText);
};



// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// + Create the footer under each page in the div with id=footer                   +
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function createFooter() {
	var lastDate = new Date();
	var thisYear = lastDate.getFullYear();
	var htmlText = '<p>&copy; 2008-' + thisYear;
	htmlText += " Doenerij - Culemborg | Original design by <a href='http://www.duconsult.nl'>DuConsult</a>, webmaster and redesigner <b>Simon van Beek</b></p>";
	$('#footer').html(htmlText);
}



// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// + hover coloring for "to top" button                                            +
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function init_go2top() {

    $('div.goToTop').hover(function() {
        $(this).toggleClass('goToTop_high');
    },
    function() {
        $(this).removeClass('goToTop_high');
    });

    $('div#goToTop').click(function() {
        location = $(this).children("a").attr("href");
    });

    // make ga naar boven bar visible when scrolling down and hide when not necessary
    // $(window).scroll(function() {
    //     var documentHeight = $(document).height();
    //     var bar = $('div.goToTop');
    //     if ($(window).scrollTop() >= $(window).height()) {
    //         if (bar.is(":hidden")) {
    //             bar.css("visibility", "visible").fadeIn(300);
    //         }
    //     } else {
    //         if (!bar.is(":hidden")) {
    //             bar.fadeOut(1000);
    //         }
    //     }
    // });
    $(window).scroll(function() {
        var documentHeight = $(document).height();
        var bar = $('div.goToTop');
        if ($(window).scrollTop() >= $(window).height()) {
                bar.css("visibility", "visible").fadeIn(300);
        } else {
            if (!bar.is(":hidden")) {
                bar.fadeOut(1000);
            }
        }
    });
};



// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// + lightBox initialisation and activation                                        +
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function initLightBox() {	
	
	var lightBoxOptions = {
// 		imageBtnNext: 'images/gallery_Next.png',
// 		imageBtnPrev: 'images/gallery_Prev.png',
		txtImage: 'Foto',
		txtOf:    '-',
		fixedNavigation: true,
		overlayOpacity: .6,
		overlayBgColor: '#000000'
	}
	
	//activiteiten.html
	$('.gallery_eetcafe a').lightBox(lightBoxOptions); 
	
	// nieuws.html
	$('.gallery_news0  a').lightBox(lightBoxOptions);
	$('.gallery_news9  a').lightBox(lightBoxOptions);
	$('.gallery_news12 a').lightBox(lightBoxOptions);
	$('.gallery_news13 a').lightBox(lightBoxOptions);
	$('.gallery_news20 a').lightBox(lightBoxOptions);
	$('.gallery_news21 a').lightBox(lightBoxOptions);
	$('.gallery_news22 a').lightBox(lightBoxOptions);
	$('.gallery_news23 a').lightBox(lightBoxOptions);
	$('.gallery_news29 a').lightBox(lightBoxOptions);
	$('.gallery_news31 a').lightBox(lightBoxOptions);
	$('.gallery_news32 a').lightBox(lightBoxOptions);
	$('.gallery_news35 a').lightBox(lightBoxOptions);
	$('.gallery_news36 a').lightBox(lightBoxOptions);
	$('.gallery_news37 a').lightBox(lightBoxOptions);

// 			
// 			//******* highlighting the borders of a gallery pickture ******
// 			heighlightGallory();
// 	
// 			function heighlightGallory() {			
// 				$('.gallery img, .film').hover(function(){
// 					$(this).toggleClass('actSelected');
// 				}, function() {
// 					$(this).toggleClass('actSelected');
// 				});
// 							
// 			}; // end of heighlightOpmerking ********************
// 			

}



