var detail_pics = 1;
var act_pic = 0;
function set_detail_pics(anzahl) {
 detail_pics = anzahl;
 for(i=1; i<=anzahl;i++) {
 $('link_Pic' + i).className = "";
 $('Pic' + i).style.display = "none";
 }
 $('link_Pic1').className = "PicAktiv";
 $('Pic1').style.display = "block";
 act_pic = 1;
}
function switch_pic(id) {
 if(id != act_pic) {
 var queue = Effect.Queue;
 queue.each(function(e) { e.cancel() });
 for(i=1; i<=detail_pics;i++) {
 $('link_Pic' + i).className = "";
 $('Pic' + i).style.display = "none";
 }
 $('link_Pic' + id).className = "PicAktiv";
 $('Pic' + id).style.display = 'block';
 //new Effect.toggle('Pic' + id, 'appear', {duration:0.2});
 act_pic = id;
 }
}


/**************************************************************************************************************
*	Extended Date-Picker
*	last modified: 2008-06-25 (hk)
*
*************************************************************************************************************/
var DatePickerExtended = Class.create(DatePicker, {
													_departure_date_list: new Hash(),
													_use_date_list: false,
													_use_date_range: false,
													_min_date: new String(),
													_max_date: new String(),
													_min_date_obj: new Date(),
													_max_date_obj: new Date(),
													
													initialize: function ( $super, h_p ) { 
																	$super(h_p); 
																	if (!Object.isUndefined(h_p["departure_date_list"])) {
																		this._departure_date_list	= h_p["departure_date_list"];
																	}
																	if (!Object.isUndefined(h_p["use_date_list"])) {
																		this._use_date_list	= h_p["use_date_list"];
																	}
																	if (!Object.isUndefined(h_p["use_date_range"])) {
																		this._use_date_range	= h_p["use_date_range"];
																	}
																	if (!Object.isUndefined(h_p["min_date"])) {
																		this._min_date	= h_p["min_date"];
																	}
																	if (!Object.isUndefined(h_p["max_date"])) {
																		this._max_date	= h_p["max_date"];
																	}
																

													}
 } );
																		
													//
									DatePickerExtended.addMethods({
										_buildCalendar		: function () {
													if(this._use_date_range == true) {
														var min_date_f = this._df.match(this._min_date);
														this._min_date_obj = new Date(min_date_f[0], (min_date_f[1]-1), min_date_f[2]);
														var max_date_f = this._df.match(this._max_date);
														this._max_date_obj = new Date(max_date_f[0], (max_date_f[1]-1), max_date_f[2], 23, 59, 59);
													}
																	
													  var _self	= this;
													  var tbody	= $(this._id_datepicker+'-tbody');
													  try {
													   while ( tbody.hasChildNodes() )
													    tbody.removeChild(tbody.childNodes[0]);
													  } catch ( e ) {};
													  /* generate day headers */
													  var trDay	= new Element('tr');
													  this._language_day.get(this._language).each( function ( item ) {
													   var td	= new Element('td');
													   td.innerHTML	= item;
													   td.className	= 'wday';
													   trDay.appendChild( td );
													  });
													  tbody.appendChild( trDay );
													  /* generate the content of days */
													  
													  /* build-up days matrix */
													  var a_d	= [ [ 0, 0, 0, 0, 0, 0, 0 ] ,[ 0, 0, 0, 0, 0, 0, 0 ]
													   ,[ 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0 ]
													   ,[ 0, 0, 0, 0, 0, 0, 0 ]
													  ];
													  /* set date at beginning of month to display */
													  var d		= new Date(this._current_year, this._current_mon, 1, 12);
													  /* start the day list on monday */
													  var startIndex	= ( !d.getDay() ) ? 6 : d.getDay() - 1;
													  var nbDaysInMonth	= this._getMonthDays(
													    this._current_year, this._current_mon);
													  var daysIndex		= 1;
													  for ( var j = startIndex; j < 7; j++ ) {
													   a_d[0][j]	= { 
													     d : daysIndex
													    ,m : this._current_mon
													    ,y : this._current_year 
													   };
													   daysIndex++;
													  }
													  var a_prevMY	= this._prevMonthYear();
													  var nbDaysInMonthPrev	= this._getMonthDays(a_prevMY[1], a_prevMY[0]);
													  for ( var j = 0; j < startIndex; j++ ) {
													   a_d[0][j]	= { 
													     d : Number(nbDaysInMonthPrev - startIndex + j + 1) 
													    ,m : Number(a_prevMY[0])
													    ,y : a_prevMY[1]
													    ,c : 'outbound'
													   };
													  }
													  var switchNextMonth	= false;
													  var currentMonth	= this._current_mon;
													  var currentYear	= this._current_year;
													  for ( var i = 1; i < 6; i++ ) {
													   for ( var j = 0; j < 7; j++ ) {
													    a_d[i][j]	= { 
													      d : daysIndex
													     ,m : currentMonth
													     ,y : currentYear
													     ,c : ( switchNextMonth ) ? 'outbound' : ( 
													      ((daysIndex == this._todayDate.getDate()) &&
													        (this._current_mon  == this._todayDate.getMonth()) &&
													        (this._current_year == this._todayDate.getFullYear())) ? 'today' : null)
													    };
													    daysIndex++;
													    /* if at the end of the month : reset counter */
													    if (daysIndex > nbDaysInMonth ) {
													     daysIndex	= 1;
													     switchNextMonth = true;
													     if (this._current_mon + 1 > 11 ) {
													      currentMonth = 0;
													      currentYear += 1;
													     } else {
													      currentMonth += 1;
													     }
													    }
													   }
													  }
													  /* generate days for current date */
													  for ( var i = 0; i < 6; i++ ) {
													   var tr	= new Element('tr');
													   for ( var j = 0; j < 7; j++ ) {
													    var h_ij	= a_d[i][j];
													    var td	= new Element('td');
													    /* id is : datepicker-day-mon-year or depending on language other way */
													    /* don't forget to add 1 on month for proper formmatting */
													    var id	= $A([
													     this._relative,
													     this._df.date_to_string(h_ij["y"], h_ij["m"]+1, h_ij["d"], '-')
													    ]).join('-');
													    /* set id and classname for cell if exists */
													    td.setAttribute('id', id);
													    if (h_ij["c"])
													     td.className	= h_ij["c"];
													    /* on onclick : rebuild date value from id of current cell */
													    var _curDate	= new Date();
													    _curDate.setFullYear(h_ij["y"], h_ij["m"], h_ij["d"]);
													     
														 var tempMonth = h_ij["m"] + 1;
														 var tempDateKey = ((h_ij["d"] < 10) ? "0"+h_ij["d"]:h_ij["d"])+"."+((tempMonth < 10) ? "0"+tempMonth:tempMonth)+"."+h_ij["y"];
														 if(this._use_date_list == true) {
															if(this._departure_date_list[tempDateKey]) {	 
																this._bindCellOnClick( td, false );
															 } else {
																this._bindCellOnClick( td, true );
															 }
														 } else if(this._use_date_range == true) {
															var _res = (( _curDate >= this._min_date_obj )&&( _curDate <= (this._max_date_obj) )) ? true : false;
															if ( this._disablePastDate ) {
															  var _res	= ( _curDate >= this._todayDate ) ? true : false;
															 }
															if ( this._disableFutureDate ) {
															  var _res	= ( this._todayDate.getTime() + this._oneDayInMs > _curDate.getTime() ) ? true : false;
															 }	
													        this._bindCellOnClick( td, true, _res, h_ij["c"] );
														 } else if ( this._disablePastDate || this._disableFutureDate ) {
															 if ( this._disablePastDate ) {
															  var _res	= ( _curDate >= this._todayDate ) ? true : false;
															  this._bindCellOnClick( td, true, _res, h_ij["c"] );
															 }
															 if ( this._disableFutureDate ) {
															  var _res	= ( this._todayDate.getTime() + this._oneDayInMs > _curDate.getTime() ) ? true : false;
															  this._bindCellOnClick( td, true, _res,  h_ij["c"] );
															 }	 
															 
														 } else {
																this._bindCellOnClick( td, false );
														 }
													    td.innerHTML= h_ij["d"];
													    tr.appendChild( td );
													   }
													   tbody.appendChild( tr );
													  }
													  return	tbody;
													 },
	setDepartureDateListData: function(departure_date_list_data) {
		this._departure_date_list = new Hash();
		this._departure_date_list = departure_date_list_data;
	}
													 //
												  } );
	//


