	var detailArray = new Array(); 
	var divArray = new Array(); 
	var tabArray = new Array(); 
	
	var imageContainer = new Object; 
	imageContainer.smaller = new Object; 
	imageContainer.bigger = new Object; 
	
	var IMG_Timeout = 29; 
	var layerTimer = new Object; 
	var visibleLayerCounter = 0; 
	var AJAX_Requests = 0; 
	var AJAX_TimeoutTimer = null; 
	var AJAX_Timeout = 29; var AJAX_sec = 0; 
	var imageCache = new Array(); 
	
	
	function getResponse()
	{
		return false;	
	}
	
	function blinkExecute(target,color)
	{
  		document.getElementById(target).style.backgroundColor = color;
	}

	function blinkBlink (target)
	{
	  	color1 = "#feff6f"; // blinking color
		color2 = "#ffffff"; // background color
		
		setTimeout('blinkExecute("'+target+'","'+color1+'")',0);
		setTimeout('blinkExecute("'+target+'","'+color2+'")',500);
		setTimeout('blinkExecute("'+target+'","'+color1+'")',1000);
		setTimeout('blinkExecute("'+target+'","'+color2+'")',1500);             
		setTimeout('blinkExecute("'+target+'","'+color1+'")',2000);
		setTimeout('blinkExecute("'+target+'","'+color2+'")',2500);     
		setTimeout('blinkExecute("'+target+'","'+color1+'")',3000);
		setTimeout('blinkExecute("'+target+'","'+color2+'")',3500);     
		setTimeout('blinkExecute("'+target+'","'+color1+'")',4000);
		setTimeout('blinkExecute("'+target+'","'+color2+'")',4500);
		document.getElementById(target).focus();
		document.getElementById(target).value = "";             
	}
	
	function clearArrays()
	{ 
		detailArray = new Array(); 
		divArray = new Array(); 
		tabArray = new Array();
	}
	
	function getObjectById(id)
	{ 
		if (document.getElementById)
		{ 
			return document.getElementById(id);
		}
		else
			return false;
	}
	
	function clearField(id)
	{ 
		var o = getObjectById(id); 
		o.value = '';
	}
	
	function alertAJAXError()
	{ 
		document.body.style.cursor = 'default'; 
		alert(AJAX_errorMessage);
	}
	
	function startAJAXTimeout(reset)
	{ 
		if (reset)
		{ 
			clearTimeout(AJAX_TimeoutTimer); 
			AJAX_sec = 0;
		}
		
		AJAX_sec++; 
		
		if (AJAX_Requests == 0)
		{ 
			AJAX_sec = 0; return;
		}
		if (AJAX_sec > AJAX_Timeout)
		{ 
			alert(AJAX_TimeoutMessage); 
			AJAX_sec = 0; return;
		}
		
		AJAX_TimeoutTimer = setTimeout("startAJAXTimeout()", 1000);
	}
	
	
	function submitSearchForm(searchForm) 
	{ 
		clearArrays(); 
		layers.search_fail.hide(); 
		layers.advancedSearch.hide(); 
		layers.loader.show(); 
		xajax_processSearch(xajax.getFormValues(searchForm)); 
		return false;
	}
	
	function submitPrintForm(searchForm, printForm) 
	{ 
		clearArrays(); 
		layers.advancedSearch.hide(); 
		layers.loader.show(); 
		xajax_printPDF(xajax.getFormValues(searchForm),xajax.getFormValues(printForm));
		return false;
	}
	
	function sendRequest(div_id,requestForm) 
	{ 
		clearArrays(); 
		layers.imprint.hide(); 
		layers.loader.show(); 
		xajax_sendMail(div_id, xajax.getFormValues(requestForm));
		return false;
	}
	
	function hide(id)
	{ 
		document.getElementById(id).style.display = 'none';
	}
	
	function show(id)
	{ 
		document.getElementById(id).style.display = 'block';
	}
	
	function checkRange(test, value, feather)
	{ 
		return ((test >= (value - feather)) && (test <= (value + feather))) ? true : false;
	}
	
	function transform(div, startPosX, startPosY, startWidth, startHeight, targetPosX, targetPosY, targetWidth, targetHeight, steps, JSCode, posX, posY, width, height, terminate)
	{ 
		if (document.getElementById) 
		{ 
			var o = document.getElementById(div); 
			if (!posX) var posX = startPosX; 
			if (!posY) var posY = startPosY; 
			if (!width) var width = startWidth; 
			if (!height) var height = startHeight; 
			if (!steps) var steps = 15; 
			if (terminate) 
			{ 
				o.style.left = targetPosX + 'px'; 
				o.style.top = targetPosY + 'px'; 
				o.style.width = targetWidth + 'px'; 
				o.style.height = targetHeight + 'px'; 
				eval (JSCode); 
				return;
			}
			else 
			{ 
				o.style.left = posX + 'px'; 
				o.style.top = posY + 'px'; 
				o.style.width = width + 'px'; 
				o.style.height = height + 'px';
			}
			
			posX += (targetPosX - startPosX) / steps; 
			posY += (targetPosY - startPosY) / steps; 
			width += (targetWidth - startWidth) / steps; 
			height += (targetHeight - startHeight) / steps; 
			terminate = checkRange(posX, targetPosX, 1)
								&& checkRange(posY, targetPosY, 1)
								&& checkRange(width, targetWidth, 1)
								&& checkRange(height, targetHeight, 1); 
			
			layerTimer[div] = setTimeout("transform('" + div + "', " + startPosX + ", " + startPosY + ", " + startWidth + ", " + startHeight + ", " + targetPosX + ", " + targetPosY + ", " + targetWidth + ", " + targetHeight + ", " + steps + ", \"" + JSCode + "\", " + posX + ", " + posY + ", " + width + ", " + height + ", " + terminate + ")", 20);
		}
	}
	
	function viewHotelClass(stars)
	{ 
		var i; 
		if (document.getElementById)
		{ 
			for (i = 1; i <= 5; i++)
			{ 
				document.getElementById('star' + i).src = (stars >= i)
															? server_address + 'images/star.gif'
															: server_address + 'images/star_grey.gif';
			}
		}
	}
	
	function resetHotelClass(reset)
	{ 
		var i; 
		if (reset)
		{ 
			var stars = 0; 
			document.getElementById('hotelClass').value = stars;
		}
		else 
		{ 
			var stars = document.getElementById('hotelClass').value;
		}
		
		if (document.getElementById)
		{ 
			for (i = 1; i <= 5; i++)
			{ 
				document.getElementById('star' + i).src = (stars >= i)
															? server_address + 'images/star.gif'
															: server_address + 'images/star_grey.gif';
			}
		}
	}
	
	function setHotelClass(stars)
	{ 
		if (document.getElementById)
		{ 
			document.getElementById('minClassChecker').checked = true; 
			document.getElementById('hotelClass').value = stars;
		}
	}
	
	function setTabStatus(id, status)
	{ 
		var tab = document.getElementById(id); 
		tab.className = status;
	}
	
	function setActiveSection(div)
	{ 
		var tabName = div + '_tab'; old = tabArray.pop(); 
		if (old == tabName)
		{ 
			tabArray.push(old); 
			return;
		}
		
		if (old)
		{ 
			setTabStatus(old, 'inactive');
		}
		
		setTabStatus(tabName, 'active'); 
		tabArray.push(tabName); 
		toggle(div, 1, 1);
	}
	
	function toggle(div, onlyOne, keep)
	{ 
		var o = document.getElementById(div); 
		if (o.style.display == 'block') 
		{ 
			if (!keep)
			{ 
				hide(div); 
				if (onlyOne)
				{ 
					old = divArray.pop(); 
					if (old) 
					{ 
						if (old != div) 
						{ 
							divArray.push(div);
						}
					}
				}
			}
		}
		else 
		{ 
			if (onlyOne)
			{ 
				old = divArray.pop(); 
				if (old) 
				{ 
					toggle(old);
				}
				
				divArray.push(div);
			}
			show(div);
		}
	}
	
	function toggleHotelDetail(hotel_id, showSection, JSAfter) 
	{ 
		var div = 'hotel_' + hotel_id; 
		var o = document.getElementById(div);
		 
		if (o.style.display == 'block') 
		{ 
			transform(div, o.offsetLeft, o.offsetTop, o.offsetWidth, hotelinformation_container_height, o.offsetLeft, o.offsetTop, hotelinformation_container_width, 0, 5, "o.style.display = 'none'; " + JSAfter); 
			var tbl = getObjectById(div + '_tablerow'); 
			tbl.className = ""; 
			old = detailArray.pop(); 
			if (old) 
			{ 
				if (old != hotel_id) 
				{ 
					detailArray.push(hotel_id);
				}
			}
		}
		else 
		{ 
			old = detailArray.pop(); 
			if (old) 
			{ 
				toggleHotelDetail(old, '_overview', "toggleHotelDetail(" + hotel_id + ", '" + showSection + "')"); 
				return;
			}
			
			var tbl = getObjectById(div + '_tablerow'); 
			tbl.className = "shown"; 
			detailArray.push(hotel_id); 
			setActiveSection(div + showSection); 
			
			if (document.getElementById(div + '_dataOK').innerHTML != 'OK')
			{ 
				xajax_getHotelDetails(hotel_id); 
				placeLoader(div + '_overview'); 
				placeLoader(div + '_facilities'); 
				placeLoader(div + '_travelInformation'); 
				placeLoader(div + '_roomInformation'); 
				placeLoader(div + '_TOS'); 
				placeLoader(div + '_enviroment'); 
				placeLoader(div + '_photos'); 
				placeLoader(div + '_misc'); 
				placeLoader(div + '_book'); 
				
				document.getElementById(div + '_dataOK').innerHTML = 'OK';
			}
			o.style.display = 'block'; 
			transform(div, o.offsetLeft, o.offsetTop, o.offsetWidth, 0, o.offsetLeft, o.offsetTop, hotelinformation_container_width, hotelinformation_container_height, 5, "o.scrollIntoView(false);");
		}
	}
	
	
	function placeLoader(div) 
	{ 
		document.getElementById(div).innerHTML = "<div class='loader'>" + loadingMsg + "<br /><img src = '" + server_address + "images/progressbar.gif' alt='" + loadingMsg + "'/></div>";
	}
	
	function updateMousePosition(e) 
	{ 
		mouseX = (ie) ? event.clientX + document.body.scrollLeft : e.pageX; mouseY = (ie) ? event.clientY + document.body.scrollTop : e.pageY;
	}
	
	function changeScrollSpeed(container, speed)
	{ 
		if (!speed)
		{ 
			clearTimeout(scrollTimer); 
			return;
		}
		
		scrollSpeed = speed; 
		var containerO = document.getElementById(container); 
		var images = containerO.childNodes; 
		scrollTimer = setTimeout("scrollPhotoCinema('" + container + "')", 50);
	}
	
	function cacheImages()
	{ 
		for (i = 0; i < arguments.length; i++)
		{ 
			imageCache[i] = new Image(); 
			imageCache[i].src = arguments[i];
		}
	}
	
	function loadImage(img, id, url, sec)
	{ 
		if (document.getElementById)
		{ 
			var o = document.getElementById(img); 
			if (!imageContainer[id])
			{ 
				imageContainer[id] = new Image(); 
				imageContainer[id].src = url;
			}
			
			if ((imageContainer[id].height > 0) || imageContainer[id].complete)
			{ 
				var w_max = 250; 
				var h_max = hotelinformation_container_height - 31; 
				var w = imageContainer[id].width; 
				var h = imageContainer[id].height; 
				var ratio = Math.floor(imageContainer[id].width / imageContainer[id].height); 
				
				if (h > h_max)
				{ 
					w = Math.floor(ratio * h_max); 
					h = h_max;
				}
				
				if (w > w_max)
				{ 
					w = w_max; 
					h = Math.floor(w_max / ratio);
				}
				
				o.style.width = w + 'px'; 
				o.style.height = h + 'px'; 
				o.src = imageContainer[id].src;
			}
			else
			{ 
				if (!sec)
				{ 
					var sec = 0;
				}
				
				sec++; 
				
				if (sec > IMG_Timeout)
				{ 
					alert('Sorry, larger image could not be retrieved. Please try again later'); 
					o.src = ""; 
					return;
				}
				
				setTimeout("loadImage('" + img + "', '" + id + "', '" + url + "', " + sec + ")", 100);
			}
		}
	}
	
	function getRect(id, win)
	{ 
		if(!document.getElementById) return null; 
		if(!win) win = window; 
		
		var o = win.document.getElementById(id); 
		if(!o) return null; 
		
		var rect = { top: 0, left: 0, width: 0, height: 0 }; 
		rect.height = o.offsetHeight; 
		rect.width = o.offsetWidth; 
		
		while (o)
		{ 
			rect.top += parseInt(o.offsetTop); 
			rect.left += parseInt(o.offsetLeft); 
			o = o.offsetParent;
		}
		
		return rect;
	}
	
	function hideFormElements(hide)
	{ 
		var rForm = document.getElementsByName('hideForm'); 
		if (rForm.length)
		{ 
			for (i = 0; i < rForm.length; i++)
			{ 
				for (j = 0; j < rForm[i].elements.length; j++)
				{ 
					rForm[i].elements[j].style.visibility = hide ? "hidden" : "visible" ;
				}
			}
		}
	}
	
	function Layer(divId, width, height, create, content)
	{ 
		if (!divId) return false; 
		
		if (create)
		{ 
			document.getElementById(create).innerHTML += "<div id = '" + divID + "' style = 'overflow:hidden; display: none; position:absolute; width: " + width + "px; height: " + height + "px'>" + content + "</div>";
		}
	
		var id = divId; 
		this.attached = false; 
		this.whereAttached = false; 
		this.attachedX = false; 
		this.attachedY = false; 
		this.animate = true; 
		this.aniDirY = 'DOWN'; 
		this.aniDirX = 'LEFT'; 
		this.width = width; 
		this.height = height; 
		this.visible = false; 
		this.steps = 15; 
		this.beforeShowJSCode = "o.style.display = 'block'; if (visibleLayerCounter == 0) hideFormElements(1); "; 
		this.afterShowJSCode = ''; 
		this.beforeHideJSCode = ''; 
		this.afterHideJSCode = "o.style.display = 'none'; if (visibleLayerCounter == 0) hideFormElements(0); "; 
		var timer = null; 
		var curWidth = 0; 
		var curHeight = 0; 
		
		function getObject()
		{ 
			return document.getElementById ? document.getElementById(id) : false;
		}
	
		function substituteArgs(str, arg1)
		{ 
			if (str.substring(0, str.indexOf('??')))
			{ 
				return str.substring(0, str.indexOf('??')) + arg1 + str.substring(str.indexOf('??') + 2);
			}
			return str;
		}
	
		this.attachTo = function(id, where)	{ this.attached = id; if (where) this.whereAttached = where; else this.whereAttached = 'TOPLEFT';}											
		this.attachToPos = function(x, y){ this.whereAttached = 'POS'; this.attachedX = x; this.attachedY = y;}		
		this.getWidth = function(){ o = getObject(); return o ? o.offsetWidth : false;}
		this.getHeight = function(){ o = getObject(); return o ? o.offsetHeight : false;}
		this.getLeft = function(){ o = getObject(); return o ? parseInt(o.style.left) : false;}
		this.getTop = function(){ o = getObject(); return o ? parseInt(o.style.top) : false;}
		this.setWidth = function(width){ this.width = width; if (this.visible){ this.show();}}	
		this.setHeight = function(height){ this.height = height; if (this.visible){ this.show();}}
		this.setDimensions = function(width, height){ this.width = width; this.height = height; curWidth = this.getWidth(); curHeight = this.getHeight(); if (this.visible){ this.show();}}
		this.setTop = function(top){ o = getObject(); o.style.top = top + 'px';}
		this.setLeft = function(left){ o = getObject(); o.style.left = left + 'px';}
		this.show = function(arg1){ o = getObject(); if (this.visible && (this.width == this.getWidth()) && (this.height == this.getHeight())){ return;}
		
		clearTimeout(layerTimer[id]); 
		var pos = getRect(this.attached); 
		o.style.zIndex = (visibleLayerCounter + 2) * 1000; 
		eval(substituteArgs(this.beforeShowJSCode, arg1)); 
		visibleLayerCounter++; 
		
		var start = new Object(); 
		var target = new Object(); 
		start.width = curWidth; 
		start.height = curHeight; 
		target.width = this.width; 
		target.height = this.height; 
		
		switch (this.whereAttached)
		{ 
			case 'TOPLEFT':
				start.x = pos.left - curWidth; 
				start.y = pos.top; 
				break; 
				
			case 'TOPRIGHT':
				start.x = pos.left + pos.width; 
				start.y = pos.top; 
				break; 
			
			case 'BOTTOMLEFT':
				start.x = pos.left - curWidth; 
				start.y = pos.top + pos.height - curHeight; 
				break; 
			
			case 'BOTTOMRIGHT':
				start.x = pos.left + pos.width; 
				start.y = pos.top + pos.height - curHeight; 
				break; 
			
			case 'POS':
				start.x = this.attachedX; 
				start.y = this.attachedY; 
				break;
		}
	
		switch (this.aniDirX)
		{ 
			case 'RIGHT':
				target.x = start.x
				break; 
			
			case 'LEFT':
			default:
				target.x = start.x - this.width; 
				break;
		}
	
		switch (this.aniDirY)
		{ 
			case 'UP':
				target.y = start.y - this.height; 
				break; 
			
			case 'DOWN':
			default:
			target.y = start.y; 
			break;
		}
		
		if (this.animate)
		{ 
			layerTimer[id] = transform(id, start.x, start.y, start.width, start.height, target.x, target.y, target.width, target.height, this.steps, substituteArgs(this.afterShowJSCode, arg1));
		}
		else
		{ 
			o.style.left = target.x + 'px'; 
			o.style.top = target.y + 'px'; 
			o.style.width = target.width + 'px'; 
			o.style.height = target.height + 'px'; 
			eval(substituteArgs(this.afterShowJSCode, arg1));
		}
		
		this.visible = true;
	}
	
	this.hide = 
	function(arg1)
	{ 
		if (!this.visible) return; 
		clearTimeout(layerTimer[id]); 
		var pos = getRect(this.attached); 
		o = getObject(); 
		o.style.zIndex = (visibleLayerCounter) * 1000; 
		curWidth = o.offsetWidth; 
		curHeight = o.offsetHeight; 
		
		eval(substituteArgs(this.beforeHideJSCode, arg1)); 
		visibleLayerCounter--; 
		
		var start = new Object(); 
		var target = new Object(); 
		start.width = curWidth; 
		start.height = curHeight; 
		target.width = 0; 
		target.height = 0; 
		
		switch (this.whereAttached)
		{ 
			case 'TOPLEFT':
				target.x = pos.left; 
				target.y = pos.top; 
				break; 
				
			case 'TOPRIGHT':
				target.x = pos.left + pos.width; 
				target.y = pos.top; 
				break; 
				
			case 'BOTTOMLEFT':
				target.x = pos.left; 
				target.y = pos.top + pos.height; 
				break; 
			
			case 'BOTTOMRIGHT':
				target.x = pos.left + pos.width; 
				target.y = pos.top + pos.height; 
				break; 
			
			case 'POS':
				target.x = this.attachedX; 
				target.y = this.attachedY; 
				break;
		}
		
		switch (this.aniDirX)
		{ 
			case 'RIGHT':
				start.x = target.x; 
				break; 
			
			case 'LEFT':
			default:
				start.x = target.x - curWidth; 
				break;
		}
		
		switch (this.aniDirY)
		{ 
			case 'UP':
				start.y = target.y - curHeight; 
				break; 
			
			case 'DOWN':
			default:
				start.y = target.y; 
				break;
		}
		
		if (this.animate)
		{ 
			layerTimer[id] = transform(id, start.x, start.y, start.width, start.height, target.x, target.y, target.width, target.height, this.steps, substituteArgs(this.afterHideJSCode, arg1));
		}
		else
		{ 
			o.style.left = target.x + 'px'; 
			o.style.top = target.y + 'px'; 
			o.style.width = target.width + 'px'; 
			o.style.height = target.height + 'px'; 
			eval(substituteArgs(this.afterHideJSCode, arg1));
		}
	
		this.visible = false; 
		curWidth = 0; 
		curHeight = 0;
	}
	
	this.toggle = 
	function(arg1)
	{ 
		if (this.visible)
			this.hide(arg1); 
		else
			this.show(arg1);}
	}

