function tooltipInit( tableId )
{
	// portfolio note activation (requires tooltip.js)											
	$$( '#' + tableId + ' td.note a' ).each( function( a ) {
		var my_toolTip = new Tooltip( a.id , 'notes' );

		var note = $( 'notestxt' );							
		if ( a.rel == '' ) {
			a.setAttribute( 'rel' , a.title );							
			a.removeAttribute( "title" );
		}					
		Event.observe( a , 'mouseover' , function( event ) {
			note.innerHTML = a.rel;													
			Event.stop( event );
			return false;			
		}); 
        Event.observe( a , 'click' , function( event ) {
			Event.stop( event );
			return false;
        });
	});
}

/******************************************************************************
 * validation.js
 *****************************************************************************/
/**
 *	validation.js
 *
 *	validates form input fields
 */
var Validation = Class.create({
	/*
	 * CONSTRUCTOR
	 */
	initialize: function ( form ) {
		this.form		= $(form);
		this.elements	= Form.getElements(form);
		this.bool		= true;				
		this.initEventHandlers();
	},	
	/*
	*	Activates Validator and stops submitting
	*/
	Validate: function( e ){		
		var h = new Hash({
				var_f: 'this.Presence(thell[i])',			
				txt_f: 'this.Format(thell[i])',
				num_f: 'this.Numeric(thell[i])', 
				mail_f: 'this.Mail(thell[i])',
				date_f: 'this.Date(thell[i])',
				sel_f: 'this.Select(thell[i])',				
				tel_f: 'this.Phone(thell[i])',
				pasw_f: 'this.Match(thell[i])',
				cha3_f: 'this.Length(thell[i])'							
		});
		
		thell = this.elements		
		for (var i = 0; i < thell.length; i++) {	
			if (h.get(thell[i].className.sub(' err', ''))) {												
				eval(h.get(thell[i].className.sub(' err', '')));
			}	
		}
		if (!(this.bool)) {
			Event.stop( e );
			this.bool = true;
			return false;
		}
	},
	/*
	*	Validates presence of inputdata
	*/
	Presence: function(ell){
		if (!(typeof ell.value=='string' && ell.value!='')) {			
			this.DisplayError(ell);
		}
	},
	/*
	*	Validates if inputdata is textual
	*/
	Format: function(ell){
		if (!(typeof ell.value=='string' && ell.value!=''&&isNaN(ell.value))) {
			this.DisplayError(ell);
		}
	},
	/*
	*	Validates if inputdata is numeric
	*/
	Numeric: function(ell){
        if (ell.value.indexOf('.') > -1) { tv = 'no'; } else { tv = ell.value; }
		if (!(!isNaN(tv.replace(',','.'))&& tv!='')) {
			this.DisplayError(ell);
		}
	},	
	/*
	*	Validates if inputdata is valid e-mail adres
	*/
	Mail: function(ell){
        var objRE=/^[\w-\.\']{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,}$/;		
        if (!(typeof ell.value=='string' && ell.value!='' && objRE.test(ell.value))) {
			this.DisplayError(ell);
		}
	},	
	/*
	*	Validates if inputdata is valid date
	*/
	Date: function(ell){
		if( $('whd').checked == true ) {
			var testDate = new Date(ell.value);
			if (!(!isNaN(testDate))) {
				this.DisplayError(ell);
			}
		}	
	},	
	/*
	*	Checks Selection box
	*/
	Select: function(ell){
        if (!(ell.options[ell.selectedIndex].value != '')) {
			this.DisplayError(ell);
		}	
	},	
	/*
	*	Validates phone number
	*/
	Phone: function(ell){
        var objRE=/^[0-9\(\)\.\/\-\+\s]*$/;
        if (!(ell.value != '' && objRE.test(ell.value))) {
			this.DisplayError(ell);
		}	
	},		
	/*
	*	Checks if 2 passwords match
	*/
	Match: function(ell){
		if (!(($('Password').value) == ($('Password2').value))) {
			this.DisplayError(ell);
		}
	},		
	/*
	*	Checks minimum chars
	*/
	Length: function(ell){
		if (ell.value.length < 3) {
			this.DisplayError(ell);
		}
	},		
	/*
	*	Displays error message above input field
	*/
	DisplayError: function(ell){
		this.bool = false;			
					
		if (!(ell.hasClassName('err'))) {
			if (ell.id == 'birthdate') {
				var dateArr = new Array($('dd'),$('mm'),$('yyyy'));
				dateArr.each( function( dell ) {
					if (isNaN(dell.value)) {				   
						new Effect.Highlight(dell, {startcolor: '#ffd4d4', endcolor: '#ffd4d4', restorecolor: '#ffd4d4'});
					}
				});				
			}
			new Effect.Highlight(ell, {startcolor: '#ffd4d4', endcolor: '#ffd4d4', restorecolor: '#ffd4d4'});
			if (ell.up('div.formrw').down('h4')) {
				ell.up('div.formrw').down('h4').toggle();
			} else if (ell.up(0).down('.alert')) {
				ell.value = ell.up(0).down('.alert').value;
			}
			ell.addClassName('err');
		}
	},	
	/*
	 * ADD EVENT HANDLERS
	 */
	initEventHandlers: function() {
		Event.observe( this.form , 'submit' , this.Validate.bindAsEventListener( this ) );
		
		this.elements.each( function( ell ) {
			if ((ell.readAttribute('type') != 'submit') && (ell.tagName.toLowerCase() != 'select')) {									 
				Event.observe( ell , 'focus' , function( e ) { 
					var ell = e.element()
					if (ell.getStyle('backgroundColor') == 'rgb(255,212,212)') {
						var stco = '#ffd4d4'
					} else {
						var stco = '#ffffff'					
					}
					new Effect.Highlight(ell, {startcolor:stco, endcolor:'#ffffaa', restorecolor:'#ffffaa'});
					if (ell.hasClassName('err')) {
						if (ell.up('div.formrw').down('h4')) {
							ell.up('div.formrw').down('h4').toggle();
						} else {
							ell.value = '';
						}
						ell.setStyle({ backgroundImage: 'none'});
						ell.removeClassName('err');
					}
				});	
				Event.observe( ell , 'blur' , function( e ) { 
					var ell = e.element()
					if (ell.getStyle('backgroundColor') == 'rgb(255,212,212)') {
						var stco = '#ffd4d4'
					} else {
						var stco = '#ffffaa'					
					}
					new Effect.Highlight(ell, {startcolor:stco, endcolor:'#ffffff', restorecolor:'#ffffff'});										
				});
			}
		});
	}		
});

function dateChange(bd) {
 	if (!isNaN(bd.value)) {
 		if (bd.hasClassName('err')) {
			if (bd.up('div.formrw').down('h4')) {				
				bd.up('div.formrw').down('h4').toggle();
				bd.removeClassName('err');
}	}	}	}

function selChange(st) {	 
 	var coS = $('CorporateSector');
 	var coD = $('CorporateDepartment');
	
 	if (st) {
 		coS.removeClassName('sel_f');
		coS.addClassName('xs');
 		coS.up().down('label').removeClassName('req');
 		if (coS.hasClassName('err')) {			
			coS.up('div.formrw').down('h4').toggle();
			coS.setStyle({ backgroundColor: '#ffffff'});
			coS.removeClassName('err');
		}			
 		coD.removeClassName('sel_f');
		coD.addClassName('xs');
 		coD.up().down('label').removeClassName('req');
 		if (coD.hasClassName('err')) {
			coD.up('div.formrw').down('h4').toggle();
			coD.setStyle({ backgroundColor: '#ffffff'});
			coD.removeClassName('err');
		}
 	} else {
 		coS.addClassName('sel_f');
		coS.removeClassName('xs');
 		coS.up().down('label').addClassName('req');
 		coD.addClassName('sel_f');
		coD.removeClassName('xs');
 		coD.up().down('label').addClassName('req');
}	}

Event.observe(window, 'load', function() {
	$$('form.chck_f').each( function( form ) {
		new Validation ( form ); 
	});
    // registration birthdate (fill onchange & onload)
    if ($('birthdate')) {
    	$('birthdate').value = $('dd').options[$('dd').selectedIndex].value + $('mm').options[$('mm').selectedIndex].value + $('yyyy').options[$('yyyy').selectedIndex].value;
		Event.observe('dd', 'change', function(event) {
			$('birthdate').value = $('birthdate').value.replace($('birthdate').value.substr(0,2),$('dd').value);
			dateChange($('birthdate'));			
		});	
		Event.observe('mm', 'change', function(event) {
			$('birthdate').value = $('birthdate').value.replace($('birthdate').value.substr(2,2),$('mm').value);
			dateChange($('birthdate'));
		});	
		Event.observe('yyyy', 'change', function(event) {
			$('birthdate').value = $('birthdate').value.replace($('birthdate').value.substr(4,4),$('yyyy').value);
			dateChange($('birthdate'));
		});	
    }	
	// onchange requirement sector & dep 
	if( $('CorporateTitle') != null ) {
	    Event.observe('CorporateTitle', 'change', function(event) {
			var th = $('CorporateTitle').options[$('CorporateTitle').selectedIndex];			
			selChange($(th).hasClassName('ns'));
	 	});      
	}	
});


/******************************************************************************
 * calendarNav.js
 *****************************************************************************/
/**
Language configuration for the Calendar.
NOTE: days starts on monday, daynames on sunday.... don't ask.
*/
Calendar.prototype.configuration = 
{ 
	'nl':{
			months:["januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"],
			months_short:['jan','feb','mar','apr','mei','jun','jul','aug','sep','okt','nov','dec'],
			days:"MDWDVZZ",
			daynames_long:['zondag','maandag','dinsdag','woensdag','donderdag','vrijdag','zaterdag'],
			daynames_short:['zo','ma','di','wo','do','vr','za'],
			dateformat:{ format:'yyyymmdd', pattern:/^(\d\d\d\d)(\d\d)(\d\d)$/, groups:{ day:3, month:2, year:1 } },
			headerformat:'mmmm yyyy',
			tooltipformat:'dddd d mmmm'
		},
	'fr':{
			months:["janvier", "f&#233;vrier", "mars", "avril", "mai", "juin", "juillet", "ao&#251;t", "septembre", "octobre", "novembre", "d&#233;cembre"],
			months_short:['jan','f&#233;v','mar','avr','mai','juin','juil','ao&#251;t','sep','oct','nov','d&#233;c'],
			days:"LMMJVSD",
			daynames_long:['dimanche','lundi','mardi','mercredi','jeudi','vendredi','samedi'],
			daynames_short:['dim','lun','mar','mer','jeu','ven','sam'],
			dateformat:{ format:'yyyymmdd', pattern:/^(\d\d\d\d)(\d\d)(\d\d)$/, groups:{ day:3, month:2, year:1 } },
			headerformat:'mmmm yyyy',
			tooltipformat:'dddd, mmmm d'
		}
};

/**
Constructs a new Calendar, constructor parameters:
- elementId: id of an element or reference to the element itself
- config: map of configuration properties

Dates can always be passed to the calendar as either a Date instance or a string in a specific format (see dateformat property).
Days in the calendar are either active (they contain a link or onclick event, there is an extra 'act' class set) or selected (there is an extra 'sel' class set).

Following is the list of possible properties in the config object:
Behaviour properties:
- language: Language in case of preconfigured configuration (currently en, nl and fr are defined)
- cssclass: Classname to put on the calendar div.
- months: Array of month names in the language used to display (see formatting).
- months_short: Array of short month names (see formatting).
- days: String of 7 characters containing header label for a day which is a single character like M (monday) or T (tuesday).  First day in string is MONDAY!!
- daynames_long: Array of full day names (first day in array is SUNDAY!!)
- daynames_short: Array of short day names (first day in array is SUNDAY!!)
- dateformat: Format in which to expect date input (see below)
- headerformat: Format in which to display the calendar header for a month.
- tooltipformat: Format for the tooltip text for an active link
- pagedate: Date for the current month to display.
- mindate: Minimum valid date for this calendar.
- maxdate: Maximum valid date for this calendar
- link: Link to attach to active dates, this will be the href of a traditional A element (see also 'onclick' property below)

Selections:
- active: String of dates  that are considered active.  Each date should be separated by a single whitespace character. 
When null is passed, ALL dates are considered active.  To have no active dates, pass an empty string.
- selected: String of dates  that are considered active.  Each date should be separated by a single whitespace character.  
It is possible to select multiple dates when setting up the calendar, but this does not work well in combination with the datepicker.
By default the date of today is selected, to have no selected dates, pass an empty string.

Event handlers:
- onclick: Function that will be called when an active date is clicked, the single parameter is a Date instance.  Can be used as alternative to link property.

Following is the list of public methods on a DatePicker instance:
- parseDate(Date|string): Returns the Date instance from a string, if the string is in the dateformat set on the Calendar.  If a Date instance is passed in 
as parameter, then that same instance is returned.  If an invalid format or incorrect date is passed in, then null is returned.
- renderDateFormat(Date): Returns the Date instance rendered as string with the dateformat set on the Calendar.
- renderFormat(Date, format): Returns the Date instance rendered as string using the format specified.
- html(): Returns the html content of the rendered Calendar.
- render(): Renders the calendar.
- select(Date|string): Selects the specified Date (of string as dateformat) on the calendar (this will first clear the selected dates).
- deselect(): Deselects all selected dates from the calendar.
- getSelected(): Returns the currently selected date on the calendar (as Date instance).

NOTE on formats: year is always specified by y, months by m, day by d (lowercase !)

About dateformat: Specifies the standard input format, can be parsed through a regex.  Should be specified as object with 3 properties:
- format: string representation like 'yyyymmdd'
- pattern: the regex pattern like '/^(\d\d\d\d)(\d\d)(\d\d)$/', this pattern must contain 3 groups!
- groups: object that specifies the group index in the pattern for every date part, f.i. { day:3, month:2, year:1 }

About headerformat, tooltipformat: can apply some basic formatting to a  date, using tokens:
- Example: saturday, february 3, 2007
	+ DAY: d = 3, dd = 03, ddd = sat, dddd = saturday
	+ MONTH: m = 3, mm = 03, mmm = feb, mmmm = february
	+ YEAR: yy = 07, yyyy = 2007

About link: a link can contain multiple format tokens determined by a pair of {} .
Example: http://mynewssite.com/{yyyy}/article.asp?date={yyyy-mm-dd}
*/
function Calendar( elementId, config )
{
	var myself 			= this;
	var configurables	= [ 'cssclass','months','days','months_short','daynames_long','daynames_short','language',
							'dateformat','headerformat','tooltipformat','pagedate','mindate','maxdate','link','onclick' ];
	
	var container		= elementId;
	
	// Properties
	this.months			= ['January','February','March','April','May','June','July','August','September','October','November','December'];
	this.months_short	= ['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'];
	this.days			= "MTWTFSS";
	this.daynames_long	= ['sunday','monday','tuesday','wednesday','thursday','friday','saturday'];
	this.daynames_short	= ['sun','mon','tue','wed','thu','fri','sat'];
	this.language		= 'en';
	
	// Properties: formatting
	this.dateformat		= { format:'yyyymmdd', pattern:/^(\d\d\d\d)(\d\d)(\d\d)$/, groups:{ day:3, month:2, year:1 } };
	this.headerformat	= "mmmm yyyy";
	this.tooltipformat	= "dddd, mmmm d";
	
	this.pagedate		= new Date();
	this.mindate		= null;			// First month will be the one containing this date
	this.maxdate		= null;			// Last month will be the one containing this date
	this.link			= null;
	this.onclick		= null;
	this.cssclass		= 'calendar';
	
	// Private members
	var active			= null;
	var selected		= [ ( this.pagedate.getFullYear() * 100 + this.pagedate.getMonth() ) * 100 + this.pagedate.getDate() ];
	var min				= 0;
	var max				= 0;

	if ( config ) {
		if ( config.language ) {
			this.language = config.language;
			if ( this.configuration[this.language] != null ) {
				for ( var key in this.configuration[this.language] )
					this[ key ] = this.configuration[this.language][ key ];
			}
		}
		for ( var key in config )
			if ( configurables.indexOf( key ) >= 0 )
				this[ key ] = config[ key ];
		
		if ( config.active != null )
			active = parseDateSet( config.active );
		if ( config.selected != null )
			selected = parseDateSet( config.selected );
	}
	
	function initialize() {
		if ( elementId != null ) container = $(elementId);
		
		min = 0; max = 0; // Disable mindate/maxdate validation
		var m = parseDate( myself.mindate );
		min = m != null ? ( ( m.getFullYear() * 100 ) + m.getMonth() ) * 100 + m.getDate() : 0;
		m = parseDate( myself.maxdate );
		max = m != null ? ( ( m.getFullYear() * 100 ) + m.getMonth() ) * 100 + m.getDate() : 0;
	}
	
	function pad( number ) {
		return number < 10 ? '0' + number : number;
	}
	
	function isValidDate( y, m, d ) {
		if ( isNaN(y) || isNaN(m) || isNaN(d) ) return false;
		if ( d < 1 || d > 31 ) return false;
		if ( m < 1 || m > 12 ) return false;
		
		var num = ( ( y * 100 ) + m - 1 ) * 100 + d;
		if ( ( min > 0 && num < min ) || ( max > 0 && num > max ) ) return false;
		if ( d > getDaysInMonth( y, m ) ) return false;
		
		return true;
	}
	
	function parseDate( date ) {
		if ( date != null && typeof date == 'string' ) {		// Convert string to date
		
			var pattern = myself.dateformat.pattern;
			var groups = myself.dateformat.groups;

			pattern.lastIndex = 0;
			var m = pattern.exec( date );		
		
			var day = NaN, month = NaN, year = NaN;
			if ( m != null && m.length > 0 && m.length >= groups.day )
				day = parseInt( m[ groups.day ], 10 );
			if ( m != null && m.length > 0 && m.length >= groups.month )
				month = parseInt( m[ groups.month ], 10 );
			if ( m != null && m.length > 0 && m.length >= groups.year )
				year = parseInt( m[ groups.year ], 10 );
		
			return isValidDate( year, month, day ) ? new Date( year, month - 1, day ) : null;
		}
		else
			return date; // date expected
	}
	
	function getDaysInMonth( year, month )
	{
		var dim	= [31,0,31,30,31,30,31,31,30,31,30,31]; // Feb has 0, see below for day count
		var ix = month - 1;
		
		if ( ix == 1 ) {
			return ( ( ( year % 100 != 0 ) && ( year % 4 == 0 ) ) || ( year % 400 == 0 ) ) ? 29 : 28;
		}
		else
			return dim[ ix ];
	}
	
	function parseDateSet( set ) {
		var list = [];
		if ( set != null && typeof set == 'string' ) {
			$w(set).each( function( element ) { var d = parseDate( element ); 
												if ( d != null )
													list.push( ( d.getFullYear() * 100 + d.getMonth() ) * 100 + d.getDate() );
												} );
		}
		
		return list;
	}
	
	function clickMoveMonth( event ) {
		var link = Event.element( event );
		var pd = parseDate( myself.pagedate );
		
		if ( pd != null ) {
			var mod = parseInt( link.readAttribute('mod'), 10 );
			
			var m = pd.getMonth() + mod ;
			var y = pd.getFullYear();
			
			if ( m < 0 ) { m = 11; y--; }
			if ( m > 11 ) { m = 0; y++; }

			myself.pagedate = new Date( y, m, pd.getDate() );
			myself.render();
		}
	}
	
	function activeClicked( event ) {
		Event.stop(event);
		if ( myself.onclick != null ) {
			var caller = Event.element( event );

			if ( caller.tagName == 'A' )
				caller = caller.parentNode;
			
			var date = caller.readAttribute('dt');
			// Fixed format
			var year = parseInt( date.substring( 0, 4 ), 10 );
			var month = parseInt( date.substring( 4, 6 ), 10 );
			var day = parseInt( date.substring( 6, 8 ), 10 );
			
			myself.onclick( new Date( year, month, day ) );
		}		
	}
	
	function createUrl( link, date ) {
		var url = link;
		var m = url.match( /\{[^}]+\}/, url );

		while ( m != null && m.length > 0 ) {
			url = url.replace( m[0], myself.renderFormat( date, m[0].substring( 1, m[0].length - 1 ) ) )
			m = url.match( /\{[^}]+\}/, url );
		}
				
		return url;
	}
		
	this.parseDate = function( date ) {
		return parseDate( date );
	}
	
	this.renderDateFormat = function( date ) {
		return this.renderFormat( date, this.dateformat.format );
	}
	
	this.renderFormat = function( date, format ) 
	{
		var value = format;
		value = value.replace( /_/g, 'XQTQX' );
		value = value.replace( /y/g, '=Y=' ).replace( /m/g, '=M=' ).replace( /d/g, '=D=' );
		value = value.replace( /=Y=/g, '_' );
		value = value.replace( /____/g, date.getFullYear() );
		value = value.replace( /__/g, ( date.getFullYear() + '' ).substring( 2, 4 ) );
		value = value.replace( /_/g, 'y' ).replace( /=M=/g, '_' );
		value = value.replace( /____/g, myself.months[ date.getMonth() ] );
		value = value.replace( /___/g, myself.months[ date.getMonth() ].substring( 0, 3 ) );
		value = value.replace( /__/g, pad( date.getMonth() + 1 ) );
		value = value.replace( /_/g, date.getMonth() + 1 );
		value = value.replace( /_/g, 'm' ).replace( /=D=/g, '_' );
		value = value.replace( /____/g, myself.daynames_long[ date.getDay() ] );
		value = value.replace( /___/g, myself.daynames_short[ date.getDay() ] );
		value = value.replace( /__/g, pad( date.getDate() ) );
		value = value.replace( /_/g, date.getDate() );
		value = value.replace( /_/g, 'd' ).replace( /XQTQX/g, '_' );
		return value;
	}
	
	this.getSelected = function()
	{
		if ( selected.length == 0 ) 
			return null;
		
		var date = '' + selected[0];
		// Fixed format
		var year = parseInt( date.substring( 0, 4 ), 10 );
		var month = parseInt( date.substring( 4, 6 ), 10 );
		var day = parseInt( date.substring( 6, 8 ), 10 );
			
		return new Date( year, month, day );
	}
	
	this.select = function( date )
	{
		var d = myself.parseDate( date ); 
		
		selected.clear();
		selected.push( ( d.getFullYear() * 100 + d.getMonth() ) * 100 + d.getDate() );
		
		this.pagedate = date;
		this.render();
	}
	
	this.deselect = function()
	{
		selected.clear();
		this.render();
	}
	
	this.render = function()
	{
		// Update the rendered html
		container.update( html() );
		
		// Create next/previous month links
		container.getElementsBySelector('a[mod]').each( function( element ) { element.observe( 'click', clickMoveMonth ); } );
		
		if ( this.onclick != null ) {
			container.getElementsBySelector('td[dt]').each( function( element ) { 
														element.observe( 'click', activeClicked );  
													} );
		}
	}
		
	function html()
	{
		var pd	= myself.parseDate( myself.pagedate );
		
		if ( pd == null ) return;
		
		var m	= pd.getMonth() + 1;
		var y	= pd.getFullYear();
		var mdl = y * 100 + pd.getMonth();
		
		var mn	= myself.months;

		var oD	= new Date( y, m-1, 1 ); //DD replaced line to fix date bug when current day is 31st
		oD.od	= oD.getDay(); //DD replaced line to fix date bug when current day is 31st
		
		if ( oD.od == 0 )
			oD.od = 7;
		
		// Render output
		var t = '<div class="' + myself.cssclass + '"><table cols="7" cellspacing="0"><tr align="center">';
		t += '<td colspan="7" align="center" class="month">';

		if ( max <= 0 || Math.round(max / 100) > mdl ) 
			t+= '<a mod="1" class="next" href="javascript:void(0)">&raquo;</a>';
		if ( min <= 0 || Math.round(min / 100) < mdl ) 
			t+= '<a mod="-1" class="previous" href="javascript:void(0)">&laquo;</a>';
		
		t += myself.renderFormat( pd, myself.headerformat ) + '</td></tr><tr align="center">';

		// Render day of week headers
		for ( var s = 0; s < 7; s++ )
			t += '<td class="header">' + myself.days.substr( s, 1 ) + '</td>';
		
		t += '</tr><tr align="center">';
		
		// Render the days
		var daycount = getDaysInMonth( y, m );
		var finish = false;
		
		for ( var i = 1; i <= 42 && !finish; i++ )
		{
			var dayNum = ( ( i - oD.od >= 0 ) && ( i - oD.od < daycount ) ) ? i - oD.od + 1 : 0;
			
			if ( dayNum == 0 )
				t += '<td>&nbsp;</td>';
			else
			{
				var day = ( y * 100 + ( m - 1 ) ) * 100 + dayNum;
				var content = dayNum;
				
				var classes = null;
				var value = '';
				
				if ( selected.indexOf( day ) >= 0 )
					classes = "sel";
				if ( ( min <= 0 || min <= day ) && ( max <= 0 || day <= max )
						&& ( ( active == null && ( myself.onclick != null || myself.link != null ) ) 
									|| ( active != null && active.indexOf( day ) >= 0 )  ) ) 
				{
					classes += " act";
					
					var dayDate = new Date( y, m - 1, dayNum );
					var href = ' href="javascript:void(0)"';
					
					if ( myself.link != null )
						href = ' href="' + createUrl( myself.link, dayDate ) + '"';
					
					value = ' dt="' + day + '"';
					
					content = '<a' + href + ' title="' + myself.renderFormat( dayDate, myself.tooltipformat ) + '">' + content + '</a>';
				}
				
				if ( classes != null )
					t+= '<td class="' + classes.strip() + '"' + value + '>' + content + '</td>';
				else
					t+= '<td>' + content + '</td>';
			}
			
			if ( ( i % 7 == 0 ) && ( i < 36 ) ) {
				if ( dayNum > 0 && dayNum < daycount )
					t += '</tr><tr align="center">';
				else
					finish = true;
			}
		}
		
		return t += '</tr></table></div>';
	}
		
	initialize();
}


/******************************************************************************
 * articleSearch.js
 *****************************************************************************/
Event.observe(window, 'load', function(event) {
	var co = 3;
	var mo = '<div class="swf_crit"><select name="article.operator"><option value="AND">et</option><option value="OR">ou</option><option value="NEAR">pr&egrave;s de</option><option value="NOT">ne ...pas</option></select></div><input type="text" maxlength="50" name="search.query" value="" /></div>';	
	$$('form.art_f input.qlist').each(function(ql) {
		var mo = '<div><select name="article.operator"><option value="AND"' + addOpe(co,'AND') + '>et</option><option value="OR"' + addOpe(co,'OR') + '>ou</option><option value="NEAR"' + addOpe(co,'NEAR') + '>pr&egrave;s de</option><option value="NOT"' + addOpe(co,'NOT') + '>ne ...pas</option></select></div><input type="text" maxlength="50" name="search.query" value="' + addVal(co) + '" /></div>';	
		var qv = ql.readAttribute('value');
		if (qv.length != 0) {
			new Insertion.Before('more_c', mo); 
			co += 1;
		}	
	});
	if ($('query_5')) {	
		if ($('query_5').value.length == 0) {
			if ($('swf_submit')) { new Insertion.Before('swf_submit', '<div id="more_i"><a id="more_a">Plus de crit&egrave;res de recherche</a></div>'); }
	}	}
	if ($('more_a')) {
		Event.observe('more_a', 'click', function(event) {
			new Insertion.Before('more_c', mo); 
			co += 1;
			if (co == 6) { $('more_i').remove(); }
			Event.stop(event);
		});
	}
	// onsubmit warrants & options check 
	$$('div#war_srch form.chck_f','div#opt_srch form.chck_f').each(function(sfm) {
		Event.observe(sfm, 'submit', function(event) {
			var selb = false;
			var subb = false;
			var inpf = sfm.down('input.chk_inp').id;
			$$('select.chk_sel').each(function(sl) {
				var op = sl.options[sl.selectedIndex].value.toLowerCase();
				if (!(op == 'all')) selb = true;
			});					
			if ((!(selb)) && ($(inpf).value.length < 3)) subb = true; 							
		if (subb) {
			Effect.BlindDown(sfm.down('h4'));
			sfm.down('h4').addClassName('err');
			Event.stop(event);			
		}	
	});	});
	// onchange warrants & options remove error
	$$('select.chk_sel').each(function(sl) {
		Event.observe(sl, 'focus', Checks.generic.bindAsEventListener(Checks));
	});
	// onfocus warrants & options remove error
	$$('input.chk_inp').each(function(sl) {
		Event.observe(sl, 'focus', Checks.generic.bindAsEventListener(Checks)); 
	});			
});

var Checks = {
  generic: function(event) {
    var sl = Event.element(event);
    if (sl.up(2).down('h4').hasClassName('err')) {
	Effect.BlindUp(sl.up(2).down('h4'));
    }
  }
};

function addVal(co) {
	var qv = $('query_' + co).value;
	if (qv.length != 0) return qv;	
}

function addOpe(co,val) {
	var qv = $('operate_' + co).value;
	if (qv == val) return ' selected="selected"';	
}
