﻿/*************************************************************************/
//
//		Landingpage Custom Scripts v2.0.02
//		Javascript Document
// 		2009 Copyright (c) GFB & Partner Marketing Services 
//		www.gfb.at
//		30.10.2009

//		24.11.2009 - calender logic
//
/*************************************************************************/



//--------------------------------------------------------------------------------------
// INIT 
//--------------------------------------------------------------------------------------
var globals = new Object();
// region colors
globals.borderColorList = 	["#3b89bd", "#d86262"];
globals.bgColorList = 		["#d9e9f7", "#f3d0d0"];

// nur gültig wenn es ein navigation für die Kategorieselektion gibt
globals.kategorieLUT = 		[
								['Baeren_5'],
								['Baeren_4'],
								['Baeren_3'],
								['kids'],							
								['teens']
							];

globals.regionLUT = new Array();

// Katalog ID
globals.katalogIDList = 	[];

// Xlayer Path
globals.xLayerPath = "http://cms.urlaubsanfragen.com/l_kamp/kwe_0926m.inc.php?id=";
globals.regionLayerPath = "";
globals.xLayerFilePrefix = "";

// Scroll to Xlayer
globals.scrollToXlayer = false;

// ----------------------------Flash Settings----------------------------
// Header
// Set path to  flash film for header
globals.headerFlashPath = "http://angebote.urlaubsanfragen.com/kwe/0926m/flash/flash_header.swf";//This is the flash file
globals.headerFlashDataFolder = "http://angebote.urlaubsanfragen.com/kwe/0926m/images/";//Flash looks in this folder for pictures
globals.headerFlashPicts = "sujet.jpg|sujet_1.jpg|sujet_2.jpg|sujet_3.jpg";//A formatted string to pass picuture file names
globals.headerFlashCheckpoint = "http://scnem.com/olt.php?sid=n10e.2pah4c,l=50332425";//URL when you click on the flash film
globals.headerFlash = {'version':'8.0.0', 'width':'970', 'height':'313' };

// Required Fields (Pflicht Felder)
// Wenn kein Pflicht feld (leere Liste) --> 'date'; []
globals.checkFieldsList = 	{
							'date':['form_P3','form_P4'], // kein Pflichtfeld 'form_P3','form_P4'
							'katalog':['form_ZIPCODE', 'form_CITY', 'form_COUNTRY', 'form_ADDRESS', 'form_STREETNUMBER'],
							'required':['form_SALUTATION', 'form_NAME', 'form_FIRSTNAME', 'form_EMAIL'],
							'partnerRequired': false	
							};
	
// Define Map Usage
globals.mapParam = 			{"mapPoint":true, "mapList":false};

globals.partnerList = 

	[
	 	{
		'title':		'Kinderhotel Benjamin',
		'kat': 			['Baeren_5'],
		'IDList':[],
		'region':		'', 
		'xlayer':		827, 
		'showOffers': [1],
		'countXlayer':		'http://scnem.com/olt.php?sid=nal5.2nje7og,l=50844032',
		'checkPoint':		'http://scnem.com/olt.php?sid=nalq.1087p6r,l=50844251'
		},	
		{
		'title':		'Baby und Kinder Hotel',
		'kat': 			['Baeren_5'],
		'IDList':[],
		'region':		'', 
		'xlayer':		826, 
		'showOffers': [1],
		'countXlayer':		'http://scnem.com/olt.php?sid=nal5.2nje7og,l=50844033',
		'checkPoint':		'http://scnem.com/olt.php?sid=nalq.1087p6r,l=50844252'
		},	
		{
		'title':		'Smileys Kinderhotel',
		'kat': 			['Baeren_5', 'kids'],
		'IDList':[],
		'region':		'', 
		'xlayer':		845, 
		'showOffers': [1],
		'countXlayer':		'http://scnem.com/olt.php?sid=nal5.2nje7og,l=50844034',
		'checkPoint':		'http://scnem.com/olt.php?sid=nalq.1087p6r,l=50844253'
		},	
		{
		'title':		'Falkensteiner Hotels',
		'kat': 			['Baeren_5', 'kids', 'teens'],
		'IDList':[],
		'region':		'', 
		'xlayer':		857, 
		'showOffers': [1],
		'countXlayer':		'http://scnem.com/olt.php?sid=nal5.2nje7og,l=50844035',
		'checkPoint':		'http://scnem.com/olt.php?sid=nalq.1087p6r,l=50844254'
		},	
		{
		'title':		'Hotel Brennseehof',
		'kat': 			['Baeren_5', 'kids', 'teens'],
		'IDList':[],
		'region':		'', 
		'xlayer':		840, 
		'showOffers': [1],
		'countXlayer':		'http://scnem.com/olt.php?sid=nal5.2nje7og,l=50844036',
		'checkPoint':		'http://scnem.com/olt.php?sid=nalq.1087p6r,l=50844255'
		},	
		{
		'title':		'Heidi-Hotel Falkertsee',
		'kat': 			['Baeren_5', 'kids', 'teens'],
		'IDList':[],
		'region':		'', 
		'xlayer':		838, 
		'showOffers': [1],
		'countXlayer':		'http://scnem.com/olt.php?sid=nal5.2nje7og,l=50844037',
		'checkPoint':		'http://scnem.com/olt.php?sid=nalq.1087p6r,l=50844256'
		},	
		{
		'title':		'Familien Feriendorf',
		'kat': 			['Baeren_5', 'kids'],
		'IDList':[],
		'region':		'', 
		'xlayer':		855, 
		'showOffers': [1],
		'countXlayer':		'http://scnem.com/olt.php?sid=nal5.2nje7og,l=50844232',
		'checkPoint':		'http://scnem.com/olt.php?sid=nalq.1087p6r,l=50844257'
		},	
		{
		'title':		'Hotel Kärntnerhof',
		'kat': 			['Baeren_5'],
		'IDList':[],
		'region':		'', 
		'xlayer':		849, 
		'showOffers': [1],
		'countXlayer':		'http://scnem.com/olt.php?sid=nal5.2nje7og,l=50844233',
		'checkPoint':		'http://scnem.com/olt.php?sid=nalq.1087p6r,l=50844258'
		},	
		{
		'title':		'Hotel Kürschner',
		'kat': 			['Baeren_5'],
		'IDList':[],
		'region':		'', 
		'xlayer':		850, 
		'showOffers': [1],
		'countXlayer':		'http://scnem.com/olt.php?sid=nal5.2nje7og,l=50844234',
		'checkPoint':		'http://scnem.com/olt.php?sid=nalq.1087p6r,l=50844259'
		},	
		{
		'title':		'Kinderhotel Ramsi',
		'kat': 			['Baeren_5', 'kids'],
		'IDList':[],
		'region':		'', 
		'xlayer':		852, 
		'showOffers': [1],
		'countXlayer':		'http://scnem.com/olt.php?sid=nal5.2nje7og,l=50844235',
		'checkPoint':		'http://scnem.com/olt.php?sid=nalq.1087p6r,l=50844260'
		},	
		{
		'title':		'Kinderhotel Hubertushof',
		'kat': 			['Baeren_5', 'kids', 'teens'],
		'IDList':[],
		'region':		'', 
		'xlayer':		842, 
		'showOffers': [1],
		'countXlayer':		'http://scnem.com/olt.php?sid=nal5.2nje7og,l=50844236',
		'checkPoint':		'http://scnem.com/olt.php?sid=nalq.1087p6r,l=50844261'
		},	
		{
		'title':		'Ginas Baby & Kinderhotel',
		'kat': 			['Baeren_5'],
		'IDList':[],
		'region':		'', 
		'xlayer':		853, 
		'showOffers': [1],
		'countXlayer':		'http://scnem.com/olt.php?sid=nal5.2nje7og,l=50844237',
		'checkPoint':		'http://scnem.com/olt.php?sid=nalq.1087p6r,l=50844262'
		},	
		{
		'title':		'Mountain Resort Feuerberg',
		'kat': 			['Baeren_5', 'kids', 'teens'],
		'IDList':[],
		'region':		'', 
		'xlayer':		843, 
		'showOffers': [1],
		'countXlayer':		'http://scnem.com/olt.php?sid=nal5.2nje7og,l=50844238',
		'checkPoint':		'http://scnem.com/olt.php?sid=nalq.1087p6r,l=50844263'
		},	
		{
		'title':		'Familienhotel Nockalm',
		'kat': 			['Baeren_5', 'kids'],
		'IDList':[],
		'region':		'', 
		'xlayer':		846, 
		'showOffers': [1],
		'countXlayer':		'http://scnem.com/olt.php?sid=nal5.2nje7og,l=50844239',
		'checkPoint':		'http://scnem.com/olt.php?sid=nalq.1087p6r,l=50844264'
		},	
		{
		'title':		'Ronacher Hotel "Die Post"',
		'kat': 			['Baeren_4', 'kids', 'teens'],
		'IDList':[],
		'region':		'', 
		'xlayer':		848, 
		'showOffers': [1],
		'countXlayer':		'http://scnem.com/olt.php?sid=nal5.2nje7og,l=50844240',
		'checkPoint':		'http://scnem.com/olt.php?sid=nalq.1087p6r,l=50844265'
		},	
		{
		'title':		'St. Urbanerhof',
		'kat': 			['Baeren_4', 'kids'],
		'IDList':[],
		'region':		'', 
		'xlayer':		856, 
		'showOffers': [1],
		'countXlayer':		'http://scnem.com/olt.php?sid=nal5.2nje7og,l=50844241',
		'checkPoint':		'http://scnem.com/olt.php?sid=nalq.1087p6r,l=50844266'
		},	
		{
		'title':		'Familienhotel Berghof',
		'kat': 			['Baeren_4'],
		'IDList':[],
		'region':		'', 
		'xlayer':		847, 
		'showOffers': [1],
		'countXlayer':		'http://scnem.com/olt.php?sid=nal5.2nje7og,l=50844242',
		'checkPoint':		'http://scnem.com/olt.php?sid=nalq.1087p6r,l=50844267'
		},	
		{
		'title':		'Glawischnig Hofer',
		'kat': 			['Baeren_4'],
		'IDList':[],
		'region':		'', 
		'xlayer':		828, 
		'showOffers': [1],
		'countXlayer':		'http://scnem.com/olt.php?sid=nal5.2nje7og,l=50844243',
		'checkPoint':		'http://scnem.com/olt.php?sid=nalq.1087p6r,l=50844268'
		},	
		{
		'title':		'Hotel Eschenhof',
		'kat': 			['Baeren_4'],
		'IDList':[],
		'region':		'', 
		'xlayer':		841, 
		'showOffers': [1],
		'countXlayer':		'http://scnem.com/olt.php?sid=nal5.2nje7og,l=50844244',
		'checkPoint':		'http://scnem.com/olt.php?sid=nalq.1087p6r,l=50844269'
		},	
		{
		'title':		'Dorfhotel Schönleitn',
		'kat': 			['Baeren_4', 'kids', 'teens'],
		'IDList':[],
		'region':		'', 
		'xlayer':		844, 
		'showOffers': [1],
		'countXlayer':		'http://scnem.com/olt.php?sid=nal5.2nje7og,l=50844245',
		'checkPoint':		'http://scnem.com/olt.php?sid=nalq.1087p6r,l=50844270'
		},	
		{
		'title':		'Familienhotel Koch',
		'kat': 			['Baeren_3', 'kids'],
		'IDList':[],
		'region':		'', 
		'xlayer':		829, 
		'showOffers': [1],
		'countXlayer':		'http://scnem.com/olt.php?sid=nal5.2nje7og,l=50844246',
		'checkPoint':		'http://scnem.com/olt.php?sid=nalq.1087p6r,l=50844271'
		},	
		{
		'title':		'Hochalmblick',
		'kat': 			['Baeren_3', 'kids'],
		'IDList':[],
		'region':		'', 
		'xlayer':		837, 
		'showOffers': [1],
		'countXlayer':		'http://scnem.com/olt.php?sid=nal5.2nje7og,l=50844247',
		'checkPoint':		'http://scnem.com/olt.php?sid=nalq.1087p6r,l=50844272'
		},	
		{
		'title':		'Gut Moserhof',
		'kat': 			['kids'],
		'IDList':[],
		'region':		'', 
		'xlayer':		825, 
		'showOffers': [1],
		'countXlayer':		'http://scnem.com/olt.php?sid=nal5.2nje7og,l=50844248',
		'checkPoint':		'http://scnem.com/olt.php?sid=nalq.1087p6r,l=50844273'
		},	
		{
		'title':		'Erlebnishotel Hinteregger',
		'kat': 			['kids'],
		'IDList':[],
		'region':		'', 
		'xlayer':		854, 
		'showOffers': [1],
		'countXlayer':		'http://scnem.com/olt.php?sid=nal5.2nje7og,l=50844249',
		'checkPoint':		'http://scnem.com/olt.php?sid=nalq.1087p6r,l=50844274'
		}
		
	];

globals.partnerCBList = new Array(); //search "SET partnerCBList"
globals.xLayerNum = null;
globals.regionDivList = new Array();
globals.formPartnerList = new Array();
globals.xLayerCBList = new Array();
globals.navColl = new Array();
globals.randomKategorieLUT = new Array();
globals.cbParentList = new Array();
globals.iFrame = true;
globals.currentIndex = null;
globals.setCB = true;
//--------------------------------------------------------------------------------------------------------
// INIT CHECKBOXES
//--------------------------------------------------------------------------------------------------------


function initIDs(){
	
	//	GLOBAL list of 'Selected Offers' elements in the form	
	var formPartnerListElement = document.getElementById('formular_partner_list');
	globals.partnerNavigationList = [];
	// Group List
	globals.groupList = new Object();
	
	
	var partnerNavigationColl = document.getElementById('scnemCheckBoxes').getElementsByTagName('div');
	
	var checkBoxCollection = document.getElementById('checboxArea').getElementsByTagName('input');
	
	
	for(var thisCB = 0; checkBoxCollection[thisCB]; thisCB++){
		currentCB = checkBoxCollection[thisCB];
		if ( currentCB.type == 'checkbox' ){globals.partnerCBList.push(currentCB)}
	}
	
	var i = 0;
	var thumbCounter = 1;
	
	// add functionality to scnetworks checkboxes
	for(var iterator = 0; partnerNavigationColl[iterator]; iterator++){	
	
	
		
		if(partnerNavigationColl[iterator].className.indexOf('cbParent')>=0){	

			var currentParent = partnerNavigationColl[iterator];
			
			//SET Kategorie Class Name
			var divList = currentParent.getElementsByTagName('div');			
			
			for (var thisDiv = 0;  divList[thisDiv]; thisDiv++ ){
				//console.log('divList[thisDiv]: ', thisDiv, divList[thisDiv]);
				if(divList[thisDiv].className.indexOf('kategorie') >= 0){
					divList[thisDiv].className = divList[thisDiv].className + ' ' + globals.partnerList[i].kat;					
				}
				
			}
			
			// init single and multiple checkboxes
			var inputColl = currentParent.getElementsByTagName('input');
			var parentCB = new Array();
			
			
			
			for (thisInput = 0; inputColl[thisInput]; thisInput++){
				if (inputColl[thisInput].type = 'checkbox'){parentCB.push(inputColl[thisInput])}	
			}
			
			//console.log('Region: ',globals.partnerList[i].region, 'i = ', i);
			if(globals.regionLUT[globals.regionLUT.length-1] != globals.partnerList[i].region && globals.partnerList[i].region != 'x'){				
				globals.regionLUT.push(globals.partnerList[i].region);
				//console.log('Region LUT: ', globals.regionLUT);
				//document.getElementById(globals.partnerList[i].region).style.backgroundColor = globals.bgColorList[globals.regionLUT.length-1];	
			}
			
			// Dynamically add checkboxes to list
			var nrOfCB = globals.partnerList[i].showOffers.length;
			for (var k=0; k<nrOfCB; k++){
				var tmpCb = globals.partnerCBList[k+(i*nrOfCB)]
				globals.partnerList[i].IDList.push(tmpCb);
			}
			
						
			var baseClass = currentParent.className;
			
			currentParent.normalClassName = baseClass;
			currentParent.overClassName = baseClass + " over";
			currentParent.hiliteClassName = baseClass + " hilite";
			currentParent.selectedClassName = baseClass + " selected";
			
			
			currentParent.cb = null;
			
								
			for (var thisOffer = 0; thisOffer < globals.partnerList[i].showOffers.length; thisOffer++){
					parentCB[0].name = globals.partnerList[i].IDList[thisOffer].name;
					parentCB[0].index = i;
					currentParent.cb = parentCB[0];	
					currentParent.offerCB = globals.partnerList[i].IDList[thisOffer];
					globals.partnerList[i].cb = parentCB[0];				
			}
			
			currentParent.xlayer = globals.partnerList[i].xlayer;
			currentParent.index = i;
			currentParent.style.cursor = 'pointer';
			globals.partnerList[i].div = currentParent;	
			
			// // Add behavior to cbParent
			addListener(currentParent, "mouseover", cbOver);
			addListener(currentParent, "mouseout", cbOut);
			addListener(currentParent, "click", pseudoCbClick);
			if(globals.scrollToXlayer){addListener(currentParent, "click", scrollPage)}	
			
			
						
			var xlayerNum = globals.partnerList[i].xlayer.toString();
			if(xlayerNum.length == 1){xlayerNum = "0"+xlayerNum;}		
			
			// Fill Name
			var thisColl = currentParent.getElementsByTagName("strong");
			thisColl[0].innerHTML = globals.partnerList[i].title;
			
			
			
			// Set Thumb Image Src
			thisColl = currentParent.getElementsByTagName("img");
			thisColl[0].src = 'http://cms.urlaubsanfragen.com/contrance/module/std_Dom/images/' + xlayerNum + '_3.jpg';
			
			//console.log(thisColl);
			
		
		}else{
			// error check authoring
			//console.log("missing: "+ partnerNavigationColl[i].className + i);
			continue;
		}
					
		
		//Dynamically create List in Form to show selected Partner				
		var formListEl = document.createElement("li");
		var inputEl = document.createElement("input");
		var label = document.createElement("label");
		
		inputEl.type = "checkbox";
		
		//inputEl.name = thisCheckBox.name;
		inputEl.name = "formCB";
		inputEl.id =  "fcb"+i;	
		inputEl.index = i;	
		
		//inputEl.checked = thisCheckBox.checked;		
		inputEl.style.cursor = "pointer";
		
		//label.htmlFor = "fcb"+i;		
		label.style.cursor = "pointer";
		label.innerHTML = globals.partnerList[i].title;
		label.index = i;
		label.region = globals.partnerList[i].region;
		label.xlayer = globals.partnerList[i].xlayer;
				
		formListEl.appendChild(inputEl);
		formListEl.appendChild(label);
		//label.appendChild(text)
		formPartnerListElement.appendChild(formListEl);
		
		// Add behavior to list elements 
		addListener(inputEl, "click", fixCheckbox);	
		addListener(label, "click", 
								function(){
								showXlayer(this.xlayer, this.region)
								}
					);
		
		
		globals.formPartnerList.push(inputEl)
		
		
		i++;
	}
	
	//console.log('DIV count' + globals.partnerNavigationList.length);

	
}


//--------------------------------------------------------------------------------------------------------
// INTERACTIVE MAP
//--------------------------------------------------------------------------------------------------------

function initMap(){
	
	var paramObj = globals.mapParam;
	// make a list of map list elements

	if(paramObj.mapList){globals.mapListColl = document.getElementById('mapList').getElementsByTagName('li')};
	
	if(paramObj.mapPoint){globals.mapPointColl = document.getElementById('mapPoints').getElementsByTagName('div')};
		

	if(paramObj.mapList){
		for(var i=0; globals.mapListColl[i]; i++){
			
				globals.partnerList[i].div.mapList = globals.mapListColl[i];
				

				// Properties of Map List Regions
				if(paramObj.mapPoint){globals.mapListColl[i].mapElement = globals.mapPointColl[i]}

				globals.mapListColl[i].xlayer = globals.partnerList[i].xlayer;
				globals.mapListColl[i].region = globals.partnerList[i].region;
				globals.mapListColl[i].normalClassName = "";
				globals.mapListColl[i].overClassName = "over";
				globals.mapListColl[i].hiliteClassName = "hilite";
				globals.mapListColl[i].cbParent = globals.partnerList[i].div;


				//Add Text to Element
				globals.mapListColl[i].innerHTML += globals.partnerList[i].title;
				globals.partnerList[i].title = globals.mapListColl[i].childNodes[1].nodeValue;
				

				// Behavior
				addListener(globals.mapListColl[i], "mouseover", mapListOver);
				addListener(globals.mapListColl[i], "mouseout", mapListOut);
				if(globals.scrollToXlayer){addListener(globals.mapListColl[i], "click", scrollPage)}

				

				addListener(globals.mapListColl[i], "click", function(){
										selectXlayer(this.xlayer);
										showHotels(this.region);
										});

				

		}

	}

		

	if(paramObj.mapPoint){

		for(var i=0; globals.mapPointColl[i]; i++){	
		
			

			globals.partnerList[i].div.mapPoint = globals.formPartnerList[i].parentNode.mapPoint = globals.mapPointColl[i];	

			// Properties of Map Points
			if(paramObj.mapList){globals.mapPointColl[i].listElement = globals.mapListColl[i]}

			globals.mapPointColl[i].xlayer = globals.partnerList[i].xlayer;
			globals.mapPointColl[i].region = globals.partnerList[i].region;
			globals.mapPointColl[i].cbParent = globals.partnerList[i].div;
			
			
			globals.mapPointColl[i].innerHTML = i+1;
			var posClass = "pos"+(i+1);			
			globals.mapPointColl[i].className = "mapPoint" + " " + posClass;
			globals.mapPointColl[i].normalClassName = globals.mapPointColl[i].className;
			globals.mapPointColl[i].overClassName = "mapPoint over" + " " + posClass;
			globals.mapPointColl[i].hiliteClassName = "mapPoint " +  posClass +  " hilite";
			globals.mapPointColl[i].selectedClassName = "mapPoint " +  posClass +  " selected";
			
			// Behavior
			addListener(globals.mapPointColl[i], "mouseover", mapOver);
			addListener(globals.mapPointColl[i], "mouseout", mapOut);
			if(globals.scrollToXlayer){addListener(globals.mapPointColl[i], "click", scrollPage)}
			
			addListener(globals.mapPointColl[i], "click", function(){
									selectXlayer(this.xlayer);
									showHotels(this.region);
									});
		}
	}
};

function mapListOver(e){
	var obj = e.target;		
	if(obj.nodeName == "LI"){
		if(obj.className != obj.hiliteClassName){
			obj.className = obj.overClassName;
			if(obj.mapElement){obj.mapElement.className = obj.mapElement.overClassName}
		}
		if(obj.cbParent){obj.cbParent.className = obj.cbParent.overClassName}
	}
	};



function mapListOut(e){
	var obj = e.target;		
	resetMapElements(true);
	if(obj.cbParent){
		if(obj.cbParent.className != obj.cbParent.hiliteClassName){
			obj.cbParent.className = obj.cbParent.normalClassName
		}
	}
};



function mapOut(e){
	resetMapElements(false);
};



function mapOver(e){
	var obj = e.target;
	//console.log('ClassName at over: ' + obj.className + ' . ' + obj.selectedClassName);
	if(obj.className != obj.hiliteClassName && obj.className != obj.selectedClassName){
		obj.className = obj.overClassName;
		if(obj.listElement){obj.listElement.className = obj.listElement.overClassName}
	}
	if(obj.cbParent){
		if(obj.cbParent.className != obj.cbParent.hiliteClassName && obj.cbParent.className != obj.cbParent.selectedClassName){
			obj.cbParent.className = obj.cbParent.overClassName
		}
	}
};



function cbOut(e){
	

	var currentParent = e.target;

	while(currentParent.className.indexOf('cbParent') < 0){
		currentParent = currentParent.parentNode;
		if(currentParent.nodeType !=1){alert("input field " + thisCheckBox.id + " must be inside a 'div' with a className of 'cbParent'");break}
	}

	if(currentParent.className != currentParent.hiliteClassName && currentParent.className != currentParent.selectedClassName){
		currentParent.className = currentParent.normalClassName
	}

	if(currentParent.mapPoint){
		if(currentParent.mapPoint.className != currentParent.mapPoint.hiliteClassName && currentParent.mapPoint.className != currentParent.mapPoint.selectedClassName){
		currentParent.mapPoint.className = currentParent.mapPoint.normalClassName
		}
	};

	if(currentParent.mapList){
		if(currentParent.mapList.className != currentParent.mapList.hiliteClassName){
		currentParent.mapList.className = currentParent.mapList.normalClassName
		}
	};
	
	
};



function cbOver(e){
	var currentParent = e.target;	
	while(currentParent.className.indexOf('cbParent') < 0){
		currentParent = currentParent.parentNode;
		if(currentParent.nodeType !=1){alert("input field " + thisCheckBox.id + " must be inside a 'div' with a className of 'cbParent'");break}
	}

	if(currentParent.className != currentParent.hiliteClassName && currentParent.className != currentParent.selectedClassName){
		currentParent.className = currentParent.overClassName;
	}

	if(currentParent.mapPoint){
		if(currentParent.mapPoint.className != currentParent.mapPoint.hiliteClassName && currentParent.mapPoint.className != currentParent.mapPoint.selectedClassName ){
		currentParent.mapPoint.className = currentParent.mapPoint.overClassName
		}
	};

	if(currentParent.mapList){
		if(currentParent.mapList.className != currentParent.mapList.hiliteClassName){
		currentParent.mapList.className = currentParent.mapList.overClassName
		}
	};
};


//--------------------------------------------------------------------------------------------------------
// Categorie NAV
//--------------------------------------------------------------------------------------------------------
function initRegionNav(){
	
	
	var navColl = document.getElementById('regionNavigation').getElementsByTagName('li');
	var counter = 0;
	
	for ( var i = 0;navColl[i]; i++){
		
			//console.log(globals.navColl);
			if( navColl[i].className.indexOf('navTab') < 0){ continue;}
			
		
			globals.navColl.push(navColl[i]);
			
			// Properties of Nav List
			globals.navColl[i].region = globals.regionLUT[counter];	
			globals.navColl[i].index = counter;	
			counter++;
			
			globals.regionDivList.push(document.getElementById(globals.navColl[i].region));
			//console.log(globals.regionDivList);
			
			
			addListener(globals.navColl[i], "click", function(){	
								showHotels(this.region, true); // true oder false wenn xLayer bei klick auf initNav rotieren soll
								this.className = this.selectedClassName;	
								});
			
			
			globals.navColl[i].normalClassName = globals.navColl[i].className;
			globals.navColl[i].overClassName = globals.navColl[i].className + " over";
			globals.navColl[i].hiliteClassName = globals.navColl[i].className + " hilite";
			globals.navColl[i].selectedClassName = globals.navColl[i].className + "selected";
			
			globals.navColl[i].style.cursor = 'pointer';
			
			//if(i==0){globals.navColl[i].className = globals.navColl[i].selectedClassName}
		
			
	}
	
	
}

function initCatNav(){
	
	
	globals.kategorieObj = new Object();	
	globals.kategorieObj.hiddenDivs = new Array();	
	globals.kategorieObj.btnList = new Array();
	
	var navColl = document.getElementById('CatNav').getElementsByTagName('li');	
	//console.log('NavColl: ', navColl);
	
	var currentIndex = 0;
	
	for ( var i = 0;navColl[i]; i++){
		
			
			if( navColl[currentIndex].className.indexOf('navBtn') < 0 ){ continue;}
						
			globals.kategorieObj.btnList.push(navColl[currentIndex]);			
			navColl[currentIndex].kat = globals.kategorieLUT.splice(0,1)[0];
			globals.randomKategorieLUT.push(navColl[currentIndex].kat);
			navColl[currentIndex].style.cursor = 'pointer';
			navColl[currentIndex].normalClassName = navColl[currentIndex].className;
			navColl[currentIndex].overClassName = navColl[currentIndex].className + " over";
			navColl[currentIndex].hiliteClassName = navColl[currentIndex].className + " hilite";
			navColl[currentIndex].selectedClassName = navColl[currentIndex].className + " selected" + i;
			
			
			//if( i == 0){navColl[currentIndex].className = navColl[0].selectedClassName; }
			var scnemCheckBoxes = document.getElementById('scnemCheckBoxes');
			var pageBtn = document.getElementById('pageBtn');
			pageBtn.div = scnemCheckBoxes;
			
			addListener(navColl[i], "click", function(){
													  
				for(thisBtn in globals.kategorieObj.btnList){globals.kategorieObj.btnList[thisBtn].className = globals.kategorieObj.btnList[thisBtn].normalClassName}
				this.className = this.selectedClassName;
				updateCatNavColor();
				// set all to none
				for(var thisCB = 0; globals.partnerList[thisCB]; thisCB++){	
					globals.partnerList[thisCB].div.style.display = 'none'; 
					globals.partnerList[thisCB].div.mapPoint.style.display = 'none';
					}
				
				
				// now turn some on
				
				var displayValue = 'block'; // or 'inline'
				
				var tmpDivList = new Array();
				
				for(thisCB = 0; globals.partnerList[thisCB]; thisCB++){									
					for(thisKat in this.kat){
						//console.log('thisKat: ', this.kat[thisKat]);
						if ( this.kat[thisKat] == 'alle' ) {globals.partnerList[thisCB].div.style.display = displayValue; continue;}
						for( cbKat in globals.partnerList[thisCB].kat){
							//console.log('cbKat: ', globals.partnerList[thisCB].kat[cbKat]);
							if ( this.kat[thisKat] == globals.partnerList[thisCB].kat[cbKat]) { 								
								globals.partnerList[thisCB].div.style.display = displayValue;
								if(globals.mapParam.mapPoint){globals.partnerList[thisCB].div.mapPoint.style.display = displayValue;}
								tmpDivList.push(globals.partnerList[thisCB]);
							}
						}
					}
				}
				
				// Page Btn
				
				pageBtn.style.display = 'none';
				pageBtn.div.scrollTop = 0;
				pageBtn.style.backgroundPosition = '0px 0px';
				
				if(scnemCheckBoxes.scrollHeight > 540){
					pageBtn.style.display = 'block';
					
					}
				
				// select a the first partner from the current category				
				var divCollection = document.getElementById('scnemCheckBoxes').getElementsByTagName('div');				
				for(var i=0;divCollection[i];i++){
					if(divCollection[i].className.indexOf('cbParent') >= 0 && divCollection[i].style.display == displayValue){
						globals.setCB = false;
						selectXlayer(divCollection[i].xlayer);
						break;
					}	
				}
				
			});	
			
			//console.log(scnemCheckBoxes.scrollTop);scnemCheckBoxes.scrollTop = 300;
			pageBtn.style.cursor = 'pointer';
			addListener(pageBtn, "click", scrollDiv);	
		
	currentIndex ++;
	}
	
	
}

// Cat Nav Events paging

function scrollDiv(e){											  
	 this.div.scrollTop = this.div.scrollHeight;
	 this.style.backgroundPosition = '-93px 0px';
	 removeListener(this, "click", scrollDiv);
	 addListener(this, "click", resetScrollDiv);
	  
 }
 
 function resetScrollDiv(e){											  
	 this.div.scrollTop = 0;
	 this.style.backgroundPosition = '0px 0px';
	 removeListener(this, "click", resetScrollDiv);
	 addListener(this, "click", scrollDiv);
	  
 }



function resetMapElements($all){
	
	
	for(var i=0; globals.partnerList[i]; i++){	
	
		if(globals.partnerList[i].div.className == globals.partnerList[i].div.hiliteClassName ){				
				if(!$all){continue}
		}
		
		
		globals.partnerList[i].div.className = globals.partnerList[i].div.normalClassName;
		
		if(globals.partnerList[i].xlayer == globals.xLayerNum){	
			globals.partnerList[i].div.className = globals.partnerList[i].div.selectedClassName;
		}
		
	
	}
	
	if(globals.mapParam.mapPoint){
		for(var i=0; globals.mapPointColl[i]; i++){
			if(globals.mapPointColl[i].className == globals.mapPointColl[i].hiliteClassName || globals.mapPointColl[i].className == globals.mapPointColl[i].selectedClassName){
				if(!$all){continue}
			}
			globals.mapPointColl[i].className = globals.mapPointColl[i].normalClassName;
		}
	}

	if(globals.mapParam.mapList){
		for(var i=0; globals.mapListColl[i]; i++){
			if(globals.mapListColl[i].className == globals.mapListColl[i].hiliteClassName || globals.mapListColl[i].className == globals.mapPointColl[i].selectedClassName){
				if(!$all){continue}
			}
			globals.mapListColl[i].className = globals.mapListColl[i].normalClassName
		}
	}
	
};


//--------------------------------------------------------------------------------------------------------
// MOUSE INTERACTION
//--------------------------------------------------------------------------------------------------------

function pseudoCbClick(e){
	
	globals.currentIndex = this.index;
	
	//globals.currentIndex = window.event.srcElement || e.currentTarget.index;
	
	
	resetMapElements(false);	
	
	if(this.hiliteClassName){this.className = this.hiliteClassName}	
	//globals.partnerList[this.index].IDList[0].checked = true;
	
	if(this.cb){
		
		//console.log('pseudoClick Target: ', e.target, e.target.type);
		
		if(e.target.type == 'checkbox'){
			if (e.target.checked == false){
				//console.log('pseudo cb');
				this.offerCB.checked = e.target.checked;				
				//console.log('FALSE: ' + e.target.checked)
				for (var i = 0; i < globals.partnerList[this.index].IDList.length; i++){
					globals.partnerList[this.index].IDList[i].checked = false;					
				}
				fixCheckbox({index:this.index, type:'thumbCB', checked:false});	
			}else{
				
				selectXlayer(this.xlayer);	
			}
			
		}else{		
			if(this.xlayer){
				//globals.partnerList[this.index].cb.checked = true;
//				globals.partnerList[this.index].IDList[0].checked = true;	
				selectXlayer(this.xlayer);
			}
		}
	}
	
	
	
};

function remoteKatClick(wKat){	
	for(i=0; globals.kategorieObj.btnList[i]; i++){
		if(globals.kategorieObj.btnList[i].kat == wKat){
			sendClickEvent(globals.kategorieObj.btnList[i]);
			break;
		}
	}
}
				

//--------------------------------------------------------------------------------------------------------
// DISPLAY CONTROLS
//--------------------------------------------------------------------------------------------------------	
function selectDeparture(e){
	if(document.getElementById('form_P3').value.length ){
			document.forms[0].form_P4.value = "";
			globals.abreiseCalendar.moveTo(globals.nextDate, true);					
		}else{
			alert('Bitte wählen Sie zuerst das Anreisedatum aus.');
		}	
}

function scrollPage(e){	
		var yScroll = getElementPos(document.getElementById("remote_container"))['y'];
		windowScroller.startScroll({start:getScrollXY()["y"], end:yScroll});
};


function selectXlayer(wXlayer){
	globals.xLayerNum = wXlayer;
	var thisIndex = getPartnerIndex('xlayer', wXlayer);
	globals.currentIndex = thisIndex;
	globals.currentNumber = globals.partnerList[thisIndex].div.number;
	asyncRequest.asyncRequest("GET", '/urlwrapper.php?url='+ globals.xLayerPath + wXlayer,  updateContent );
	//asyncRequest("GET", '/urlwrapper.php?url='+ globals.xLayerPath + globals.xLayerFilePrefix + wXlayer + '.html',  updateContent );
};

function getRegionLayer(wXlayer){
	regionRequest("GET", '/urlwrapper.php?url='+ globals.regionLayerPath + wXlayer,  UpdateRegionLayer );
};

function getWeather(){
	var myDate=new Date()
	var dateArrayFrom = [myDate.getDate(), myDate.getMonth()+1, myDate.getFullYear()];
	myDate.setDate(myDate.getDate()+5);
	var dateArrayTo = [myDate.getDate(), myDate.getMonth()+1, myDate.getFullYear()+1];
	var weatherLink = 'http://www.kaernten.at/de.aspx/Wetter/WeatherReload/'+dateArrayFrom.join(".")+'/to/'+dateArrayTo.join(".")+'/filter';
	var weatherRequest = new ajaxClass();
	weatherRequest.asyncRequest("GET", '/urlwrapper.php?url='+ weatherLink,  showWeather );
};


function showHotels(wRegion, selectRandomLayer){
	

	for (var regionLUTindex = 0; globals.regionLUT[regionLUTindex]; regionLUTindex++){
		if (wRegion == globals.regionLUT[regionLUTindex]){globals.regionColor = regionLUTindex;}
	}
	
	//	regionLayerLUT = [763, 759, 760, 761, 762, 755 ]
	//	getRegionLayer(regionLayerLUT[regionID]);



	//	document.getElementById('centerColumn').style.backgroundColor = globals.bgColorList[regionID];
	//	document.getElementById('arrowLong').style.backgroundPosition = '0px -' + (regionID*26) + 'px';
	//	document.getElementById('xlayerArrow').style.backgroundPosition = '0px -' + (regionID*42) + 'px';
	
	updateCatNavColor();
	
	
	for(var j=0; j<globals.navColl.length; j++){		
		globals.navColl[j].className = globals.navColl[j].normalClassName
		if( globals.navColl[j].region == wRegion){globals.navColl[j].className = globals.navColl[j].selectedClassName}		
		}
	
	var xlayerList = new Array();	
	for(var i=0;globals.partnerList[i];i++){
		if(globals.partnerList[i].region == wRegion){
			xlayerList.push(globals.partnerList[i]);
		}	
	}
	
	if ( xlayerList.length && selectRandomLayer ) {
		//var randomIndex = Math.floor( Math.random()*xlayerList.length );
		//globals.currentIndex = xlayerList[ randomIndex ].div.index;		
		//selectXlayer( xlayerList[ randomIndex ].xlayer );
		//xlayerList[ randomIndex ].div.className = xlayerList[ randomIndex ].div.selectedClassName 
		
		var randomIndex = 0;
		globals.setCB = false;
		globals.currentIndex = xlayerList[ randomIndex ].div.index;		
		selectXlayer( xlayerList[ randomIndex ].xlayer );
		xlayerList[ randomIndex ].div.className = xlayerList[ randomIndex ].div.selectedClassName 
	}
	
	//console.log('show hotels', globals.regionDivList);
	
	for(i=0; globals.regionDivList[i];i++){
		//console.log(globals.regionDivList[i].id);
			if(globals.regionDivList[i].id == wRegion){
				globals.regionDivList[i].style.display = 'block';
				}
			else{
				globals.regionDivList[i].style.display = 'none';
				}
		
		}

};

function showXlayer(wLayer, wRegion){	
	showHotels(wRegion);
	selectXlayer(wLayer);
		
}

function limitRegionViewTo(wRegion){ return null;};	

function hideHotelAngebote(wCont,LUTindex){
	
	// make a list of divs with the classname 'regionCont'
	var divCollection = document.getElementById(wCont).getElementsByTagName('div');
	var regionCountDivList = new Array();	
	for (i = divCollection.length - 1; i >=	0; i--){		
		if(divCollection[i].className == 'regionCont'){
			regionCountDivList.push(divCollection[i]);							
		}
		if(divCollection[i].className == 'angebotslink'){
			divCollection[i].style.display = 'none';							
		}
	}
	
	regionCountDivList.reverse();
	
	for(i = 0; i < regionCountDivList.length; i++){
		if(i != LUTindex) {
			regionCountDivList[i].style.display = 'none';
		}else{
			regionCountDivList[i].style.width = '475px';
		}
	}
};

function hideRegionAngebote(wCont,LUTindex){
	
	// make a list of divs with the classname 'regionCont'
	var divCollection = document.getElementById(wCont).getElementsByTagName('div');
	var regionCountDivList = new Array();	
	for (var i = divCollection.length - 1; i >=	0; i--){		
		if(divCollection[i].className == 'regionCont'){
			regionCountDivList.push(divCollection[i]);							
		}
	}
	
	regionCountDivList.reverse();
	
	

	for( i = 0; regionCountDivList[i]; i++){
		var cbParentDivList = new Array();
		for(var thisNode in regionCountDivList[i].childNodes){	
			var currentNode = regionCountDivList[i].childNodes[thisNode];
			if(currentNode.className){
				if( currentNode.className.indexOf('cbParent') >=0 ){ cbParentDivList.push(currentNode); }
			}
		}
		for ( var j = 0; cbParentDivList[j]; j++){
			if(j!=LUTindex){ cbParentDivList[j].style.display='none' }
		}
	}
};

function showMapLayer(){
	document.getElementById('mapLayer').getElementsByTagName('img')[0].src = 'http://angebote.urlaubsanfragen.com/tms/0906m/tol/images/kartetirol.gif';
	blendeAngebotEin('mapLayer', {x:347, y:5})
	}

function hideMapLayer(wElement){
	blendeAngebotAus(wElement.id, {x:100, y:40})
	}
	
	
	
		
function updateCatNavColor(colorIndex){
	
	return;
	
	var katBtns = document.getElementById('katBox').getElementsByTagName('div');
	
	for(var thisBtn = 0; katBtns[thisBtn]; thisBtn++ ){
		if(katBtns[thisBtn].className.indexOf('selected') >= 0){
			katBtns[thisBtn].style.borderLeft = '5px solid ' + globals.borderColorList[globals.regionColor];
			katBtns[thisBtn].style.borderTop = '1px solid ' + globals.borderColorList[globals.regionColor];
			katBtns[thisBtn].style.borderBottom = '1px solid ' + globals.borderColorList[globals.regionColor];
		}else{	
			katBtns[thisBtn].style.borderLeft = '';
			katBtns[thisBtn].style.borderTop = '';
			katBtns[thisBtn].style.borderBottom = '';
			katBtns[thisBtn].className = 'katBtn';
		}
	}
	
	
};


//--------------------------------------------------------------------------------------------------------
// XLAYER RELATED
//--------------------------------------------------------------------------------------------------------



function updateContent(myResponse){
	
	
	pC = document.getElementById("remote_container");
	
	
	
	if(pC){
		
		globals.xLayerCBList = new Array();
		
		pC.style.display = "block";
		
		pC.innerHTML = myResponse.responseText;
		
		crossDomainIframeResize();
		
		var index = globals.currentIndex;
				
		// Find Checkbox in xLayer and add click
		// Checkbox must have correct form_id as name!
		var cbColl = pC.getElementsByTagName("input");	
	
		if(cbColl.length == 1){
			// all checkboxes are created equal
			
			for(var i=0; cbColl[i]; i++){				
				if(cbColl[i].type == "checkbox"){
					//console.log('checked? ', cbColl[i].checked);
					globals.xLayerCBList.push(cbColl[i]);
					addListener(cbColl[i], "click", fixCheckbox);
					cbColl[i].style.cursor = "pointer";
					var value=globals.partnerList[index].cb;					
					cbColl[i].name = value.name;
					//cbColl[i].id = "cb"+ value.id;
					cbColl[i].index = index;
					cbColl[i].checkBox = value;
				}
			}			
			
		}else{
			
			var deltaIndex = index - (( globals.partnerList[index].showOffers[0]-1) * 5)
			
			for(var i=0; cbColl[i]; i++){				
				if(cbColl[i].type == "checkbox"){	
					var newIndex = deltaIndex + (i*5)
					globals.xLayerCBList.push(cbColl[i]);
					addListener(cbColl[i], "click", fixCheckbox);
					cbColl[i].style.cursor = "pointer";
					var value=globals.partnerList[newIndex].cb;				
					cbColl[i].name = value.name;
					//cbColl[i].id = "cb"+ value.newIndex;
					cbColl[i].index = newIndex;
					cbColl[i].checkBox = value;
				}
			}
			
		}
		
		
		fixCheckbox({index:index});
		
		
		// set labels
		var labelColl = pC.getElementsByTagName("label");
		for(var i=0; labelColl[i]; i++){			
			if(index >= 0 && i < globals.partnerList[index].IDList.length){
				var value=globals.partnerList[index].IDList[i];
				labelColl[i].htmlFor = "cb"+value.id;
				labelColl[i].style.cursor = "pointer";
			}
		}
		
		// set Number in Span
		var spanColl = pC.getElementsByTagName("span");
		for(var i=0; spanColl[i]; i++){			
				spanColl[i].innerHTML = globals.currentNumber;
		}
		
		
		// Find Image in xLayer and add click
		var imgColl = pC.getElementsByTagName("img");
		for(var i=0; imgColl[i]; i++){
			imgColl[i].style.cursor = "pointer";
			imgColl[i].url = value=globals.partnerList[index].checkPoint;
			addListener(imgColl[i], "click", function(){
							if(index >= 0){
								if(this.url){
									goPartnerPage(this.url);
								}else{
									//this.cbID.click();
								}
							}
						})
		}
		
		var aColl = pC.getElementsByTagName("a");
		for(var i=0; aColl[i]; i++){			
				aColl[i].style.cursor = "pointer";				
				//aColl[i].href = globals.partnerList[index][aColl[i].rel];
				var linkText = aColl[i].innerHTML;
				aColl[i].href = globals.partnerList[index].checkPoint;
				aColl[i].innerHTML = linkText;
		};
		
		// insert Flash	
		var flashContainer = document.getElementById('insertFlash');
		if(flashContainer){
			insertXlayerFlash(flashContainer);	
		}
		
		// Change src of invisible iFrame to trigger tracking of the xlayers
		document.getElementById('countXlayer').src = globals.partnerList[index].countXlayer;	
		
		for(var thisRegion = 0; globals.regionLUT[thisRegion]; thisRegion++){	
			if(globals.regionLUT[thisRegion] == globals.partnerList[index].region){
				var xlayerDivColl = pC.getElementsByTagName("div");
				for (i=0; xlayerDivColl[i]; i++){
					
					// Background color list
					if(xlayerDivColl[i].id.indexOf('xlayerContainer') >=0){
						
						xlayerDivColl[i].style.backgroundColor = globals.bgColorList[globals.regionColor];
						xlayerDivColl[i].style.borderColor = globals.bgColorList[globals.regionColor];
					}
					
					
					// Border Color list
					if(xlayerDivColl[i].className.indexOf('angebot') >=0){
						xlayerDivColl[i].style.backgroundColor = globals.borderColorList[globals.regionColor];
					}
					if(xlayerDivColl[i].className.indexOf('hotelNumber') >=0){
						xlayerDivColl[i].style.backgroundColor = globals.borderColorList[globals.regionColor];
						xlayerDivColl[i].innerHTML = globals.currentNumber;
					}
					
				}
					
				
				break;
			}
		}

	}
	
	
};
function showWeather(myResponse){
	
	var weatherCont = document.getElementById('weather');
 	weatherCont.innerHTML = myResponse.responseText;
	
	imgColl = weatherCont.getElementsByTagName('img');
	
	for(var thisIndex = 0; imgColl[thisIndex]; thisIndex++){
		var file = (imgColl[thisIndex].src).substring(imgColl[thisIndex].src.lastIndexOf('/')+1)
		imgColl[thisIndex].src = 'http://www.kaernten.at/Content/images/weather/small/' + file; 
		}
	
};

function UpdateRegionLayer(myResponse){
	var regionContainer = document.getElementById('regionInfo');
	regionContainer.innerHTML = myResponse.responseText;	
	}

function resetTools(){
		for(thisTool in toolList){toolList[thisTool].style.display = 'none'}
};

//------------------------------------------

function reNumberThumbs(wID){
	
	var divColl = document.getElementById(wID).getElementsByTagName('div');
	var i = 0;
	for(j=0; divColl[j]; j++){		
		if(divColl[j].className.indexOf('number') >=0){
			divColl[j].innerHTML = (i+1);
			divColl[j].parentNode.number = (i+1);
			if(divColl[j].parentNode.mapPoint){ divColl[j].parentNode.mapPoint.innerHTML = (i+1); }	
			i++;
		}		
	}
}


//--------------------------------------------------------------------------------------
// FILL FORMS
//--------------------------------------------------------------------------------------



function fillForms(){

	var formList = new Array();

	if(window.location.search != "") {
	     QUERYSTRING = window.location.search;
	     QUERYSTRING = QUERYSTRING.replace(/\?/,"");
		 
	     //trenne den querystring nach jedem & in teilstringe auf
	     var teilstrings = QUERYSTRING.split("&");

	     //durchlaufe jeden dieser teilstrings
	     for (i=0;i<teilstrings.length;i++) {
	         //trenne den teilsring in weiteren teilstring auf,
	         //trenne also formListnamen vom inhalt
	         vararr = teilstrings[i].split("=");
	         formList[vararr[0]] = vararr[1];
	      }

	}
        var formElementsCol = document.forms[0].elements
        for(thisElement=0;formElementsCol[thisElement];thisElement++)
        {
                var currentElement = formElementsCol[thisElement];
                var thisValue = formList["an_"+ currentElement.name];

		if(currentElement.value){
                                if(currentElement.value.length){
                                continue;
                                }

}

                if (thisValue != undefined){
					thisValue = unescape(thisValue);
					switch(formElementsCol[thisElement].type){
                        case "submit": break;
                        case "select-one":      currentElement.value            = thisValue ;break;
                        case "radio":           currentElement.checked          = thisValue ;break;
                        case "text":            currentElement.value            = thisValue ; break;
                        case "checkbox":        currentElement.checked          = thisValue ; break;
					}
                }
       }
};




function resetFormList(){
        formList = [];
        var formElementsCol = document.forms[0].elements
        for(thisElement=0;formElementsCol[thisElement];thisElement++)
        {
                var currentElement = formElementsCol[thisElement];
                thisValue = "";
                switch(currentElement.type)
                        {
                        case "submit": break;
                        case "select-one":      thisValue = currentElement.value                ; break;
                        case "radio":           thisValue = ""                                  ; break;
                        case "text":            thisValue = currentElement.value                ; break;
						case "hidden":          thisValue = currentElement.value                ; break;
                        case "checkbox":        thisValue = currentElement.checked              ; break;
                        }
                if(thisValue!="")formList[currentElement.name] = thisValue ;

        }
                return true;
};





function insertXlayerFlash(wDiv){	
	
	var id = wDiv.id;	
	var flashURL = globals.xLayerFlashPath;
	
	var partnerIndex = getPartnerIndex('xlayer',globals.xLayerNum);
	
	var filesString = "";
	if(partnerIndex >= 0){
		filesString=globals.partnerList[partnerIndex].flashPicts;
		}
		
	var checkPoint = "";
	if(partnerIndex >= 0){
		checkPoint=globals.partnerList[partnerIndex].checkPoint;
		}	
		
	
	var flashvars = {};	
	flashvars.files = filesString;
	flashvars.checkpoint = checkPoint;
	flashvars.path = globals.xLayerFlashDataFolder;
	flashvars.fadeSpeed = "2";	
	flashvars.pauseTime = "5";
		
	var params = {};
	params.allowfullscreen = "false";
	params.wmode = "transparent";
	params.scale = "noscale";
	params.align = "left";
	params.salign = "lt";
		
	var attributes = {};
	attributes.id = id;
	attributes.name = id;
		
	swfobject.embedSWF(flashURL, id, globals.xLayerFlash.width, globals.xLayerFlash.height, globals.xLayerFlash.version, "", flashvars, params, attributes);
	
	
};



//--------------------------------------------------------------------------------------
// EIN / AUSBLENDEN DER ANGEBOTE
//--------------------------------------------------------------------------------------
 
 var currentTween = null;
 
 
 function changeHeightUp(wAngebot) {
	 
	 if(currentTween){
	 	for( var i = 0; currentTween.objects[i]; i++){
		 	currentTween.objects[i].killTween = true;
		 }
	 }
			
      var el = document.getElementById(wAngebot);
	  var thisheight = el.origHeight

	  el.style.display = 'block';
	  
	  //console.log('blendeAngebotEin: ' ,el);
	  
	  currentTween = JSTweener.addTween(el.style, {
        time: 1,
        transition: 'easeInOutQuad',
		height:thisheight,
		suffix: {
	  		height:'px'
        },
		killTween:false
		
      });
			
 }; 

 
function changeHeightDown(wAngebot) {
	
	var einBlenden = (wAngebot == 'Gletscherhotels') ? 'weiterAngebote':'Gletscherhotels';
	 if(currentTween){
	 	for( var i = 0; currentTween.objects[i]; i++){
		 	currentTween.objects[i].killTween = true;
		 }
	 }
			
      var el = document.getElementById(wAngebot);
	  
	  //console.log('blendeAngebotAus: ' ,el);
	  
	  currentTween = JSTweener.addTween(el.style, {
        time: 1,
        transition: 'easeInOutQuad',
		height:0,
		suffix: {
	  		height:'px'
        },
		killTween:false,
		onComplete: function(){el.style.display = 'none'; blendeAngebotEin(einBlenden)}
		
      });
			
 };
 
 //--------------------------------------------------------------------------------------
// EIN / AUSBLENDEN DER Karte
//--------------------------------------------------------------------------------------
 
 blendeAngebotEin = function(wAngebot, point) {
	 
	 if(currentTween){
	 	for( var i = 0; currentTween.objects[i]; i++){
		 	currentTween.objects[i].killTween = true;
		 }
	 }
	
      var el = document.getElementById(wAngebot);
    
	  el.style.filter = "alpha(opacity=0)";
	  el.style.opacity = 0;
	  el.style.display = 'block'
	  
	  if(point){
		  
		el.style.top = point.y + 'px'
		el.style.left = point.x + 'px'
		
		}
    	  
	 currentTween = JSTweener.addTween(el.style, {
        time: .5,
        transition: 'easeInOutQuad',
		opacity:1,
		filter: 100,
		suffix: {
            filter:')',
	  		left:'px',
			top:'px'
        },
        prefix: {
            filter:'alpha(opacity='
        },
		killTween:false
		//,onComplete: function(){ document.body.removeChild(el)}
		
      });
	
	};
 
 blendeAngebotAus = function(wAngebot) {
	 
	 //<div><a onMouseOver="blendeAngebotEin('angebot1')" onMouseOut="blendeAngebotAus('angebot1')">Show this Angebot</a></div>
	//<div id='angebot1' style="display:none;background-color:red;">kldfjlkd flkdfl flkjfö klf lkf lkf öaföladjf dflksd kldflkafölkaj ölkadjf ö aljfölkajflkad flaöksjf lakdjflkadsf adöklfj alkdfj aölkdjf lakdjf kl</div>
		
	 
	 if(currentTween){
	 	for( var i = 0; currentTween.objects[i]; i++){
		 	currentTween.objects[i].killTween = true;
		 }
	 }
			
      var el = document.getElementById(wAngebot);
      
	  el.style.filter = "alpha(opacity=100)";
	  el.style.opacity = 1;
	  el.style.display = 'block'

	  currentTween = JSTweener.addTween(el.style, {
        time: .5,
        transition: 'easeInOutQuad',
		opacity:0,
		filter: 0,
		suffix: {
            filter:')',
	  		left:'px',
			top:'px'
        },
        prefix: {
            filter:'alpha(opacity='
        },
		killTween:false,
		onComplete: function(){el.style.display = 'none'}
		//,onComplete: function(){ document.body.removeChild(el)}
		
      });
			
 };
 
 
 
//--------------------------------------------------------------------------------------
// CROSS DOMAIN IFRAME
//--------------------------------------------------------------------------------------
function crossDomainIframeResize() {
	return;
	if(globals.iFrame == true){		
		var iframe = document.getElementById( 'inneriframe' );
		var height = Math.max( document.body.offsetHeight, document.body.scrollHeight );
		//console.log('resize iframe:', height);
		iframe.src = 'http://www.tirolergletscher.com/basic/init/resize_interface.html?height='+height;
	}
}

 

// Was wird beim ersten Start geladen?
function getRandomLayer(){	
	var randomNum = Math.ceil(Math.random()* globals.regionLUT.length-1)
	var region = globals.regionLUT[randomNum];
		if (region == 'x'){
			getRandomLayer()
		}else{
			showHotels(region, true);
		}	
	}
	
function randomStartPage(){
		
		
		var showLayer = getParam('id');
		
		if(showLayer){	
			var regionplusid = getPartnerIndex('xlayer', showLayer);
			globals.currentIndex = regionplusid;
			var region = globals.partnerList[regionplusid]['region'];		// Angebot -> Region auslesen
			showHotels(region, false);										// ausgabe Region vom Angebot der übergebenen ID(Url)
			selectXlayer(showLayer);
			globals.partnerList[regionplusid].div.className = globals.partnerList[regionplusid].div.selectedClassName 
		}else if ( getParam('region') ) { 
			if ( getParam('region') != '0'){		
				limitRegionViewTo( getParam('region') );
				showLayer = true;
			}
		}
		
		if(!showLayer){		
			var index = Math.floor( Math.random() * globals.partnerList.length  );
			globals.currentIndex = index;
			var xlayerNum = globals.partnerList[index].xlayer;
			//selectXlayer(xlayerNum);
			globals.partnerList[index].div.className = globals.partnerList[index].div.selectedClassName 
			showHotels(globals.partnerList[index].region, true)
		}
			
		
};

function showRandomCat(){	
	var index = Math.floor( Math.random() * globals.randomKategorieLUT.length );
	remoteKatClick(globals.randomKategorieLUT[index][0]);
	showFirstXlayer();
	}
	
function showFirstXlayer(){
	for(var i = 0; globals.partnerList[i]; i++){
		if(globals.partnerList[i].div.style.display == 'inline' || globals.partnerList[i].div.style.display == 'block'){
			globals.setCB = false;
			selectXlayer(globals.partnerList[i].xlayer);
			break;
		}
	}
}
	

//--------------------------------------------------------------------------------------
// SET LOAD EVENTS
//--------------------------------------------------------------------------------------

function start() {	
	initIDs();
	initMap();
	//initRegionNav();
	initCatNav();
	showAddressFields();
	catalogClick();
	initAgeGroup();
	checkErrors();
	
	randomLayerOrder('scnemCheckBoxes');
	reNumberThumbs('scnemCheckBoxes');
	
	getWeather();
	
	// Calendar Setup
	globals.heute = new Date();
	var minDate = Calendar.dateToInt(globals.heute);
	globals.selectDate = globals.heute;
	
	
	Calendar.setup({
        
		inputField		: "form_P3",     // id of the input field
        trigger    		: "anreiseTrigger",  // trigger for the calendar (button ID)
        singleClick		: true,
		min				: minDate,
   		max				: 20100430,
		weekNumbers		: false,		
		dateFormat		: "%d.%m.%Y",
		onSelect     	: function() {
							this.hide();
							var selectedDateInt = this.selection.get();
							globals.selectDate = Calendar.intToDate(selectedDateInt);
							var minDate = new Date();
							minDate.setFullYear(globals.selectDate.getFullYear(), globals.selectDate.getMonth(), globals.selectDate.getDate()+1);
							//console.log('MinDATE',minDate, globals.selectDate);
							globals.nextDate = Calendar.dateToInt(minDate);	
							
							if(!globals.abreiseCalendar){
									
									globals.abreiseCalendar = Calendar.setup({
										inputField		: "form_P4",     // id of the input field
										trigger    		: "abreiseTrigger",  // trigger for the calendar (button ID)
										singleClick		: true,
										min				: Calendar.dateToInt(new Date()),
										max				: 20100430,
										weekNumbers		: false,
										dateFormat		: "%d.%m.%Y",
										onSelect     	: function() { this.hide();},
										onFocus			: function(){},
										disabled: function(date)
														{
															if (date <= globals.selectDate) {
																return true;
															} else {
																return false;
														}
										},
										dateInfo 		: abreiseCSS
									});
									
								}
							
						},
		dateInfo : anreiseCSS
						
    					});
	
	 addListener(document.getElementById('abreiseTrigger'), 'click', selectDeparture)
	 
	//randomStartPage();
	
	insertFlashHeader();
	
	showRandomCat();
	
		
};

function anreiseCSS(date) {
  var as_number = Calendar.dateToInt(date); 
  if ( as_number > 20100430 || as_number < Calendar.dateToInt(globals.heute) )
    return {
      klass   : "cancelDate"
    };
};
function abreiseCSS(date) {
  var as_number = Calendar.dateToInt(date); 
  if ( as_number > 20100430 || as_number < Calendar.dateToInt(globals.selectDate) )
    return {
      klass   : "cancelDate"
    };
};


addListener(window, "load", start);