/*
 * jQuery 1.2.6 - New Wave Javascript
 *
 * Copyright (c) 2008 John Resig (jquery.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * $Date: 2008-05-24 14:22:17 -0400 (Sat, 24 May 2008) $
 * $Rev: 5685 $
 */
 /* ====================================== ///// End jquery-latest.js ====================================== */

/* ====================================== Begin jquery.specialhover.js ====================================== */

;(function($){ // secure $ jQuery alias
/*******************************************************************************************/	
// jquery.event.hover.js - rev 5 
// Copyright (c) 2008, Three Dub Media (http://threedubmedia.com)
// Liscensed under the MIT License (MIT-LICENSE.txt)
// http://www.opensource.org/licenses/mit-license.php
// Created: 2008-06-02 | Updated: 2008-07-30
/*******************************************************************************************/

//	USE THESE PROPERTIES TO CUSTOMIZE SETTINGS...

//	$.event.special.hover.delay = 100; 
//	Defines the delay (msec) while mouse is inside the element before checking the speed

//	$.event.special.hover.speed = 100; 
//	Defines the maximum speed (px/sec) the mouse may be moving to trigger the hover event

// save the old jquery "hover" method
$.fn._hover = $.fn.hover;

// jquery method 
$.fn.hover = function( fn1, fn2, fn3 ) {
	if ( fn3 ) this.bind('hoverstart', fn1 ); // 3 args
	if ( fn2 ) this.bind('hoverend', fn3 ? fn3 : fn2 ); // 2+ args
	return !fn1 ? this.trigger('hover') // 0 args 
		: this.bind('hover', fn3 ? fn2 : fn1 ); // 1+ args
	};	

// special event configuration
var hover = $.event.special.hover = {
	delay: 100, // milliseconds
	speed: 100, // pixels per second
	setup: function( data ){
		data = $.extend({ speed: hover.speed, delay: hover.delay, hovered:0 }, data||{} );
		$.event.add( this, "mouseenter mouseleave", hoverHandler, data );
		},
	teardown: function(){
		$.event.remove( this, "mouseenter mouseleave", hoverHandler );
		}
	};

// shared event handler
function hoverHandler( event ){
	var data = event.data || event;
	switch ( event.type ){
		case 'mouseenter': // mouseover
			data.dist2 = 0; // init mouse distance²
			data.event = event; // store the event
			event.type = "hoverstart"; // hijack event
			if ( $.event.handle.call( this, event ) !== false ){ // handle "hoverstart"
				data.elem = this; // ref to the current element
				$.event.add( this, "mousemove", hoverHandler, data ); // track the mouse
				data.timer = setTimeout( compare, data.delay ); // start async compare
				}
			break;
		case 'mousemove': // track the event, mouse distance² = x² + y²
			data.dist2 += Math.pow( event.pageX-data.event.pageX, 2 ) 
				+ Math.pow( event.pageY-data.event.pageY, 2 ); 
			data.event = event; // store current event
			break;
		case 'mouseleave': // mouseout
			clearTimeout( data.timer ); // uncompare
			if ( data.hovered ){ 
				event.type = "hoverend"; // hijack event
				$.event.handle.call( this, event ); // handle "hoverend"
				data.hovered--; // reset flag
				}
			else $.event.remove( data.elem, "mousemove", hoverHandler ); // untrack
			break;
		default: // timeout compare // distance² = x² + y²  = ( speed * time )²
			if ( data.dist2 <= Math.pow( data.speed*( data.delay/1e3 ), 2 ) ){ // speed acceptable
				$.event.remove( data.elem, "mousemove", hoverHandler ); // untrack
				data.event.type = "hover"; // hijack event
				if ( $.event.handle.call( data.elem, data.event ) !== false ) // handle "hover"
					data.hovered++; // flag for "hoverend"
				}
			else data.timer = setTimeout( compare, data.delay ); // async recurse
			data.dist2 = 0; // reset distance² for next compare
			break;
		}
	function compare(){ hoverHandler( data ); }; // timeout/recursive function
	};
	
/*******************************************************************************************/
})(jQuery); // confine scope

/* ====================================== ///// End jquery.specialhover.js ====================================== */

/* ====================================== Begin date.js ====================================== */


/*
 * Date prototype extensions. Doesn't depend on any
 * other code. Doens't overwrite existing methods.
 *
 * Adds dayNames, abbrDayNames, monthNames and abbrMonthNames static properties and isLeapYear,
 * isWeekend, isWeekDay, getDaysInMonth, getDayName, getMonthName, getDayOfYear, getWeekOfYear,
 * setDayOfYear, addYears, addMonths, addDays, addHours, addMinutes, addSeconds methods
 *
 * Copyright (c) 2006 JÃ¶rn Zaefferer and Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
 *
 * Additional methods and properties added by Kelvin Luck: firstDayOfWeek, dateFormat, zeroTime, asString, fromString -
 * I've added my name to these methods so you know who to blame if they are broken!
 * 
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 */

/**
 * An Array of day names starting with Sunday.
 * 
 * @example dayNames[0]
 * @result 'Sunday'
 *
 * @name dayNames
 * @type Array
 * @cat Plugins/Methods/Date
 */
Date.dayNames = ['Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag'];

/**
 * An Array of abbreviated day names starting with Sun.
 * 
 * @example abbrDayNames[0]
 * @result 'Sun'
 *
 * @name abbrDayNames
 * @type Array
 * @cat Plugins/Methods/Date
 */
Date.abbrDayNames = ['Zon', 'Ma', 'Di', 'Woe', 'Don', 'Vrij', 'Zat'];

/**
 * An Array of month names starting with Janurary.
 * 
 * @example monthNames[0]
 * @result 'January'
 *
 * @name monthNames
 * @type Array
 * @cat Plugins/Methods/Date
 */
Date.monthNames = ['Januari', 'Februari', 'Maart', 'April', 'Mei', 'Juni', 'July', 'Augustus', 'September', 'Oktober', 'November', 'December'];

/**
 * An Array of abbreviated month names starting with Jan.
 * 
 * @example abbrMonthNames[0]
 * @result 'Jan'
 *
 * @name monthNames
 * @type Array
 * @cat Plugins/Methods/Date
 */
Date.abbrMonthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'];

/**
 * The first day of the week for this locale.
 *
 * @name firstDayOfWeek
 * @type Number
 * @cat Plugins/Methods/Date
 * @author Kelvin Luck
 */
Date.firstDayOfWeek = 1;

/**
 * The format that string dates should be represented as (e.g. 'dd/mm/yyyy' for UK, 'mm/dd/yyyy' for US, 'yyyy-mm-dd' for Unicode etc).
 *
 * @name format
 * @type String
 * @cat Plugins/Methods/Date
 * @author Kelvin Luck
 */
Date.format = 'dd/mm/yyyy';
//Date.format = 'mm/dd/yyyy';
//Date.format = 'yyyy-mm-dd';
//Date.format = 'dd mmm yy';

/**
 * The first two numbers in the century to be used when decoding a two digit year. Since a two digit year is ambiguous (and date.setYear
 * only works with numbers < 99 and so doesn't allow you to set years after 2000) we need to use this to disambiguate the two digit year codes.
 *
 * @name format
 * @type String
 * @cat Plugins/Methods/Date
 * @author Kelvin Luck
 */
Date.fullYearStart = '20';

(function() {

	/**
	 * Adds a given method under the given name 
	 * to the Date prototype if it doesn't
	 * currently exist.
	 *
	 * @private
	 */
	function add(name, method) {
		if( !Date.prototype[name] ) {
			Date.prototype[name] = method;
		}
	};
	
	/**
	 * Checks if the year is a leap year.
	 *
	 * @example var dtm = new Date("01/12/2008");
	 * dtm.isLeapYear();
	 * @result true
	 *
	 * @name isLeapYear
	 * @type Boolean
	 * @cat Plugins/Methods/Date
	 */
	add("isLeapYear", function() {
		var y = this.getFullYear();
		return (y%4==0 && y%100!=0) || y%400==0;
	});
	
	/**
	 * Checks if the day is a weekend day (Sat or Sun).
	 *
	 * @example var dtm = new Date("01/12/2008");
	 * dtm.isWeekend();
	 * @result false
	 *
	 * @name isWeekend
	 * @type Boolean
	 * @cat Plugins/Methods/Date
	 */
	add("isWeekend", function() {
		return this.getDay()==0 || this.getDay()==6;
	});
	
	/**
	 * Check if the day is a day of the week (Mon-Fri)
	 * 
	 * @example var dtm = new Date("01/12/2008");
	 * dtm.isWeekDay();
	 * @result false
	 * 
	 * @name isWeekDay
	 * @type Boolean
	 * @cat Plugins/Methods/Date
	 */
	add("isWeekDay", function() {
		return !this.isWeekend();
	});
	
	/**
	 * Gets the number of days in the month.
	 * 
	 * @example var dtm = new Date("01/12/2008");
	 * dtm.getDaysInMonth();
	 * @result 31
	 * 
	 * @name getDaysInMonth
	 * @type Number
	 * @cat Plugins/Methods/Date
	 */
	add("getDaysInMonth", function() {
		return [31,(this.isLeapYear() ? 29:28),31,30,31,30,31,31,30,31,30,31][this.getMonth()];
	});
	
	/**
	 * Gets the name of the day.
	 * 
	 * @example var dtm = new Date("01/12/2008");
	 * dtm.getDayName();
	 * @result 'Saturday'
	 * 
	 * @example var dtm = new Date("01/12/2008");
	 * dtm.getDayName(true);
	 * @result 'Sat'
	 * 
	 * @param abbreviated Boolean When set to true the name will be abbreviated.
	 * @name getDayName
	 * @type String
	 * @cat Plugins/Methods/Date
	 */
	add("getDayName", function(abbreviated) {
		return abbreviated ? Date.abbrDayNames[this.getDay()] : Date.dayNames[this.getDay()];
	});

	/**
	 * Gets the name of the month.
	 * 
	 * @example var dtm = new Date("01/12/2008");
	 * dtm.getMonthName();
	 * @result 'Janurary'
	 *
	 * @example var dtm = new Date("01/12/2008");
	 * dtm.getMonthName(true);
	 * @result 'Jan'
	 * 
	 * @param abbreviated Boolean When set to true the name will be abbreviated.
	 * @name getDayName
	 * @type String
	 * @cat Plugins/Methods/Date
	 */
	add("getMonthName", function(abbreviated) {
		return abbreviated ? Date.abbrMonthNames[this.getMonth()] : Date.monthNames[this.getMonth()];
	});

	/**
	 * Get the number of the day of the year.
	 * 
	 * @example var dtm = new Date("01/12/2008");
	 * dtm.getDayOfYear();
	 * @result 11
	 * 
	 * @name getDayOfYear
	 * @type Number
	 * @cat Plugins/Methods/Date
	 */
	add("getDayOfYear", function() {
		var tmpdtm = new Date("1/1/" + this.getFullYear());
		return Math.floor((this.getTime() - tmpdtm.getTime()) / 86400000);
	});
	
	/**
	 * Get the number of the week of the year.
	 * 
	 * @example var dtm = new Date("01/12/2008");
	 * dtm.getWeekOfYear();
	 * @result 2
	 * 
	 * @name getWeekOfYear
	 * @type Number
	 * @cat Plugins/Methods/Date
	 */
	add("getWeekOfYear", function() {
		return Math.ceil(this.getDayOfYear() / 7);
	});

	/**
	 * Set the day of the year.
	 * 
	 * @example var dtm = new Date("01/12/2008");
	 * dtm.setDayOfYear(1);
	 * dtm.toString();
	 * @result 'Tue Jan 01 2008 00:00:00'
	 * 
	 * @name setDayOfYear
	 * @type Date
	 * @cat Plugins/Methods/Date
	 */
	add("setDayOfYear", function(day) {
		this.setMonth(0);
		this.setDate(day);
		return this;
	});
	
	/**
	 * Add a number of years to the date object.
	 * 
	 * @example var dtm = new Date("01/12/2008");
	 * dtm.addYears(1);
	 * dtm.toString();
	 * @result 'Mon Jan 12 2009 00:00:00'
	 * 
	 * @name addYears
	 * @type Date
	 * @cat Plugins/Methods/Date
	 */
	add("addYears", function(num) {
		this.setFullYear(this.getFullYear() + num);
		return this;
	});
	
	/**
	 * Add a number of months to the date object.
	 * 
	 * @example var dtm = new Date("01/12/2008");
	 * dtm.addMonths(1);
	 * dtm.toString();
	 * @result 'Tue Feb 12 2008 00:00:00'
	 * 
	 * @name addMonths
	 * @type Date
	 * @cat Plugins/Methods/Date
	 */
	add("addMonths", function(num) {
		var tmpdtm = this.getDate();
		
		this.setMonth(this.getMonth() + num);
		
		if (tmpdtm > this.getDate())
			this.addDays(-this.getDate());
		
		return this;
	});
	
	/**
	 * Add a number of days to the date object.
	 * 
	 * @example var dtm = new Date("01/12/2008");
	 * dtm.addDays(1);
	 * dtm.toString();
	 * @result 'Sun Jan 13 2008 00:00:00'
	 * 
	 * @name addDays
	 * @type Date
	 * @cat Plugins/Methods/Date
	 */
	add("addDays", function(num) {
		this.setDate(this.getDate() + num);
		return this;
	});
	
	/**
	 * Add a number of hours to the date object.
	 * 
	 * @example var dtm = new Date("01/12/2008");
	 * dtm.addHours(24);
	 * dtm.toString();
	 * @result 'Sun Jan 13 2008 00:00:00'
	 * 
	 * @name addHours
	 * @type Date
	 * @cat Plugins/Methods/Date
	 */
	add("addHours", function(num) {
		this.setHours(this.getHours() + num);
		return this;
	});

	/**
	 * Add a number of minutes to the date object.
	 * 
	 * @example var dtm = new Date("01/12/2008");
	 * dtm.addMinutes(60);
	 * dtm.toString();
	 * @result 'Sat Jan 12 2008 01:00:00'
	 * 
	 * @name addMinutes
	 * @type Date
	 * @cat Plugins/Methods/Date
	 */
	add("addMinutes", function(num) {
		this.setMinutes(this.getMinutes() + num);
		return this;
	});
	
	/**
	 * Add a number of seconds to the date object.
	 * 
	 * @example var dtm = new Date("01/12/2008");
	 * dtm.addSeconds(60);
	 * dtm.toString();
	 * @result 'Sat Jan 12 2008 00:01:00'
	 * 
	 * @name addSeconds
	 * @type Date
	 * @cat Plugins/Methods/Date
	 */
	add("addSeconds", function(num) {
		this.setSeconds(this.getSeconds() + num);
		return this;
	});
	
	/**
	 * Sets the time component of this Date to zero for cleaner, easier comparison of dates where time is not relevant.
	 * 
	 * @example var dtm = new Date();
	 * dtm.zeroTime();
	 * dtm.toString();
	 * @result 'Sat Jan 12 2008 00:01:00'
	 * 
	 * @name zeroTime
	 * @type Date
	 * @cat Plugins/Methods/Date
	 * @author Kelvin Luck
	 */
	add("zeroTime", function() {
		this.setMilliseconds(0);
		this.setSeconds(0);
		this.setMinutes(0);
		this.setHours(0);
		return this;
	});
	
	/**
	 * Returns a string representation of the date object according to Date.format.
	 * (Date.toString may be used in other places so I purposefully didn't overwrite it)
	 * 
	 * @example var dtm = new Date("01/12/2008");
	 * dtm.asString();
	 * @result '12/01/2008' // (where Date.format == 'dd/mm/yyyy'
	 * 
	 * @name asString
	 * @type Date
	 * @cat Plugins/Methods/Date
	 * @author Kelvin Luck
	 */
	add("asString", function() {
		var r = Date.format;
		return r
			.split('yyyy').join(this.getFullYear())
			.split('yy').join((this.getFullYear() + '').substring(2))
			.split('mmm').join(this.getMonthName(true))
			.split('mm').join(_zeroPad(this.getMonth()+1))
			.split('dd').join(_zeroPad(this.getDate()));
	});
	
	/**
	 * Returns a new date object created from the passed String according to Date.format or false if the attempt to do this results in an invalid date object
	 * (We can't simple use Date.parse as it's not aware of locale and I chose not to overwrite it incase it's functionality is being relied on elsewhere)
	 *
	 * @example var dtm = Date.fromString("12/01/2008");
	 * dtm.toString();
	 * @result 'Sat Jan 12 2008 00:00:00' // (where Date.format == 'dd/mm/yyyy'
	 * 
	 * @name fromString
	 * @type Date
	 * @cat Plugins/Methods/Date
	 * @author Kelvin Luck
	 */
	Date.fromString = function(s)
	{
		var f = Date.format;
		var d = new Date('01/01/1977');
		var iY = f.indexOf('yyyy');
		if (iY > -1) {
			d.setFullYear(Number(s.substr(iY, 4)));
		} else {
			// TODO - this doesn't work very well - are there any rules for what is meant by a two digit year?
			d.setFullYear(Number(Date.fullYearStart + s.substr(f.indexOf('yy'), 2)));
		}
		var iM = f.indexOf('mmm');
		if (iM > -1) {
			var mStr = s.substr(iM, 3);
			for (var i=0; i<Date.abbrMonthNames.length; i++) {
				if (Date.abbrMonthNames[i] == mStr) break;
			}
			d.setMonth(i);
		} else {
			d.setMonth(Number(s.substr(f.indexOf('mm'), 2)) - 1);
		}
		d.setDate(Number(s.substr(f.indexOf('dd'), 2)));
		if (isNaN(d.getTime())) {
			return false;
		}
		return d;
	};
	
	// utility method
	var _zeroPad = function(num) {
		var s = '0'+num;
		return s.substring(s.length-2)
		//return ('0'+num).substring(-2); // doesn't work on IE :(
	};
	
})();

/* ====================================== ///// End Date.js ====================================== */

/* ====================================== Begin jquery.dimensions.js ====================================== */

/* Copyright (c) 2007 Paul Bakaus (paul.bakaus@googlemail.com) and Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $LastChangedDate: 2007-06-22 04:38:37 +0200 (Fr, 22 Jun 2007) $
 * $Rev: 2141 $
 *
 * Version: 1.0b2
 */

(function($){

// store a copy of the core height and width methods
var height = $.fn.height,
    width  = $.fn.width;

$.fn.extend({
	/**
	 * If used on document, returns the document's height (innerHeight)
	 * If used on window, returns the viewport's (window) height
	 * See core docs on height() to see what happens when used on an element.
	 *
	 * @example $("#testdiv").height()
	 * @result 200
	 *
	 * @example $(document).height()
	 * @result 800
	 *
	 * @example $(window).height()
	 * @result 400
	 *
	 * @name height
	 * @type Object
	 * @cat Plugins/Dimensions
	 */
	height: function() {
		if ( this[0] == window )
			return self.innerHeight ||
				$.boxModel && document.documentElement.clientHeight || 
				document.body.clientHeight;
		
		if ( this[0] == document )
			return Math.max( document.body.scrollHeight, document.body.offsetHeight );
		
		return height.apply(this, arguments);
	},
	
	/**
	 * If used on document, returns the document's width (innerWidth)
	 * If used on window, returns the viewport's (window) width
	 * See core docs on height() to see what happens when used on an element.
	 *
	 * @example $("#testdiv").width()
	 * @result 200
	 *
	 * @example $(document).width()
	 * @result 800
	 *
	 * @example $(window).width()
	 * @result 400
	 *
	 * @name width
	 * @type Object
	 * @cat Plugins/Dimensions
	 */
	width: function() {
		if ( this[0] == window )
			return self.innerWidth ||
				$.boxModel && document.documentElement.clientWidth ||
				document.body.clientWidth;

		if ( this[0] == document )
			return Math.max( document.body.scrollWidth, document.body.offsetWidth );

		return width.apply(this, arguments);
	},
	
	/**
	 * Returns the inner height value (without border) for the first matched element.
	 * If used on document, returns the document's height (innerHeight)
	 * If used on window, returns the viewport's (window) height
	 *
	 * @example $("#testdiv").innerHeight()
	 * @result 800
	 *
	 * @name innerHeight
	 * @type Number
	 * @cat Plugins/Dimensions
	 */
	innerHeight: function() {
		return this[0] == window || this[0] == document ?
			this.height() :
			this.is(':visible') ?
				this[0].offsetHeight - num(this, 'borderTopWidth') - num(this, 'borderBottomWidth') :
				this.height() + num(this, 'paddingTop') + num(this, 'paddingBottom');
	},
	
	/**
	 * Returns the inner width value (without border) for the first matched element.
	 * If used on document, returns the document's Width (innerWidth)
	 * If used on window, returns the viewport's (window) width
	 *
	 * @example $("#testdiv").innerWidth()
	 * @result 1000
	 *
	 * @name innerWidth
	 * @type Number
	 * @cat Plugins/Dimensions
	 */
	innerWidth: function() {
		return this[0] == window || this[0] == document ?
			this.width() :
			this.is(':visible') ?
				this[0].offsetWidth - num(this, 'borderLeftWidth') - num(this, 'borderRightWidth') :
				this.width() + num(this, 'paddingLeft') + num(this, 'paddingRight');
	},
	
	/**
	 * Returns the outer height value (including border) for the first matched element.
	 * Cannot be used on document or window.
	 *
	 * @example $("#testdiv").outerHeight()
	 * @result 1000
	 *
	 * @name outerHeight
	 * @type Number
	 * @cat Plugins/Dimensions
	 */
	outerHeight: function() {
		return this[0] == window || this[0] == document ?
			this.height() :
			this.is(':visible') ?
				this[0].offsetHeight :
				this.height() + num(this,'borderTopWidth') + num(this, 'borderBottomWidth') + num(this, 'paddingTop') + num(this, 'paddingBottom');
	},
	
	/**
	 * Returns the outer width value (including border) for the first matched element.
	 * Cannot be used on document or window.
	 *
	 * @example $("#testdiv").outerHeight()
	 * @result 1000
	 *
	 * @name outerHeight
	 * @type Number
	 * @cat Plugins/Dimensions
	 */
	outerWidth: function() {
		return this[0] == window || this[0] == document ?
			this.width() :
			this.is(':visible') ?
				this[0].offsetWidth :
				this.width() + num(this, 'borderLeftWidth') + num(this, 'borderRightWidth') + num(this, 'paddingLeft') + num(this, 'paddingRight');
	},
	
	/**
	 * Returns how many pixels the user has scrolled to the right (scrollLeft).
	 * Works on containers with overflow: auto and window/document.
	 *
	 * @example $("#testdiv").scrollLeft()
	 * @result 100
	 *
	 * @name scrollLeft
	 * @type Number
	 * @cat Plugins/Dimensions
	 */
	/**
	 * Sets the scrollLeft property and continues the chain.
	 * Works on containers with overflow: auto and window/document.
	 *
	 * @example $("#testdiv").scrollLeft(10).scrollLeft()
	 * @result 10
	 *
	 * @name scrollLeft
	 * @param Number value A positive number representing the desired scrollLeft.
	 * @type jQuery
	 * @cat Plugins/Dimensions
	 */
	scrollLeft: function(val) {
		if ( val != undefined )
			// set the scroll left
			return this.each(function() {
				if (this == window || this == document)
					window.scrollTo( val, $(window).scrollTop() );
				else
					this.scrollLeft = val;
			});
		
		// return the scroll left offest in pixels
		if ( this[0] == window || this[0] == document )
			return self.pageXOffset ||
				$.boxModel && document.documentElement.scrollLeft ||
				document.body.scrollLeft;
				
		return this[0].scrollLeft;
	},
	
	/**
	 * Returns how many pixels the user has scrolled to the bottom (scrollTop).
	 * Works on containers with overflow: auto and window/document.
	 *
	 * @example $("#testdiv").scrollTop()
	 * @result 100
	 *
	 * @name scrollTop
	 * @type Number
	 * @cat Plugins/Dimensions
	 */
	/**
	 * Sets the scrollTop property and continues the chain.
	 * Works on containers with overflow: auto and window/document.
	 *
	 * @example $("#testdiv").scrollTop(10).scrollTop()
	 * @result 10
	 *
	 * @name scrollTop
	 * @param Number value A positive number representing the desired scrollTop.
	 * @type jQuery
	 * @cat Plugins/Dimensions
	 */
	scrollTop: function(val) {
		if ( val != undefined )
			// set the scroll top
			return this.each(function() {
				if (this == window || this == document)
					window.scrollTo( $(window).scrollLeft(), val );
				else
					this.scrollTop = val;
			});
		
		// return the scroll top offset in pixels
		if ( this[0] == window || this[0] == document )
			return self.pageYOffset ||
				$.boxModel && document.documentElement.scrollTop ||
				document.body.scrollTop;

		return this[0].scrollTop;
	},
	
	/** 
	 * Returns the top and left positioned offset in pixels.
	 * The positioned offset is the offset between a positioned
	 * parent and the element itself.
	 *
	 * @example $("#testdiv").position()
	 * @result { top: 100, left: 100 }
	 * 
	 * @name position
	 * @param Map options Optional settings to configure the way the offset is calculated.
	 * @option Boolean margin Should the margin of the element be included in the calculations? False by default.
	 * @option Boolean border Should the border of the element be included in the calculations? False by default.
	 * @option Boolean padding Should the padding of the element be included in the calculations? False by default.
	 * @param Object returnObject An object to store the return value in, so as not to break the chain. If passed in the
	 *                            chain will not be broken and the result will be assigned to this object.
	 * @type Object
	 * @cat Plugins/Dimensions
	 */
	position: function(options, returnObject) {
		var elem = this[0], parent = elem.parentNode, op = elem.offsetParent,
		    options = $.extend({ margin: false, border: false, padding: false, scroll: false }, options || {}),
			x = elem.offsetLeft,
			y = elem.offsetTop, 
			sl = elem.scrollLeft, 
			st = elem.scrollTop;
			
		// Mozilla and IE do not add the border
		if ($.browser.mozilla || $.browser.msie) {
			// add borders to offset
			x += num(elem, 'borderLeftWidth');
			y += num(elem, 'borderTopWidth');
		}

		if ($.browser.mozilla) {
			do {
				// Mozilla does not add the border for a parent that has overflow set to anything but visible
				if ($.browser.mozilla && parent != elem && $.css(parent, 'overflow') != 'visible') {
					x += num(parent, 'borderLeftWidth');
					y += num(parent, 'borderTopWidth');
				}

				if (parent == op) break; // break if we are already at the offestParent
			} while ((parent = parent.parentNode) && (parent.tagName.toLowerCase() != 'body' || parent.tagName.toLowerCase() != 'html'));
		}
		
		var returnValue = handleOffsetReturn(elem, options, x, y, sl, st);
		
		if (returnObject) { $.extend(returnObject, returnValue); return this; }
		else              { return returnValue; }
	},
	
	/**
	 * Returns the location of the element in pixels from the top left corner of the viewport.
	 *
	 * For accurate readings make sure to use pixel values for margins, borders and padding.
	 * 
	 * Known issues:
	 *  - Issue: A div positioned relative or static without any content before it and its parent will report an offsetTop of 0 in Safari
	 *    Workaround: Place content before the relative div ... and set height and width to 0 and overflow to hidden
	 *
	 * @example $("#testdiv").offset()
	 * @result { top: 100, left: 100, scrollTop: 10, scrollLeft: 10 }
	 *
	 * @example $("#testdiv").offset({ scroll: false })
	 * @result { top: 90, left: 90 }
	 *
	 * @example var offset = {}
	 * $("#testdiv").offset({ scroll: false }, offset)
	 * @result offset = { top: 90, left: 90 }
	 *
	 * @name offset
	 * @param Map options Optional settings to configure the way the offset is calculated.
	 * @option Boolean margin Should the margin of the element be included in the calculations? True by default.
	 * @option Boolean border Should the border of the element be included in the calculations? False by default.
	 * @option Boolean padding Should the padding of the element be included in the calculations? False by default.
	 * @option Boolean scroll Should the scroll offsets of the parent elements be included in the calculations? True by default.
	 *                        When true it adds the totla scroll offets of all parents to the total offset and also adds two properties
	 *                        to the returned object, scrollTop and scrollLeft. 
	 * @options Boolean lite Will use offsetLite instead of offset when set to true. False by default.
	 * @param Object returnObject An object to store the return value in, so as not to break the chain. If passed in the
	 *                            chain will not be broken and the result will be assigned to this object.
	 * @type Object
	 * @cat Plugins/Dimensions
	 */
	offset: function(options, returnObject) {
		var x = 0, y = 0, sl = 0, st = 0,
		    elem = this[0], parent = this[0], op, parPos, elemPos = $.css(elem, 'position'),
		    mo = $.browser.mozilla, ie = $.browser.msie, sf = $.browser.safari, oa = $.browser.opera,
		    absparent = false, relparent = false, 
		    options = $.extend({ margin: true, border: false, padding: false, scroll: true, lite: false }, options || {});
		
		// Use offsetLite if lite option is true
		if (options.lite) return this.offsetLite(options, returnObject);
		
		if (elem.tagName.toLowerCase() == 'body') {
			// Safari is the only one to get offsetLeft and offsetTop properties of the body "correct"
			// Except they all mess up when the body is positioned absolute or relative
			x = elem.offsetLeft;
			y = elem.offsetTop;
			// Mozilla ignores margin and subtracts border from body element
			if (mo) {
				x += num(elem, 'marginLeft') + (num(elem, 'borderLeftWidth')*2);
				y += num(elem, 'marginTop')  + (num(elem, 'borderTopWidth') *2);
			} else
			// Opera ignores margin
			if (oa) {
				x += num(elem, 'marginLeft');
				y += num(elem, 'marginTop');
			} else
			// IE does not add the border in Standards Mode
			if (ie && jQuery.boxModel) {
				x += num(elem, 'borderLeftWidth');
				y += num(elem, 'borderTopWidth');
			}
		} else {
			do {
				parPos = $.css(parent, 'position');
			
				x += parent.offsetLeft;
				y += parent.offsetTop;

				// Mozilla and IE do not add the border
				if (mo || ie) {
					// add borders to offset
					x += num(parent, 'borderLeftWidth');
					y += num(parent, 'borderTopWidth');

					// Mozilla does not include the border on body if an element isn't positioned absolute and is without an absolute parent
					if (mo && parPos == 'absolute') absparent = true;
					// IE does not include the border on the body if an element is position static and without an absolute or relative parent
					if (ie && parPos == 'relative') relparent = true;
				}

				op = parent.offsetParent;
				if (options.scroll || mo) {
					do {
						if (options.scroll) {
							// get scroll offsets
							sl += parent.scrollLeft;
							st += parent.scrollTop;
						}
				
						// Mozilla does not add the border for a parent that has overflow set to anything but visible
						if (mo && parent != elem && $.css(parent, 'overflow') != 'visible') {
							x += num(parent, 'borderLeftWidth');
							y += num(parent, 'borderTopWidth');
						}
				
						parent = parent.parentNode;
					} while (parent != op);
				}
				parent = op;

				if (parent.tagName.toLowerCase() == 'body' || parent.tagName.toLowerCase() == 'html') {
					// Safari and IE Standards Mode doesn't add the body margin for elments positioned with static or relative
					if ((sf || (ie && $.boxModel)) && elemPos != 'absolute' && elemPos != 'fixed') {
						x += num(parent, 'marginLeft');
						y += num(parent, 'marginTop');
					}
					// Mozilla does not include the border on body if an element isn't positioned absolute and is without an absolute parent
					// IE does not include the border on the body if an element is positioned static and without an absolute or relative parent
					if ( (mo && !absparent && elemPos != 'fixed') || 
					     (ie && elemPos == 'static' && !relparent) ) {
						x += num(parent, 'borderLeftWidth');
						y += num(parent, 'borderTopWidth');
					}
					break; // Exit the loop
				}
			} while (parent);
		}

		var returnValue = handleOffsetReturn(elem, options, x, y, sl, st);

		if (returnObject) { $.extend(returnObject, returnValue); return this; }
		else              { return returnValue; }
	},
	
	/**
	 * Returns the location of the element in pixels from the top left corner of the viewport.
	 * This method is much faster than offset but not as accurate. This method can be invoked
	 * by setting the lite option to true in the offset method.
	 *
	 * @name offsetLite
	 * @param Map options Optional settings to configure the way the offset is calculated.
	 * @option Boolean margin Should the margin of the element be included in the calculations? True by default.
	 * @option Boolean border Should the border of the element be included in the calculations? False by default.
	 * @option Boolean padding Should the padding of the element be included in the calculations? False by default.
	 * @option Boolean scroll Should the scroll offsets of the parent elements be included in the calculations? True by default.
	 *                        When true it adds the totla scroll offets of all parents to the total offset and also adds two properties
	 *                        to the returned object, scrollTop and scrollLeft. 
	 * @param Object returnObject An object to store the return value in, so as not to break the chain. If passed in the
	 *                            chain will not be broken and the result will be assigned to this object.
	 * @type Object
	 * @cat Plugins/Dimensions
	 */
	offsetLite: function(options, returnObject) {
		var x = 0, y = 0, sl = 0, st = 0, parent = this[0], op, 
		    options = $.extend({ margin: true, border: false, padding: false, scroll: true }, options || {});
				
		do {
			x += parent.offsetLeft;
			y += parent.offsetTop;

			op = parent.offsetParent;
			if (options.scroll) {
				// get scroll offsets
				do {
					sl += parent.scrollLeft;
					st += parent.scrollTop;
					parent = parent.parentNode;
				} while(parent != op);
			}
			parent = op;
		} while (parent && parent.tagName.toLowerCase() != 'body' && parent.tagName.toLowerCase() != 'html');

		var returnValue = handleOffsetReturn(this[0], options, x, y, sl, st);

		if (returnObject) { $.extend(returnObject, returnValue); return this; }
		else              { return returnValue; }
	}
});

/**
 * Handles converting a CSS Style into an Integer.
 * @private
 */
var num = function(el, prop) {
	return parseInt($.css(el.jquery?el[0]:el,prop))||0;
};

/**
 * Handles the return value of the offset and offsetLite methods.
 * @private
 */
var handleOffsetReturn = function(elem, options, x, y, sl, st) {
	if ( !options.margin ) {
		x -= num(elem, 'marginLeft');
		y -= num(elem, 'marginTop');
	}

	// Safari and Opera do not add the border for the element
	if ( options.border && ($.browser.safari || $.browser.opera) ) {
		x += num(elem, 'borderLeftWidth');
		y += num(elem, 'borderTopWidth');
	} else if ( !options.border && !($.browser.safari || $.browser.opera) ) {
		x -= num(elem, 'borderLeftWidth');
		y -= num(elem, 'borderTopWidth');
	}

	if ( options.padding ) {
		x += num(elem, 'paddingLeft');
		y += num(elem, 'paddingTop');
	}
	
	// do not include scroll offset on the element
	if ( options.scroll ) {
		sl -= elem.scrollLeft;
		st -= elem.scrollTop;
	}

	return options.scroll ? { top: y - st, left: x - sl, scrollTop:  st, scrollLeft: sl }
	                      : { top: y, left: x };
};

})(jQuery);


/* ====================================== ///// End jquery.dimensions.js ====================================== */

/* ====================================== Start jquery.ajaxmanager.js ====================================== */

/**
 * @author alexander.farkas
 * @version 1.01 
 */
(function($){
    $.extend({
        manageAjax: function(o){
            o = $.extend({
                manageType: 'normal',
                maxReq: 0,
                blockSameRequest: false,
				global: true
            }, o);
            return new $.ajaxManager(o);
        },
        ajaxManager: function(o){
            this.opt = o;
            this.queue = [];
        }
    });
    $.extend($.ajaxManager.prototype, {
        add: function(o){
            var quLen = this.queue.length, s = this.opt, q = this.queue, self = this, i, j;
            var cD = (o.data && typeof o.data != "string") ? $.param(o.data) : o.data;
            if (s.blockSameRequest) {
                var toPrevent = false;
                for (i = 0; i < quLen; i++) {
                    if (q[i] && q[i].data === cD && q[i].url === o.url && q[i].type === o.type) {
                        toPrevent = true;
                        break;
                    }
                }
                if (toPrevent) {
                    return false;
                }
            }
            q[quLen] = {
                fnError: o.error,
                fnSuccess: o.success,
                fnComplete: o.complete,
                fnAbort: o.abort,
                error: [],
                success: [],
                complete: [],
                done: false,
                queued: false,
                data: cD,
                url: o.url,
                type: o.type,
                xhr: null
            };
            
            o.error = function(){
                if (q[quLen]) {
                    q[quLen].error = arguments;
                }
            };
            o.success = function(){
                if (q[quLen]) {
                    q[quLen].success = arguments;
                }
            };
            o.abort = function(){
                if (q[quLen]) {
                    q[quLen].abort = arguments;
                }
            };
            function startCallbacks(num){
                if (q[num].fnError) {
                    q[num].fnError.apply($, q[num].error);
                }
                if (q[num].fnSuccess) {
                    q[num].fnSuccess.apply($, q[num].success);
                }
                if (q[num].fnComplete) {
                    q[num].fnComplete.apply($, q[num].complete);
                }
                self.abort(num, true);
            }
            
            o.complete = function(){
                if (!q[quLen]) {
                    return;
                }
                q[quLen].complete = arguments;
                q[quLen].done = true;
                switch (s.manageType) {
                    case 'sync':
                        if (quLen === 0 || !q[quLen - 1]) {
                            var curQLen = q.length;
                            for (i = quLen; i < curQLen; i++) {
                                if (q[i]) {
                                    if (q[i].done) {
                                        startCallbacks(i);
                                    }
                                    else {
                                        break;
                                    }
                                }
                                
                            }
                        }
                        break;
                    case 'queue':
                        if (quLen === 0 || !q[quLen - 1]) {
                            var curQLen = q.length;
                            for (i = 0, j = 0; i < curQLen; i++) {
                                if (q[i] && q[i].queued) {
                                    q[i].xhr = jQuery.ajax(q[i].xhr);
                                    q[i].queued = false;
                                    break;
                                }
                            }
                        }
                        startCallbacks(quLen);
                        break;
                    case 'abortOld':
                        startCallbacks(quLen);
                        for (i = quLen; i >= 0; i--) {
                            if (q[i]) {
                                self.abort(i);
                            }
                        }
                        break;
                    default:
                        startCallbacks(quLen);
                        break;
                }
            };
            
            if (s.maxReq) {
                if (s.manageType != 'queue') {
                    for (i = quLen, j = 0; i >= 0; i--) {
                        if (j >= s.maxReq) {
                            this.abort(i);
                        }
                        if (q[i]) {
                            j++;
                        }
                    }
                }
                else {
                    for (i = 0, j = 0; i <= quLen && !q[quLen].queued; i++) {
                        if (q[i] && !q[i].queued) 
                            j++;
                        if (j > s.maxReq) 
                            q[quLen].queued = true;
                    }
                }
            }
            q[quLen].xhr = (q[quLen].queued) ? o : jQuery.ajax(o);
            return quLen;
        },
        cleanUp: function(){
            this.queue = [];
        },
        abort: function(num, completed){
            var qLen = this.queue.length, s = this.opt, q = this.queue, self = this, i;
            function del(num){
                if (!q[num]) {
                    return;
                }
                (!completed && q[num].fnAbort) && q[num].fnAbort.apply($, [num]);
                if (!q[num]) {
                    return;
                }
                if (q[num].xhr) {
                    if (typeof q[num].xhr.abort != 'undefined') {
                        q[num].xhr.abort();
                    }
                    if (typeof q[num].xhr.close != 'undefined') {
                        q[num].xhr.close();
                    }
                    q[num].xhr = null;
                }
				// Handle the global AJAX counter
			
				if ( s.global && $.active && ! --$.active){
					$.event.trigger( "ajaxStop" );
				}
                q[num] = null;
            }
            if (!num && num !== 0) {
                for (i = 0; i < qLen; i++) {
                    del(i);
                }
                this.cleanUp();
            }
            else {
                del(num);
                var allowCleaning = true;
                for (i = qLen; i >= 0; i--) {
                    if (q[i]) {
                        allowCleaning = false;
                        break;
                    }
                }
                if (allowCleaning) {
                    this.cleanUp();
                }
            }
        }
    });
})(jQuery);

/* ====================================== ///// End jquery.ajaxmanager.js ====================================== */

/* ====================================== Begin jquery.tooltip.js ====================================== */

/*
 * jQuery Tooltip plugin 1.2
 *
 * http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/
 * http://docs.jquery.com/Plugins/Tooltip
 *
 * Copyright (c) 2006 - 2008 Jörn Zaefferer
 *
 * $Id: jquery.tooltip.js 4569 2008-01-31 19:36:35Z joern.zaefferer $
 * 
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */;(function($){var helper={},current,title,tID,IE=$.browser.msie&&/MSIE\s(5\.5|6\.)/.test(navigator.userAgent),track=false;$.tooltip={blocked:false,defaults:{delay:200,showURL:true,extraClass:"",top:15,left:15,id:"tooltip"},block:function(){$.tooltip.blocked=!$.tooltip.blocked;}};$.fn.extend({tooltip:function(settings){settings=$.extend({},$.tooltip.defaults,settings);createHelper(settings);return this.each(function(){$.data(this,"tooltip-settings",settings);this.tooltipText=this.title;$(this).removeAttr("title");this.alt="";}).hover(save,hide).click(hide);},fixPNG:IE?function(){return this.each(function(){var image=$(this).css('backgroundImage');if(image.match(/^url\(["']?(.*\.png)["']?\)$/i)){image=RegExp.$1;$(this).css({'backgroundImage':'none','filter':"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='"+image+"')"}).each(function(){var position=$(this).css('position');if(position!='absolute'&&position!='relative')$(this).css('position','relative');});}});}:function(){return this;},unfixPNG:IE?function(){return this.each(function(){$(this).css({'filter':'',backgroundImage:''});});}:function(){return this;},hideWhenEmpty:function(){return this.each(function(){$(this)[$(this).html()?"show":"hide"]();});},url:function(){return this.attr('href')||this.attr('src');}});function createHelper(settings){if(helper.parent)return;helper.parent=$('<div id="'+settings.id+'"><h3></h3><div class="body"></div><div class="url"></div></div>').appendTo(document.body).hide();if($.fn.bgiframe)helper.parent.bgiframe();helper.title=$('h3',helper.parent);helper.body=$('div.body',helper.parent);helper.url=$('div.url',helper.parent);}function settings(element){return $.data(element,"tooltip-settings");}function handle(event){if(settings(this).delay)tID=setTimeout(show,settings(this).delay);else
show();track=!!settings(this).track;$(document.body).bind('mousemove',update);update(event);}function save(){if($.tooltip.blocked||this==current||(!this.tooltipText&&!settings(this).bodyHandler))return;current=this;title=this.tooltipText;if(settings(this).bodyHandler){helper.title.hide();var bodyContent=settings(this).bodyHandler.call(this);if(bodyContent.nodeType||bodyContent.jquery){helper.body.empty().append(bodyContent)}else{helper.body.html(bodyContent);}helper.body.show();}else if(settings(this).showBody){var parts=title.split(settings(this).showBody);helper.title.html(parts.shift()).show();helper.body.empty();for(var i=0,part;part=parts[i];i++){if(i>0)helper.body.append("<br/>");helper.body.append(part);}helper.body.hideWhenEmpty();}else{helper.title.html(title).show();helper.body.hide();}if(settings(this).showURL&&$(this).url())helper.url.html($(this).url().replace('http://','')).show();else
helper.url.hide();helper.parent.addClass(settings(this).extraClass);if(settings(this).fixPNG)helper.parent.fixPNG();handle.apply(this,arguments);}function show(){tID=null;helper.parent.show();update();}function update(event){if($.tooltip.blocked)return;if(!track&&helper.parent.is(":visible")){$(document.body).unbind('mousemove',update)}if(current==null){$(document.body).unbind('mousemove',update);return;}helper.parent.removeClass("viewport-right").removeClass("viewport-bottom");var left=helper.parent[0].offsetLeft;var top=helper.parent[0].offsetTop;if(event){left=event.pageX+settings(current).left;top=event.pageY+settings(current).top;helper.parent.css({left:left+'px',top:top+'px'});}var v=viewport(),h=helper.parent[0];if(v.x+v.cx<h.offsetLeft+h.offsetWidth){left-=h.offsetWidth+20+settings(current).left;helper.parent.css({left:left+'px'}).addClass("viewport-right");}if(v.y+v.cy<h.offsetTop+h.offsetHeight){top-=h.offsetHeight+20+settings(current).top;helper.parent.css({top:top+'px'}).addClass("viewport-bottom");}}function viewport(){return{x:$(window).scrollLeft(),y:$(window).scrollTop(),cx:$(window).width(),cy:$(window).height()};}function hide(event){if($.tooltip.blocked)return;if(tID)clearTimeout(tID);current=null;helper.parent.hide().removeClass(settings(this).extraClass);if(settings(this).fixPNG)helper.parent.unfixPNG();}$.fn.Tooltip=$.fn.tooltip;})(jQuery);

/* ====================================== ///// End jquery.tooltip.js ====================================== */

/* ====================================== Start jquery.datepicker.js ====================================== */


/**
 * Copyright (c) 2007 Kelvin Luck (http://www.kelvinluck.com/)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $Id: jquery.datePicker.js 3739 2007-10-25 13:55:30Z kelvin.luck $
 **/

(function($){
    
	$.fn.extend({
/**
 * Render a calendar table into any matched elements.
 * 
 * @param Object s (optional) Customize your calendars.
 * @option Number month The month to render (NOTE that months are zero based). Default is today's month.
 * @option Number year The year to render. Default is today's year.
 * @option Function renderCallback A reference to a function that is called as each cell is rendered and which can add classes and event listeners to the created nodes. Default is no callback.
 * @option Number showHeader Whether or not to show the header row, possible values are: $.dpConst.SHOW_HEADER_NONE (no header), $.dpConst.SHOW_HEADER_SHORT (first letter of each day) and $.dpConst.SHOW_HEADER_LONG (full name of each day). Default is $.dpConst.SHOW_HEADER_SHORT.
 * @option String hoverClass The class to attach to each cell when you hover over it (to allow you to use hover effects in IE6 which doesn't support the :hover pseudo-class on elements other than links). Default is dp-hover. Pass false if you don't want a hover class.
 * @type jQuery
 * @name renderCalendar
 * @cat plugins/datePicker
 * @author Kelvin Luck (http://www.kelvinluck.com/)
 *
 * @example $('#calendar-me').renderCalendar({month:0, year:2007});
 * @desc Renders a calendar displaying January 2007 into the element with an id of calendar-me.
 *
 * @example
 * var testCallback = function($td, thisDate, month, year)
 * {
 * if ($td.is('.current-month') && thisDate.getDay() == 4) {
 *		var d = thisDate.getDate();
 *		$td.bind(
 *			'click',
 *			function()
 *			{
 *				alert('You clicked on ' + d + '/' + (Number(month)+1) + '/' + year);
 *			}
 *		).addClass('thursday');
 *	} else if (thisDate.getDay() == 5) {
 *		$td.html('Friday the ' + $td.html() + 'th');
 *	}
 * }
 * $('#calendar-me').renderCalendar({month:0, year:2007, renderCallback:testCallback});
 * 
 * @desc Renders a calendar displaying January 2007 into the element with an id of calendar-me. Every Thursday in the current month has a class of "thursday" applied to it, is clickable and shows an alert when clicked. Every Friday on the calendar has the number inside replaced with text.
 **/
		renderCalendar  :   function(s)
		{
			var dc = function(a)
			{
				return document.createElement(a);
			};
			
			s = $.extend(
				{
					month			: null,
					year			: null,
					renderCallback	: null,
					showHeader		: $.dpConst.SHOW_HEADER_SHORT,
					dpController	: null,
					hoverClass		: 'dp-hover'
				}
				, s
			);
			
			if (s.showHeader != $.dpConst.SHOW_HEADER_NONE) {
				var headRow = $(dc('tr'));
				for (var i=Date.firstDayOfWeek; i<Date.firstDayOfWeek+7; i++) {
					var weekday = i%7;
					var day = Date.dayNames[weekday];
					headRow.append(
						jQuery(dc('th')).attr({'scope':'col', 'abbr':day, 'title':day, 'class':(weekday == 0 || weekday == 6 ? 'weekend' : 'weekday')}).html(s.showHeader == $.dpConst.SHOW_HEADER_SHORT ? day.substr(0, 1) : day)
					);
				}
			};
			
			var calendarTable = $(dc('table'))
									.attr(
										{
											'cellspacing':2,
											'className':'jCalendar'
										}
									)
									.append(
										(s.showHeader != $.dpConst.SHOW_HEADER_NONE ? 
											$(dc('thead'))
												.append(headRow)
											:
											dc('thead')
										)
									);
			var tbody = $(dc('tbody'));
			
			var today = (new Date()).zeroTime();
			
			var month = s.month == undefined ? today.getMonth() : s.month;
			var year = s.year || today.getFullYear();
			
			var currentDate = new Date(year, month, 1);
			
			
			var firstDayOffset = Date.firstDayOfWeek - currentDate.getDay() + 1;
			if (firstDayOffset > 1) firstDayOffset -= 7;
			var weeksToDraw = Math.ceil(( (-1*firstDayOffset+1) + currentDate.getDaysInMonth() ) /7);
			currentDate.addDays(firstDayOffset-1);
			
			var doHover = function()
			{
				if (s.hoverClass) {
					$(this).addClass(s.hoverClass);
				}
			};
			var unHover = function()
			{
				if (s.hoverClass) {
					$(this).removeClass(s.hoverClass);
				}
			};
			
			var w = 0;
			while (w++<weeksToDraw) {
				var r = jQuery(dc('tr'));
				for (var i=0; i<7; i++) {
					var thisMonth = currentDate.getMonth() == month;
					var d = $(dc('td'))
								.text(currentDate.getDate() + '')
								.attr('className', (thisMonth ? 'current-month ' : 'other-month ') +
													(currentDate.isWeekend() ? 'weekend ' : 'weekday ') +
													(thisMonth && currentDate.getTime() == today.getTime() ? 'today ' : '')
								)
								.hover(doHover, unHover)
							;
					if (s.renderCallback) {
						s.renderCallback(d, currentDate, month, year);
					}
					r.append(d);
					currentDate.addDays(1);
				}
				tbody.append(r);
			}
			calendarTable.append(tbody);
			
			return this.each(
				function()
				{
					$(this).empty().append(calendarTable);
				}
			);
		},
/**
 * Create a datePicker associated with each of the matched elements.
 *
 * The matched element will receive a few custom events with the following signatures:
 *
 * dateSelected(event, date, $td, status)
 * Triggered when a date is selected. event is a reference to the event, date is the Date selected, $td is a jquery object wrapped around the TD that was clicked on and status is whether the date was selected (true) or deselected (false)
 * 
 * dpClosed(event, selected)
 * Triggered when the date picker is closed. event is a reference to the event and selected is an Array containing Date objects.
 *
 * dpMonthChanged(event, displayedMonth, displayedYear)
 * Triggered when the month of the popped up calendar is changed. event is a reference to the event, displayedMonth is the number of the month now displayed (zero based) and displayedYear is the year of the month.
 *
 * dpDisplayed(event, $datePickerDiv)
 * Triggered when the date picker is created. $datePickerDiv is the div containing the date picker. Use this event to add custom content/ listeners to the popped up date picker.
 *
 * @param Object s (optional) Customize your date pickers.
 * @option Number month The month to render when the date picker is opened (NOTE that months are zero based). Default is today's month.
 * @option Number year The year to render when the date picker is opened. Default is today's year.
 * @option String startDate The first date date can be selected.
 * @option String endDate The last date that can be selected.
 * @option Boolean inline Whether to create the datePicker as inline (e.g. always on the page) or as a model popup. Default is false (== modal popup)
 * @option Boolean createButton Whether to create a .dp-choose-date anchor directly after the matched element which when clicked will trigger the showing of the date picker. Default is true.
 * @option Boolean showYearNavigation Whether to display buttons which allow the user to navigate through the months a year at a time. Default is true.
 * @option Boolean closeOnSelect Whether to close the date picker when a date is selected. Default is true.
 * @option Boolean displayClose Whether to create a "Close" button within the date picker popup. Default is false.
 * @option Boolean selectMultiple Whether a user should be able to select multiple dates with this date picker. Default is false.
 * @option Boolean clickInput If the matched element is an input type="text" and this option is true then clicking on the input will cause the date picker to appear.
 * @option Number verticalPosition The vertical alignment of the popped up date picker to the matched element. One of $.dpConst.POS_TOP and $.dpConst.POS_BOTTOM. Default is $.dpConst.POS_TOP.
 * @option Number horizontalPosition The horizontal alignment of the popped up date picker to the matched element. One of $.dpConst.POS_LEFT and $.dpConst.POS_RIGHT.
 * @option Number verticalOffset The number of pixels offset from the defined verticalPosition of this date picker that it should pop up in. Default in 0.
 * @option Number horizontalOffset The number of pixels offset from the defined horizontalPosition of this date picker that it should pop up in. Default in 0.
 * @option (Function|Array) renderCallback A reference to a function (or an array of seperate functions) that is called as each cell is rendered and which can add classes and event listeners to the created nodes. Each callback function will receive four arguments; a jquery object wrapping the created TD, a Date object containing the date this TD represents, a number giving the currently rendered month and a number giving the currently rendered year. Default is no callback.
 * @option String hoverClass The class to attach to each cell when you hover over it (to allow you to use hover effects in IE6 which doesn't support the :hover pseudo-class on elements other than links). Default is dp-hover. Pass false if you don't want a hover class.
 * @type jQuery
 * @name datePicker
 * @cat plugins/datePicker
 * @author Kelvin Luck (http://www.kelvinluck.com/)
 *
 * @example $('input.date-picker').datePicker();
 * @desc Creates a date picker button next to all matched input elements. When the button is clicked on the value of the selected date will be placed in the corresponding input (formatted according to Date.format).
 *
 * @example demo/index.html
 * @desc See the projects homepage for many more complex examples...
 **/
		datePicker : function(s)
		{			
			if (!$.event._dpCache) $.event._dpCache = [];
			
			// initialise the date picker controller with the relevant settings...
			s = $.extend(
				{
					month				: undefined,
					year				: undefined,
					startDate			: undefined,
					endDate				: undefined,
					inline				: false,
					renderCallback		: [],
					createButton		: true,
					showYearNavigation	: true,
					closeOnSelect		: true,
					displayClose		: false,
					selectMultiple		: false,
					clickInput			: false,
					verticalPosition	: $.dpConst.POS_TOP,
					horizontalPosition	: $.dpConst.POS_LEFT,
					verticalOffset		: 0,
					horizontalOffset	: 0,
					hoverClass			: 'dp-hover'
				}
				, s
			);
			
			return this.each(
				function()
				{
					var $this = $(this);
					var alreadyExists = true;
					
					if (!this._dpId) {
						this._dpId = $.event.guid++;
						$.event._dpCache[this._dpId] = new DatePicker(this);
						alreadyExists = false;
					}
					
					if (s.inline) {
						s.createButton = false;
						s.displayClose = false;
						s.closeOnSelect = false;
						$this.empty();
					}
					
					var controller = $.event._dpCache[this._dpId];
					
					controller.init(s);
					
					if (!alreadyExists && s.createButton) {
						// create it!
						controller.button = $('<a href="#" class="dp-choose-date" title="' + $.dpText.TEXT_CHOOSE_DATE + '">' + $.dpText.TEXT_CHOOSE_DATE + '</a>')
								.bind(
									'click',
									function()
									{
										$this.dpDisplay(this);
										this.blur();
										return false;
									}
								);
						$this.after(controller.button);
					}
					
					if (!alreadyExists && $this.is(':text')) {
						$this
							.bind(
								'dateSelected',
								function(e, selectedDate, $td)
								{
									this.value = selectedDate.asString();
								}
							).bind(
								'change',
								function()
								{
									var d = Date.fromString(this.value);
									if (d) {
										controller.setSelected(d, true, true);
									}
								}
							);
						if (s.clickInput) {
							$this.bind(
								'click',
								function()
								{
									$this.dpDisplay();
								}
							);
						}
						var d = Date.fromString(this.value);
						if (this.value != '' && d) {
							controller.setSelected(d, true, true);
						}
					}
					
					$this.addClass('dp-applied');
					
				}
			)
		},
/**
 * Disables or enables this date picker
 *
 * @param Boolean s Whether to disable (true) or enable (false) this datePicker
 * @type jQuery
 * @name dpSetDisabled
 * @cat plugins/datePicker
 * @author Kelvin Luck (http://www.kelvinluck.com/)
 *
 * @example $('.date-picker').datePicker();
 * $('.date-picker').dpSetDisabled(true);
 * @desc Prevents this date picker from displaying and adds a class of dp-disabled to it (and it's associated button if it has one) for styling purposes. If the matched element is an input field then it will also set the disabled attribute to stop people directly editing the field.
 **/
		dpSetDisabled : function(s)
		{
			return _w.call(this, 'setDisabled', s);
		},
/**
 * Updates the first selectable date for any date pickers on any matched elements.
 *
 * @param String d A string representing the first selectable date (formatted according to Date.format).
 * @type jQuery
 * @name dpSetStartDate
 * @cat plugins/datePicker
 * @author Kelvin Luck (http://www.kelvinluck.com/)
 *
 * @example $('.date-picker').datePicker();
 * $('.date-picker').dpSetStartDate('01/01/2000');
 * @desc Creates a date picker associated with all elements with a class of "date-picker" then sets the first selectable date for each of these to the first day of the millenium.
 **/
		dpSetStartDate : function(d)
		{
			return _w.call(this, 'setStartDate', d);
		},
/**
 * Updates the last selectable date for any date pickers on any matched elements.
 *
 * @param String d A string representing the last selectable date (formatted according to Date.format).
 * @type jQuery
 * @name dpSetEndDate
 * @cat plugins/datePicker
 * @author Kelvin Luck (http://www.kelvinluck.com/)
 *
 * @example $('.date-picker').datePicker();
 * $('.date-picker').dpSetEndDate('01/01/2010');
 * @desc Creates a date picker associated with all elements with a class of "date-picker" then sets the last selectable date for each of these to the first Janurary 2010.
 **/
		dpSetEndDate : function(d)
		{
			return _w.call(this, 'setEndDate', d);
		},
/**
 * Gets a list of Dates currently selected by this datePicker. This will be an empty array if no dates are currently selected or NULL if there is no datePicker associated with the matched element.
 *
 * @type Array
 * @name dpGetSelected
 * @cat plugins/datePicker
 * @author Kelvin Luck (http://www.kelvinluck.com/)
 *
 * @example $('.date-picker').datePicker();
 * alert($('.date-picker').dpGetSelected());
 * @desc Will alert an empty array (as nothing is selected yet)
 **/
		dpGetSelected : function()
		{
			var c = _getController(this[0]);
			if (c) {
				return c.getSelected();
			}
			return null;
		},
/**
 * Selects or deselects a date on any matched element's date pickers. Deselcting is only useful on date pickers where selectMultiple==true. Selecting will only work if the passed date is within the startDate and endDate boundries for a given date picker.
 *
 * @param String d A string representing the date you want to select (formatted according to Date.format).
 * @param Boolean v Whether you want to select (true) or deselect (false) this date. Optional - default = true.
 * @param Boolean m Whether you want the date picker to open up on the month of this date when it is next opened. Optional - default = true.
 * @type jQuery
 * @name dpSetSelected
 * @cat plugins/datePicker
 * @author Kelvin Luck (http://www.kelvinluck.com/)
 *
 * @example $('.date-picker').datePicker();
 * $('.date-picker').dpSetSelected('01/01/2010');
 * @desc Creates a date picker associated with all elements with a class of "date-picker" then sets the selected date on these date pickers to the first Janurary 2010. When the date picker is next opened it will display Janurary 2010.
 **/
		dpSetSelected : function(d, v, m)
		{
			if (v == undefined) v=true;
			if (m == undefined) m=true;
			return _w.call(this, 'setSelected', Date.fromString(d), v, m);
		},
/**
 * Sets the month that will be displayed when the date picker is next opened. If the passed month is before startDate then the month containing startDate will be displayed instead. If the passed month is after endDate then the month containing the endDate will be displayed instead.
 *
 * @param Number m The month you want the date picker to display. Optional - defaults to the currently displayed month.
 * @param Number y The year you want the date picker to display. Optional - defaults to the currently displayed year.
 * @type jQuery
 * @name dpSetDisplayedMonth
 * @cat plugins/datePicker
 * @author Kelvin Luck (http://www.kelvinluck.com/)
 *
 * @example $('.date-picker').datePicker();
 * $('.date-picker').dpSetDisplayedMonth(10, 2008);
 * @desc Creates a date picker associated with all elements with a class of "date-picker" then sets the selected date on these date pickers to the first Janurary 2010. When the date picker is next opened it will display Janurary 2010.
 **/
		dpSetDisplayedMonth : function(m, y)
		{
			return _w.call(this, 'setDisplayedMonth', Number(m), Number(y));
		},
/**
 * Displays the date picker associated with the matched elements. Since only one date picker can be displayed at once then the date picker associated with the last matched element will be the one that is displayed.
 *
 * @param HTMLElement e An element that you want the date picker to pop up relative in position to. Optional - default behaviour is to pop up next to the element associated with this date picker.
 * @type jQuery
 * @name dpDisplay
 * @cat plugins/datePicker
 * @author Kelvin Luck (http://www.kelvinluck.com/)
 *
 * @example $('#date-picker').datePicker();
 * $('#date-picker').dpDisplay();
 * @desc Creates a date picker associated with the element with an id of date-picker and then causes it to pop up.
 **/
		dpDisplay : function(e)
		{
			return _w.call(this, 'display', e);
		},
/**
 * Sets a function or array of functions that is called when each TD of the date picker popup is rendered to the page
 *
 * @param (Function|Array) a A function or an array of functions that are called when each td is rendered. Each function will receive four arguments; a jquery object wrapping the created TD, a Date object containing the date this TD represents, a number giving the currently rendered month and a number giving the currently rendered year.
 * @type jQuery
 * @name dpSetRenderCallback
 * @cat plugins/datePicker
 * @author Kelvin Luck (http://www.kelvinluck.com/)
 *
 * @example $('#date-picker').datePicker();
 * $('#date-picker').dpSetRenderCallback(function($td, thisDate, month, year)
 * {
 * 	// do stuff as each td is rendered dependant on the date in the td and the displayed month and year
 * });
 * @desc Creates a date picker associated with the element with an id of date-picker and then creates a function which is called as each td is rendered when this date picker is displayed.
 **/
		dpSetRenderCallback : function(a)
		{
			return _w.call(this, 'setRenderCallback', a);
		},
/**
 * Sets the position that the datePicker will pop up (relative to it's associated element)
 *
 * @param Number v The vertical alignment of the created date picker to it's associated element. Possible values are $.dpConst.POS_TOP and $.dpConst.POS_BOTTOM
 * @param Number h The horizontal alignment of the created date picker to it's associated element. Possible values are $.dpConst.POS_LEFT and $.dpConst.POS_RIGHT
 * @type jQuery
 * @name dpSetPosition
 * @cat plugins/datePicker
 * @author Kelvin Luck (http://www.kelvinluck.com/)
 *
 * @example $('#date-picker').datePicker();
 * $('#date-picker').dpSetPosition($.dpConst.POS_BOTTOM, $.dpConst.POS_RIGHT);
 * @desc Creates a date picker associated with the element with an id of date-picker and makes it so that when this date picker pops up it will be bottom and right aligned to the #date-picker element.
 **/
		dpSetPosition : function(v, h)
		{
			return _w.call(this, 'setPosition', v, h);
		},
/**
 * Sets the offset that the popped up date picker will have from it's default position relative to it's associated element (as set by dpSetPosition)
 *
 * @param Number v The vertical offset of the created date picker.
 * @param Number h The horizontal offset of the created date picker.
 * @type jQuery
 * @name dpSetOffset
 * @cat plugins/datePicker
 * @author Kelvin Luck (http://www.kelvinluck.com/)
 *
 * @example $('#date-picker').datePicker();
 * $('#date-picker').dpSetOffset(-20, 200);
 * @desc Creates a date picker associated with the element with an id of date-picker and makes it so that when this date picker pops up it will be 20 pixels above and 200 pixels to the right of it's default position.
 **/
		dpSetOffset : function(v, h)
		{
			return _w.call(this, 'setOffset', v, h);
		},
/**
 * Closes the open date picker associated with this element.
 *
 * @type jQuery
 * @name dpClose
 * @cat plugins/datePicker
 * @author Kelvin Luck (http://www.kelvinluck.com/)
 *
 * @example $('.date-pick')
 *		.datePicker()
 *		.bind(
 *			'focus',
 *			function()
 *			{
 *				$(this).dpDisplay();
 *			}
 *		).bind(
 *			'blur',
 *			function()
 *			{
 *				$(this).dpClose();
 *			}
 *		);
 * @desc Creates a date picker and makes it appear when the relevant element is focused and disappear when it is blurred.
 **/
		dpClose : function()
		{
			return _w.call(this, '_closeCalendar', false, this[0]);
		},
		// private function called on unload to clean up any expandos etc and prevent memory links...
		_dpDestroy : function()
		{
			// TODO - implement this?
		}
	});
	
	// private internal function to cut down on the amount of code needed where we forward
	// dp* methods on the jQuery object on to the relevant DatePicker controllers...
	var _w = function(f, a1, a2, a3)
	{
		return this.each(
			function()
			{
				var c = _getController(this);
				if (c) {
					c[f](a1, a2, a3);
				}
			}
		);
	};
	
	function DatePicker(ele)
	{
		this.ele = ele;
		
		// initial values...
		this.displayedMonth		=	null;
		this.displayedYear		=	null;
		this.startDate			=	null;
		this.endDate			=	null;
		this.showYearNavigation	=	null;
		this.closeOnSelect		=	null;
		this.displayClose		=	null;
		this.selectMultiple		=	null;
		this.verticalPosition	=	null;
		this.horizontalPosition	=	null;
		this.verticalOffset		=	null;
		this.horizontalOffset	=	null;
		this.button				=	null;
		this.renderCallback		=	[];
		this.selectedDates		=	{};
		this.inline				=	null;
		this.context			=	'#dp-popup';
	};
	$.extend(
		DatePicker.prototype,
		{	
			init : function(s)
			{
				this.setStartDate(s.startDate);
				this.setEndDate(s.endDate);
				this.setDisplayedMonth(Number(s.month), Number(s.year));
				this.setRenderCallback(s.renderCallback);
				this.showYearNavigation = s.showYearNavigation;
				this.closeOnSelect = s.closeOnSelect;
				this.displayClose = s.displayClose;
				this.selectMultiple = s.selectMultiple;
				this.verticalPosition = s.verticalPosition;
				this.horizontalPosition = s.horizontalPosition;
				this.hoverClass = s.hoverClass;
				this.setOffset(s.verticalOffset, s.horizontalOffset);
				this.inline = s.inline;
				if (this.inline) {
					this.context = this.ele;
					this.display();
				}
			},
			setStartDate : function(d)
			{
				if (d) {
					this.startDate = Date.fromString(d);
				}
				if (!this.startDate) {
					this.startDate = (new Date()).zeroTime();
				}
				this.setDisplayedMonth(this.displayedMonth, this.displayedYear);
			},
			setEndDate : function(d)
			{
				if (d) {
					this.endDate = Date.fromString(d);
				}
				if (!this.endDate) {
					this.endDate = (new Date('12/31/2999')); // using the JS Date.parse function which expects mm/dd/yyyy
				}
				if (this.endDate.getTime() < this.startDate.getTime()) {
					this.endDate = this.startDate;
				}
				this.setDisplayedMonth(this.displayedMonth, this.displayedYear);
			},
			setPosition : function(v, h)
			{
				this.verticalPosition = v;
				this.horizontalPosition = h;
			},
			setOffset : function(v, h)
			{
				this.verticalOffset = parseInt(v) || 0;
				this.horizontalOffset = parseInt(h) || 0;
			},
			setDisabled : function(s)
			{
				$e = $(this.ele);
				$e[s ? 'addClass' : 'removeClass']('dp-disabled');
				if (this.button) {
					$but = $(this.button);
					$but[s ? 'addClass' : 'removeClass']('dp-disabled');
					$but.attr('title', s ? '' : $.dpText.TEXT_CHOOSE_DATE);
				}
				if ($e.is(':text')) {
					$e.attr('disabled', s ? 'disabled' : '');
				}
			},
			setDisplayedMonth : function(m, y)
			{
				if (this.startDate == undefined || this.endDate == undefined) {
					return;
				}
				var s = new Date(this.startDate.getTime());
				s.setDate(1);
				var e = new Date(this.endDate.getTime());
				e.setDate(1);
				
				var t;
				if ((!m && !y) || (isNaN(m) && isNaN(y))) {
					// no month or year passed - default to current month
					t = new Date().zeroTime();
					t.setDate(1);
				} else if (isNaN(m)) {
					// just year passed in - presume we want the displayedMonth
					t = new Date(y, this.displayedMonth, 1);
				} else if (isNaN(y)) {
					// just month passed in - presume we want the displayedYear
					t = new Date(this.displayedYear, m, 1);
				} else {
					// year and month passed in - that's the date we want!
					t = new Date(y, m, 1)
				}
				
				// check if the desired date is within the range of our defined startDate and endDate
				if (t.getTime() < s.getTime()) {
					t = s;
				} else if (t.getTime() > e.getTime()) {
					t = e;
				}
				this.displayedMonth = t.getMonth();
				this.displayedYear = t.getFullYear();
			},
			setSelected : function(d, v, moveToMonth)
			{
				if (this.selectMultiple == false) {
					this.selectedDates = {};
					$('td.selected', this.context).removeClass('selected');
				}
				if (moveToMonth) {
					this.setDisplayedMonth(d.getMonth(), d.getFullYear());
				}
				this.selectedDates[d.toString()] = v;
			},
			isSelected : function(d)
			{
				return this.selectedDates[d.toString()];
			},
			getSelected : function()
			{
				var r = [];
				for(s in this.selectedDates) {
					if (this.selectedDates[s] == true) {
						r.push(Date.parse(s));
					}
				}
				return r;
			},
			display : function(eleAlignTo)
			{
				if ($(this.ele).is('.dp-disabled')) return;
				
				eleAlignTo = eleAlignTo || this.ele;
				var c = this;
				var $ele = $(eleAlignTo);
				var eleOffset = $ele.offset();
				
				var $createIn;
				var attrs;
				var attrsCalendarHolder;
				var cssRules;
				
				if (c.inline) {
					$createIn = $(this.ele);
					attrs = {
						'id'		:	'calendar-' + this.ele._dpId,
						'className'	:	'dp-popup dp-popup-inline'
					};
					cssRules = {
					};
				} else {
					$createIn = $('body');
					attrs = {
						'id'		:	'dp-popup',
						'className'	:	'dp-popup'
					};
					cssRules = {
						'top'	:	eleOffset.top + c.verticalOffset,
						'left'	:	eleOffset.left + c.horizontalOffset
					};
					
					var _checkMouse = function(e)
					{
						var el = e.target;
						var cal = $('#dp-popup')[0];
						
						while (true){
							if (el == cal) {
								return true;
							} else if (el == document) {
								c._closeCalendar();
								return false;
							} else {
								el = $(el).parent()[0];
							}
						}
					};
					this._checkMouse = _checkMouse;
				
					this._closeCalendar(true);
				}
				
				
				$createIn
					.append(
						$('<div></div>')
							.attr(attrs)
							.css(cssRules)
							.append(
								$('<h2></h2>'),
								$('<div class="dp-nav-prev"></div>')
									.append(
										$('<a class="dp-nav-prev-year" href="#" title="' + $.dpText.TEXT_PREV_YEAR + '">&lt;&lt;</a>')
											.bind(
												'click',
												function()
												{
													return c._displayNewMonth.call(c, this, 0, -1);
												}
											),
										$('<a class="dp-nav-prev-month" href="#" title="' + $.dpText.TEXT_PREV_MONTH + '">&lt;</a>')
											.bind(
												'click',
												function()
												{
													return c._displayNewMonth.call(c, this, -1, 0);
												}
											)
									),
								$('<div class="dp-nav-next"></div>')
									.append(
										$('<a class="dp-nav-next-year" href="#" title="' + $.dpText.TEXT_NEXT_YEAR + '">&gt;&gt;</a>')
											.bind(
												'click',
												function()
												{
													return c._displayNewMonth.call(c, this, 0, 1);
												}
											),
										$('<a class="dp-nav-next-month" href="#" title="' + $.dpText.TEXT_NEXT_MONTH + '">&gt;</a>')
											.bind(
												'click',
												function()
												{
													return c._displayNewMonth.call(c, this, 1, 0);
												}
											)
									),
								$('<div></div>')
									.attr('className', 'dp-calendar')
							)
							.bgIframe()
						);
					
				var $pop = this.inline ? $('.dp-popup', this.context) : $('#dp-popup');
				
				if (this.showYearNavigation == false) {
					$('.dp-nav-prev-year, .dp-nav-next-year', c.context).css('display', 'none');
				}
				if (this.displayClose) {
					$pop.append(
						$('<a href="#" id="dp-close">' + $.dpText.TEXT_CLOSE + '</a>')
							.bind(
								'click',
								function()
								{
									c._closeCalendar();
									return false;
								}
							)
					);
				}
				c._renderCalendar();
				
				$(this.ele).trigger('dpDisplayed', $pop);
				
				if (!c.inline) {
					if (this.verticalPosition == $.dpConst.POS_BOTTOM) {
						$pop.css('top', eleOffset.top + $ele.height() - $pop.height() + c.verticalOffset);
					}
					if (this.horizontalPosition == $.dpConst.POS_RIGHT) {
						$pop.css('left', eleOffset.left + $ele.width() - $pop.width() + c.horizontalOffset);
					}
					$(document).bind('mousedown', this._checkMouse);
				}
			},
			setRenderCallback : function(a)
			{
				if (a && typeof(a) == 'function') {
					a = [a];
				}
				this.renderCallback = this.renderCallback.concat(a);
			},
			cellRender : function ($td, thisDate, month, year) {
				var c = this.dpController;
				var d = new Date(thisDate.getTime());
				
				// add our click handlers to deal with it when the days are clicked...
				
				$td.bind(
					'click',
					function()
					{
						var $this = $(this);
						if (!$this.is('.disabled')) {
							c.setSelected(d, !$this.is('.selected') || !c.selectMultiple);
							var s = c.isSelected(d);
							$(c.ele).trigger('dateSelected', [d, $td, s]);
							$(c.ele).trigger('change');
							if (c.closeOnSelect) {
								c._closeCalendar();
							} else {
								$this[s ? 'addClass' : 'removeClass']('selected');
							}
						}
					}
				);
				
				if (c.isSelected(d)) {
					$td.addClass('selected');
				}
				
				// call any extra renderCallbacks that were passed in
				for (var i=0; i<c.renderCallback.length; i++) {
					c.renderCallback[i].apply(this, arguments);
				}
				
				
			},
			// ele is the clicked button - only proceed if it doesn't have the class disabled...
			// m and y are -1, 0 or 1 depending which direction we want to go in...
			_displayNewMonth : function(ele, m, y) 
			{
				if (!$(ele).is('.disabled')) {
					this.setDisplayedMonth(this.displayedMonth + m, this.displayedYear + y);
					this._clearCalendar();
					this._renderCalendar();
					$(this.ele).trigger('dpMonthChanged', [this.displayedMonth, this.displayedYear]);
				}
				ele.blur();
				return false;
			},
			_renderCalendar : function()
			{
				// set the title...
				$('h2', this.context).html(Date.monthNames[this.displayedMonth] + ' ' + this.displayedYear);
				
				// render the calendar...
				$('.dp-calendar', this.context).renderCalendar(
					{
						month			: this.displayedMonth,
						year			: this.displayedYear,
						renderCallback	: this.cellRender,
						dpController	: this,
						hoverClass		: this.hoverClass
					}
				);
				
				// update the status of the control buttons and disable dates before startDate or after endDate...

				// TODO: When should the year buttons be disabled? When you can't go forward a whole year from where you are or is that annoying?
				if (this.displayedYear == this.startDate.getFullYear() && this.displayedMonth == this.startDate.getMonth()) {
					$('.dp-nav-prev-year', this.context).addClass('disabled');
					$('.dp-nav-prev-month', this.context).addClass('disabled');
					$('.dp-calendar td.other-month', this.context).each(
						function()
						{
							var $this = $(this);
							if (Number($this.text()) > 20) {
								$this.addClass('disabled');
							}
						}
					);
					var d = this.startDate.getDate();
					$('.dp-calendar td.current-month', this.context).each(
						function()
						{
							var $this = $(this);
							if (Number($this.text()) < d) {
								$this.addClass('disabled');
							}
						}
					);
				} else {
					$('.dp-nav-prev-year', this.context).removeClass('disabled');
					$('.dp-nav-prev-month', this.context).removeClass('disabled');
					var d = this.startDate.getDate();
					if (d > 20) {
						// check if the startDate is last month as we might need to add some disabled classes...
						var sd = new Date(this.startDate.getTime());
						sd.addMonths(1);
						if (this.displayedYear == sd.getFullYear() && this.displayedMonth == sd.getMonth()) {
							$('dp-calendar td.other-month', this.context).each(
								function()
								{
									var $this = $(this);
									if (Number($this.text()) < d) {
										$this.addClass('disabled');
									}
								}
							);
						}
					}
				}
				if (this.displayedYear == this.endDate.getFullYear() && this.displayedMonth == this.endDate.getMonth()) {
					$('.dp-nav-next-year', this.context).addClass('disabled');
					$('.dp-nav-next-month', this.context).addClass('disabled');
					$('.dp-calendar td.other-month', this.context).each(
						function()
						{
							var $this = $(this);
							if (Number($this.text()) < 14) {
								$this.addClass('disabled');
							}
						}
					);
					var d = this.endDate.getDate();
					$('.dp-calendar td.current-month', this.context).each(
						function()
						{
							var $this = $(this);
							if (Number($this.text()) > d) {
								$this.addClass('disabled');
							}
						}
					);
				} else {
					$('.dp-nav-next-year', this.context).removeClass('disabled');
					$('.dp-nav-next-month', this.context).removeClass('disabled');
					var d = this.endDate.getDate();
					if (d < 13) {
						// check if the endDate is next month as we might need to add some disabled classes...
						var ed = new Date(this.endDate.getTime());
						ed.addMonths(-1);
						if (this.displayedYear == ed.getFullYear() && this.displayedMonth == ed.getMonth()) {
							$('.dp-calendar td.other-month', this.context).each(
								function()
								{
									var $this = $(this);
									if (Number($this.text()) > d) {
										$this.addClass('disabled');
									}
								}
							);
						}
					}
				}
			},
			_closeCalendar : function(programatic, ele)
			{
				if (!ele || ele == this.ele)
				{
					$(document).unbind('mousedown', this._checkMouse);
					this._clearCalendar();
					$('#dp-popup a').unbind();
					$('#dp-popup').empty().remove();
					if (!programatic) {
						$(this.ele).trigger('dpClosed', [this.getSelected()]);
					}
				}
			},
			// empties the current dp-calendar div and makes sure that all events are unbound
			// and expandos removed to avoid memory leaks...
			_clearCalendar : function()
			{
				// TODO.
				$('.dp-calendar td', this.context).unbind();
				$('.dp-calendar', this.context).empty();
			}
		}
	);
	
	// static constants
	$.dpConst = {
		SHOW_HEADER_NONE	:	0,
		SHOW_HEADER_SHORT	:	1,
		SHOW_HEADER_LONG	:	2,
		POS_TOP				:	0,
		POS_BOTTOM			:	1,
		POS_LEFT			:	0,
		POS_RIGHT			:	1
	};
	// localisable text
	$.dpText = {
		TEXT_PREV_YEAR		:	'Vorig jaar',
		TEXT_PREV_MONTH		:	'Vorige maand',
		TEXT_NEXT_YEAR		:	'Volgend jaar',
		TEXT_NEXT_MONTH		:	'Volgende maand',
		TEXT_CLOSE			:	'Sluit',
		TEXT_CHOOSE_DATE	:	'Kies datum'
	};
	// version
	$.dpVersion = '$Id: jquery.datePicker.js 3739 2007-10-25 13:55:30Z kelvin.luck $';

	function _getController(ele)
	{
		if (ele._dpId) return $.event._dpCache[ele._dpId];
		return false;
	};
	
	// make it so that no error is thrown if bgIframe plugin isn't included (allows you to use conditional
	// comments to only include bgIframe where it is needed in IE without breaking this plugin).
	if ($.fn.bgIframe == undefined) {
		$.fn.bgIframe = function() {return this; };
	};


	// clean-up
	$(window)
		.bind('unload', function() {
			var els = $.event._dpCache || [];
			for (var i in els) {
				$(els[i].ele)._dpDestroy();
			}
		});
		
	
})(jQuery);

/* ====================================== ///// End jquery.datepicker.js ====================================== */

/* ====================================== Start jquery.tablesorter.pak.js ====================================== */

eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(8($){$.1V({I:D 8(){7 C=[],1d=[];k.2v={28:"3Z",2b:"48",29:"49",2P:"4a",2D:"4b",1I:1E,1w:"25",C:{},1d:[],1m:{S:["2c","2L"]},x:{},2u:K,2Q:13,u:[],1y:[],1l:"2O",J:K};8 17(s,d){1h(s+","+(D T().1e()-d.1e())+"4c")}k.17=17;8 1h(s){q(1u 1P!="2S"&&1u 1P.J!="2S"){1P.1h(s)}N{2V(s)}}8 1T(6,$x){q(6.f.J){7 1O=""}7 G=6.L[0].G;q(6.L[0].G[0]){7 Z=[],12=G[0].12,l=12.w;y(7 i=0;i<l;i++){7 p=K;q($.1o&&($($x[i]).16()&&$($x[i]).16().1g)){p=1K($($x[i]).16().1g)}N q((6.f.x[i]&&6.f.x[i].1g)){p=1K(6.f.x[i].1g)}q(!p){p=22(6.f,12[i])}q(6.f.J){1O+="1D:"+i+" 1B:"+p.B+"\\n"}Z.R(p)}}q(6.f.J){1h(1O)}m Z};8 22(f,V){7 l=C.w;y(7 i=1;i<l;i++){q(C[i].O($.1M(1Q(f,V)))){m C[i]}}m C[0]}8 1K(1x){7 l=C.w;y(7 i=0;i<l;i++){q(C[i].B.14()==1x.14()){m C[i]}}m K}8 1U(6){q(6.f.J){7 23=D T()}7 19=(6.L[0]&&6.L[0].G.w)||0,2r=(6.L[0].G[0]&&6.L[0].G[0].12.w)||0,C=6.f.C,F={1c:[],1j:[]};y(7 i=0;i<19;++i){7 c=6.L[0].G[i],1p=[];F.1c.R($(c));y(7 j=0;j<2r;++j){1p.R(C[j].H(1Q(6.f,c.12[j]),6,c.12[j]))}1p.R(i);F.1j.R(1p);1p=1E};q(6.f.J){17("2W F y "+19+" G:",23)}m F};8 1Q(f,V){q(!V)m"";7 t="";q(f.1w=="25"){q(V.1L[0]&&V.1L[0].2X()){t=V.1L[0].1S}N{t=V.1S}}N{q(1u(f.1w)=="8"){t=f.1w(V)}N{t=$(V).1i()}}m t}8 1G(6,F){q(6.f.J){7 2U=D T()}7 c=F,r=c.1c,n=c.1j,19=n.w,1J=(n[0].w-1),2h=$(6.L[0]),G=[];y(7 i=0;i<19;i++){G.R(r[n[i][1J]]);q(!6.f.20){7 o=r[n[i][1J]];7 l=o.w;y(7 j=0;j<l;j++){2h[0].32(o[j])}}}q(6.f.20){6.f.20(6,G)}G=1E;q(6.f.J){17("4d 6:",2U)}1z(6)};8 2x(6){q(6.f.J){7 1f=D T()}7 1o=($.1o)?13:K,27=[];y(7 i=0;i<6.1t.G.w;i++){27[i]=0};$1r=$("35 37",6);$1r.1s(8(1F){k.1a=0;k.1D=1F;k.18=2B(6.f.2P);q(2d(k)||2e(6,1F))k.1C=13;q(!k.1C){$(k).1q(6.f.28)}6.f.1y[1F]=k});q(6.f.J){17("3a x:",1f);1h($1r)}m $1r};8 2K(6,G,1c){7 1k=[],r=6.1t.G,c=r[1c].12;y(7 i=0;i<c.w;i++){7 11=c[i];q(11.41>1){1k=1k.3b(2K(6,3c,1c++))}N{q(6.1t.w==1||(11.3e>1||!r[1c+1])){1k.R(11)}}}m 1k};8 2d(11){q(($.1o)&&($(11).16().1g===K)){m 13};m K}8 2e(6,i){q((6.f.x[i])&&(6.f.x[i].1g===K)){m 13};m K}8 1z(6){7 c=6.f.1d;7 l=c.w;y(7 i=0;i<l;i++){1Z(c[i]).H(6)}}8 1Z(1x){7 l=1d.w;y(7 i=0;i<l;i++){q(1d[i].B.14()==1x.14()){m 1d[i]}}};8 2B(v){q(1u(v)!="3i"){i=(v.14()=="3j")?1:0}N{i=(v==(0||1))?v:0}m i}8 2E(v,a){7 l=a.w;y(7 i=0;i<l;i++){q(a[i][0]==v){m 13}}m K}8 1W(6,$x,Z,S){$x.1H(S[0]).1H(S[1]);7 h=[];$x.1s(8(3L){q(!k.1C){h[k.1D]=$(k)}});7 l=Z.w;y(7 i=0;i<l;i++){h[Z[i][0]].1q(S[Z[i][1]])}}8 2z(6,$x){7 c=6.f;q(c.2u){7 1v=$(\'<1v>\');$("2j:3l 3H",6.L[0]).1s(8(){1v.3G($(\'<3o>\').S(\'2l\',$(k).2l()))});$(6).3r(1v)}}8 2M(6,u){7 c=6.f,l=u.w;y(7 i=0;i<l;i++){7 s=u[i],o=c.1y[s[0]];o.1a=s[1];o.1a++}}8 1Y(6,u,F){q(6.f.J){7 2m=D T()}7 Y="7 2k = 8(a,b) {",l=u.w;y(7 i=0;i<l;i++){7 c=u[i][0];7 18=u[i][1];7 s=(2s(6.f.C,c)=="1i")?((18==0)?"2n":"2o"):((18==0)?"2p":"2q");7 e="e"+i;Y+="7 "+e+" = "+s+"(a["+c+"],b["+c+"]); ";Y+="q("+e+") { m "+e+"; } ";Y+="N { "}7 1N=F.1j[0].w-1;Y+="m a["+1N+"]-b["+1N+"];";y(7 i=0;i<l;i++){Y+="}; "}Y+="m 0; ";Y+="}; ";3t(Y);F.1j.3u(2k);q(6.f.J){17("3w 3x "+u.3z()+" 3A 3B "+18+" 1f:",2m)}m F};8 2n(a,b){m((a<b)?-1:((a>b)?1:0))};8 2o(a,b){m((b<a)?-1:((b>a)?1:0))};8 2p(a,b){m a-b};8 2q(a,b){m b-a};8 2s(C,i){m C[i].Q};k.2f=8(2w){m k.1s(8(){q(!k.1t||!k.L)m;7 $k,$3E,$x,F,f,3F=0,3I;k.f={};f=$.1V(k.f,$.I.2v,2w);$k=$(k);$x=2x(k);k.f.C=1T(k,$x);F=1U(k);7 1X=[f.29,f.2b];2z(k);$x.3K(8(e){7 19=($k[0].L[0]&&$k[0].L[0].G.w)||0;q(!k.1C&&19>0){7 $11=$(k);7 i=k.1D;k.18=k.1a++%2;q(!e[f.2D]){f.u=[];q(f.1I!=1E){7 a=f.1I;y(7 j=0;j<a.w;j++){f.u.R(a[j])}}f.u.R([i,k.18])}N{q(2E(i,f.u)){y(7 j=0;j<f.u.w;j++){7 s=f.u[j],o=f.1y[s[0]];q(s[0]==i){o.1a=s[1];o.1a++;s[1]=o.1a%2}}}N{f.u.R([i,k.18])}};$k.1R("3S");1W($k[0],$x,f.u,1X);3T(8(){1G($k[0],1Y($k[0],f.u,F));$k.1R("3U")},0);m K}}).3V(8(){q(f.2Q){k.3X=8(){m K};m K}});$k.1n("3Y",8(){k.f.C=1T(k,$x);F=1U(k)}).1n("2J",8(e,Z){f.u=Z;7 u=f.u;2M(k,u);1W(k,$x,u,1X);1G(k,1Y(k,u,F))}).1n("44",8(){1G(k,F)}).1n("45",8(e,B){1Z(B).H(k)}).1n("47",8(){1z(k)});q($.1o&&($(k).16()&&$(k).16().2N)){f.u=$(k).16().2N}q(f.u.w>0){$k.1R("2J",[f.u])}1z(k)})};k.P=8(1B){7 l=C.w,a=13;y(7 i=0;i<l;i++){q(C[i].B.14()==1B.B.14()){a=K}}q(a){C.R(1B)}};k.2R=8(21){1d.R(21)};k.U=8(s){7 i=2Y(s);m(26(i))?0:i};k.2Z=8(s){7 i=30(s);m(26(i))?0:i};k.33=8(6){q($.34.36){8 2I(){38(k.2a)k.39(k.2a)}2I.3d(6.L[0])}N{6.L[0].1S=""}}}});$.3f.1V({I:$.I.2f});7 M=$.I;M.P({B:"1i",O:8(s){m 13},H:8(s){m $.1M(s.14())},Q:"1i"});M.P({B:"3k",O:8(s){m/^\\d+$/.15(s)},H:8(s){m $.I.U(s)},Q:"W"});M.P({B:"3m",O:8(s){m/^[3n£$3pÇ¨?.]/.15(s)},H:8(s){m $.I.U(s.X(D 1b(/[^0-9.]/g),""))},Q:"W"});M.P({B:"3s",O:8(s){m s.2G(D 1b(/^(\\+|-)?[0-9]+\\.[0-9]+((E|e)(\\+|-)?[0-9]+)?$/))},H:8(s){m $.I.U(s.X(D 1b(/,/),""))},Q:"W"});M.P({B:"3v",O:8(s){m/^\\d{2,3}[\\.]\\d{2,3}[\\.]\\d{2,3}[\\.]\\d{2,3}$/.15(s)},H:8(s){7 a=s.3y("."),r="",l=a.w;y(7 i=0;i<l;i++){7 1A=a[i];q(1A.w==2){r+="0"+1A}N{r+=1A}}m $.I.U(r)},Q:"W"});M.P({B:"3J",O:8(s){m/^(2y?|2A|2C):\\/\\/$/.15(s)},H:8(s){m 2T.1M(s.X(D 1b(/(2y?|2A|2C):\\/\\//),\'\'))},Q:"1i"});M.P({B:"3P",O:8(s){m/^\\d{4}[\\/-]\\d{1,2}[\\/-]\\d{1,2}$/.15(s)},H:8(s){m $.I.U((s!="")?D T(s.X(D 1b(/-/g),"/")).1e():"0")},Q:"W"});M.P({B:"3Q",O:8(s){m/^\\d{1,3}%$/.15(s)},H:8(s){m $.I.U(s.X(D 1b(/%/g),""))},Q:"W"});M.P({B:"3R",O:8(s){m s.2G(D 1b(/^[A-3W-z]{3,10}\\.? [0-9]{1,2}, ([0-9]{4}|\'?[0-9]{2}) (([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\\s(40|42)))$/))},H:8(s){m $.I.U(D T(s).1e())},Q:"W"});M.P({B:"43",O:8(s){m/\\d{1,2}[\\/\\-]\\d{1,2}[\\/\\-]\\d{2,4}/.15(s)},H:8(s,6){7 c=6.f;s=s.X(/\\-/g,"/");q(c.1l=="2O"){s=s.X(/(\\d{1,2})[\\/\\-](\\d{1,2})[\\/\\-](\\d{4})/,"$3/$1/$2")}N q(c.1l=="46"){s=s.X(/(\\d{1,2})[\\/\\-](\\d{1,2})[\\/\\-](\\d{4})/,"$3/$2/$1")}N q(c.1l=="2t/24/2g"||c.1l=="2t-24-2g"){s=s.X(/(\\d{1,2})[\\/\\-](\\d{1,2})[\\/\\-](\\d{2})/,"$1/$2/$3")}m $.I.U(D T(s).1e())},Q:"W"});M.P({B:"1f",O:8(s){m/^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\\s(3g|3h)))$/.15(s)},H:8(s){m $.I.U(D T("3q/2i/2i "+s).1e())},Q:"W"});M.P({B:"3D",O:8(s){m K},H:8(s,6,11){7 c=6.f,p=(!c.2F)?\'3M\':c.2F;m $(11).16()[p]},Q:"W"});M.2R({B:"31",H:8(6){q(6.f.J){7 1f=D T()}$("2j:3C",6.L[0]).2H(\':2c\').1H(6.f.1m.S[1]).1q(6.f.1m.S[0]).3O().2H(\':2L\').1H(6.f.1m.S[0]).1q(6.f.1m.S[1]);q(6.f.J){$.I.17("3N 4e 21",1f)}}})})(2T);',62,263,'||||||table|var|function|||||||config|||||this||return||||if||||sortList||length|headers|for|||id|parsers|new||cache|rows|format|tablesorter|debug|false|tBodies|ts|else|is|addParser|type|push|css|Date|formatFloat|node|numeric|replace|dynamicExp|list||cell|cells|true|toLowerCase|test|data|benchmark|order|totalRows|count|RegExp|row|widgets|getTime|time|sorter|log|text|normalized|arr|dateFormat|widgetZebra|bind|meta|cols|addClass|tableHeaders|each|tHead|typeof|colgroup|textExtraction|name|headerList|applyWidget|item|parser|sortDisabled|column|null|index|appendToTable|removeClass|sortForce|checkCell|getParserById|childNodes|trim|orgOrderCol|parsersDebug|console|getElementText|trigger|innerHTML|buildParserCache|buildCache|extend|setHeadersCss|sortCSS|multisort|getWidgetById|appender|widget|detectParserForColumn|cacheTime|mm|simple|isNaN|tableHeadersRows|cssHeader|cssDesc|firstChild|cssAsc|even|checkHeaderMetadata|checkHeaderOptions|construct|yy|tableBody|01|tr|sortWrapper|width|sortTime|sortText|sortTextDesc|sortNumeric|sortNumericDesc|totalCells|getCachedSortType|dd|widthFixed|defaults|settings|buildHeaders|https|fixColumnWidth|ftp|formatSortingOrder|file|sortMultiSortKey|isValueInArray|parserMetadataName|match|filter|empty|sorton|checkCellColSpan|odd|updateHeaderSortCount|sortlist|us|sortInitialOrder|cancelSelection|addWidget|undefined|jQuery|appendTime|alert|Building|hasChildNodes|parseFloat|formatInt|parseInt|zebra|appendChild|clearTableBody|browser|thead|msie|th|while|removeChild|Built|concat|headerArr|apply|rowSpan|fn|am|pm|Number|desc|integer|first|currency|¬|col|‚|2000|prepend|floating|eval|sort|ipAddress|Sorting|on|split|toString|and|dir|visible|metadata|document|shiftDown|append|td|sortOrder|url|click|offset|sortValue|Applying|end|isoDate|percent|usLongDate|sortStart|setTimeout|sortEnd|mousedown|Za|onselectstart|update|header|AM|colSpan|PM|shortDate|appendCache|applyWidgetId|uk|applyWidgets|headerSortUp|headerSortDown|asc|shiftKey|ms|Rebuilt|Zebra'.split('|'),0,{}))

/* ====================================== ///// End jquery.tablesorter.pak.js ====================================== */

/* ====================================== Start jquery.fancybox.js ====================================== */
/*
 * FancyBox - simple jQuery plugin for fancy image zooming
 * Examples and documentation at: http://fancy.klade.lv/
 * Version: 0.1b (22/03/2008)
 * Copyright (c) 2008 Janis Skarnelis
 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
 * Requires: jQuery v1.2.1 or later
*/
$.fn.fancybox = function(settings) {
	settings = $.extend({}, $.fn.fancybox.defaults, settings);

	var clickedElem;
	var currentElem;
	var imgThumb;

	function getPageSize() {
		var d = document.documentElement;
		var w = window.innerWidth	|| self.innerWidth	|| (d && d.clientWidth)		|| document.body.clientWidth;
		var h = window.innerHeight	|| self.innerHeight	|| (d && d.clientHeight)	|| document.body.clientHeight;

		return [w,h];
	}

	function getPosition(el) {
		var pos = el.offset();

		pos.top		+= parseFloat(el.css('paddingTop'));
		pos.left	+= parseFloat(el.css('paddingLeft'));

		pos.top		+= parseFloat(el.css('borderTopWidth'));
		pos.left	+= parseFloat(el.css('borderLeftWidth'));

		return pos;
	}

	function getImageSize(maxWidth, maxHeight, imageWidth, imageHeight) {
		if (imageWidth > maxWidth) {
			imageHeight	= imageHeight * (maxWidth / imageWidth);
			imageWidth	= maxWidth;

			if (imageHeight > maxHeight) {
				imageWidth = imageWidth * (maxHeight / imageHeight);
				imageHeight = maxHeight;
			}

		} else if (imageHeight > maxHeight) {
			imageWidth	= imageWidth * (maxHeight / imageHeight);
			imageHeight	= maxHeight;

			if (imageWidth > maxWidth) {
				imageHeight = imageHeight * (maxWidth / imageWidth);
				imageWidth = maxWidth;
			}
		}

		return [Math.round(imageWidth), Math.round(imageHeight)];
	}

	function createTransparentDiv(attr, file, w, h, pos) {
		var z = arguments[5] !== undefined ? arguments[5]  : 90;
		var s = arguments[6] !== undefined ? arguments[6]  : '';
		var t = arguments[7] !== undefined ? arguments[7]  : '';

		var el = '';

		el += '<div ' + attr + ' style="z-index:' + z + ';position:absolute;' + pos + ';' + (h ? 'height:' + h  + 'px;' : '') + 'width:' + w + 'px;' + s + ';';

		el += $.browser.msie ? 'FILTER:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale, src=\'' + file + '\');' : 'background:transparent url(\'' + file + '\') ' + (w && h ? 'repeat-' + (w > h ? 'x' : 'y') : '') + ';';

		el += '">' + t + '</div>';

		return el;
	}

	var removeFancy = function() {
		$(document).unbind("keydown");

		$("#fancy_close,#fancy_img").unbind("click");
        $("#fancy_block").stop();

		if (arguments[0] !== undefined && arguments[0] == true) {
			$("#fancy_wrap").remove();

		} else {
			$('#fancy_close,#btnLeft,#btnRight,div.fancy_shadow,#fancy_title').remove();

			if (settings.fancy) {
				imgThumb = currentElem.children("img:first");

				var pos = getPosition(imgThumb);
				var w	= imgThumb.width();
				var h	= imgThumb.height();

				var params = {
					left:		pos.left	+ "px",
					top:		pos.top		+ "px",
					height:		h,
					width:		w
				}

				if (settings.opacity) {
					params.opacity = 'hide';
				}

				$('#fancy_block').animate(params, settings.speed, "swing", function() {
					$("#fancy_wrap").remove();
				});

			} else {
				$('#fancy_block').fadeOut(settings.speed, function() {
					$("#fancy_wrap").remove();
				});
			}
		}
	}

	var showFancy = function() {
	    currentElem = clickedElem;

		var pageSize	= getPageSize();
		var imageSize	= getImageSize(pageSize[0] - 70, pageSize[1] - 70, imgPreloader.width,  imgPreloader.height);

		var m_left	= Math.round(pageSize[0] / 2)  - Math.round(imageSize[0] / 2);
		var m_top	= Math.round(pageSize[1] / 2)  - Math.round(imageSize[1] / 2);

		m_top	+= typeof window.pageYOffset != 'undefined' ? window.pageYOffset : document.documentElement.scrollTop;
		m_left	+= typeof window.pageXOffset != 'undefined' ? window.pageXOffset : document.documentElement.scrollLeft;

        $("#fancy_loading").remove();

		if ($("#fancy_wrap").is('*')) {
			removeFancy(true);
		}

		$('<div id="fancy_wrap"	style="z-index:90;position:absolute;top:0px;left:0px;"></div>').prependTo("body");

		$('<div id="fancy_block" style="position:absolute;top:' + m_top + 'px;left:' + m_left + 'px;width:' + imageSize[0] + 'px;height:' + imageSize[1] + 'px;display:none;"></div>').appendTo("#fancy_wrap");

		$('<img id="fancy_img" style="width:100%;height:100%;position:absolute;z-index:93;" src="' + imgPreloader.src + '" />').appendTo("#fancy_block");

		var currentElemId		= currentElem.attr('id');
		var currentElemRel		= currentElem.attr('rel');
		//var currentElemTitle	= currentElem.attr('title');
		var currentElemTitle = "Gebruik de pijltjestoetsen om te navigeren";
		
		var nextElem = false, prevElem = false, foundElem = false;

		if (currentElemRel !== undefined) {
			var arr_rel	= $("a[@rel=" + currentElemRel + "]").get();

			for (var i = 0; ((i < arr_rel.length) && (nextElem === false)); i++) {
				if (!(arr_rel[i].id == currentElemId)) {
					foundElem ? nextElem = arr_rel[i].id : prevElem = arr_rel[i].id;

				} else {
					foundElem = true;
				}
			}
		}

        $(document).keydown(function(event) {
            if (event.keyCode == 27) {
                removeFancy();

            } else if(event.keyCode == 37 && prevElem) {
				$("#" + prevElem).click();

			} else if(event.keyCode == 39 && nextElem) {
				$("#" + nextElem).click();
			}
        });

        $('#fancy_block').fadeIn("normal", function() {
			$( createTransparentDiv('id="fancy_close"', settings.path + 'fancy_closebox.png', 30, 30, 'top:-10px;left:-15px', 94) ).appendTo("#fancy_block");

			if (currentElemRel !== undefined || currentElemTitle !== undefined) {
				var titlePadding = nextElem || prevElem ? 50 : 15;
				currentElemTitle = currentElemTitle === undefined ? '&nbsp;' : currentElemTitle;

				$("#fancy_block").append(createTransparentDiv('id="fancy_title"', settings.path + 'fancy_title.png', (imageSize[0] - titlePadding), false, 'bottom:0px;left:0px', 94, 'color:#aaa;padding:12px 0 7px ' + titlePadding + 'px;font:' + settings.font,  currentElemTitle));
			}

			$("#fancy_block").append( createTransparentDiv('class="fancy_shadow"', settings.path + 'fancy_shadow1.png', (imageSize[0] - 28), 25, 'top:-7px;left:14px') );
			$("#fancy_block").append( createTransparentDiv('class="fancy_shadow"', settings.path + 'fancy_shadow2.png', 27, 25, 'top:-7px;right:-13px') );
			$("#fancy_block").append( createTransparentDiv('class="fancy_shadow"', settings.path + 'fancy_shadow3.png', 27, (imageSize[1] - 26), 'top:18px;right:-13px') );
			$("#fancy_block").append( createTransparentDiv('class="fancy_shadow"', settings.path + 'fancy_shadow4.png', 27, 26, 'bottom:-18px;right:-13px;') );
			$("#fancy_block").append( createTransparentDiv('class="fancy_shadow"', settings.path + 'fancy_shadow5.png', (imageSize[0] - 28), 26, 'bottom:-18px;left:14px;') );
			$("#fancy_block").append( createTransparentDiv('class="fancy_shadow"', settings.path + 'fancy_shadow6.png', 27, 26, 'bottom:-18px;left:-13px;') );
			$("#fancy_block").append( createTransparentDiv('class="fancy_shadow"', settings.path + 'fancy_shadow7.png', 27, (imageSize[1] - 26), 'top:18px;left:-13px;') );
			$("#fancy_block").append( createTransparentDiv('class="fancy_shadow"', settings.path + 'fancy_shadow8.png', 27, 25, 'top:-7px;left:-13px;') );

			if (prevElem) {
				$("#fancy_block").append( createTransparentDiv('id="btnLeft"', settings.path + 'fancy_left.png',24,24,'bottom:6px;left:14px',94, 'cursor:pointer;') );
				$("#btnLeft").click(function() {
					$("#" + prevElem).click();
				});

			} else if (nextElem) {
				$("#fancy_block").append( createTransparentDiv('id="btnLeft"', settings.path + 'fancy_left_off.png',24,24,'bottom:6px;left:14px',94) );
			}

			if (nextElem) {
				$("#fancy_block").append( createTransparentDiv('id="btnRight"', settings.path + 'fancy_right.png',24,24,'bottom:6px;right:14px',94,'cursor:pointer;') );
				$("#btnRight").click(function() {
					$("#" + nextElem).click();
				});

			} else if (prevElem) {
				$("#fancy_block").append( createTransparentDiv('id="btnRight"', settings.path + 'fancy_right_off.png',24,24,'bottom:6px;right:14px',94) );
			}

			$("#fancy_close,#fancy_img").click( function() {
				removeFancy();
			});
		});
	}

	var loadFancy = function(el) {
	    clickedElem = el;

		imgThumb = clickedElem.children("img:first");
		imgThumb.css("z-index", "80");

		var pos = getPosition(imgThumb);
		var w	= imgThumb.width();
		var h	= imgThumb.height();

		$("#fancy_loading").remove();

		if ($("#fancy_wrap").is('*')) {
			removeFancy(true);
		}

        imgPreloader = new Image();
		imgPreloader.src = clickedElem.attr('href');

		if (imgPreloader.complete) {
			showFancy();
			return;
		}

		$('<div id="fancy_loading" style="position:absolute;z-index: 90;top:' + pos.top + 'px;left:' +  pos.left + 'px; width:' + w + 'px;height:' + h + 'px;background: #FFF url(\'' + settings.path + 'fancy_loader.gif\') no-repeat center center;"></div>').prependTo("body");

		$("#fancy_loading").css("opacity", 0.5);

		$("#fancy_loading").click(function() {
			imgPreloader.onload = null;
			$(this).remove();
		});

		imgPreloader.onload = function() {
			showFancy();
		}
	}

	return this.each(function() {
		var $this = $(this);

		$this.click(function(e) {
			loadFancy($this);
			return false;
		});
	});
};

$.fn.fancybox.defaults = {
	fancy:		true,
	opacity:	true,
	speed:		500,
	font:		'normal 12px/18px Verdana,Helvetica;letter-spacing:1px;',
	path:		'/'
}

/* ====================================== ///// End jquery.fancybox.js ====================================== */


/* ====================================== Start notarim-front-functions ====================================== */

/**
 * Maakt HTML aan voor tooltip
 */
 
function generateHTMLForTooltip(buildingID) {
	
 	 var bHTML = '';
 	var ajaxManager1 = $.manageAjax({manageType: 'abortOld', maxReq: 1, 

 	 
			type: "POST",
 			url: '/ajax/tooltip.php',
			data: 'functionName=getTooltip&buildingID=' + buildingID, 
 			async: true,
			dataType: 'xml',
			timeout: 1000,
			success: function(xml, textStatus) { 
				var bedrooms, garages, sold;
				var temp = $(xml).find('data').each( function() {
					bedrooms = $(this).find('numberOfBedrooms').text();
					garages = $(this).find('numberOfGarages').text();
					sold = $(this).find('sold').text();
					bHTML += '<tr><td>Slaapkamers:</td><td>' + bedrooms + '</td></tr>';
					bHTML += '<tr><td>Garages:</td><td>' + garages + '</td></tr>';
					bHTML += '<tr><td>Verkocht: </td><td>';
					if (sold == 1) { sold = 'ja' } else { sold = 'nee'; }
					bHTML += sold + '</td></tr>';
				});
			}
			
		});
		return bHTML;
 }
 
 /*
 * Voorspelt het aantal zoekresultaten voor buildings
 */
function displayNumberOfSearchResults() {
	var sql = buildDataForBuilding();
		
	$.ajax({
   			type: "GET",
   			url: '/ajax/countBuildingSearchResults.php',
			data: sql, 
   			async: true,
			dataType: 'xml',
			timeout: 1000,
			success: function(xml, textStatus) { 
				showCount(xml);
			},
			error: function() {
				
			}
	});
}

function displayNumberOfSearchResultsNotary() {
		var sql = buildDataForNotary();
		
		$.ajax({
   			type: "GET",
   			url: '/ajax/countNotarySearchResults.php',
			  data: sql, 
   			async: true,
			  dataType: 'xml',
			  timeout: 1000,
			  success: function(xml, textStatus) { 
				  showCountForNotary(xml);
			  },
			  error: function() {
			  }
	  });
		
		
}

/*
 * Maakt querystring aan voor building
 */
function buildDataForBuilding() {
	var data = "";
	
	//Waarden van zoekvelden ophalen
	$('div.kolom input, div.kolom select').each(function() {
		if ($(this).val() != '')
		data += ($(this).attr('id')) + '=' + ($(this).val() + '&');
	});
		
	//Categorie ophalen
	var category = $.trim(($('div#submenu ul li.active').text()));
	data += 'cat=' + category;
	
	return data;
}

function buildDataForNotary() {
	var data = "";
	
	//Waarden van zoekvelden ophalen
	$('div.notaryColl input, div.notaryColl select').each(function() {
		if ($(this).val() != '')
		data += ($(this).attr('id')) + '=' + ($(this).val() + '&');
	});
	
	return data;
}

/* 
 * Toont resultaat op pagina
 */
function showCount(xml) {
	$("#count").empty();
	$("#count").append($(xml).find('count').text());
	$("#count").append(' resultaten die voldoen aan uw zoekcriteria');
}

function showCountForNotary(xml) {
	$("#countNotary").empty();
	$("#countNotary").append($(xml).find('count').text());
	$("#countNotary").append(' resultaten die voldoen aan uw zoekcriteria');
}

function showBig(filename) {
	var src = "http://notarim.be/images/houses/_panddetail/" + filename;
	$("#foto-big img").attr("src", src);
}

function formatNumber(str) {
	str += 'test';
	return str;
}

/*function makeActive(tabid) {
	$("#" + tabid).attr({ 
	    class: "active",
  	});
}*/

function convertSquareMeterToAcres(squareMetres) {
	squareMetres = squareMetres.split(" ");
	squareMetres = squareMetres[0];
	squareMetres = squareMetres.replace(/\./g,"")
	squareMetres = parseInt(squareMetres);
	
	var hectare, are, centiare, converted;
	converted = "(";
	if (squareMetres > 9999) {
		hectare = String(squareMetres / 10000);
		hectare = hectare.substring(0, hectare.length-5);
		converted += hectare + "ha ";
	}
	if (squareMetres > 99) {
		are = String(squareMetres / 100);
		are = are.substring(are.length-5, are.length-3);
		converted += are + "a ";
	}
	if (squareMetres > 1) {
		centiare = String(squareMetres / 1);
		centiare = centiare.substring(centiare.length-2, centiare.length);
		converted += centiare + "ca";
	}
	converted += ")";
	return converted;
}

function submitForm() {
	$("#searchForm").submit();
}



/* Functies voor nieuwe searchform */
function activateByCheckbox(control, field) {
//	alert ($("#" + control).attr("checked"));
	if ($("#" + control).attr("checked") == true) {
		$("#" + field).attr("disabled", "");
	} else {
		$("#" + field).attr("disabled", "disabled");
	}
}

function activateDates(control, container) {
//	var check = $("#" + control).attr("checked");
//	alert (check);
	if ( $("#" + control).attr("checked") == true) {
		$("#" + container).css("display", "block");
	} else {
		$("#" + container).css("display", "none");
	}
}

function appendCity() {
	var numberOfCities = parseInt ($("#numberOfCities").val());
	numberOfCities++;
	
	var appendHtml = "<div class=\"si-append-container\"><label class=\"formLabelSmall\" for=\"postalcode\">Postcode: </label>" +
					      	 "<div id=\"postalcodediv\"><input class=\"postalcodeInput\" autocomplete=\"off\" type=\"text\" id=\"postalcode" + numberOfCities + "\" name=\"postalcode_" + numberOfCities + "\" value=\"\"  /></div>" +
					      	 "<label class=\"formLabelSmall\" for=\"city_" + numberOfCities + "\">Gemeente: </label>" +
	        				 "<div id=\"citydiv\"><input class=\"cityInput\" autocomplete=\"off\" type=\"text\" id=\"city_" + numberOfCities + "\" name=\"city_" + numberOfCities + "\" value=\"\" /></div></div>";
  $("#numberOfCities").val(numberOfCities);
  $("#city-container").append(appendHtml);
}

/* ====================================== ///// End notarim-front-functions.js ====================================== */

/* ====================================== ///// Start notarim-front.js ====================================== */

$(document).ready(function() {
   var allowAjax = true;
   
   $('#results tr').hover(
   	function() {
   		$(this).css('background-color', '#eff0f0');
   	}, 
   	function() {
   		$(this).css('background-color', 'transparent');
   	});
   
   $("#results tbody tr").bind("hover", {speed:200, delay:200}, function() {
   $("#results tbody tr").tooltip({ 
   	
    
    bodyHandler: function() { 
    	  var hiddenDivID = $(this).attr("id"); 
        var buildingID = $(this).attr("class");
				buildingID = getBuildingIDFromString(buildingID);        
   			var bHTML = generateTooltipBegin(buildingID);
   			bHTML += generateHTMLForTooltip(buildingID);        
   			bHTML = generateTooltipEnd(bHTML);
   			return bHTML;
   	},
    track: true
    
	});
	
   });
   
   $("#openbareVerkopenStartDate").datePicker({startDate:'01/01/2007'});
	 $("#openbareVerkopenEndDate").datePicker({startDate:'01/01/2007'});
	 
	  $(".propertyTypeLink").click( function() {
 	 	var propertyType = $.trim (($(this).text()));
 	 	
 	 	if (propertyType == "alle types") {
 	 		propertyType = "Alle";
 	 	}
 	 	
 	 	$("#cat").val(propertyType);
 	 	$(".propertyTypeCheckbox").val("");
 	 	document.forms[0].submit();
	 });
	 
	 $("#listStyle").change ( function() {
	 	document.forms[0].submit();
	 });

   $.tablesorter.addParser({ 
        // set a unique id 
        id: 'squareParser', 
        is: function(s) { 
            // return false so this parser is not auto detected 
            return false; 
        }, 
        format: function(s) { 
            // format your data for normalization 
            return parseInt(s.replace(/ m²/,"").replace(/\./,"").replace(/,/,""));
				}, 
        // set type, either numeric or text 
        type: 'numeric' 
    }); 
    
   $.tablesorter.addParser({
   		 // set a unique id 
        id: 'priceParser', 
        is: function(s) { 
            // return false so this parser is not auto detected 
            return false; 
        }, 
        format: function(s) { 
            // format your data for normalization 
            return ( s.replace(/€ /,"").replace(/\./,"").replace(/,/,""));
				}, 
        // set type, either numeric or text 
        type: 'numeric' 
   });

		
  $.tablesorter.addParser({
  		 // set a unique id 
       id: 'dateParser', 
       is: function(s) { 
           return false; 
       }, 
       format: function(s) { 
					s = jQuery.trim(s);
					var parts = s.split("/");
					var dateAlf = parts[2] + parts[1] + parts[0];
					// if (dateAlf) == 
					if (dateAlf != "NaN") {
						return dateAlf;
					} else {
						return 0;
					}
				}, 
       // set type, either numeric or text 
       type: 'numeric' 
  });
   
   
   $.tablesorter.addParser({
			id: 'cityParser',
			is: function(s) {
				return false;
			},   	
			format: function(s) {
				s = jQuery.trim(s);
				var imgStr = "<img id=\"recentToegevoegdLabel\" src=\"//notarim.be/images/front/recent_toegevoegd.png\" />";
				imgStr = "<img id=\"recentToegevoegdLabel\" src=\"//notarim.be/images/front/recent_toegevoegd.png\">";
				return ( jQuery.trim( (s.replace(/imgStr/, "")) ));
			},
			type: 'text'
 	});
   	 
	 $(function() { 
 			if ($('#results').find('tbody').find('tr:first').html() != null) {	 			
        $("#results").tablesorter({ 
            headers: { 
            		2: {
            			sorter:'cityParser'
            		},
                5: { 
                    sorter:'squareParser' 
                },
                6: {
                		sorter:'priceParser'
                },
								7: {
										sorter:'dateParser'
								}
            },
            sortList: [[7,0]]
        }); 
 			}
    });  
	 	 
   $("#notaryTable").tablesorter(); { 
        $("#myTable").tablesorter( {sortList: [[0,0], [1,0]] }); 
    } 
   jQuery.fn.fancybox.defaults.path = "/images/front/fancybox/";
	 $(".foto-container a").fancybox();
	 $('#content-standard a').not('.item-file-link').fancybox();
	 $('#city').KeywordDropDown({server:"/city.php"});
	 $('#postalcode').KeywordDropDown({server:"/city.php"});
		 //Input velden activeren via checkbox
	 $("#garageActive").change( function() {
	 	activateByCheckbox("garageActive", "numberOfGarages");
	 });
	 
	 $("#gardenActive").change( function() {
	 	activateByCheckbox("gardenActive", "gardenSurface");
	 });
	 
	 $("#soldSelect").click( function() {
	 	activateDates("soldSelect", "openbareVerkopenContainer");
	 });
	 
	 $("#appendCity").click( function() {
	 	appendCity();
	 });
});

function getBuildingIDFromString(buildingSt) {
	return parseInt(buildingSt.substring(9, buildingSt.length));
}

function generateTooltipBegin(buildingID) {
	var ident = '.building_' + buildingID;
	var imgsrc = $(ident + ' .row-foto .foto').attr('src');
	imgsrc = imgsrc.replace("/_medium/","/_popup/");
	var html = '<div class="popup-div-container"><div class="dialog"><div class="hd"><div class="c"></div></div><div class="bd"><div class="c">';
			if (imgsrc != '//notarim.be/images/front/geen_foto.gif') {
				html += '<img class="popup-img" src="' + imgsrc +'" alt="" />';
			}
			html += '<div class="popup-icons">' + $(ident + ' .table-icons').html() + '</div><table>';
			html += '<tr><td colspan=2>' + $(ident + ' .row-adres').text() + ', ' + $(ident + ' .row-gemeente').text() + '</td></tr>';
			html += '<tr><td>Type:</td><td>' + $(ident + ' .row-types').text() + '</td></tr>';
			if ($(ident + ' .row-surface').text() != '')
			html += '<tr><td>Oppervlakte:</td><td>' + $(ident + ' .row-surface').text() + '</td></tr>';
			if (jQuery.trim($(ident + ' .row-price').text()) != '')
			html += '<tr><td>Prijs:	</td><td>' + $(ident + ' .row-price').text() + '</td></tr>';
			return html;
}			

function generateTooltipEnd(ttBegin) {
	ttBegin += '</table></div></div><div class="ft"><div class="c"></div></div></div></div>';
	return ttBegin;
}

/* ====================================== ///// End notarim-front.js ====================================== */

/* ====================================== Start jquery.keyworddropdown.js ====================================== */


(function($) {
	
	var selected = null;
	// De constructor. Roep je aan in JS door: $('element').KeywordDropDown()
	$.fn.KeywordDropDown = function(options) {
		
		var defaults = {
			server: "/ajaxSearch.php"
		};
		
		var options = $.extend(defaults, options);
		
		return this.each(function() {
			setUp(this, options);
		});
	};
	
	// Een private function. Gebruik je enkel intern, kan niet overschreven worden.
	function setUp(field, options) {
		var container = $('<ul id="keywordList"></ul>').insertAfter(field);
		var form = $(field).parents('form');
		var button = $('input[type=submit], input[type=image]', form);
		container.hide();
		$(document).bind("click", function() {container.hide()});
		$(field).bind("keypress",{container: container, server:options.server}, navigate);
		$(field).bind("keyup",{container: container, server:options.server}, getKeywords);
	}
	
	function navigate(e) {
		if (e.keyCode == '13') {
			if (selected != null) {
				e.data.query = this;
				e.data.keyword = $(selected).text();
				selectKeyword(e);
				selected = null;
				return false;
			}
		}
	}
	
	function getKeywords(e) {
		if (e.keyCode == '40') {
			goDown(e);

		}
		else if (e.keyCode == '38') {
			goUp(e);
		}
		else if (e.keyCode != 13) {
			var query = this;
			var cont = e.data.container;
			cont.empty();
			cont.attr('scrollTop', 0);
			cont.hide();
			$.ajax({
				url: e.data.server,
				type: 'POST',
				data: {keyword: $(this).val(), lang: $('#lang').val()},
				dataType: 'xml',
				timeout: 1000,
				success: function(xml) { 
					showKeywords(query, cont, xml);
				}
			});
		}
	}
	
	function goDown(e) {
		$('li', e.data.container).css('background-color', '');
		if (selected == null) {
			selected = $('li:first', e.data.container);
		}
		else if($(selected).next().is('li')) {
			selected = $(selected).next();
		}
		$(selected).css('background-color', '#ccc');
		if ($(selected).is('li'))
			scrollKeywords(e.data.container, selected);
	}
	
	function goUp(e) {
		$('li', e.data.container).css('background-color', '');
		if (selected != null && $(selected).prev().is('li')) {
			selected = $(selected).prev();
			$(selected).css('background-color', '#ccc');
			scrollKeywords(e.data.container, selected);
		}
	}
	
	function scrollKeywords(cont, sel) {

		if(sel.offset().top>cont.offset().top + cont.height() - 10){
			$(cont).each(function(e){this.scrollTop = this.scrollTop + 60});
		}
		else if(sel.offset().top<cont.offset().top+10) {
			$(cont).each(function(e){this.scrollTop = this.scrollTop - 60});
		}
	}
	
	function showKeywords(field, container, xml) {
		selected = null;
		var i=0;
		$(xml).find('keyword').each( function() {
			var keyword = $(this).text();
			i++;
			$('<li></li>').html(keyword).appendTo(container).bind("click", {query:field, container: container, keyword:keyword}, selectKeyword);
		});
		if (i>0)
			$(container).show();
			
	}
	
	function selectKeyword(e) {
		var parts = e.data.keyword.split(" ");
		var lastPart = parts[parts.length-1];
		parts.pop();
		var city = parts.join(' ');
		$('#city').val(city);
		$('#postalcode').val(lastPart);
		//$(e.data.query).val(e.data.keyword);
		$(e.data.container).hide();
	}

	/*
	// Een public function. Kan extern gebruikt worden: $('element').KeywordDropDown.publicFunction(), en overschreven worden
	$.fn.KeywordDropDown.publicFunction = function(args) {
		
	};*/
})(jQuery);

/* ====================================== ///// End jquery.keyworddropdown.js ====================================== */











