/* ---

teycom technology GmbH
Brüderstr. 14
20355 HAmburg

JavaScript Bibliothek

--- */

var WWGR = {
  Browser: {
    IE:     !!(window.attachEvent && !window.opera),
    Opera:  !!window.opera,
    WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
    Gecko:  navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1
  },
  BrowserFeatures: {
    XPath: !!document.evaluate,
    ElementExtensions: !!window.HTMLElement,
    SpecificElementExtensions:
      (document.createElement('div').__proto__ !==
       document.createElement('form').__proto__)
  }
}
WWGR.Browser.IE6=WWGR.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5))==6;
WWGR.Browser.IE7=WWGR.Browser.IE && !WWGR.Browser.IE6;

function display_detail(DIVID) {
	new Effect.toggle('detail_' + DIVID, 'appear', {duration:0.3});
}


function zahlungsarten_alle_formulare_ausblenden() {
	$('kreditkarte').style.display = 'none';
}

function zahlungsart_einblenden(FELD) {
	zahlungsarten_alle_formulare_ausblenden();
	if($(FELD)) $(FELD).style.display = '';
}


function ein_ausblenden() {
	args=ein_ausblenden.arguments;
	
	ein_aus = args[0];
	
	for(k=1;k<args.length;k++) {
		feld = args[k];
		if(ein_aus == 0) {
			$(feld).style.display = 'none';
		} else {
			$(feld).style.display = '';
		}
	}
}

function block_ein_ausblenden() {
	args=block_ein_ausblenden.arguments;
	ein_aus = args[0];
	for(k=1;k<args.length;k++) {
		feld = args[k];
		if(ein_aus == 0) {
			$(feld).style.display = 'none';
		} else {
			$(feld).style.display = 'block';
		}
	}
}

var actSearch;
function suche_alle_ausblenden() {
	$('pauschalreise').style.display = 'none';
	$('eigeneanreise').style.display = 'none';
	$('hotel').style.display = 'none';
	$('lastminute').style.display = 'none';
	$('fluege').style.display = 'none';
	$('mietwagen').style.display = 'none';
}
function suche_einblenden(FELD) {
	if(actSearch != FELD) {
		var queue = Effect.Queue;
		queue.each(function(e) { e.cancel() });
		suche_alle_ausblenden();
		if($(FELD)) show_ids(FELD);
		actSearch = FELD;
	}
}


function HideInfoBox(BoxId) {
	new Effect.BlindUp(BoxId, {duration:1});
	new Effect.toggle(BoxId, 'appear', {duration:1});
}
function ShowInfoBox(BoxId) {
	new Effect.BlindDown(BoxId, {duration:1});
	new Effect.toggle(BoxId, 'appear', {duration:1});
}
function PopupInfoBox(BoxId) {
	ShowInfoBox(BoxId);
	var myInfoTimeout = window.setTimeout("HideInfoBox(\'" + BoxId + "\')", 5000);
}

function ShowHideBox(Box) {
	if($(Box).visible()) {
		$(Box).style.display = 'none';
	} else {
		$(Box).style.display = 'block';
	}
}
function CheckTheBox(chkBox) {
	if($(chkBox).checked == true) {
		$(chkBox).checked = false;
	} else {
		$(chkBox).checked = true;
	}
}

function merkliste() {
	window.scrollTo(0, 0);
	PopupInfoBox('InfoMerkliste');
}

function show_popup(obj, BoxId) {
	var queue = Effect.Queue;
	queue.each(function(e) { e.cancel() });
	
	args=show_popup.arguments;
	if(args.length > 2) {
		for(i=2; i<args.length; i++) {
			Box = args[i];
			if($(Box).visible()) {
				$(Box).style.display = 'block';
				$(Box).style.height = '493px';
				HideInfoBox(Box);
			}
		}
	}
	
	if($(BoxId).visible()) {
		if(WWGR.Browser.IE6) {
			$(BoxId).style.display = 'none';
		} else {
			$(BoxId).style.display = 'block';
			$(BoxId).style.height = '525px';
			HideInfoBox(BoxId);
		}
	} else {
		if(WWGR.Browser.IE6) {
			$(BoxId).style.position = 'relative';
			$(BoxId).style.left = '139px';
			$(BoxId).style.top = '0px';
			$(BoxId).style.display = 'block';
			window.scrollTo(0, 635);
		} else {
			$(BoxId).style.display = 'none';
			$(BoxId).style.height = '525px';
			var coors = Position.cumulativeOffset(obj);
			$(BoxId).style.position = 'absolute';
			$(BoxId).style.left = coors[0] + 'px';
			$(BoxId).style.top = (coors[1] + 13) + 'px';
			ShowInfoBox(BoxId);
		}
	}
}

function newsletter_themen(obj, BoxId) {
	var queue = Effect.Queue;
	queue.each(function(e) { e.cancel() });
	if(obj.checked == true) {
		$(BoxId).style.display = 'none';
		new Effect.toggle(BoxId, 'appear', {duration:0.3});
	} else {
		$(BoxId).style.display = 'block';
		new Effect.toggle(BoxId, 'appear', {duration:0.3});
	}
}

var anzahl_agb = 0;
function set_agb(anzahl) {
	anzahl_agb = anzahl;
}
function agb_all(obj) {
	if(obj.checked == true) {
		for(i=1; i<=anzahl_agb; i++) $('agb' + i).checked = true;
	} else {
		for(i=1; i<=anzahl_agb; i++) $('agb' + i).checked = false;
	}
}
function agb_check() {
	var all_agb_checked = true;
	for(i=1; i<=anzahl_agb; i++) {
		if($('agb' + i).checked == false) all_agb_checked = false;
	}
	if(all_agb_checked == true) {
		$('agb_gesamt').checked = true;
	} else {
		$('agb_gesamt').checked = false;
	}
}

var myTimer;
function show_ids() {
	args=show_ids.arguments;
	for(i=0;i<args.length;i++) {
		feld = args[i];
		new Effect.toggle(feld, 'appear', {duration:0.3});
	}
}
function display_ids() {
	args=display_ids.arguments;
	for(i=0;i<args.length;i++) {
		feld = args[i];
		$(feld).style.display = '';
	}
}
function hide_ids() {
	args=hide_ids.arguments;
	for(i=0;i<args.length;i++) {
		feld = args[i];
		$(feld).style.display = 'none';
	}
}


var teaser_aktiv = 1;
var teaser_anzahl = 1;
var auto_switch = true;
var switch_time = 5000;
function start_teaser() {
	var ts = $('TeaserSwitcher');
	var tsbg = $('TeaserSwitcherBG');
	tsbg.style.width = ((ts.offsetWidth * 1) + 4) + "px";
	tsbg.style.height = ((ts.offsetHeight * 1) + 4) + "px";
	window.setTimeout("auto_teaser_switch()", switch_time);
	
	var tslink = $('TeaserLink' + teaser_aktiv);
	tslink.className = "TeaserAktiv";
}
function auto_teaser_switch() {
	if(auto_switch == true) {
		change_teaser_next();
		window.setTimeout("auto_teaser_switch()", switch_time);
	}
}
function next_teaser() {
	auto_switch = false;
	change_teaser_next();
}
function prev_teaser() {
	auto_switch = false;
	change_teaser_prev();
}
function select_teaser(teaser) {
	auto_switch = false;
	if(teaser != teaser_aktiv) {
		var teaser_alt = teaser_aktiv;
		var teaser_neu = teaser;
		
		var queue = Effect.Queues.get('sliderteaser');
		queue.each(function(e) { e.cancel() });
		for(i=1; i<=teaser_anzahl; i++) { if(i != teaser_neu) { $('teaser' + i).style.display = 'none'; } }
		new Effect.toggle('teaser' + teaser_neu, 'appear', {duration:0.5, queue: {position:'end', scope: 'sliderteaser'}});
	
		teaser_aktiv = teaser_neu;
		
		var tslink = $('TeaserLink' + teaser_alt);
		tslink.className = "";
		var tslink = $('TeaserLink' + teaser_neu);
		tslink.className = "TeaserAktiv";
	}
}
function change_teaser_next() {
	var teaser_alt = teaser_aktiv;
	var teaser_neu = teaser_aktiv + 1;
	if(teaser_neu > teaser_anzahl) teaser_neu = 1;
	
	var queue = Effect.Queues.get('sliderteaser');
	queue.each(function(e) { e.cancel() });
	for(i=1; i<=teaser_anzahl; i++) { if(i != teaser_neu) { $('teaser' + i).style.display = 'none'; } }
	new Effect.toggle('teaser' + teaser_neu, 'appear', {duration:0.5, queue: {position:'end', scope: 'sliderteaser'}});
	
	teaser_aktiv = teaser_neu;

	var tslink = $('TeaserLink' + teaser_alt);
	tslink.className = "";
	var tslink = $('TeaserLink' + teaser_neu);
	tslink.className = "TeaserAktiv";
}
function change_teaser_prev() {
	var teaser_alt = teaser_aktiv;
	var teaser_neu = teaser_aktiv - 1;
	if(teaser_neu < 1) teaser_neu = teaser_anzahl;
	
	var queue = Effect.Queues.get('sliderteaser');
	queue.each(function(e) { e.cancel() });
	for(i=1; i<=teaser_anzahl; i++) { if(i != teaser_neu) { $('teaser' + i).style.display = 'none'; } }
	new Effect.toggle('teaser' + teaser_neu, 'appear', {duration:0.5, queue: {position:'end', scope: 'sliderteaser'}});
	
	teaser_aktiv = teaser_neu;

	var tslink = $('TeaserLink' + teaser_alt);
	tslink.className = "";
	var tslink = $('TeaserLink' + teaser_neu);
	tslink.className = "TeaserAktiv";
}
function set_teaser_max(anzahl) {
	teaser_anzahl = anzahl;
}

var detail_tabs = Array();
var act_tab = 0;
function set_detail_tabs() {
	args=set_detail_tabs.arguments;
	act_tab = args[0];
	for(i=0;i<args.length;i++) {
		var tab = args[i];
		detail_tabs[i] = tab;
		if(tab != act_tab) {
			$('link_' + tab).className = "";
			$(tab).style.display = "none";
		}
	}
}
function switch_tab(id) {
	if(id != act_tab) {
		var queue = Effect.Queue;
		queue.each(function(e) { e.cancel() });
		for(i=0;i<detail_tabs.length;i++) {
			feld = detail_tabs[i];
			$('link_' + feld).className = "";
			$(feld).style.display = "none";
		}
		$('link_' + id).className = "aktiv";
		new Effect.toggle(id, 'appear', {duration:0.5});
		act_tab = id;
	}
}

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";
		new Effect.toggle('Pic' + id, 'appear', {duration:1.0});
		act_pic = id;
	}
}

var weiterempfehlen_sichtbar = false;
var telefonbuchung_sichtbar = false;
function weiterempfehlen() {
	if(telefonbuchung_sichtbar == true) {
		$('TelefonBuchung').style.display = "none";
		telefonbuchung_sichtbar = false;
	}
	if(weiterempfehlen_sichtbar == false) {
		$('DetailTop').style.display = "none";
		new Effect.toggle('DetailRecommend', 'appear', {duration:0.5});
		weiterempfehlen_sichtbar = true;
	}
	window.scrollTo(0, 340);
}
function weiterempfehlen_ende() {
	$('DetailRecommend').style.display = "none";
	new Effect.toggle('DetailTop', 'appear', {duration:0.5});
	weiterempfehlen_sichtbar = false;
}
function telefonbuchung(bookcode) {
	if(weiterempfehlen_sichtbar == true) {
		$('DetailRecommend').style.display = "none";
		weiterempfehlen_sichtbar = false;
	}
	if(telefonbuchung_sichtbar == false) {
		$('DetailTop').style.display = "none";
		//eingefÃ¼gt: hk
		$('TelefonBuchung_' + bookcode).style.display = "block";
		//<<
		new Effect.toggle('TelefonBuchung', 'appear', {duration:0.5});
		telefonbuchung_sichtbar = true;
	}
	window.scrollTo(0, 340);
}
function telefonbuchung_ende(bookcode) {
	$('TelefonBuchung').style.display = "none";
	//geÃ¤ndert: hk
	$('TelefonBuchung_' + bookcode).style.display = "none";
	//<<
	new Effect.toggle('DetailTop', 'appear', {duration:0.5});
	telefonbuchung_sichtbar = false;
}

if(window.location.hostname == 'ibe.WWGR-reisen.de') {
	PicLoader1 = new Image();
	PicLoader1.src = "http://www.WWGR-reisen.de/fileadmin/imgs/loader_bg.png";
}
if(window.location.hostname == 'buchung.WWGR-reisen.de') {
	PicLoader2 = new Image();
	PicLoader2.src = "http://www.WWGR-reisen.de/fileadmin/imgs/loader_bg.png";
}
if(window.location.hostname == 'buchung2.WWGR-reisen.de') {
	PicLoader3 = new Image();
	PicLoader3.src = "http://www.WWGR-reisen.de/fileadmin/imgs/loader_bg.png";
}

function Loader() {
	var obj = $('Loader');

	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}

	var Hoehe = (myHeight - 137) / 2;
	var Breite = (myWidth - 265) / 2 + 87;
	//obj.style.top = Hoehe + "px";
	obj.style.left = Breite + "px";
	obj.style.display = 'block';
}

function calc_price(priceID) {
	var prozent = 5;
	
	pp = $('price_pp' + priceID);
	pp_old = $('old_pp' + priceID);
	ges = $('price_ges' + priceID);
	ges_old = $('old_ges' + priceID);
	
	$('rab1_' + priceID).innerHTML = '-' + prozent + '%';
	$('rab2_' + priceID).innerHTML = '-' + prozent + '%';
	
	price = pp_old.innerHTML;
	price = price.replace(/-/, "0");
	price = price * 1 * 0.95;
	pp.innerHTML = price.toFixed(2);
	
	price = ges_old.innerHTML;
	price = price.replace(/-/, "0");
	price = price * 1 * (1 - (prozent / 100));
	ges.innerHTML = price.toFixed(2);
}

var actPage = 0;
function change_flyer(Nr) {
	$('flyer' + actPage).className = '';
	$('image' + actPage).style.display = 'none';

	$('flyer' + Nr).className = 'current';
	$('image' + Nr).style.display = 'block';
	
	actPage = Nr;
}

/*

	Ferien-Datenbank

*/

var Ferien = new Array();
var FerienZeitraum = new Array();

/*

IDs der BundeslÃ¤nder um Arrays zu fÃ¼llen:

1: Baden-WÃ¼rttemberg
2: Bayern
3: Berlin
4: Brandenburg
5: Bremen
6: Hamburg
7: Hessen
8: Mecklenburg-Vorpommern
9: Niedersachsen
10: Nordrhein-Westfalen
11: Rheinland-Pfalz
12: Saarland
13: Sachsen
14: Sachsen-Anhalt
15: Schleswig-Holstein
16: ThÃ¼ringen

*/


/*

	Ferientage
	Format: DD-MM-YYYY

*/

Ferien[1] = new Array();
Ferien[2] = new Array();
Ferien[3] = new Array('04-02-2008', '02-05-2008', '16-07-2008', '22-05-2009');
Ferien[4] = new Array('04-02-2008', '22-05-2009');
Ferien[5] = new Array('02-02-2009', '02-06-2009');
Ferien[6] = new Array('01-02-2008', '02-05-2008', '30-01-2009');
Ferien[7] = new Array();
Ferien[8] = new Array();
Ferien[9] = new Array('31-01-2008', '01-02-2008', '02-05-2008', '13-05-2008', '22-05-2009', '02-06-2009');
Ferien[10] = new Array('13-05-2008', '02-06-2009');
Ferien[11] = new Array();
Ferien[12] = new Array();
Ferien[13] = new Array('02-05-2008', '22.05.2009');
Ferien[14] = new Array();
Ferien[15] = new Array();
Ferien[16] = new Array();


/*

	Ferienzeiten
	Format: DD-MM-YYYY
	Array('VON', 'BIS')

*/

FerienZeitraum[1] = new Array(
	Array('26-07-2007', '08-09-2007'),
	Array('29-10-2007', '03-11-2007'),
	Array('24-12-2007', '05-01-2008'),
	Array('17-03-2008', '28-03-2008'),
	Array('13-05-2008', '23-05-2008'),
	
	Array('24-07-2008', '06-09-2008'),
	Array('27-10-2008', '30-10-2008'),
	Array('22-12-2008', '10-01-2009'),
	Array('14-04-2009', '17-04-2009'),
	Array('02-06-2009', '13-06-2009')
);

FerienZeitraum[2] = new Array(
	Array('30-07-2007', '10-09-2007'),
	Array('29-10-2007', '03-11-2007'),
	Array('24-12-2007', '05-01-2008'),
	Array('04-02-2008', '09-02-2008'),
	Array('17-03-2008', '29-03-2008'),
	Array('13-05-2008', '24-05-2008'),
	
	Array('04-08-2008', '15-09-2008'),
	Array('03-11-2008', '05-11-2008'),
	Array('22-12-2008', '05-01-2009'),
	Array('23-02-2009', '28-02-2009'),
	Array('06-04-2009', '18-04-2009'),
	Array('02-06-2009', '13-06-2009')
);

FerienZeitraum[3] = new Array(
	Array('12-07-2007', '25-08-2007'),
	Array('15-10-2007', '20-10-2007'),
	Array('24-12-2007', '12-01-2008'),
	Array('17-03-2008', '29-03-2008'),
	Array('13-05-2008', '16-05-2008'),

	Array('17-07-2008', '29-08-2008'),
	Array('20-10-2008', '31-10-2008'),
	Array('22-12-2008', '03-01-2009'),
	Array('02-02-2009', '07-02-2009'),
	Array('06-04-2009', '18-04-2009')
);

FerienZeitraum[4] = new Array(
	Array('12-07-2007', '25-08-2007'),
	Array('15-10-2007', '20-10-2007'),
	Array('24-12-2007', '12-01-2008'),
	Array('19-03-2008', '28-03-2008'),
	Array('13-05-2008', '16-05-2008'),

	Array('17-07-2008', '30-08-2008'),
	Array('20-10-2008', '30-10-2008'),
	Array('22-12-2008', '03-01-2009'),
	Array('02-02-2009', '07-02-2009'),
	Array('08-04-2009', '17-04-2009')
);

FerienZeitraum[5] = new Array(
	Array('19-07-2007', '29-08-2007'),
	Array('22-10-2007', '03-11-2007'),
	Array('24-12-2007', '05-01-2008'),
	Array('31-01-2008', '01-02-2008'),
	Array('10-03-2008', '25-03-2008'),
	Array('13-05-2008', '16-05-2008'),

	Array('10-07-2008', '20-08-2008'),
	Array('13-10-2008', '25-10-2008'),
	Array('22-12-2008', '06-01-2009'),
	Array('30-03-2009', '15-04-2009')
);

FerienZeitraum[6] = new Array(
	Array('12-07-2007', '22-08-2007'),
	Array('15-10-2007', '27-10-2007'),
	Array('21-12-2007', '05-01-2008'),
	Array('10-03-2008', '20-03-2008'),
	Array('13-05-2008', '17-05-2008'),

	Array('17-07-2008', '27-08-2008'),
	Array('13-10-2008', '25-10-2008'),
	Array('22-12-2008', '02-01-2009'),
	Array('09-03-2009', '21-03-2009'),
	Array('18-05-2009', '23-05-2009')
);

FerienZeitraum[7] = new Array(
	Array('09-07-2007', '17-08-2007'),
	Array('08-10-2007', '20-10-2007'),
	Array('23-12-2007', '11-01-2008'),
	Array('25-03-2008', '04-04-2008'),

	Array('23-06-2008', '01-08-2008'),
	Array('06-10-2008', '18-10-2008'),
	Array('22-12-2008', '10-01-2009'),
	Array('06-04-2009', '18-04-2009')
);

FerienZeitraum[8] = new Array(
	Array('16-07-2007', '25-08-2007'),
	Array('22-10-2007', '27-10-2007'),
	Array('24-12-2007', '04-01-2008'),
	Array('04-02-2008', '16-02-2008'),
	Array('17-03-2008', '26-03-2008'),
	Array('09-05-2008', '13-05-2008'),

	Array('21-07-2008', '30-08-2008'),
	Array('27-10-2008', '01-11-2008'),
	Array('22-12-2008', '03-01-2009'),
	Array('09-02-2009', '20-02-2009'),
	Array('06-04-2009', '14-04-2009'),
	Array('02-06-2009', '06-06-2009')
);

FerienZeitraum[9] = new Array(
	Array('19-07-2007', '29-08-2007'),
	Array('22-10-2007', '03-11-2007'),
	Array('24-12-2007', '05-01-2008'),
	Array('10-03-2008', '26-03-2008'),

	Array('10-07-2008', '20-08-2008'),
	Array('13-10-2008', '25-10-2008'),
	Array('22-12-2008', '06-01-2009'),
	Array('02-02-2009', '03-02-2009'),
	Array('30-03-2009', '15-04-2009')
);

FerienZeitraum[10] = new Array(
	Array('21-06-2007', '03-08-2007'),
	Array('24-09-2007', '06-10-2007'),
	Array('20-12-2007', '04-01-2008'),
	Array('17-03-2008', '29-03-2008'),

	Array('26-06-2008', '08-08-2008'),
	Array('29-09-2008', '11-10-2008'),
	Array('22-12-2008', '06-01-2009'),
	Array('06-04-2009', '18-04-2009')
);

FerienZeitraum[11] = new Array(
	Array('09-07-2007', '17-08-2007'),
	Array('08-10-2007', '19-10-2007'),
	Array('24-12-2007', '08-01-2008'),
	Array('12-03-2008', '28-03-2008'),

	Array('23-06-2008', '01-08-2008'),
	Array('06-10-2008', '17-10-2008'),
	Array('22-12-2008', '07-01-2009'),
	Array('01-04-2009', '17-04-2009')
);

FerienZeitraum[12] = new Array(
	Array('09-07-2007', '18-08-2007'),
	Array('08-10-2007', '20-10-2007'),
	Array('19-12-2007', '05-01-2008'),
	Array('31-01-2008', '06-02-2008'),
	Array('17-03-2008', '29-03-2008'),

	Array('30-06-2008', '09-08-2008'),
	Array('04-10-2008', '18-10-2008'),
	Array('19-12-2008', '03-01-2009'),
	Array('19-02-2009', '25-02-2009'),
	Array('06-04-2009', '18-04-2009')
);

FerienZeitraum[13] = new Array(
	Array('23-07-2007', '31-08-2007'),
	Array('08-10-2007', '19-10-2007'),
	Array('22-12-2007', '02-01-2008'),
	Array('04-02-2008', '15-02-2008'),
	Array('20-03-2008', '28-03-2008'),
	Array('10-05-2008', '13-05-2008'),

	Array('14-07-2008', '22-08-2008'),
	Array('20-10-2008', '30-10-2008'),
	Array('22-12-2008', '02-01-2009'),
	Array('09-02-2009', '21-02-2009'),
	Array('09-04-2009', '18-04-2009')
);

FerienZeitraum[14] = new Array(
	Array('19-07-2007', '29-08-2007'),
	Array('15-10-2007', '20-10-2007'),
	Array('21-12-2007', '04-01-2008'),
	Array('02-02-2008', '09-02-2008'),
	Array('17-03-2008', '20-03-2008'),
	Array('13-05-2008', '23-05-2008'),

	Array('10-07-2008', '22-08-2008'),
	Array('13-10-2008', '17-10-2008'),
	Array('22-12-2008', '05-01-2009'),
	Array('02-02-2009', '10-02-2009'),
	Array('06-04-2009', '18-04-2009'),
	Array('22-05-2009', '29-05-2009')
);

FerienZeitraum[15] = new Array(
	Array('16-07-2007', '25-08-2007'),
	Array('15-10-2007', '27-10-2007'),
	Array('24-12-2007', '08-01-2008'),
	Array('20-03-2008', '05-04-2008'),

	Array('21-07-2008', '30-08-2008'),
	Array('13-10-2008', '25-10-2008'),
	Array('22-12-2008', '07-01-2009'),
	Array('06-04-2009', '21-04-2009')
);

FerienZeitraum[16] = new Array(
	Array('19-07-2007', '29-08-2007'),
	Array('15-10-2007', '26-10-2007'),
	Array('22-12-2007', '05-01-2008'),
	Array('04-02-2008', '09-02-2008'),
	Array('22-03-2008', '28-03-2008'),
	Array('13-05-2008', '16-05-2008'),

	Array('10-07-2008', '20-08-2008'),
	Array('13-10-2008', '24-10-2008'),
	Array('20-12-2008', '03-01-2009'),
	Array('02-02-2009', '07-02-2009'),
	Array('06-04-2009', '17-04-2009')
);


/*

	FerienzeitrÃ¤ume umformatieren in einzelne Tage und dem Ferien-Array anhÃ¤ngen

*/

function left_zero( str, padToLength ) {
	var result	= '';
	for ( var i = 0; i < (padToLength - String(str).length); i++ ) result += '0';
	return	result + str;
}

for(i=1; i<=FerienZeitraum.length; i++) {
	var Zeitraum = FerienZeitraum[i];
	var Tag = 24 * 60 * 60 * 1000;
	if(Zeitraum) {
		for(j=0; j<Zeitraum.length; j++) {
			var VonDatum = Zeitraum[j][0];
			var VonArray = VonDatum.match(/^(\d{1,2})(?:\/|\.|\-)(\d{1,2})(?:\/|\.|\-)(\d{4})$/);
			var v_d = VonArray[1];
			var v_m = VonArray[2] - 1;
			var v_y = VonArray[3];
			var VonDate =new Date(v_y, v_m, v_d);
			var Von = VonDate.getTime();

			var BisDatum = Zeitraum[j][1];
			var BisArray = BisDatum.match(/^(\d{1,2})(?:\/|\.|\-)(\d{1,2})(?:\/|\.|\-)(\d{4})$/);
			var b_d = BisArray[1];
			var b_m = BisArray[2] - 1;
			var b_y = BisArray[3];
			var BisDate =new Date(b_y, b_m, b_d);
			var Bis = BisDate.getTime();

			for(k=Von; k<=Bis; k=k+Tag) {
				var Datum = new Date(k);
				var d = Datum.getDate();
				var m = Datum.getMonth() + 1;
				var y = Datum.getFullYear();
				var neuesDatum = left_zero(d, 2) + '-' + left_zero(m, 2) + '-' + left_zero(y, 4);
				Ferien[i].push(neuesDatum);
			}
		}
	}
}

/**
 * DatePicker widget using Prototype and Scriptaculous.
 * (c) 2007 Mathieu Jondet <mathieu@eulerian.com>
 * Eulerian Technologies
 *
 * DatePicker is freely distributable under the same terms as Prototype.
 *
 * Now it is a "DoubleDatePicker" - modified by SEC
 *
 */

var oldelement = "";
var oldclassname = "";
var activeElement = "";
var oldelement2 = "";
var oldclassname2 = "";
var activeElement2 = "";

var ActiveDates = [];

Array.prototype.contains = function(searchString){
	for(result=[], x=0; x<this.length; x++){
		if(this[x] == searchString){
			result[result.length]=x;
		}
	}
	return result.length ? result : -1;
};

var DatePicker = Class.create();

DatePicker.prototype = {
 Version	: '0.9.2',
 _relative	: 'date1',
 _field2	: 'date2',
 _hdr1		: 'Anreise',
 _hdr2		: 'Abreise',
 _JSvarName	: 'reise_kalender',
 _disableIDs	: new Array(),
 _div		: null,
 _zindex	: 9999,
 _keepFieldEmpty: false,
 _daysInMonth	: [31,28,31,30,31,30,31,31,30,31,30,31],
 /* language */
 _language	: 'de',
 _language_month	: $H({
  'fr'	: [ 'Janvier', 'F&#233;vrier', 'Mars', 'Avril', 'Mai', 'Juin', 
   'Juillet', 'Aout', 'Septembre', 'Octobre', 'Novembre', 'D&#233;cembre' ],
  'en'	: [ 'January', 'February', 'March', 'April', 'May',
   'June', 'July', 'August', 'September', 'October', 'November', 'December' ],
  'sp'	: [ 'Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 
   'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre' ],
  'it'	: [ 'Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno',
   'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre' ],
  'de'	: [ 'Januar', 'Februar', 'M&#228;rz', 'April', 'Mai', 'Juni',
   'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember' ],
  'pt'	: [ 'Janeiro', 'Fevereiro', 'Mar&#231;o', 'Abril', 'Maio', 'Junho',
   'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro' ]
 }),
 _language_day	: $H({
  'fr'	: [ 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam', 'Dim' ],
  'en'	: [ 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun' ],
  'sp'	: [ 'Lun', 'Mar', 'Mie', 'Jue', 'Vie', 'S&#224;b', 'Dom' ],
  'it'	: [ 'Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab', 'Dom' ],
  'de'	: [ 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So' ],
  'pt'	: [ 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'S&#225;', 'Dom' ]
 }),
 _language_close	: $H({
  'fr'	: 'fermer',
  'en'	: 'close',
  'sp'	: 'cierre',
  'it'	: 'fine',
  'de'	: 'schliessen',
  'pt'	: 'fim'
 }),
 /* date manipulation */
 _todayDate	: new Date(),
 _date_regexp	: /^(\d{1,2})(\/|\.|\-)(\d{1,2})(?:\/|\.|\-)(\d{4})$/,
 _current_date	: null,
 _clickCallback	: Prototype.emptyFunction,
 _date_separator: '.',
 _id_datepicker	: null,
 /* positionning */
 _topOffset	: 0,
 _leftOffset	: 0,
 _isPositionned	: false,
 _relativePosition : true,
 /* return the name of current month in appropriate language */
 getMonthLocale	: function ( month ) {
  return	this._language_month[this._language][month];
 },
 getLocaleClose	: function () {
  /* return	this._language_close[this._language]; */
  var selectbox = Builder.node('select',{id: 'bundesland', className: 'bundesland', onchange: 'load_holidays(this.value, \'' + this._relative + '\')'}, [
	Builder.node('option', {value: '0'}, 'Bundesland wÃ¤hlen'),
	Builder.node('option', {value: '1'}, 'Baden-WÃ¼rttemberg'),
	Builder.node('option', {value: '2'}, 'Bayern'),
	Builder.node('option', {value: '3'}, 'Berlin'),
	Builder.node('option', {value: '4'}, 'Brandenburg'),
	Builder.node('option', {value: '5'}, 'Bremen'),
	Builder.node('option', {value: '6'}, 'Hamburg'),
	Builder.node('option', {value: '7'}, 'Hessen'),
	Builder.node('option', {value: '8'}, 'Mecklenburg-Vorpommern'),
	Builder.node('option', {value: '9'}, 'Niedersachsen'),
	Builder.node('option', {value: '10'}, 'Nordrhein-Westfalen'),
	Builder.node('option', {value: '11'}, 'Rheinland-Pfalz'),
	Builder.node('option', {value: '12'}, 'Saarland'),
	Builder.node('option', {value: '13'}, 'Sachsen'),
	Builder.node('option', {value: '14'}, 'Sachsen-Anhalt'),
	Builder.node('option', {value: '15'}, 'Schleswig-Holstein'),
	Builder.node('option', {value: '16'}, 'ThÃ¼ringen')
	]);
  selectbox.options[0].selected = true;

  return [
      Builder.node('ul', {className:'datepicker-list'}, [
  	    Builder.node('li', {className: 'left'}, [Builder.node('span', 'Ferien in ')]),
  	    Builder.node('li', {className: 'middle'}, [selectbox]),
  	    Builder.node('li', {className: 'right'}, [Builder.node('a', {className: 'datepicker-button', href: 'javascript:void(0);', onclick: 'load_holidays(document.getElementById(\'bundesland\').value, \'' + this._relative + '\')'}, 'Zeigen')])
      ]),
  	  Builder.node('a', {className: 'datepicker-longbutton', href: 'javascript:void(0);', onclick: this._JSvarName + '.close();'}, 'Diesen Reisezeitraum Ã¼bernehmen')
    ];
 },
 _initCurrentDate : function (tab) {
  /* check if value in field is proper, set to today */
  if(tab == '1') {
  	this._current_date	= $F(this._field2);
  } else {
  	this._current_date	= $F(this._relative);
  }
  if ( !this._date_regexp.test(this._current_date) ) {
   var now	= new Date();
   var day	= this._leftpad_zero(now.getDate(), 2);
   var mon	= this._leftpad_zero(now.getMonth() + 1, 2);
   /* depending on language not presented the same way */
   if ( this._language == 'en' )
    this._current_date	= mon+'/'+day+'/'+now.getFullYear();
   else 
    this._current_date	= day+'/'+mon+'/'+now.getFullYear();
   /* set the field value ? */
   if ( !this._keepFieldEmpty )
    $(this._relative).setAttribute('value', this._current_date);
  }
  var a_date_regexp	= this._current_date.match(this._date_regexp);
  /* fetch date separator as specified in option or via value */
  this._date_separator	= String(a_date_regexp[2]);
  /* check language */
  if ( this._language == 'en' ) {
   this._current_mon	= Number(a_date_regexp[1]) - 1;
   this._current_day	= Number(a_date_regexp[3]);
  } else {
   this._current_day	= Number(a_date_regexp[1]);
   this._current_mon	= Number(a_date_regexp[3]) - 1;
  }
  this._current_year	= Number(a_date_regexp[4]);
  
  if(tab == '1') {
    this.dev_cur_mon2 = this._current_mon;
    this.dev_cur_year2 = this._current_year;
  } else {
    this.dev_cur_mon1 = this._current_mon;
    this.dev_cur_year1 = this._current_year;
  }
 },
 /* init */
 initialize	: function ( h_p ) {
  /* arguments */
  if ( typeof(h_p["field1"]) != 'undefined' ) this._relative= h_p["field1"];
  if ( typeof(h_p["field2"]) != 'undefined' ) this._field2= h_p["field2"];
  if ( typeof(h_p["hdr1"]) != 'undefined' ) this._hdr1= h_p["hdr1"];
  if ( typeof(h_p["hdr2"]) != 'undefined' ) this._hdr2= h_p["hdr2"];
  if ( typeof(h_p["hideFields"]) != 'undefined' ) this._disableIDs= h_p["hideFields"];
  if ( typeof(h_p["varName"]) != 'undefined' ) this._JSvarName= h_p["varName"];
  if ( h_p["language"] )
   this._language = h_p["language"];
  this._zindex	= ( h_p["zindex"] ) ? parseInt(Number(h_p["zindex"])) : 1;
  if ( typeof(h_p["keepFieldEmpty"]) != 'undefined' )
   this._keepFieldEmpty	= h_p["keepFieldEmpty"];
  if ( typeof(h_p["clickCallback"]) == 'function' )
   this._clickCallback	= h_p["clickCallback"];
  if ( typeof(h_p["leftOffset"]) != 'undefined' )
   this._leftOffset	= parseInt(h_p["leftOffset"]);
  if ( typeof(h_p["topOffset"]) != 'undefined' )
   this._topOffset	= parseInt(h_p["topOffset"]);
  if ( typeof(h_p["relativePosition"]) != 'undefined' )
   this._relativePosition = h_p["relativePosition"];
  this._id_datepicker		= 'datepicker-'+this._relative;
  this._id_datepicker_prev	= this._id_datepicker+'-prev';
  this._id_datepicker_next	= this._id_datepicker+'-next';
  this._id_datepicker_hdr	= this._id_datepicker+'-header';
  this._id_datepicker_ftr	= this._id_datepicker+'-footer';

  this._id_datepicker_prev2	= this._id_datepicker+'-prev2';
  this._id_datepicker_next2	= this._id_datepicker+'-next2';
  this._id_datepicker_hdr2	= this._id_datepicker+'-header2';

  this._id_datepicker_closer	= this._id_datepicker+'-closer';

  /* build up calendar skel */
  this._div = Builder.node('div', { 
    id 		: this._id_datepicker,
    className	: 'datepicker',
    style	: 'display: none; z-index: 9;'
   }, [
      Builder.node('div', { className : 'datepicker-header-text' }, [
       Builder.node('span', { id : 'datepicker-hdr-text_right', style : 'float:right; width:138px;' }, this._hdr2),
       Builder.node('span', { id : 'datepicker-hdr-text_left', style : '' }, this._hdr1),
       Builder.node('a', { id : this._id_datepicker_closer, className : 'datepicker-closer' }, 'x')
      ]),
      /* header 2 */
      Builder.node('div', { className : 'datepicker-header', style: 'float:right;' }, [
       Builder.node('span', { 
	id : this._id_datepicker_prev2, className : 'datepicker_left' }, ' '),
       Builder.node('span', { id : this._id_datepicker_hdr2 }),
       Builder.node('span', { 
	id : this._id_datepicker_next2, className : 'datepicker_right' }, ' ')
      ]),
      /* header 1 */
      Builder.node('div', { className : 'datepicker-header' }, [
       Builder.node('span', { 
	id : this._id_datepicker_prev, className : 'datepicker_left' }, ' '),
       Builder.node('span', { id : this._id_datepicker_hdr }),
       Builder.node('span', { 
	id : this._id_datepicker_next, className : 'datepicker_right' }, ' ')
      ]),
      
      /* calendar 2 */
      Builder.node('div', { className : 'datepicker-calendar', style: 'float:right;' }, [
       Builder.node('table', { id : this._id_datepicker+'-table2' }) ]),
      /* calendar 1 */
      Builder.node('div', { className : 'datepicker-calendar' }, [
       Builder.node('table', { id : this._id_datepicker+'-table' }) ]),
      
      /* footer */
      Builder.node('div', { 
       id 	: this._id_datepicker_ftr,
       className: 'datepicker-footer' }, this.getLocaleClose() )
  ]);
  /* finally declare the event listener on input field */
  Event.observe(this._relative, 
    'click', this.click.bindAsEventListener(this), false);
  Event.observe(this._field2, 
    'click', this.click.bindAsEventListener(this), false);
  /* need to append on body when doc is loaded for IE */
  Event.observe(window, 'load', this.load.bindAsEventListener(this), false);
 },
 /**
  * load	: called when document is fully-loaded to append datepicker
  *		  to main object.
  */
 load		: function () {
  /* append to body */
  var body	= document.getElementsByTagName("body").item(0);
  if ( body )
   body.appendChild( this._div );
  /* init the date in field if needed */
  this._initCurrentDate();
  /* declare the observers for UI control */
  Event.observe($(this._id_datepicker_prev), 
    'click', this.prevMonth.bindAsEventListener(this, ''), false);
  Event.observe($(this._id_datepicker_next), 
    'click', this.nextMonth.bindAsEventListener(this, ''), false);
  Event.observe($(this._id_datepicker_prev2), 
    'click', this.prevMonth.bindAsEventListener(this, '1'), false);
  Event.observe($(this._id_datepicker_next2), 
    'click', this.nextMonth.bindAsEventListener(this, '1'), false);
  /* Event.observe($(this._id_datepicker_ftr), 
    'click', this.close.bindAsEventListener(this), false); */
  Event.observe($(this._id_datepicker_closer), 
    'click', this.close.bindAsEventListener(this), false);
 },
 /**
  * click	: called when input element is clicked
  */
 click		: function () {
  if ( !this._isPositionned && this._relativePosition ) {
   /* position the datepicker relatively to element */
   var a_lt = Position.positionedOffset($(this._relative));
   $(this._id_datepicker).setStyle({
    'left'	: Number(a_lt[0]+this._leftOffset)+'px',
    'top'	: Number(a_lt[1]+this._topOffset)+'px'
   });
   this._isPositionned	= true;
  }
  if ( !$(this._id_datepicker).visible() ) {
   this._initCurrentDate();
   this._redrawCalendar();
   var actel = this._relative + '-' + this._leftpad_zero(this._current_day, 2) + '-' + this._leftpad_zero((this._current_mon + 1), 2) + '-' + this._current_year;
   oldelement = document.getElementById(actel);
   oldelement.className = oldelement.className + ' active';
   this._initCurrentDate('1');
   this._redrawCalendar('1');
   var actel = this._relative + '_1-' + this._leftpad_zero(this._current_day, 2) + '-' + this._leftpad_zero((this._current_mon + 1), 2) + '-' + this._current_year;
   oldelement2 = document.getElementById(actel);
   oldelement2.className = oldelement2.className + ' active';
  }
  /* eval the clickCallback function */
  eval(this._clickCallback());
  /* Effect toggle to fade-in / fade-out the datepicker */
  new Effect.toggle(this._id_datepicker, 'appear', {duration:0.3});
  load_holidays(lastbundesland, this._relative);

  for(i=0; i<this._disableIDs.length;i++) {
	feld = document.getElementById(this._disableIDs[i]);
	if($(feld).style.visibility == 'hidden') {
		$(feld).style.visibility = 'visible';
	} else {
		$(feld).style.visibility = 'hidden';
	}
    // new Effect.toggle(feld, 'appear', {duration:0.3});
  }

  if($(this._id_datepicker).visible() == true) if( window.CallAjaxCalendar ) CallAjaxCalendar();
 },
 /**
  * close	: called when the datepicker is closed
  */
 close		: function () {
  new Effect.Fade(this._id_datepicker, { duration : 0.3 });

  for(i=0; i<this._disableIDs.length;i++) {
	feld = document.getElementById(this._disableIDs[i]);
	if($(feld).style.visibility == 'hidden') {
		$(feld).style.visibility = 'visible';
	} else {
		$(feld).style.visibility = 'hidden';
	}
  }

  if( window.CallAjaxCalendar ) CallAjaxCalendar();
 },
 /**
  * setPosition	: set the position of the datepicker.
  *  param : t=top | l=left
  */
 setPosition	: function ( t, l ) {
  var h_pos	= { 'top' : '0px', 'left' : '0px' };
  if ( typeof(t) != 'undefined' )
   h_pos['top']	= Number(t)+this._topOffset+'px';
  if ( typeof(l) != 'undefined' )
   h_pos['left']= Number(l)+this._leftOffset+'px';
  $(this._id_datepicker).setStyle(h_pos);
  this._isPositionned	= true;
 },
 /**
  * _leftpad_zero : pad the provided string to given number of 0
  */
  /** CHECK toPaddedString: from http://dev.rubyonrails.org/changeset/6363 */
 _leftpad_zero	: function ( str, padToLength ) {
  var result	= '';
  for ( var i = 0; i < (padToLength - String(str).length); i++ )
   result	+= '0';
  return	result + str;
 },
 /**
  * _getMonthDays : given the year and month find the number of days.
  */
 _getMonthDays	: function ( year, month ) {
  if (((0 == (year%4)) && 
   ( (0 != (year%100)) || (0 == (year%400)))) && (month == 1))
   return 29;
  return this._daysInMonth[month];
 },
 /**
  * _buildCalendar	: draw the days array for current date
  */
 _buildCalendar		: function (ZusatzID) {
  var _self	= this;
  var tbody	= document.createElement('tbody');
  /* generate day headers */
  var trDay	= document.createElement('tr');
  this._language_day[this._language].each( function ( item ) {
   var td	= document.createElement('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	= document.createElement('tr');
   for ( var j = 0; j < 7; j++ ) {
    var h_ij	= a_d[i][j];
    var td	= document.createElement('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 tdZusatzID = '';
    if(ZusatzID != "") tdZusatzID = '_' + ZusatzID;
    if ( this._language == 'en' ) 
     var id	= $A([ this._relative, this._leftpad_zero((h_ij["m"] +1), 2),
       this._leftpad_zero(h_ij["d"], 2), h_ij["y"] ]).join('-');
     else 
      var id	= $A([ this._relative + tdZusatzID, this._leftpad_zero(h_ij["d"], 2),
	this._leftpad_zero((h_ij["m"] + 1), 2), h_ij["y"] ]).join('-');
    /* set id and classname for cell if exists */
    td.setAttribute('id', id);

    /* checking date if clickable or not */
	if(h_ij["c"] == "outbound") {
		td.className	= h_ij["c"];
	} else {
	    var checkDatum	= $A([ this._leftpad_zero(h_ij["d"], 2), this._leftpad_zero((h_ij["m"] + 1), 2), h_ij["y"] ]).join('.');
	    var pruefDatum = ActiveDates.contains(checkDatum);
	    if(pruefDatum.length > 0 || ActiveDates.length == 0) {
			if ( h_ij["c"] ) td.className	= h_ij["c"];
		    /* on onclick : rebuild date value from id of current cell */
		    td.onclick	= function () {
		     if(ZusatzID != "") {
		     	var replStr = _self._relative + '_' + ZusatzID;
		     	var replField = _self._field2;
		     	activeElement2 = $(this).readAttribute('id');
		     } else {
		     	var replStr = _self._relative;
		     	var replField = _self._relative;
		     	activeElement = $(this).readAttribute('id');
		     }
		     $(replField).value = String($(this).readAttribute('id')
			).replace(replStr+'-','').replace(/-/g,_self._date_separator); 
		     /* _self.close(); */
     
		     if(ZusatzID != "") {
			     if(oldelement2 != "") {
			       if(oldelement2) oldelement2.className = oldelement2.className.replace(/active/g, "");
			     }
			     oldelement2 = this;
			     this.className = this.className + ' active';
		     } else {
			     if(oldelement != "") {
			       if(oldelement) oldelement.className = oldelement.className.replace(/active/g, "");
			     }
			     oldelement = this;
			     this.className = this.className + ' active';
		     }
		    };
		} else {
			td.className	= "inactive";
			if ( h_ij["c"] ) td.className	= h_ij["c"] + " inactive";
		}
	}
    td.innerHTML= h_ij["d"];
    tr.appendChild( td );
   }
   tbody.appendChild( tr );
  }
  return	tbody;
 },
 /**
  * nextMonth	: redraw the calendar content for next month.
  */
 _nextMonthYear	: function (tab) {
  var c_mon	= this._current_mon;
  var c_year	= this._current_year;
  if(tab == '') {
    var c_mon	= this.dev_cur_mon1;
    var c_year	= this.dev_cur_year1;
  }
  if(tab == '1') {
    var c_mon	= this.dev_cur_mon2;
    var c_year	= this.dev_cur_year2;
  }
  
  if ( c_mon + 1 > 11 ) {
   c_mon	= 0;
   c_year	+= 1;
  } else {
   c_mon	+= 1;
  }
  return	[ c_mon, c_year ];
 },
 nextMonth	: function (evt, tab) {
  var a_next		= this._nextMonthYear(tab);
  this._current_mon	= a_next[0];
  this._current_year 	= a_next[1];
  if(tab == '') {
    this.dev_cur_mon1	= a_next[0];
    this.dev_cur_year1	= a_next[1];
  }
  if(tab == '1') {
    this.dev_cur_mon2	= a_next[0];
    this.dev_cur_year2	= a_next[1];
  }
  this._redrawCalendar(tab);
  load_holidays(lastbundesland, this._relative);
  load_activeElements();
 },
 /**
  * prevMonth	: redraw the calendar content for previous month.
  */
 _prevMonthYear	: function (tab) {
  var c_mon	= this._current_mon;
  var c_year	= this._current_year;
  if(tab == '') {
    var c_mon	= this.dev_cur_mon1;
    var c_year	= this.dev_cur_year1;
  }
  if(tab == '1') {
    var c_mon	= this.dev_cur_mon2;
    var c_year	= this.dev_cur_year2;
  }
  
  if ( c_mon - 1 < 0 ) {
   c_mon	= 11;
   c_year	-= 1;
  } else {
   c_mon	-= 1;
  }
  return	[ c_mon, c_year ];
 },
 prevMonth	: function (evt, tab) {
  var a_prev		= this._prevMonthYear(tab);
  this._current_mon	= a_prev[0];
  this._current_year 	= a_prev[1];
  if(tab == '') {
    this.dev_cur_mon1	= a_prev[0];
    this.dev_cur_year1	= a_prev[1];
  }
  if(tab == '1') {
    this.dev_cur_mon2	= a_prev[0];
    this.dev_cur_year2	= a_prev[1];
  }
  this._redrawCalendar(tab);
  load_holidays(lastbundesland, this._relative);
  load_activeElements();
 },
 _redrawCalendar	: function (Tabelle2) {
  if(Tabelle2 == '1') {
  	this._setLocaleHdr('1');
  	var ZusatzTableId = '2';
  	var BuildTableId = '1';
  } else {
  	this._setLocaleHdr('0');
  	var ZusatzTableId = '';
  	var BuildTableId = '';
  }
  
  var table	= $(this._id_datepicker+'-table' + ZusatzTableId);
  try {
   while ( table.hasChildNodes() )
    table.removeChild(table.childNodes[0]);
  } catch ( e ) {}
  table.appendChild( this._buildCalendar(BuildTableId) );
 },
 _setLocaleHdr	: function (Tabelle2) {
  if(Tabelle2 == '1') {
  	var div_next	= this._id_datepicker_next2;
  	var div_prev	= this._id_datepicker_prev2;
  	var div_hdr	= this._id_datepicker_hdr2;
  } else {
  	var div_next	= this._id_datepicker_next;
  	var div_prev	= this._id_datepicker_prev;
  	var div_hdr	= this._id_datepicker_hdr;
  }
  /* next link */
  var a_next	= this._nextMonthYear();
  $(div_next).setAttribute('title', this.getMonthLocale(a_next[0])+' '+a_next[1]);
  /* prev link */
  var a_prev	= this._prevMonthYear();
  $(div_prev).setAttribute('title', this.getMonthLocale(a_prev[0])+' '+a_prev[1]);
  /* header */
  $(div_hdr).update('&nbsp;'+this.getMonthLocale(this._current_mon)+'&nbsp;'+this._current_year+'&nbsp;');
 }
};

/* Ferien fÃ¼r BundeslÃ¤nder mit anderer Class versehen, wenn man das Bundesland auswÃ¤hlt */

var lastbundesland = 0;
function load_holidays(bundesland, DIVID) {
	
	if(lastbundesland > 0) {
		if(Ferien[lastbundesland]) {
			var AlteFerien = Ferien[lastbundesland];
			for (var i = 0; i < AlteFerien.length; ++i) {
				var element = DIVID + '-' + AlteFerien[i];
				var element2 = DIVID + '_1-' + AlteFerien[i];
				if(document.getElementById(element)) document.getElementById(element).className = document.getElementById(element).className.replace('highlight');
				if(document.getElementById(element2)) document.getElementById(element2).className = document.getElementById(element2).className.replace('highlight');
			}
		}
	}

	if(bundesland > 0) {
		if(Ferien[bundesland]) {
			var NeueFerien = Ferien[bundesland];
			for (var i = 0; i < NeueFerien.length; ++i) {
				var element = DIVID + '-' + NeueFerien[i];
				var element2 = DIVID + '_1-' + NeueFerien[i];
				if(document.getElementById(element)) document.getElementById(element).className =  document.getElementById(element).className + " highlight";
				if(document.getElementById(element2)) document.getElementById(element2).className = document.getElementById(element2).className + " highlight";
			}
		}
	}
	
	lastbundesland = bundesland;
	load_activeElements();
}

/* Die 2 aktiven Tage markieren */

function load_activeElements() {
	if(activeElement != "") {
		if(document.getElementById(activeElement)) {
			oldelement = document.getElementById(activeElement);
			document.getElementById(activeElement).className = document.getElementById(activeElement).className + ' active';
		}
	}
	if(activeElement2 != "") {
		if(document.getElementById(activeElement2)) {
			oldelement2 = document.getElementById(activeElement2);
			document.getElementById(activeElement2).className = document.getElementById(activeElement2).className + ' active';
		}
	}
}
