var sPreloadingArea = 'v3_home';lazyModules['cTemplate'].loaded = true;lazyModules['session-store'].loaded = true;lazyModules['badjie-ibe-mask'].loaded = true;lazyModules['badjie-ibe-flight-mask'].loaded = true;lazyModules['jqueryDatePicker'].loaded = true;

/* ---------- /var/www/africanworld.de/htdocs/totoya/cache/core/clib/admin/framework/skin/default/js/ctemplate.js ---------- */

var cTemplate = {

	parse: function(sTemplate, oData) {
		for(var i in oData) {
			if(typeof oData[i] == "array" || typeof oData[i] == "object") {
				// explode template in three parts (before block, block and after block)
				var sBlock = this.getBlock(sTemplate, i);
				if(sBlock == null) continue;
				// recurse with only parsing the block for each item in array or object
				var sReplace = "";
				for(var j in oData[i]) {
					sReplace += this.parse(sBlock, oData[i][j]);
				}
				// replace block by generated content
				sTemplate = this.replaceBlock(sTemplate, i, sReplace);
			}
			else if(typeof oData[i] == "boolean") {
				var sBlock = this.getBlock(sTemplate, i);
				if(sBlock == null) continue;
				// recurse with only parsing the block for each item in array or object
				if(!oData[i]) {
					sBlock = "";
				}
				// replace block by generated content
				sTemplate = this.replaceBlock(sTemplate, i, sBlock);
			}
			else {
				sTemplate = this.replaceItem(sTemplate, i, oData[i]);
			}
		}
		return sTemplate;
	}

	,getBlock:	function(sTemplate, sBlockName) {
		var sRegExp = '{{'+sBlockName+':}}([\\s\\S]*){{:'+sBlockName+'}}';
		var oRegExp = new RegExp(sRegExp, "g");
		var aMatches = oRegExp.exec(sTemplate);
		if(aMatches == null) {
			return null;
		}
		return aMatches[1];
	}

	,replaceBlock:	function(sTemplate, sBlockName, sReplace) {
		var sRegExp = '{{'+sBlockName+':}}([\\s\\S]*){{:'+sBlockName+'}}';
		if (typeof sReplace != 'string' && typeof sReplace != 'number') {
			sReplace = '';
		}
		var sNewTemplate = sTemplate.replace(new RegExp(sRegExp, "g"), sReplace);
		return sNewTemplate;
	}

	,replaceItem:	function(sTemplate, sItemName, sReplace) {
		var sRegExp = '{{'+sItemName+'}}';
		if (typeof sReplace != 'string' && typeof sReplace != 'number') {
			sReplace = '';
		}
		var sNewTemplate = sTemplate.replace(new RegExp(sRegExp, "g"), sReplace);
		return sNewTemplate;
	}

};

/* ---------- /var/www/africanworld.de/htdocs/totoya/cache/core/clib/core/ajax/js/csessionstore.class.js ---------- */

/**
 * js session data storage
 *
 * @package ajax
 * @author haustein
 */
var oSessionstore = {};
(function(oSelf) {
	$.extend(oSelf, {
		oData:	{}
		,init:	function() {
			/*$(window).unload(function() {
				oSelf.saveData();
			});*/
		}
		,saveData:	function(fCallback) {
			for(var sArea in oSelf.oData) {
				if(oSelf.oData[sArea].bDirty) {
					$.post(
						'/ajax/cAjaxSessionStore/ajaxSaveSessionData',
						{
							"sArea":	sArea
							, "mData":	oSelf.oData[sArea].mData
						}
					);
				}
			}
			if(typeof fCallback == 'function') {
				window.setTimeout(fCallback, 100);
			}
		}
		,getData:	function(sArea, fCallback) {
			if(oSelf.oData[sArea] != null && oSelf.oData[sArea] != undefined) {
				executeCallback(fCallback,  oSelf.oData[sArea].mData);
				return;
			}
			$.post(
				'/ajax/cAjaxSessionStore/ajaxGetSessionData'
				, { "sArea": sArea }
				, function(o){
					oSelf.oData[sArea] = {"mData": $.parseJSON(o).mData, "bDirty": false};
					executeCallback(fCallback,  oSelf.oData[sArea].mData);
				}
				, 'JSON'
			);
		}
		,setData:	function(sArea, mData) {
			oSelf.oData[sArea] = {"mData": mData, "bDirty": true};
		}
	});
	oSelf.init();
})(oSessionstore);

/* ---------- /var/www/africanworld.de/htdocs/totoya/cache/core/clib/badjie/ibe/js/cibemask.class.js ---------- */

/**
 * js frontend for the search engine
 * handels the display and the inputs
 *
 * @package badjie
 * @author frenzel
 * @author haustein
 */
var oIbeMask = {};
(function() {
	var oSelf = oIbeMask;
	$.extend(oIbeMask, {
		
		/** id of ul which will be converted into tabs in the dom */
		sTabsDomId: null
				
		/** first choosable date */
		,oDatePickerOption:		{
			startDate:					'01/01/1900'
			, beforeRenderCallback: 	function(id) {
				if (id == 'searchfield_earliest_input') {
					$('.searchfield_earliest').css("z-index", "80");
					$('.searchfield_latest').css("z-index", "70");
				} else if (id == 'searchfield_latest_input') {
					$('.searchfield_earliest').css("z-index", "70");
					$('.searchfield_latest').css("z-index", "80");
				} else if (id == 'searchfield_departure_input') {
					$('.searchfield_departure').css("z-index", "80");
					$('.searchfield_return_flight').css("z-index", "70");
				} else {
					$('.searchfield_departure').css("z-index", "70");
					$('.searchfield_return_flight').css("z-index", "80");
				}
			}
		}
		
		/** meals constants */
		,oMeals: 				{
			'accomodation only':	'&Uuml;'
			, 'bed and breakfast':	'&Uuml;F'
			, 'half board': 		'HP'
			, 'full board':			'VP'
			, 'all inclusive':		'AI'
		}
		,oMealsLong:			{
			'accomodation only':	'nur &Uuml;bernachtung'
			, 'bed and breakfast':	'Fr&uuml;hst&uuml;ck'
			, 'half board':			'Halbpension'
			, 'full board':			'Vollpension'
			, 'all inclusive':		'All inclusive'
		}
		
		/** children count */
		, iChildrenCount:		0
		
		/** remember current offer */
		, iCurrentOffer:		null
		
		/** more hotel details */
		, oMoreHotelDetails:	{}
		
		


		/**
		 * kind of constructor, does some things that have to be done first
		 */
		,init: function(sSearchTabsId) {
			// do some inits
			oSelf.sTabsDomId = sSearchTabsId;
			$('#'+sSearchTabsId).hide();
			
			// use lazy load to get tab- and form-handling functions
			$.lazyLoad(['jqueryDatePicker', 'cTemplate', 'session-store'], function() {
			
				// ------------------------
				// create tabs
				// ------------------------
				
				
				// ui create tabs
				$('#'+sSearchTabsId).tabs({
					"selected": 	0
					, "disabled":	[1]
					,  "show":	function(event, ui) {
						switch(ui.index) {
							case 0:
								$.historyLoad('search_div');
								break;
							case 2:
								$.historyLoad('cart_div');
								break;
						}
					}
				});
				
				// init rendering the first tab
				oSelf.renderSearchTab();
				
				// disable flickering
				$('#'+sSearchTabsId).css('display','block');
			});			
		}
		
		
		
				
		/**
		 * will be called whenever the first tab is clicked
		 */
		
		,renderSearchTab:	function() {
			$('#first-content').html('<div id="ibe_searchmask"></div><div id="ibe_searchresult"></div>');
			oSelf.renderSearchMask();
		}
		
		
		
		/**
		 * fetches the search-mask html and renders the mask
		 */
		
		,renderSearchMask: function() {
				// ------------------------
				// init form
				// ------------------------
				
				// set booking date
				var oToday = new Date();
				var sDate = 
					oSelf.fillString(oToday.getDate().toString(), '0', 2, 'left') 
					+ '.' 
					+ oSelf.fillString((oToday.getMonth() + 1).toString(), '0', 2, 'left')
					+ '.' 
					+ oSelf.fillString(oToday.getFullYear().toString(), '0', 2, 'left');
				$('#searchfield_booking_date_input').val(sDate);

				// add datepicker
				$.dpText = {
					TEXT_PREV_YEAR		:	'Vorheriges Jahr',
					TEXT_PREV_MONTH		:	'Vorheriger Monat',
					TEXT_NEXT_YEAR		:	'N&auml;chstes Jahr',
					TEXT_NEXT_MONTH		:	'N&auml;chster Monat',
					TEXT_CLOSE			:	'Schlie&szlig;en',
					TEXT_CHOOSE_DATE	:	'Kalender',
					HTML_CHOOSE_DATE	:	'<img src="/totoya/cache/core/clib/lib/jquery/datepicker/btn_calendar.png" alt="Kalender" />'
				}
				setGermanDate();
				$('.datepicker').datePicker(oSelf.oDatePickerOption);

				// set region, country and hotel selects
				var iTempRegion = $('#searchfield_region_input').val();
				if (iTempRegion < 1) {
					iTempRegion = null;
				}
				oSelf.getSearchOptions(iTempRegion, oSelf.iCountryId, oSelf.iHotelId);
				

				// ---------------------------
				// bind events
				// ---------------------------

				
				// start search button
				function startSearch() {
					oWaitingScreen.open();
					
					// store parameters to session store
					var oIbeData = {
						"searchfield_country_input": 	$('#searchfield_country_input').val()
						,"searchfield_hotel_id":		0
						,"searchfield_earliest_input":	$('#searchfield_earliest_input').val()
						,"searchfield_latest_input": 	$('#searchfield_latest_input').val()
						,"searchfield_nights_input": 	$('#searchfield_nights_input').val()
						,"searchfield_rooms_input": 	$('#searchfield_rooms_input').val()
						,"searchfield_adults_input": 	$('#searchfield_adults_input').val()
					};

					$.post(
						'/ajax/cControlIbeSessionStore/ajaxSaveSessionData'
						, {
							"sArea":			'ibe'
							, "mData":			oIbeData
							, "iCountryId":		$('#searchfield_country_input').val()
							, "sToType":		'both'
						}
						, function(o) {
							var iHotelId = parseInt($('#searchfield_hotel_input').val());
							if (!isNaN(iHotelId) && iHotelId > 0 && typeof oSelf.oHotels[iHotelId] != 'undefined') {
								// move to hotel
								window.location.href = oSelf.oHotels[iHotelId].url;
							} else {
								// forward to next page
								window.location.href = o.mData;
							}
						}
						, 'json'
					);
/*
					oSessionstore.setData('ibe', {
						"searchfield_region_input":		$('#searchfield_region_input').val()
						,"searchfield_country_input": 	$('#searchfield_country_input').val()
						,"searchfield_earliest_input":	$('#searchfield_earliest_input').val()
						,"searchfield_latest_input": 	$('#searchfield_latest_input').val()
						,"searchfield_nights_input": 	$('#searchfield_nights_input').val()
						,"searchfield_rooms_input": 	$('#searchfield_rooms_input').val()
						,"searchfield_adults_input": 	$('#searchfield_adults_input').val()
					});
					oSessionstore.saveData(function(){
						window.location.href="/german/IBE/";
					});
*/
					return false;
				}
				$('#searchfield_search_button').click(startSearch);
				$('#serch-form').bind('submit',startSearch);
		}



		/***********************************************************************
		 *
		 * Helper functions to handle the search mask
		 *
		 ***********************************************************************/


		
		/**
		 * Json-request to get the search options.
		 * 
		 * @param	int 	iRegionId		json data: region id
		 * @param	int 	iCountryId		json data: country id
		 * @param	int		iHotelId		json data: hotel id
		 */
		
		,getSearchOptions: function(iRegionId, iCountryId, iHotelId) {
			// get region, country and hotel options
			$.getJSON(
				'/ajax/cControlOfferSearch/ajaxGetSearchOptions'
				,{ 
					'region_id': 	iRegionId
					,'country_id':	iCountryId
					, 'hotel_id':	iHotelId 
				}
				,oSelf.setSearchOptions
			);
		}
		
		
		
		/**
		 * Callback getting the search options - sets the options to the search fields.
		 * 
		 * @param	object	o		o.mData = {
		 * 		regions:		{ >iRegionId<: 	{ name: >sRegionName< }		, ...}
		 * 		, countries:	{ >iCountryId<:	{ name: >sCountryName< }	, ...}
		 * 		, hotels:		{ >iHotelId<:	{ name: >sHotelName< }		, ...}
		 * }
		 */
		
		,oHotels: null
		,setSearchOptions:	function(o) {
			var oRegions = o.mData.regions;
			var oCountries = o.mData.countries;
			oSelf.oHotels = o.mData.hotels;
			
			// set region options
			oSelf.setOptions('region', 'searchfield_region_input', oRegions, o.mData.current.region_id);
			
			// set "on change" function
			$('#searchfield_region_input').unbind('change').change(function() {
				oSelf.getSearchOptions(
					$('#searchfield_region_input').val()
					, null
					, null
				);
			});
			
			// set country options
			oSelf.setOptions('country', 'searchfield_country_input', oCountries, o.mData.current.country_id);
			
			// set "on change" function
			$('#searchfield_country_input').unbind('change').change(function() {
				oSelf.getSearchOptions(
					$('#searchfield_region_input').val()
					, $('#searchfield_country_input').val() 
					, null
				);
			});

			// set hotel options
			oSelf.setOptions('hotel', 'searchfield_hotel_input', oSelf.oHotels, o.mData.current.hotel_id);
			
			// set "on change" function
/*
			$('#searchfield_hotel_input').unbind('change').change(function() {
				oSelf.getSearchOptions(
					$('#searchfield_region_input').val()
					, $('#searchfield_country_input').val() 
					, $('#searchfield_hotel_input').val()
				);
			});
*/
		}
		
		
		
		/**
		 * Insert the options to the search select fields.
		 * 
		 * @param	string	sType			'region', 'country' or 'hotel'
		 * @param	string	sFieldname		the id of the select field
		 * @param	object	oOptions		{ >sValue<:	{ name: >sText< } }
		 * @param	int		iSelectedId		value of the selected option
		 */
		
		,setOptions:	function(sType, sFieldname, oOptions, iSelectedId) {
			// init select
			var sDefaultSelect;
			switch (sType) {
				case 'hotel':
					sDefaultSelect = 'beliebig';
					break;
					
				default:
					sDefaultSelect = 'bitte w&auml;hlen';
			}
			
			$('#'+sFieldname)
				.empty()
				.html(
					$('<option></option>')
			        	.val(0)
			        	.html(sDefaultSelect)
			    );

			// for each option
			for (var iValue in oOptions) {
				// add option
				$('#'+sFieldname).append(
					$('<option></option>')
	        			.attr('id', sType+'_'+iValue)
			        	.val(iValue)
			        	.html(oOptions[iValue].name)
			    );
				
				// set selected option
				if (parseInt(iValue) == iSelectedId && parseInt(iValue) > 0) {
					$('#'+sType+'_'+iValue).attr('selected', 'selected');
				}
			}
		}
		
		
		
		/**
		 * Fills a string.
		 * 
		 * @param	string	sValue		starting string value
		 * @param	string	sChar		the char to be added
		 * @param	int		iMax		target count of the string
		 * @param	string	sPos		'left' to add the char on the left side
		 * @return	string	the filled string 
		 */
		
		,fillString:	function(sValue, sChar, iMax, sPos) {
			var sNewValue = sValue;
			while (sNewValue.length < iMax) {
				if (sPos == 'left') {
					sNewValue = sChar + sNewValue;
				} else {
					sNewValue += sChar;
				}
			}
			return sNewValue;
		}
		
	});
})(oIbeMask);

/* ---------- /var/www/africanworld.de/htdocs/totoya/cache/core/clib/badjie/ibe/js/cibeflightmask.class.js ---------- */

/**
 * js frontend for the search engine
 * handels the display and the inputs
 *
 * @package badjie
 * @author frenzel
 * @author haustein
 */
var oIbeFlightMask = {};
(function() {
	var oSelf = oIbeFlightMask;
	
	$.extend(oIbeFlightMask, {
		
		sFlightTabDomId:	null
		
		
		,init:	function(sFlightTabId) {
			// do some inits
			oSelf.sFlightTabDomId = sFlightTabId;
			
			oSelf.render();
		}
		
	
		,render: function() {
			var sHtml =
				'<form action="/german/billig-fluege-afrika/flugbuchung_new.html" method="POST">'
					+'<div class="flightmask" style="z-index: 40">'
						+'<div class="searchfield_div">'
							+'<div class="searchfield_label_div"><label>Abflugort</label></div>'
							+'<div class="searchfield_input_div"><input name="depApt" type="text" /></div>'
						+'</div>'
						+'<div class="searchfield_div">'
							+'<div class="searchfield_label_div"><label>Zielort</label></div>'
							+'<div class="searchfield_input_div"><input name="dstApt" type="text" /></div>'
						+'</div>'
						+'<div class="searchfield_div searchfield_departure">'
							+'<div class="searchfield_label_div"><label>Abflugdatum</label></div>'
							+'<div class="searchfield_input_div"><input id="searchfield_departure_input" name="depDate" type="text" class="datepicker dp-applied" /></div>'
						+'</div>'
						+'<div class="searchfield_div searchfield_return_flight">'
							+'<div class="searchfield_label_div"><label>R&uuml;ckflugdatum</label></div>'
							+'<div class="searchfield_input_div"><input id="searchfield_return_flight_input" name="dstDate" type="text" class="datepicker dp-applied" /></div>'
						+'</div>'
						+'<div class="searchfield_div">'
							+'<div class="searchfield_input_div_radio">'
								+'<input type="radio" name="onewayswitch" value="0" checked="checked" /> Hin- und R&uuml;ckflug<br />'
								+'<input type="radio" name="onewayswitch" value="1" /> nur Hinflug'
							+'</div>'
						+'</div>'
					+'</div>'
					+'<div class="flightmask flightmask_left_padding" style="z-index: 35">'
						+'<div class="searchfield_div">'
							+'<div class="searchfield_label_div_small"><label>Erwachsene</label></div>'
							+'<div class="searchfield_input_div">'
								+'<select name="pax">'
									+'<option value="1">1</option>'
									+'<option value="2">2</option>'
									+'<option value="3">3</option>'
									+'<option value="4">4</option>'
									+'<option value="5">5</option>'
									+'<option value="6">6</option>'
								+'</select>'
							+'</div>'
						+'</div>'
						+'<div class="searchfield_div">'
							+'<div class="searchfield_label_div_small"><label>Kinder</label></div>'
							+'<div class="searchfield_input_div">'
								+'<select name="pax_chd">'
									+'<option value="0">keine</option>'
									+'<option value="1">1</option>'
									+'<option value="2">2</option>'
									+'<option value="3">3</option>'
									+'<option value="4">4</option>'
									+'<option value="5">5</option>'
									+'<option value="6">6</option>'
								+'</select>'
							+'</div>'
						+'</div>'
						+'<div class="searchfield_div">'
							+'<div class="searchfield_label_div_small"><label>Babys</label></div>'
							+'<div class="searchfield_input_div">'
								+'<select name="pax_inf">'
									+'<option value="0">keine</option>'
									+'<option value="1">1</option>'
									+'<option value="2">2</option>'
									+'<option value="3">3</option>'
									+'<option value="4">4</option>'
								+'</select>'
							+'</div>'
						+'</div>'
						+'<div class="searchfield_div">'
							+'<div class="searchfield_label_div_small"><label>Tarif</label></div>'
							+'<div class="searchfield_input_div">'
								+'<select name="tarif_klasse">'
									+'<option value="DL">Ethnic Tarife</option>'
									+'<option value="N">Economy Klasse</option>'
									+'<option value="J">Jugend-/Studententarif</option>'
									+'<option value="B">Business-/First Class</option>'
								+'</select>'
							+'</div>'
						+'</div>'
						+'<div class="searchfield_div">'
							+'<div class="searchfield_input_div_radio">'
								+'<input type="checkbox" name="only_avail" value="Y" /> Nur verfügbare Flüge '
							+'</div>'
						+'</div>'
					+'</div>'
					+'<div class="floatEnd"></div>'
					+'<div class="searchfield_div" style="z-index: 30">'
						+'<div class="searchfield_label_div"><label>&nbsp;</label></div>'
						+'<div class="searchfield_input_div"><button type="submit">Suchen</button></div>'
					+'</div>'
					+'<input type="hidden" name="action" value="search" />'
					+'<input type="hidden" name="agent" value="co66194" />'
					+'<input type="hidden" name="aork" value="K" />'
					+'<input type="hidden" name="minday_dep" value="5" />'
				+'</form>';
			$('#'+oSelf.sFlightTabDomId).html(sHtml);

		}
	});
})(oIbeFlightMask);


/* ---------- /var/www/africanworld.de/htdocs/totoya/cache/core/clib/lib/jquery/datepicker/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 = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];

/**
 * An Array of abbreviated day names starting with Sun.
 * 
 * @example abbrDayNames[0]
 * @result 'Sun'
 *
 * @name abbrDayNames
 * @type Array
 * @cat Plugins/Methods/Date
 */
Date.abbrDayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];

/**
 * An Array of month names starting with Janurary.
 * 
 * @example monthNames[0]
 * @result 'January'
 *
 * @name monthNames
 * @type Array
 * @cat Plugins/Methods/Date
 */
Date.monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', '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', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', '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);
		this.setTime(this.getTime() + (num*86400000) );
		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(format) {
		var r = format || Date.format;
		return r
			.split('yyyy').join(this.getFullYear())
			.split('yy').join((this.getFullYear() + '').substring(2))
			.split('mmmm').join(this.getMonthName(false))
			.split('mmm').join(this.getMonthName(true))
			.split('mm').join(_zeroPad(this.getMonth()+1))
			.split('dd').join(_zeroPad(this.getDate()))
			.split('hh').join(_zeroPad(this.getHours()))
			.split('min').join(_zeroPad(this.getMinutes()))
			.split('ss').join(_zeroPad(this.getSeconds()));
	});
	
	/**
	 * 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, format)
	{
		var f = format || Date.format;
		var d = new Date('01/01/1977');
		
		var mLength = 0;

		var iM = f.indexOf('mmmm');
		if (iM > -1) {
			for (var i=0; i<Date.monthNames.length; i++) {
				var mStr = s.substr(iM, Date.monthNames[i].length);
				if (Date.monthNames[i] == mStr) {
					mLength = Date.monthNames[i].length - 4;
					break;
				}
			}
			d.setMonth(i);
		} else {
			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);
			}
		}
		
		var iY = f.indexOf('yyyy');

		if (iY > -1) {
			if (iM < iY)
			{
				iY += mLength;
			}
			d.setFullYear(Number(s.substr(iY, 4)));
		} else {
			if (iM < iY)
			{
				iY += mLength;
			}
			// 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 iD = f.indexOf('dd');
		if (iM < iD)
		{
			iD += mLength;
		}
		d.setDate(Number(s.substr(iD, 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 :(
	};
	
})();

/* ---------- /var/www/africanworld.de/htdocs/totoya/cache/core/clib/lib/jquery/datepicker/date_de.js ---------- */

function setGermanDate() {
	// date localization for locale 'de'
	Date.dayNames = ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'];
	Date.abbrDayNames = ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'];
	Date.monthNames = ['Januar', 'Februar', 'M&auml;rz', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'];
	Date.abbrMonthNames = ['Jan', 'Feb', 'Mrz', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'];
	Date.firstDayOfWeek = 1;
	Date.format = 'dd.mm.yyyy';
}

/* ---------- /var/www/africanworld.de/htdocs/totoya/cache/core/clib/lib/jquery/jquery.datepicker-2.1.2.js ---------- */

/**
 * Copyright (c) 2008 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 15 2008-12-17 04:40:18Z 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({}, $.fn.datePicker.defaults, 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({}, $.fn.datePicker.defaults, 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.HTML_CHOOSE_DATE + '</a>')
								.bind(
									'click',
									function()
									{
										if (s.beforeRenderCallback) {
											s.beforeRenderCallback($this.attr('id'));
										}
										$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()
								{
									if (s.beforeRenderCallback) {
										s.beforeRenderCallback($this.attr('id'));
									}
									this.value = $this.val();
									if (this.value != '') {
										var d = Date.fromString(this.value);
										if (d) {
											controller.setSelected(d, true, true);
											controller.setDisplayedMonth(parseInt(d.asString('mm'), 10)-1, d.asString('yyyy'));
										}
									}
								}
							);
						if (s.clickInput) {
							$this.bind(
								'click',
								function()
								{
									$this.dpDisplay();
								}
							);
						}
						var d = Date.fromString(this.value);
						if (this.value != '' && d) {
							controller.setSelected(d, true, true);
							controller.setDisplayedMonth(parseInt(d.asString('mm'), 10)-1, d.asString('yyyy'));
						}
					}
					
					$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, true);
		},
/**
 * 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), true);
		},
/**
 * 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 that is called when the button is clicked.
 * 
 * @param Function a A function that is called when the button is clicked.
 * @type jQuery
 * @name dpSetBeforeRenderCallback
 * @cat plugins/datePicker
 **/
		dpSetBeforeRenderCallback : function(f)
		{
			return _w.call(this, 'setBeforeRenderCallback', f);
		},
/**
 * 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, a4)
	{
		return this.each(
			function()
			{
				var c = _getController(this);
				if (c) {
					c[f](a1, a2, a3, a4);
				}
			}
		);
	};
	
	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.beforeRenderCallback = 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.setBeforeRenderCallback(s.beforeRenderCallback);
				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, rerender)
			{
				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;
				}
				var oldMonth = this.displayedMonth;
				var oldYear = this.displayedYear;
				this.displayedMonth = t.getMonth();
				this.displayedYear = t.getFullYear();

				if (rerender && (this.displayedMonth != oldMonth || this.displayedYear != oldYear))
				{
					this._rerenderCalendar();
					$(this.ele).trigger('dpMonthChanged', [this.displayedMonth, this.displayedYear]);
				}
			},
			setSelected : function(d, v, moveToMonth, dispatchEvents)
			{
				if (v == this.isSelected(d)) // this date is already un/selected
				{
					return;
				}
				if (this.selectMultiple == false) {
					this.selectedDates = {};
					$('td.selected', this.context).removeClass('selected');
				}
				if (moveToMonth && this.displayedMonth != d.getMonth()) {
					this.setDisplayedMonth(d.getMonth(), d.getFullYear(), true);
				}
				this.selectedDates[d.toString()] = v;
				
				var selectorString = 'td.';
				selectorString += d.getMonth() == this.displayedMonth ? 'current-month' : 'other-month';
				selectorString += ':contains("' + d.getDate() + '")';
				var $td;
				$(selectorString, this.ele).each(
					function()
					{
						if ($(this).text() == d.getDate())
						{
							$td = $(this);
							$td[v ? 'addClass' : 'removeClass']('selected');
						}
					}
				);
				
				if (dispatchEvents)
				{
					var s = this.isSelected(d);
					$e = $(this.ele);
					$e.trigger('dateSelected', [d, $td, s]);
					$e.trigger('change');
				}
			},
			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 $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 = $(this.ele);
					attrs = {
						'id'		:	'dp-popup',
						'className'	:	'dp-popup'
					};
					cssRules = {
						'top'	:	parseInt(this.verticalOffset)+'px',
						'right'	:	parseInt(this.horizontalOffset)+'px'
					};
					
					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);
				}
				
				
				var newDiv = 
						$('<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();
				
				if (this.inline) {
					$createIn.append(newDiv);
				} else {
					$createIn.after(newDiv);
				}
					
				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', parseInt(this.verticalOffset)+'px');
					}
					if (this.horizontalPosition == $.dpConst.POS_RIGHT) {
						$pop.css('right', parseInt(this.horizontalOffset)+'px');
					}
					$(document).bind('mousedown', this._checkMouse);
				}
			},
			setBeforeRenderCallback : function(f)
			{
				this.beforeRenderCallback = f;
			},
			setRenderCallback : function(a)
			{
				if (a == null) return;
				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, false, true);
							if (c.closeOnSelect) {
								c._closeCalendar();
							}
						}
					}
				);
				
				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, true);
				}
				ele.blur();
				return false;
			},
			_rerenderCalendar : function()
			{
				this._clearCalendar();
				this._renderCalendar();
			},
			_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		:	'Previous year',
		TEXT_PREV_MONTH		:	'Previous month',
		TEXT_NEXT_YEAR		:	'Next year',
		TEXT_NEXT_MONTH		:	'Next month',
		TEXT_CLOSE			:	'Close',
		TEXT_CHOOSE_DATE	:	'Choose date'
	};
	// version
	$.dpVersion = '$Id: jquery.datePicker.js 15 2008-12-17 04:40:18Z kelvin.luck $';

	$.fn.datePicker.defaults = {
		month				: undefined,
		year				: undefined,
		showHeader			: $.dpConst.SHOW_HEADER_SHORT,
		startDate			: undefined,
		endDate				: undefined,
		inline				: false,
		beforeRenderCallback: null,
		renderCallback		: null,
		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'
	};

	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);


/* ---------- template-global_v3-animation ---------- */

/*
 * jQuery UI 1.7.3
 *
 * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI
 */
jQuery.ui||(function(c){var i=c.fn.remove,d=c.browser.mozilla&&(parseFloat(c.browser.version)<1.9);c.ui={version:"1.7.3",plugin:{add:function(k,l,n){var m=c.ui[k].prototype;for(var j in n){m.plugins[j]=m.plugins[j]||[];m.plugins[j].push([l,n[j]])}},call:function(j,l,k){var n=j.plugins[l];if(!n||!j.element[0].parentNode){return}for(var m=0;m<n.length;m++){if(j.options[n[m][0]]){n[m][1].apply(j.element,k)}}}},contains:function(k,j){return document.compareDocumentPosition?k.compareDocumentPosition(j)&16:k!==j&&k.contains(j)},hasScroll:function(m,k){if(c(m).css("overflow")=="hidden"){return false}var j=(k&&k=="left")?"scrollLeft":"scrollTop",l=false;if(m[j]>0){return true}m[j]=1;l=(m[j]>0);m[j]=0;return l},isOverAxis:function(k,j,l){return(k>j)&&(k<(j+l))},isOver:function(o,k,n,m,j,l){return c.ui.isOverAxis(o,n,j)&&c.ui.isOverAxis(k,m,l)},keyCode:{BACKSPACE:8,CAPS_LOCK:20,COMMA:188,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38}};if(d){var f=c.attr,e=c.fn.removeAttr,h="http://www.w3.org/2005/07/aaa",a=/^aria-/,b=/^wairole:/;c.attr=function(k,j,l){var m=l!==undefined;return(j=="role"?(m?f.call(this,k,j,"wairole:"+l):(f.apply(this,arguments)||"").replace(b,"")):(a.test(j)?(m?k.setAttributeNS(h,j.replace(a,"aaa:"),l):f.call(this,k,j.replace(a,"aaa:"))):f.apply(this,arguments)))};c.fn.removeAttr=function(j){return(a.test(j)?this.each(function(){this.removeAttributeNS(h,j.replace(a,""))}):e.call(this,j))}}c.fn.extend({remove:function(j,k){return this.each(function(){if(!k){if(!j||c.filter(j,[this]).length){c("*",this).add(this).each(function(){c(this).triggerHandler("remove")})}}return i.call(c(this),j,k)})},enableSelection:function(){return this.attr("unselectable","off").css("MozUserSelect","").unbind("selectstart.ui")},disableSelection:function(){return this.attr("unselectable","on").css("MozUserSelect","none").bind("selectstart.ui",function(){return false})},scrollParent:function(){var j;if((c.browser.msie&&(/(static|relative)/).test(this.css("position")))||(/absolute/).test(this.css("position"))){j=this.parents().filter(function(){return(/(relative|absolute|fixed)/).test(c.curCSS(this,"position",1))&&(/(auto|scroll)/).test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0)}else{j=this.parents().filter(function(){return(/(auto|scroll)/).test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0)}return(/fixed/).test(this.css("position"))||!j.length?c(document):j}});c.extend(c.expr[":"],{data:function(l,k,j){return !!c.data(l,j[3])},focusable:function(k){var l=k.nodeName.toLowerCase(),j=c.attr(k,"tabindex");return(/input|select|textarea|button|object/.test(l)?!k.disabled:"a"==l||"area"==l?k.href||!isNaN(j):!isNaN(j))&&!c(k)["area"==l?"parents":"closest"](":hidden").length},tabbable:function(k){var j=c.attr(k,"tabindex");return(isNaN(j)||j>=0)&&c(k).is(":focusable")}});function g(m,n,o,l){function k(q){var p=c[m][n][q]||[];return(typeof p=="string"?p.split(/,?\s+/):p)}var j=k("getter");if(l.length==1&&typeof l[0]=="string"){j=j.concat(k("getterSetter"))}return(c.inArray(o,j)!=-1)}c.widget=function(k,j){var l=k.split(".")[0];k=k.split(".")[1];c.fn[k]=function(p){var n=(typeof p=="string"),o=Array.prototype.slice.call(arguments,1);if(n&&p.substring(0,1)=="_"){return this}if(n&&g(l,k,p,o)){var m=c.data(this[0],k);return(m?m[p].apply(m,o):undefined)}return this.each(function(){var q=c.data(this,k);(!q&&!n&&c.data(this,k,new c[l][k](this,p))._init());(q&&n&&c.isFunction(q[p])&&q[p].apply(q,o))})};c[l]=c[l]||{};c[l][k]=function(o,n){var m=this;this.namespace=l;this.widgetName=k;this.widgetEventPrefix=c[l][k].eventPrefix||k;this.widgetBaseClass=l+"-"+k;this.options=c.extend({},c.widget.defaults,c[l][k].defaults,c.metadata&&c.metadata.get(o)[k],n);this.element=c(o).bind("setData."+k,function(q,p,r){if(q.target==o){return m._setData(p,r)}}).bind("getData."+k,function(q,p){if(q.target==o){return m._getData(p)}}).bind("remove",function(){return m.destroy()})};c[l][k].prototype=c.extend({},c.widget.prototype,j);c[l][k].getterSetter="option"};c.widget.prototype={_init:function(){},destroy:function(){this.element.removeData(this.widgetName).removeClass(this.widgetBaseClass+"-disabled "+this.namespace+"-state-disabled").removeAttr("aria-disabled")},option:function(l,m){var k=l,j=this;if(typeof l=="string"){if(m===undefined){return this._getData(l)}k={};k[l]=m}c.each(k,function(n,o){j._setData(n,o)})},_getData:function(j){return this.options[j]},_setData:function(j,k){this.options[j]=k;if(j=="disabled"){this.element[k?"addClass":"removeClass"](this.widgetBaseClass+"-disabled "+this.namespace+"-state-disabled").attr("aria-disabled",k)}},enable:function(){this._setData("disabled",false)},disable:function(){this._setData("disabled",true)},_trigger:function(l,m,n){var p=this.options[l],j=(l==this.widgetEventPrefix?l:this.widgetEventPrefix+l);m=c.Event(m);m.type=j;if(m.originalEvent){for(var k=c.event.props.length,o;k;){o=c.event.props[--k];m[o]=m.originalEvent[o]}}this.element.trigger(m,n);return !(c.isFunction(p)&&p.call(this.element[0],m,n)===false||m.isDefaultPrevented())}};c.widget.defaults={disabled:false};c.ui.mouse={_mouseInit:function(){var j=this;this.element.bind("mousedown."+this.widgetName,function(k){return j._mouseDown(k)}).bind("click."+this.widgetName,function(k){if(j._preventClickEvent){j._preventClickEvent=false;k.stopImmediatePropagation();return false}});if(c.browser.msie){this._mouseUnselectable=this.element.attr("unselectable");this.element.attr("unselectable","on")}this.started=false},_mouseDestroy:function(){this.element.unbind("."+this.widgetName);(c.browser.msie&&this.element.attr("unselectable",this._mouseUnselectable))},_mouseDown:function(l){l.originalEvent=l.originalEvent||{};if(l.originalEvent.mouseHandled){return}(this._mouseStarted&&this._mouseUp(l));this._mouseDownEvent=l;var k=this,m=(l.which==1),j=(typeof this.options.cancel=="string"?c(l.target).parents().add(l.target).filter(this.options.cancel).length:false);if(!m||j||!this._mouseCapture(l)){return true}this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){k.mouseDelayMet=true},this.options.delay)}if(this._mouseDistanceMet(l)&&this._mouseDelayMet(l)){this._mouseStarted=(this._mouseStart(l)!==false);if(!this._mouseStarted){l.preventDefault();return true}}this._mouseMoveDelegate=function(n){return k._mouseMove(n)};this._mouseUpDelegate=function(n){return k._mouseUp(n)};c(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);(c.browser.safari||l.preventDefault());l.originalEvent.mouseHandled=true;return true},_mouseMove:function(j){if(c.browser.msie&&!j.button){return this._mouseUp(j)}if(this._mouseStarted){this._mouseDrag(j);return j.preventDefault()}if(this._mouseDistanceMet(j)&&this._mouseDelayMet(j)){this._mouseStarted=(this._mouseStart(this._mouseDownEvent,j)!==false);(this._mouseStarted?this._mouseDrag(j):this._mouseUp(j))}return !this._mouseStarted},_mouseUp:function(j){c(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this._preventClickEvent=(j.target==this._mouseDownEvent.target);this._mouseStop(j)}return false},_mouseDistanceMet:function(j){return(Math.max(Math.abs(this._mouseDownEvent.pageX-j.pageX),Math.abs(this._mouseDownEvent.pageY-j.pageY))>=this.options.distance)},_mouseDelayMet:function(j){return this.mouseDelayMet},_mouseStart:function(j){},_mouseDrag:function(j){},_mouseStop:function(j){},_mouseCapture:function(j){return true}};c.ui.mouse.defaults={cancel:null,distance:1,delay:0}})(jQuery);;/*


 * jQuery UI Tabs 1.7.3
 *
 * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Tabs
 *
 * Depends:
 *	ui.core.js
 */
(function(c){var b=0,a=0;c.widget("ui.tabs",{_init:function(){if(this.options.deselectable!==undefined){this.options.collapsible=this.options.deselectable}this._tabify(true)},_setData:function(d,e){if(d=="selected"){if(this.options.collapsible&&e==this.options.selected){return}this.select(e)}else{this.options[d]=e;if(d=="deselectable"){this.options.collapsible=e}this._tabify()}},_tabId:function(d){return d.title&&d.title.replace(/\s/g,"_").replace(/[^A-Za-z0-9\-_:\.]/g,"")||this.options.idPrefix+(++b)},_sanitizeSelector:function(d){return d.replace(/:/g,"\\:")},_cookie:function(){var d=this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+(++a));return c.cookie.apply(null,[d].concat(c.makeArray(arguments)))},_ui:function(e,d){return{tab:e,panel:d,index:this.anchors.index(e)}},_cleanup:function(){this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function(){var d=c(this);d.html(d.data("label.tabs")).removeData("label.tabs")})},_tabify:function(q){this.list=this.element.children("ul:first");this.lis=c("li:has(a[href])",this.list);this.anchors=this.lis.map(function(){return c("a",this)[0]});this.panels=c([]);var r=this,f=this.options;var e=/^#.+/;this.anchors.each(function(u,o){var s=c(o).attr("href");var v=s.split("#")[0],w;if(v&&(v===location.toString().split("#")[0]||(w=c("base")[0])&&v===w.href)){s=o.hash;o.href=s}if(e.test(s)){r.panels=r.panels.add(r._sanitizeSelector(s))}else{if(s!="#"){c.data(o,"href.tabs",s);c.data(o,"load.tabs",s.replace(/#.*$/,""));var y=r._tabId(o);o.href="#"+y;var x=c("#"+y);if(!x.length){x=c(f.panelTemplate).attr("id",y).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(r.panels[u-1]||r.list);x.data("destroy.tabs",true)}r.panels=r.panels.add(x)}else{f.disabled.push(u)}}});if(q){this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all");this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.lis.addClass("ui-state-default ui-corner-top");this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom");if(f.selected===undefined){if(location.hash){this.anchors.each(function(s,o){if(o.hash==location.hash){f.selected=s;return false}})}if(typeof f.selected!="number"&&f.cookie){f.selected=parseInt(r._cookie(),10)}if(typeof f.selected!="number"&&this.lis.filter(".ui-tabs-selected").length){f.selected=this.lis.index(this.lis.filter(".ui-tabs-selected"))}f.selected=f.selected||0}else{if(f.selected===null){f.selected=-1}}f.selected=((f.selected>=0&&this.anchors[f.selected])||f.selected<0)?f.selected:0;f.disabled=c.unique(f.disabled.concat(c.map(this.lis.filter(".ui-state-disabled"),function(s,o){return r.lis.index(s)}))).sort();if(c.inArray(f.selected,f.disabled)!=-1){f.disabled.splice(c.inArray(f.selected,f.disabled),1)}this.panels.addClass("ui-tabs-hide");this.lis.removeClass("ui-tabs-selected ui-state-active");if(f.selected>=0&&this.anchors.length){this.panels.eq(f.selected).removeClass("ui-tabs-hide");this.lis.eq(f.selected).addClass("ui-tabs-selected ui-state-active");r.element.queue("tabs",function(){r._trigger("show",null,r._ui(r.anchors[f.selected],r.panels[f.selected]))});this.load(f.selected)}c(window).bind("unload",function(){r.lis.add(r.anchors).unbind(".tabs");r.lis=r.anchors=r.panels=null})}else{f.selected=this.lis.index(this.lis.filter(".ui-tabs-selected"))}this.element[f.collapsible?"addClass":"removeClass"]("ui-tabs-collapsible");if(f.cookie){this._cookie(f.selected,f.cookie)}for(var j=0,p;(p=this.lis[j]);j++){c(p)[c.inArray(j,f.disabled)!=-1&&!c(p).hasClass("ui-tabs-selected")?"addClass":"removeClass"]("ui-state-disabled")}if(f.cache===false){this.anchors.removeData("cache.tabs")}this.lis.add(this.anchors).unbind(".tabs");if(f.event!="mouseover"){var h=function(o,i){if(i.is(":not(.ui-state-disabled)")){i.addClass("ui-state-"+o)}};var l=function(o,i){i.removeClass("ui-state-"+o)};this.lis.bind("mouseover.tabs",function(){h("hover",c(this))});this.lis.bind("mouseout.tabs",function(){l("hover",c(this))});this.anchors.bind("focus.tabs",function(){h("focus",c(this).closest("li"))});this.anchors.bind("blur.tabs",function(){l("focus",c(this).closest("li"))})}var d,k;if(f.fx){if(c.isArray(f.fx)){d=f.fx[0];k=f.fx[1]}else{d=k=f.fx}}function g(i,o){i.css({display:""});if(c.browser.msie&&o.opacity){i[0].style.removeAttribute("filter")}}var m=k?function(i,o){c(i).closest("li").removeClass("ui-state-default").addClass("ui-tabs-selected ui-state-active");o.hide().removeClass("ui-tabs-hide").animate(k,k.duration||"normal",function(){g(o,k);r._trigger("show",null,r._ui(i,o[0]))})}:function(i,o){c(i).closest("li").removeClass("ui-state-default").addClass("ui-tabs-selected ui-state-active");o.removeClass("ui-tabs-hide");r._trigger("show",null,r._ui(i,o[0]))};var n=d?function(o,i){i.animate(d,d.duration||"normal",function(){r.lis.removeClass("ui-tabs-selected ui-state-active").addClass("ui-state-default");i.addClass("ui-tabs-hide");g(i,d);r.element.dequeue("tabs")})}:function(o,i,s){r.lis.removeClass("ui-tabs-selected ui-state-active").addClass("ui-state-default");i.addClass("ui-tabs-hide");r.element.dequeue("tabs")};this.anchors.bind(f.event+".tabs",function(){var o=this,u=c(this).closest("li"),i=r.panels.filter(":not(.ui-tabs-hide)"),s=c(r._sanitizeSelector(this.hash));if((u.hasClass("ui-tabs-selected")&&!f.collapsible)||u.hasClass("ui-state-disabled")||u.hasClass("ui-state-processing")||r._trigger("select",null,r._ui(this,s[0]))===false){this.blur();return false}f.selected=r.anchors.index(this);r.abort();if(f.collapsible){if(u.hasClass("ui-tabs-selected")){f.selected=-1;if(f.cookie){r._cookie(f.selected,f.cookie)}r.element.queue("tabs",function(){n(o,i)}).dequeue("tabs");this.blur();return false}else{if(!i.length){if(f.cookie){r._cookie(f.selected,f.cookie)}r.element.queue("tabs",function(){m(o,s)});r.load(r.anchors.index(this));this.blur();return false}}}if(f.cookie){r._cookie(f.selected,f.cookie)}if(s.length){if(i.length){r.element.queue("tabs",function(){n(o,i)})}r.element.queue("tabs",function(){m(o,s)});r.load(r.anchors.index(this))}else{throw"jQuery UI Tabs: Mismatching fragment identifier."}if(c.browser.msie){this.blur()}});this.anchors.bind("click.tabs",function(){return false})},destroy:function(){var d=this.options;this.abort();this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs");this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.anchors.each(function(){var e=c.data(this,"href.tabs");if(e){this.href=e}var f=c(this).unbind(".tabs");c.each(["href","load","cache"],function(g,h){f.removeData(h+".tabs")})});this.lis.unbind(".tabs").add(this.panels).each(function(){if(c.data(this,"destroy.tabs")){c(this).remove()}else{c(this).removeClass(["ui-state-default","ui-corner-top","ui-tabs-selected","ui-state-active","ui-state-hover","ui-state-focus","ui-state-disabled","ui-tabs-panel","ui-widget-content","ui-corner-bottom","ui-tabs-hide"].join(" "))}});if(d.cookie){this._cookie(null,d.cookie)}},add:function(g,f,e){if(e===undefined){e=this.anchors.length}var d=this,i=this.options,k=c(i.tabTemplate.replace(/#\{href\}/g,g).replace(/#\{label\}/g,f)),j=!g.indexOf("#")?g.replace("#",""):this._tabId(c("a",k)[0]);k.addClass("ui-state-default ui-corner-top").data("destroy.tabs",true);var h=c("#"+j);if(!h.length){h=c(i.panelTemplate).attr("id",j).data("destroy.tabs",true)}h.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");if(e>=this.lis.length){k.appendTo(this.list);h.appendTo(this.list[0].parentNode)}else{k.insertBefore(this.lis[e]);h.insertBefore(this.panels[e])}i.disabled=c.map(i.disabled,function(m,l){return m>=e?++m:m});this._tabify();if(this.anchors.length==1){k.addClass("ui-tabs-selected ui-state-active");h.removeClass("ui-tabs-hide");this.element.queue("tabs",function(){d._trigger("show",null,d._ui(d.anchors[0],d.panels[0]))});this.load(0)}this._trigger("add",null,this._ui(this.anchors[e],this.panels[e]))},remove:function(d){var f=this.options,g=this.lis.eq(d).remove(),e=this.panels.eq(d).remove();if(g.hasClass("ui-tabs-selected")&&this.anchors.length>1){this.select(d+(d+1<this.anchors.length?1:-1))}f.disabled=c.map(c.grep(f.disabled,function(j,h){return j!=d}),function(j,h){return j>=d?--j:j});this._tabify();this._trigger("remove",null,this._ui(g.find("a")[0],e[0]))},enable:function(d){var e=this.options;if(c.inArray(d,e.disabled)==-1){return}this.lis.eq(d).removeClass("ui-state-disabled");e.disabled=c.grep(e.disabled,function(g,f){return g!=d});this._trigger("enable",null,this._ui(this.anchors[d],this.panels[d]))},disable:function(e){var d=this,f=this.options;if(e!=f.selected){this.lis.eq(e).addClass("ui-state-disabled");f.disabled.push(e);f.disabled.sort();this._trigger("disable",null,this._ui(this.anchors[e],this.panels[e]))}},select:function(d){if(typeof d=="string"){d=this.anchors.index(this.anchors.filter("[href$="+d+"]"))}else{if(d===null){d=-1}}if(d==-1&&this.options.collapsible){d=this.options.selected}this.anchors.eq(d).trigger(this.options.event+".tabs")},load:function(g){var e=this,i=this.options,d=this.anchors.eq(g)[0],f=c.data(d,"load.tabs");this.abort();if(!f||this.element.queue("tabs").length!==0&&c.data(d,"cache.tabs")){this.element.dequeue("tabs");return}this.lis.eq(g).addClass("ui-state-processing");if(i.spinner){var h=c("span",d);h.data("label.tabs",h.html()).html(i.spinner)}this.xhr=c.ajax(c.extend({},i.ajaxOptions,{url:f,success:function(k,j){c(e._sanitizeSelector(d.hash)).html(k);e._cleanup();if(i.cache){c.data(d,"cache.tabs",true)}e._trigger("load",null,e._ui(e.anchors[g],e.panels[g]));try{i.ajaxOptions.success(k,j)}catch(l){}e.element.dequeue("tabs")}}))},abort:function(){this.element.queue([]);this.panels.stop(false,true);if(this.xhr){this.xhr.abort();delete this.xhr}this._cleanup()},url:function(e,d){this.anchors.eq(e).removeData("cache.tabs").data("load.tabs",d)},length:function(){return this.anchors.length}});c.extend(c.ui.tabs,{version:"1.7.3",getter:"length",defaults:{ajaxOptions:null,cache:false,cookie:null,collapsible:false,disabled:[],event:"click",fx:null,idPrefix:"ui-tabs-",panelTemplate:"<div></div>",spinner:"<em>Loading&#8230;</em>",tabTemplate:'<li><a href="#{href}"><span>#{label}</span></a></li>'}});c.extend(c.ui.tabs.prototype,{rotation:null,rotate:function(f,h){var d=this,i=this.options;var e=d._rotate||(d._rotate=function(j){clearTimeout(d.rotation);d.rotation=setTimeout(function(){var k=i.selected;d.select(++k<d.anchors.length?k:0)},f);if(j){j.stopPropagation()}});var g=d._unrotate||(d._unrotate=!h?function(j){if(j.clientX){d.rotate(null)}}:function(j){t=i.selected;e()});if(f){this.element.bind("tabsshow",e);this.anchors.bind(i.event+".tabs",g);e()}else{clearTimeout(d.rotation);this.element.unbind("tabsshow",e);this.anchors.unbind(i.event+".tabs",g);delete this._rotate;delete this._unrotate}}})})(jQuery);;



/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);






/*
 *	jQuery carouFredSel 1.1.2
 *	www.frebsite.nl
 *	Copyright (c) 2009 Fred Heusschen
 *	Licensed under the MIT license.
 *	http://www.opensource.org/licenses/mit-license.php
 */


(function($) {
	$.fn.carouFredSel = function(options) {
		return this.each(function() {
			var opts 			= $.extend({}, $.fn.carouFredSel.defaults, options),
				$ul 			= $(this),
				$items 			= $("li", $ul),
				totalItems		= $items.length,
				lastItem		= opts.visibleItems,
				firstItem		= totalItems-1,
				itemWidth		= $items.outerWidth(),
				itemHeight		= $items.outerHeight(),
				autoInterval	= null,
				direction		= (opts.direction == "up" || opts.direction == "right") ? "next" : "prev";


			if (opts.direction == "right" ||
				opts.direction == "left"
			) {
				var css = {
					width	: itemWidth * opts.visibleItems,
					height	: $ul.outerHeight() || itemHeight
				}
			} else {
				var css = {
					height	: itemHeight * opts.visibleItems,
					width	: $ul.outerWidth() || itemWidth
				}
			}

			$ul.wrap('<div class="caroufredsel_wrapper" />').css({
				position	: "absolute"
			}).parent().css(css).css({
				position	: "relative",
				overflow	: "hidden"
			});

			if (opts.scrollItems 		== 0)	opts.scrollItems		= opts.visibleItems;
			if (opts.scrollItemsButtons == 0)	opts.scrollItemsButtons = opts.scrollItems;

			if (opts.visibleItems >= totalItems) return false;

			$items.filter(":gt("+(opts.visibleItems-1)+")").remove();
			$ul
				.bind("pause", function() {
					if (autoInterval != null) {
						clearTimeout(autoInterval);
					}
				})
				.bind("play", function(e, d) {
					if (opts.pauseDuration > 0) {
						if (d == null	||
							d == '' 	||
							typeof(d)	|| 'undefined'
						) {
							d = direction;
						}

						autoInterval = setTimeout(function() {
							$ul.trigger(d);
						}, opts.pauseDuration);
					}
				})
				.bind("next", function(e, b) {
					if ($ul.is(":animated")) return false;

					var numItems = (b) ? opts.scrollItemsButtons : opts.scrollItems;

					for (var a = 0; a < numItems; a++) {
						$ul.append($($items[lastItem]).clone());
						if (++lastItem  >= totalItems) lastItem  = 0;
						if (++firstItem >= totalItems) firstItem = 0;
					}
					if (opts.direction == "right" ||
						opts.direction == "left"
					) {
						var pos = 'left',
							mea = 'width',
							siz = itemWidth;
					} else {
						var pos = 'top',
							mea = 'height',
							siz = itemHeight;
					}
					var css = {},
						ani = {},
						cal = {};

					css[mea] = (siz * 0.1) + (siz * $("li", $ul).length);
					ani[pos] = -(siz * numItems);
					cal[pos] = 0;

					$ul.css(css)
						.animate(ani, {
							duration: opts.scrollSpeed,
							easing	: opts.scrollEffect,
							complete: function() {
								$ul.css(cal).find("li:lt("+numItems+")").remove();
							}
						}
					);

					//	auto-play
					$ul.trigger("pause").trigger("play", "next");
				})
				.bind("prev", function(e, b) {
					if ($ul.is(":animated")) return false;

					var numItems = (b) ? opts.scrollItemsButtons : opts.scrollItems;

					for (var a = 0; a < numItems; a++) {
						$ul.prepend($($items[firstItem]).clone());
						if (--firstItem < 0) firstItem = totalItems-1;
						if (--lastItem  < 0) lastItem  = totalItems-1;
					}
					if (opts.direction == "right" ||
						opts.direction == "left"
					) {
						var pos = 'left',
							mea = 'width',
							siz = itemWidth;
					} else {
						var pos = 'top',
							mea = 'height',
							siz = itemHeight;
					}

					var css = {},
						ani = {};

					css[pos] = -(siz * numItems);
					css[mea] = (siz * 0.1) + (siz * $("li", $ul).length);
					ani[pos] = 0;

					$ul.css(css)
						.animate(ani, {
							duration: opts.scrollSpeed,
							easing	: opts.scrollEffect,
							complete: function() {
								$ul.find("li:gt("+(opts.visibleItems-1)+")").remove();
							}
						}
					);

					//	auto-play
					$ul.trigger("pause").trigger("play", "prev");
				});

			if (opts.pauseOnHover) {
				$ul.hover(
					function() { $ul.trigger("pause"); },
					function() { $ul.trigger("play", direction); }
				);
			}

			//	via prev- en/of next-buttons
			if (opts.next != null || opts.prev != null) {
				if (opts.next != null) {
					opts.next.click(function() {
						$ul.trigger("next", true);
						return false;
					});
				}
				if (opts.prev != null) {
					opts.prev.click(function() {
						$ul.trigger("prev", true);
						return false;
					});
				}

			//	alleen via auto-play
			} else {
				if (opts.pauseDuration == 0) opts.pauseDuration = 2500;
			}

			//	via auto-play
			$ul.trigger("play", direction);
		});
	}
	$.fn.carouFredSel.defaults = {
		visibleItems		: 4,
		scrollItems			: 0,
		scrollItemsButtons	: 0,
		scrollEffect		: 'swing',
		scrollSpeed			: 500,
		next				: null,
		prev				: null,
		direction			: "right",
		pauseDuration		: 0,
		pauseOnHover		: false
	}
})(jQuery);






/***********************************************************************
 *
 * fixed header
 *
 **********************************************************************/

var bFixed = false;
function createFixedHeader () {
	$(window).scroll(function() {

		if ($(window).scrollTop() >= 120) {
			$('#header').addClass('header_fixed');
			$('#sub_menue').addClass('header_fixed');
			bFixed = true;
		}
		else {
			$('#header').removeClass('header_fixed');
			$('#sub_menue').removeClass('header_fixed');
			bFixed = false;
		}
	})
	.trigger('scroll');
}






/***********************************************************************
 *
 * MAW-Menü
 *
 **********************************************************************/
var aMainMenu		= [];
var iActiveItem		= -1;
var iLastActiveItem	= -1;
var iMouseOutCnt	= 0;
var iMouseX = 0;
var iMouseY = 0;
var bSubOpen = false;
function getMainMenuStructure() {
	var iMenuId = 0;
	var bAnyActiveItem = false;
	$('li.main-menu').each(function() {
		var me 		= $(this);
		var myAnker = me.find('a');
		var myPic	= me.find('img');
		// store date in array
		aMainMenu[iMenuId] = {
			sName:		myPic.attr('alt')
			,sUrl:		myAnker.attr('href')
			,bActive:	me.hasClass('active')
			,oElement:	me
			,oPic:		myPic
		};

		// determine if there is any active item
		bAnyActiveItem |= aMainMenu[iMenuId].bActive;
		if(aMainMenu[iMenuId].bActive) {
			iActiveItem = iMenuId;
		}
		// setup events
		me.bind('mouseover',	{iId:iMenuId}, handleMainOver)
			.bind('click',		{iId:iMenuId}, handleMainClick);
		iMenuId++;
	});

	// if none is active, it should be home!
	if(!bAnyActiveItem) {
		aMainMenu[0].bActive = true;
		aMainMenu[0].oElement.trigger('mouseover');
		iActiveItem = 0;
	}
	getSubmenuStructure();
}




function getSubmenuStructure() {
	var iMenuId = 0;
	$('ul.submenu').each(function() {
		var me 		= $(this);
		// store date in array
		aMainMenu[iMenuId].oSubMenu = me;
		aMainMenu[iMenuId].iSubItems = me.find('li').length;
		iMenuId++;
		me.css('display','none');
	});
}




function createMawMenu() {
	getMainMenuStructure();

	// do some inits
	$(document).mousemove( function(e) {
	   iMouseX = e.pageX;
	   iMouseY = e.pageY;
	 });
	window.setInterval(handleMousePosition,500);
	window.setTimeout(function(){
		var aOffset	= aMainMenu[iActiveItem].oElement.offset();
		var iWidth	= aMainMenu[iActiveItem].oElement.width();
		var iDestX	= aOffset.left + iWidth / 2 - 19;
		$('#sun').css('left', iDestX+'px').fadeIn('slow');
		log('sonne scheint!');
	} ,500);
	$('#sub_menue').css('opacity', 0.85);
	$(window).resize(function(){
		moveSun(iLastActiveItem);
	});
}


function handleMainOver(o) {
	iMouseOutCnt = 0;
	var iId = o.data.iId;

	// supress double hover's
	if(iId == iLastActiveItem && bSubOpen) {
		return;
	}
	iLastActiveItem = iId;


	for(var i in aMainMenu) {
		aMainMenu[i].oPic.attr('src','/media/template/global_v2/header/' + (i==iId?'':'in') +'active/' + aMainMenu[i].sName.toLowerCase() + '.png');
	}
	moveSun(iId);



	// create submenu


	// make empty menus show fast:
	if(aMainMenu[iId].iSubItems==1) { // there is allways an empty element for w3c compience
		$('#sub_menue').clearQueue().stop().animate({height: 1}, 400, 'swing');
		$('#submenu_items').clearQueue().stop().fadeOut(200);
	}
	
	// change content animated
	else {
		$('#submenu_items').clearQueue().stop().fadeOut(200,function(){
			for(var i in aMainMenu) {
				aMainMenu[i].oSubMenu.css('display',(i==iId?'block':'none'));
			}
			var h = $(this).height();
			$('#sub_menue').clearQueue().stop().animate({height: h+30}, 400, 'swing');
			$(this).fadeIn(300, function(){
				$(this).css('opacity',1);
			})
		});
	}

	// show submenue
	fadeinSubmenu();
}

function handleMainClick(o) {
	var iId = o.data.iId;
	if(aMainMenu[iId].sUrl) {
		document.location.href = aMainMenu[iId].sUrl;
	}
}

function resetMenu() {
	for(var i in aMainMenu) {
		aMainMenu[i].oPic.attr('src','/media/template/global_v2/header/' + (aMainMenu[i].bActive?'':'in') +'active/' + aMainMenu[i].sName.toLowerCase() + '.png');
	}
	moveSun(iActiveItem);
	fadeoutSubmenu();
}

function handleMousePosition(o) {

	// consider fixed menu
	var iMyMouseY = iMouseY;
	if(bFixed) {
		iMyMouseY = iMouseY - $(window).scrollTop() + 115;
	}

	// consider actual menu height
	var iMenuHeight = $('#sub_menue').height();

	// if mouse out of menu than count time
	if(iMyMouseY > (175 + iMenuHeight) || iMyMouseY < 100) {
		iMouseOutCnt += 500;
	}

	// if mouse over menu than reset time
	if(iMyMouseY < (140 + iMenuHeight) && iMyMouseY > 125) {
		iMouseOutCnt = 0;
	}

	// if time counter over 1 sec than reset menu
	if(iMouseOutCnt >= 1000 || iMyMouseY > (200 + iMenuHeight)) {
		resetMenu();
		iMouseOutCnt = 0;
	}
}

function moveSun(iPos) {
	var aOffset	= aMainMenu[iPos].oPic.offset();
	var iWidth	= aMainMenu[iPos].oPic.width();
	var iDestX	= aOffset.left + iWidth / 2 - 19;
	$('#sun').css('opacity','1').clearQueue().stop().animate({left:	iDestX}, 900, 'swing');
}

function fadeoutSubmenu() {
	iLastActiveItem	= iActiveItem;
	$('#sub_menue').animate({height:0}, 600, 'swing');
	$('#submenu_items').fadeOut(400);
}

function fadeinSubmenu() {
}







/***********************************************************************
 *
 * MAW-Flights
 *
 **********************************************************************/

function setupFlightRotation() {

	// define routation
	$('#flights').carouFredSel({
		visibleItems		: 5,
		scrollItems			: 1,
		scrollItemsButtons	: 5,
		scrollEffect		: 'swing',
		scrollSpeed			: 500,
		direction			: 'right',
		next				: $('#flightbox_right'),
		prev				: $('#flightbox_left'),
		pauseDuration		: 2500,
		pauseOnHover		: true
	});

	// define click action
	$('#flights li').live('click', function(){
		document.location.href= '/german/angebote/flugangebote.html';
	});
}




/***********************************************************************
 *
 * IBE-Box
 *
 **********************************************************************/

var iIbeboxMouseOutside	= 0;
var iIbeboxActiveTab	= 0;

function setupIbebox() {
	for(var iCnt = 1; iCnt < 5; iCnt ++) {
		$('#ibebox_reiter_'+iCnt).bind('mouseover', {iId:iCnt}, function(o){
			iIbeboxActiveTab = o.data.iId;
			for(var i = 1; i < 5; i ++)
			{
				if(o.data.iId == i) {
					$('#ibebox_reiter_'+i).addClass('ibr_active');
					$('#ibebox_content_'+i).addClass('ibc_active');
				}
				else {
					$('#ibebox_reiter_'+i).removeClass('ibr_active');
					$('#ibebox_content_'+i).removeClass('ibc_active');
				}
			}
		});
	}
	$('#ibebox_reiter_1').trigger('mouseover');

}




/***********************************************************************
 *
 * Hotelsuche
 *
 **********************************************************************/

var cBadjieHotelsearch = {
	iLastKBHit:		999,
	sSearchstring:	'',

	init: function() {

		// set input attributes
		$('#search-input')
			.attr('autocomplete','off')
			.bind('keydown',	cBadjieHotelsearch.onKeyDown)
			.bind('focus',		cBadjieHotelsearch.onFocus)
			.bind('blur',		cBadjieHotelsearch.onBlur);
		// set trigger to check every 100ms
		window.setInterval(cBadjieHotelsearch.triggerAction, 100);
	},

	triggerAction: function(){
		// if last kbhit is more than 300ms ago AND the content has changed => request new searchresults
		if(cBadjieHotelsearch.iLastKBHit==400) {
			// fire ajax request to get data
			cBadjieHotelsearch.getBestResults();
		}
		cBadjieHotelsearch.iLastKBHit+=100;
	},

	onKeyDown: function() {
		// reset time since last keydown
		cBadjieHotelsearch.iLastKBHit=0;
	},

	onFocus: function() {log('focus');
		// show searchresult div
		if($('#search-input').val() == 'Suche') {
			$('#search-input').val('');
		}
		cBadjieHotelsearch.getBestResults();
	},

	onBlur: function() {log('bluer');
		// hide searchresult div
		if($('#search-input').val() == '') {
			$('#search-input').val('Suche');
		}
		window.setTimeout("$('#searchresult').fadeOut('fast')", 100);
		window.setTimeout("$('#searchresult').css('display','none')", 500);
	},

	getBestResults: function() {
		// request server via ajax
		cBadjieHotelsearch.sSearchstring = $('#search-input').val();
		if(typeof cBadjieHotelsearch.sSearchstring == 'string' && cBadjieHotelsearch.sSearchstring.length >= 3) {
			$('#searchresult')
				.html('Lade Suchergebnis ...')
				.fadeIn('fast');
			$.getJSON('/ajax/cBadjieHotelSearch/ajaxGetBestHits', {sSearchstring: cBadjieHotelsearch.sSearchstring}, cBadjieHotelsearch.getBestResultsRecall);
		}
		else {
			$('#searchresult').fadeOut('fast');
		}
	},

	getBestResultsRecall: function(o) {
		// set innerHTML of div id=searchresult
		//if(cBadjieHotelsearch.sSearchstring != o.argument) return;
		var oData = o.mData;
		var sHtml ="";
		if(oData.hotels.count>0) {
			sHtml += "<strong><a href='/german/suche.html?sSearchstring="+encodeURIComponent(cBadjieHotelsearch.sSearchstring)+"&sArea=hotels'>"+oData.hotels.count + " Hotels gefunden (anzeigen...)</a></strong>";
			for(i in oData.hotels.results) {
				sHtml += "&nbsp;&nbsp;<a href='"+oData.hotels.results[i].url+"'>"+oData.hotels.results[i].title+"</a>";
			}
		}
		if(oData.rundreisen.count>0) {
			sHtml += "<strong><a href='/german/suche.html?sSearchstring="+encodeURIComponent(cBadjieHotelsearch.sSearchstring)+"&sArea=rundreisen'>"+oData.rundreisen.count + " Rundreisen gefunden (anzeigen...)</a></strong>";
			for(i in oData.rundreisen.results) {
				sHtml += "&nbsp;&nbsp;<a href='"+oData.rundreisen.results[i].url+"'>"+oData.rundreisen.results[i].title+"</a>";
			}
		}
		if(oData.exkursionen.count>0) {
			sHtml += "<strong><a href='/german/suche.html?sSearchstring="+encodeURIComponent(cBadjieHotelsearch.sSearchstring)+"&sArea=exkursionen'>"+oData.exkursionen.count + " Exkursionen gefunden (anzeigen...)</a></strong>";
			for(i in oData.exkursionen.results) {
				sHtml += "&nbsp;&nbsp;<a href='"+oData.exkursionen.results[i].url+"'>"+oData.exkursionen.results[i].title+"</a>";
			}
		}
/*
		if(oData.landundleute.count>0) {
			sHtml += "<strong><a href='/german/suche.html?sSearchstring="+encodeURIComponent(cBadjieHotelsearch.sSearchstring)+"&sArea=landundleute'>"+oData.landundleute.count + " Land &amp; Leute-Seiten gefunden (anzeigen...)</a></strong>";
			for(i in oData.landundleute.results) {
				sHtml += "&nbsp;&nbsp;<a href='"+oData.landundleute.results[i].url+"'>"+oData.landundleute.results[i].title+"</a>";
			}
		}
		 */
		if(sHtml == '') {
			_('searchresult').style.display='none';
		}
		else {
			_('searchresult').style.display='block';
			sHtml += "<strong><a href='/german/suche.html?sSearchstring="+encodeURIComponent(cBadjieHotelsearch.sSearchstring)+"&sArea='>Alle Ergebnisse anzeigen...</a></strong>";
		}
		$('#searchresult').html(sHtml);
	}
}



/***********************************************************************
 *
 * Specials-Teaser / Offerbox
 *
 **********************************************************************/
var iOfferboxMouseOutside	= 0;
var iOfferboxActiveTab		= 0;

var cSpecialsTeaser = {
	sHref:	''
	,init:	function() {
		var sHtml = "<div id='special_teasers'><div id='special_teasers_inner'>";
		var iCnt = 1;
		$('#special_offers li').each(function(){
			var me = $(this);
			var sTeaser = me.find('.teaser').html();
			var sInfo = me.find('.info').html();
			sHtml +=
				  '<div class="teaser" id="teaser_' + iCnt+ '">'
					+ '<div class="pic">' + sTeaser + '</div>'
					+ '<div class="info">' + sInfo + '</div>'
				+ '</div>'
			me.find('.teaser').remove();
			me.find('.info').remove();
			me.bind('mouseover', {iCnt: (iCnt-1)}, function(o) {
				iOfferboxActiveTab = o.data.iCnt;
				$('#special_teasers_inner').clearQueue().stop().animate({top: (o.data.iCnt*-270)+'px'}, 200, 'swing');
				$('#offer_slider').clearQueue().stop().animate({top: (13+o.data.iCnt*55)+'px'}, 200, 'swing');
				var oLink = $('#offerbox_offer' + ( o.data.iCnt+1 ) + ' a');
				$('#offer_slider_text').html(oLink.html());
				cSpecialsTeaser.sHref = oLink.attr('href');
			});
			iCnt ++;
		});
		sHtml += "</div></div>";
		$('#offerbox').prepend(sHtml);

		$('#offer_slider_text').html($('#offerbox_offer1 a').html());
		$('#offer_slider, div.info').click(function() {
			if(typeof cSpecialsTeaser.sHref == 'string' && cSpecialsTeaser.sHref != '') {
				document.location.href = cSpecialsTeaser.sHref;
			}
		});

		// automate rotation when mouse is outside
		// sets up the interval
		//checks 6 times outside before action
		window.setInterval(function() {
			if(cSpecialsTeaser.mouseOutsideOfferbox()) {
				iOfferboxMouseOutside++;
				if(iOfferboxMouseOutside % 10 == 0) {
					cSpecialsTeaser.rotateOfferBox()
				}
			}
			else {
				iOfferboxMouseOutside = 0;
			}
		}, 500);
	}


	// checks if mouse is outside
	,mouseOutsideOfferbox:	function () {
		var aOffset = $('#offerbox').offset()
		var iOffsetX = iMouseX - aOffset.left;
		var iOffsetY = iMouseY - aOffset.top;
		if(iOffsetX > 0	&& iOffsetX < $('#offerbox').width()
		&& iOffsetY > 0	&& iOffsetY < $('#offerbox').height()) {
			return false;
		}
		else {
			return true;
		}
	}

	// triggers the rotate action
	,rotateOfferBox:	function () {
		$('#offerbox_offer'+((iOfferboxActiveTab+1)%5+1)).trigger('mouseover');
	}

}




/***********************************************************************
 *
 * Catalog-Box
 *
 **********************************************************************/

function setupCatalogbox() {
	$('#katalogbox_index_item_1, #katalogbox_hover_1')
		.hover(
			function(){
				$('#katalogbox_index_item_1').css('background-position','-40px 0');
				$('#katalogbox_content_over').css('background-position','0 -190px');
			}
			,function(){
				$('#katalogbox_index_item_1').css('background-position','0 0');
				$('#katalogbox_content_over').css('background-position','0 0');
			})
		.click(
			function(){
				var oNewWindow = window.open("http://ehg4.giata-web.de/index.php?uid=176999&com=ks&width=954&height=706&frame=2&xl=1&Vea=640&cid=8266", '_blank');
				oNewWindow.focus();
			}
		);
	$('#katalogbox_index_item_2, #katalogbox_hover_2')
		.hover(
			function(){
				$('#katalogbox_index_item_2').css('background-position','-40px -71px');
				$('#katalogbox_content_over').css('background-position','0 -370px');
			}
			,function(){
				$('#katalogbox_index_item_2').css('background-position','0 -71px');
				$('#katalogbox_content_over').css('background-position','0 0');
			})
		.click(
			function(){
				var oNewWindow = window.open("http://ehg4.giata-web.de/index.php?uid=176999&com=ks&width=954&height=706&frame=2&xl=1&Vea=640&cid=8757", '_blank');
				oNewWindow.focus();
			}
		);
	$('#katalogbox_index_item_3, #katalogbox_hover_3')
		.hover(
			function(){
				$('#katalogbox_index_item_3').css('background-position','-40px -140px');
				$('#katalogbox_content_over').css('background-position','0 -560px');
			}
			,function(){
				$('#katalogbox_index_item_3').css('background-position','0 -140px');
				$('#katalogbox_content_over').css('background-position','0 0');
			})
		.click(
			function(){
				var oNewWindow = window.open("http://ehg4.giata-web.de/index.php?uid=176999&com=ks&width=954&height=706&frame=2&xl=1&Vea=640&cid=8265", '_blank');
				oNewWindow.focus();
			}
		);
}




/***********************************************************************
 *
 * Info-Box
 *
 **********************************************************************/

var iInfoboxMouseOutside	= 0;
var iInfoboxActiveTab		= 0;

function setupInfobox() {
	for(var iCnt = 1; iCnt < 5; iCnt ++) {
		$('#infobox_reiter_'+iCnt).bind('mouseover', {iId:iCnt}, function(o){
			iInfoboxActiveTab = o.data.iId;
			for(var i = 1; i < 5; i ++)
			{
				if(o.data.iId == i) {
					$('#infobox_reiter_'+i).addClass('ibr_active');
					$('#infobox_content_'+i).addClass('ibc_active');
				}
				else {
					$('#infobox_reiter_'+i).removeClass('ibr_active');
					$('#infobox_content_'+i).removeClass('ibc_active');
				}
			}
		});
	}
	$('#infobox_reiter_1').trigger('mouseover');

	// automate rotation when mouse is outside

	// checks if mouse is outside
	function mouseOutsideInfobox() {
		var aOffset = $('#infobox').offset()
		var iOffsetX = iMouseX - aOffset.left;
		var iOffsetY = iMouseY - aOffset.top;
		if(iOffsetX > 0	&& iOffsetX < $('#infobox').width()
		&& iOffsetY > 0	&& iOffsetY < $('#infobox').height()) {
			return false;
		}
		else {
			return true;
		}
	}

	// triggers the rotate action
	function rotateInfoBox() {
		$('#infobox_reiter_'+(iInfoboxActiveTab%4+1)).trigger('mouseover');
	}

	// sets up the interval
	//checks 3 times outside before action
	window.setInterval(function() {
		if(mouseOutsideInfobox()) {
			iInfoboxMouseOutside++;
			if(iInfoboxMouseOutside % 5 == 0) {
				rotateInfoBox()
			}
		}
		else {
			iInfoboxMouseOutside = 0;
		}
	}, 500);

}



/***********************************************************************
 *
 * Website init
 *
 **********************************************************************/

function setupPage(){
	$('#servicetelefon').click(function(){
		document.location.href= '/german/kontakt.html';
	});
}

/***********************************************************************
 *
 * standard js
 *
 **********************************************************************/

/* ------------------------
   common known variables
   (like constants)
   ------------------------ */

var sAjaxLoaderSrc = '/totoya/cache/core/clib/admin/framework/skin/default/media/ajaxloader.gif';
var sAjaxLoaderImg = '<img src="'+sAjaxLoaderSrc+'">';

/* ------------------------
    standard functions lib
   ------------------------ */

function log(o) {
	if(typeof console == "object"){
		if(typeof console.log == "function") {
			top.console.log(o);
		}
	}
}

function _(id) {return document.getElementById(id)};

// AJAX HANDLING
function convert2PostData(obj, aOuterElements) {
	var ret="";
	var seperator="";
	for(var i in obj) {
		if(typeof obj[i] == "function") {
			continue;
		}
		if(typeof obj[i] == "object" || typeof obj[i] == "array" ) {
			if(typeof aOuterElements != "array" && typeof aOuterElements != "object") {
				aOuterElements = new Array();
			}
			aOuterElements.push(i);
			ret += convert2PostData(obj[i], aOuterElements);
			aOuterElements.pop();
		} else {
			if(typeof aOuterElements == "array" || typeof aOuterElements == "object") {
				seperator="&";
				ret += seperator;
				for(var k in aOuterElements) {
					 if(k==0) {
						ret += aOuterElements[0];
					 }
					 else {
					 	ret += "["+aOuterElements[k]+"]";
					 }
				}
				ret += "["+i+"]";
			}
			else {
				ret += seperator;
				ret += i;
			}
			ret += '=' + encodeURIComponent(obj[i]);
			seperator="&";
		}
	}
	delete aOuterElements;
	return ret;
}



// CALLBACK HANDLING
function executeCallback(oCallbackObject, mAdditionalParam) {
	var ret;
	// no callback -> nothing to do!
	if(oCallbackObject == null) {
		return false;
	}

	// initialize CB Temp Store
	if(typeof oCallbackObject == "object") {
		var oTempStore = {
			"fFunction"	: oCallbackObject.fFunction,
			"oScope"	: oCallbackObject.oScope,
			"mParam"	: oCallbackObject.mParam
		};
		delete oCallbackObject;
		oCallbackObject = null;
	}
	else {
		var oTempStore = {
			"fFunction"	: oCallbackObject,
			"oScope"	: null,
			"mParam"	: {}
		};

	}

	// add additional param
	if(mAdditionalParam != null) {
		$.extend(oTempStore.mParam, mAdditionalParam);
	}

	// if there is a valid function -> execute callback!
	if(typeof oTempStore.fFunction == "function") {
		if(oTempStore.oScope) {
			ret = oTempStore.fFunction.apply(oTempStore.oScope, [oTempStore.mParam]);
		}
		else {
			ret = oTempStore.fFunction(oTempStore.mParam);
		}
	}
	return ret;
}


function cloneObject(oObj) {
	Object.prototype.clone = function() {
		var tmp = this.constructor();
		for(var i in this)  {
			if(typeof this[i] == "object" && this[i] != null) {
				tmp[i] = this[i].clone();
			}
			else {
		 		tmp[i] = this[i];
		 	}
		}
		return tmp;
	};
	var tmp = oObj.clone();
	delete Object.prototype.clone;
	return tmp;
}


function getInEuros(fPrice) {
	var aPrice = fPrice.toString().split('.');
	var sPrice = ',' + parseInt(parseFloat('0.'+aPrice[1])*100).toString();
	var sHundreds = (parseInt(aPrice[0])%1000).toString();
	var sThousends = parseInt(parseInt(aPrice[0])/1000).toString();
	return (sThousends=='0'?'':sThousends + '.') + sHundreds + sPrice;
}

/***********************************************************************
 * ENDE standard.js
 **********************************************************************/


/***********************************************************************
 *
 * Website init
 *
 **********************************************************************/

$(document).ready(function() {
	createFixedHeader();
	createMawMenu();
	setupFlightRotation();
	setupIbebox();
	cBadjieHotelsearch.init();
	cSpecialsTeaser.init();
	setupCatalogbox();
	setupInfobox();
	setupPage();
});


/* ---------- template-global_v3-waiting ---------- */

var oWaitingScreen = {};
(function(){
	
	var oSelf			= oWaitingScreen;

	$.extend(oWaitingScreen, {


		/**
		 * init
		 */
		init: function() {

		}
		
		
		/**
		 * configure
		 */
		,configure: function() {
		
			$('#waiting_sreen_overlay').css({
				'top':		'0px'
				,'left':	'0px'
				,'height':	$(document).height() + 'px'
				,'width':	$(document).width() + 'px'
			});
			
			$('#waiting_screen_doc').css({
				'top':		($(document).scrollTop() + 50) + 'px'
				,'left':	(($(window).width() - $('#waiting_screen_doc').width()) / 2) + 'px'
			});
		}
		
		
		/**
		 * show waiting screen
		 */
		,open: function() {
			
			oSelf.configure();
			$('#waiting_sreen_overlay').show();
			$('#waiting_screen_doc').show();
		}
		
		
		/**
		 * hide waiting screen
		 */
		,close: function() {
		
			$('#waiting_sreen_overlay').hide();
			$('#waiting_screen_doc').hide();
		}
		
	});
	
})(oWaitingScreen);



$(document).ready(function() {
	oWaitingScreen.init();	
});

