var BasePath = 'http://www.autovanoortrebelle.nl/';

jQuery(function($){
	$.datepicker.regional['nl'] = {clearText: 'Wissen', clearStatus: 'Wis de huidige datum',
		closeText: 'Sluiten', closeStatus: 'Sluit zonder verandering',
		prevText: '&lt;Terug', prevStatus: 'Laat de voorgaande maand zien',
		nextText: 'Volgende&gt;', nextStatus: 'Laat de volgende maand zien',
		currentText: 'Vandaag', currentStatus: 'Laat de huidige maand zien',
		monthNames: ['Januari','Februari','Maart','April','Mei','Juni',
		'Juli','Augustus','September','Oktober','November','December'],
		monthNamesShort: ['Jan','Feb','Mrt','Apr','Mei','Jun',
		'Jul','Aug','Sep','Okt','Nov','Dec'],
		monthStatus: 'Laat een andere maand zien', yearStatus: 'Laat een ander jaar zien',
		weekHeader: 'Wk', weekStatus: 'Week van het jaar',
		dayNames: ['Zondag','Maandag','Dinsdag','Woensdag','Donderdag','Vrijdag','Zaterdag'],
		dayNamesShort: ['Zon','Maa','Din','Woe','Don','Vri','Zat'],
		dayNamesMin: ['Zo','Ma','Di','Wo','Do','Vr','Za'],
		dayStatus: 'DD', dateStatus: 'D, M d',
		dateFormat: 'dd.mm.yy', firstDay: 1, 
		initStatus: 'Kies een datum', isRTL: false};
	$.datepicker.setDefaults($.datepicker.regional['nl']);
});

$(document).ready(function() {
	$('div#HeaderImages').cycle({
		timeout : 9000,
		speed : 2500
	});
	
	$('div#SponsorImages').cycle({
		timeout : 5000,
		speed : 2000
	});

    $('div#Content img[height]').removeAttr('height');
    $('div#Content img').each(function() {
        if ( $(this).hasClass('NoPopup') ) return;
        //Elke afbeelding groter dan XY vervangen door een kleinere
        //versie en daarna lightbox toevoege
        var par = $(this).parent();
        var parDOM = par.get(0);
        if ( parDOM.tagName.toLowerCase() != 'a' ) { // alleen als het geen A is
            var a = $(document.createElement('a'));
            a.attr('rel', 'lightbox');
            a.attr('href', $(this).attr('src'));
            var clone = $(this).clone();
            a.html(clone);
            $(this).replaceWith(a);
        }
    });
	
	$(".Datepicker").datepicker($.datepicker.regional['nl']);
	
	$('div.MenuBlock li').bind('mouseover', function() {
		$(this).children('ul').show();
	}).bind('mouseout', function() {
		$(this).children('ul').hide();
	});
	
	
	$("a[rel*='lightbox']").lightBox({
		maxHeight: 200,
        maxWidth: 200
	});
	
	if ( $.browser.mozilla || $.browser.msie ) {
	    $('textarea.FCKEditor').fck({ path:BasePath+'icontent/FCKeditor/', toolbar:'Guestbook', height: 180 });
    }
	
	$('#Popup').height($(document.body).height());
	$('#Popup').show().children('div.Background').css('opacity', 0).animate({
		opacity : 0.5
	}, 2000 ).bind('click', function() { HidePopup(); } );
	$('#Popup div.Content').css('opacity', 0).animate({opacity:1}, 2000);
	
	
	
	$('h1.Expandable').click(function() {
			if ( $(this).attr('state') == undefined && $(this).next().css('display') == 'none')
				$(this).attr('state', 'closed');
			else if ( $(this).attr('state') == undefined && $(this).next().css('display') != 'none') {
				$(this).attr('state', 'opened').addClass('Opened');
			}
					
			if ( $(this).attr('state') == 'opened') {
				// sluiten
				//$(this).next().css('display', 'none');
				$(this).next().toggle('slow');
				$(this).attr('state', 'closed').removeClass('Opened');
			} else {
				// openen
				//$(this).next().css('display', 'block');
				$(this).next().toggle('slow');
				$(this).attr('state', 'opened').addClass('Opened');
			}
	});
	
});

function HidePopup() {
	$('#Popup').animate({opacity: 0}, 2000, function() { $(this).hide() } );
}

function ShowGuestbookForm(anchor) {
	$(anchor).parent().hide('slow');
	
	GuestbookDialog = $('#Dialog').dialog({
		modal : true,
		resizable : false,
		height : 400,
		width : 600,
		close : function() { $(anchor).parent().show('slow'); $(this).dialog('destroy'); } 
	});
}
