function newXMLObject(){
	var xmlHttp;
	try{ xmlHttp=new XMLHttpRequest(); } catch (e){
	try{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e){
	try{ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){
	alert("Your browser doesn't support AJAX. Application aborted.");
	return false; } } }
	return xmlHttp;
}

function gotoUrl(url){
	browserWindow = window.open(url, "Browser", "width=900,height=700,left=100,top=20,resizable=1,location=1,directories=0,status=1,menubar=1,scrollbars=1,toolbar=1");
	browserWindow.focus();
}
function changeRoom(idx,txt){
	if(document.getElementById){
		document.getElementById("room"+idx).innerHTML = txt;
		switchVis("list"+idx);
	}
	else{
	alert("Ihr Browser unterst�tzt notwendige Funktionen leider nicht.\n\nBitte aktualisieren Sie ihren Browser oder rufen uns ggf. an"); 
	}
}
if (document.layers) { // Netscape
 document.captureEvents(Event.MOUSEMOVE);
 document.onmousemove = captureMousePosition;
} else if (document.all) { // Internet Explorer
 document.onmousemove = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
 document.onmousemove = captureMousePosition;
}

function openGalleryImage(folder,file,no){
	
	
	var request = newXMLObject();
	
	var date = new Date;
	var url = "/_includes/display_gallery.php?";
	url = url + date.getDate() + date.getTime() + "|";
	url = url + folder + "|";
	url = url + file + "|";
	url = url + no + "|";
	url = url + window.location;

	var rem = document.getElementById("zoomnavi");
	rem.parentNode.removeChild(rem);
	
	request.onreadystatechange=function(){
		if(request.readyState==4){
		document.getElementById("zoomcontent").style.marginTop = "100px";
		document.getElementById("zoomcontent").innerHTML = request.responseText;
		YAHOO.util.Event.addListener("zoomclose", "click", YAHOO.groco.container.zoomarea.hide, YAHOO.groco.container.zoomarea, true);
		YAHOO.groco.container.zoomcontent = new YAHOO.widget.Overlay("zoomcontent", { fixedcenter:true,
			  visible:true,
			  zIndex:999,
			  effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.25} } );
		YAHOO.groco.container.zoomcontent.render("groco");
		
		YAHOO.util.Event.addListener("zoomclose", "click", YAHOO.groco.container.zoomcontent.hide, YAHOO.groco.container.zoomcontent, true);
        }
	}
	
	request.open("GET",url,true);
	request.send(null);
}

xpos = 0; 
ypos = 0; 
xmax = 0; 
ymax = 0; 

function captureMousePosition(e) {
	if (document.layers) {
		xpos = e.pageX;
	    ypos = e.pageY;
	    xmax = window.innerWidth+window.pageXOffset;
	    ymax = window.innerHeight+window.pageYOffset;
	} else if (document.all) {
		xpos = window.event.x+document.body.scrollLeft;
	    ypos = window.event.y+document.body.scrollTop;
	    xmax = document.body.clientWidth+document.body.scrollLeft;
	    ymax = document.body.clientHeight+document.body.scrollTop;
	} else if (document.getElementById) {
	    // Netscape 6 behaves the same as Netscape 4 in this regard
	    xpos = e.pageX;
	    ypos = e.pageY;
	    xmax = window.innerWidth+window.pageXOffset;
	    ymax = window.innerHeight+window.pageYOffset;
	}
}

var posX;
var posY;


function image_loader(img,img_width,img_height){
	var swf_string = '<center><object type="application/x-shockwave-flash" data="_dta/flash/image_loader.swf?img='+img+'&amp;uri='+window.location+'" width="'+img_width+'" height="'+img_height+'">'+
	'<param name="movie" value="_dta/flash/image_loader.swf?img='+img+'&amp;uri='+window.location+'" />'+
	//'<param name="wmode" value="transparent" />'+
	'<param name="align" value="top" />'+
	'<param name="scale" value="noscale" />'+
	'</object></center>';

	var imageDiv = document.createElement("div");
	imageDiv.style.width = "100%";
	imageDiv.style.height = "100%";
	imageDiv.style.background = "transparent";
	imageDiv.style.position = "absolute";
	imageDiv.style.left = "0px";
	imageDiv.style.top = "50px";
	imageDiv.innerHTML = swf_string;
	document.body.appendChild(imageDiv);
}

function showWeather(cid,cname){
	var meteo_string = '<table cellspacing="1" cellpadding="0" border="0" style="background-color: #ABCDDD" width="122">'+
	'<tr><td align="center" style="background-color : #ABCDDD;">'+
	'<a href="'+window.location+'">schlie&szlig;en</a>'+
	'</td></tr>'+
	'<tr><td align="center" style="background-color : #ABCDDD;">'+
	'<a href="http://www.meteo24.de/wetter/'+cid+'.html" style="text-decoration: none;" target="_blank">'+
	'<font face="Verdana" size="1" color="#000000" style="text-decoration: none; font-weight: bold;">Wetter '+cname+'</font></a></td></tr>'+
	'<tr><td align="center"><iframe width="120" height="98" scrolling="no" frameborder="0" src="http://www.meteo24.de/hptool/v1?cid='+cid+'&l=de&style=1"> </iframe></td></tr>'+
	'<tr><td align="center" height="15" style="background-color : #ABCDDD;"><a href="http://www.meteo24.de/" style="text-decoration: none;" target="_blank"><font face="Verdana" size="1" color="#000000">&copy; meteo24.de</font></a></td>'+
	'</tr></table>';
	var weather = document.createElement("div");
	weather.style.width = "122px";
	weather.style.background = "#CCCCCC";
	weather.style.position = "absolute";
	weather.style.left = (xpos-160)+"px";
	weather.style.top = ypos+"px";
	weather.innerHTML = meteo_string;
	document.body.appendChild(weather);
}

var _date = new Date();

var objStats = new Array;
objStats[1] = "visible";
objStats[0] = "hidden";
var clicks = 0;
var t = '';
var zoomWidth = 0;
var zoomHeight = 0;
var zoomFont = 0;
var info = '';
var aktiv = '';

function uncheck(idx){
	//var e = document.forms["dates"].elements["date[]"];
	var e = document.getElementsByName("date[]");
	for(var i = 0;i<e.length;i++){
		if(idx != i)
		{
		e[i].checked = false;
		}
	}
}

function setValue(what,val){
	if(document.getElementById){
		document.getElementById(what).value = val;
	}
	else{
	alert("Ihr Browser unterst�tzt notwendige Funktionen leider nicht.\n\nBitte aktualisieren Sie ihren Browser oder rufen uns ggf. an"); 
	}
}

function setAirport(fees,idx,txt){
	document.getElementById("airport_id").value = idx;
	document.getElementById("airport_fees").value = fees;
	document.getElementById("airport_name").value = txt; 
}

function setAirport2(obj,idx,txt){
	document.getElementById("airport0").innerHTML = txt;
	document.getElementById("p_airport_name["+obj+"]").value = txt;
	document.getElementsByName("airport"+obj)[0].value = idx; 
	
	switchVis("cityList"+obj);
}

function setValueByName(name,val){
	var e = document.getElementsByName(name);
	for(var i = 0;i<e.length;i++){
	e[i].value = val;
	}
}

function showRooms(idx){
	var room = document.getElementById("room"+idx);
	var list = document.getElementById("list"+idx);
	var xPos = room.offsetLeft;
	var yPos = room.offsetTop;
	list.style.left = xPos+"px";
	list.style.top = (yPos+18)+"px";
	switchVis("list"+idx);
}

function showRooms2(p,idx){
	var room = document.getElementById("p_"+p+"_room"+idx);
	var list = document.getElementById("p_"+p+"_list"+idx);
	var xPos = room.offsetLeft;
	var yPos = room.offsetTop;
	list.style.left = xPos+"px";
	list.style.top = (yPos+18)+"px";
	switchVis("p_"+p+"_list"+idx);
}

function showGenderList(idx)
{
	var e = document.getElementById("gender"+idx);
	var xPos = e.offsetLeft;
	var yPos = e.offsetTop;
	document.getElementById("genderList").style.left = (xPos-1)+"px";
	document.getElementById("genderList").style.top = (yPos+18)+"px";
	switchVis("genderList");
}

function switchGender(idx,val){
	var txt = document.getElementById("gender1");
	var field = document.getElementsByName("gender0");
	
	if(navigator.appName == "Opera"){
		var p = txt.parentNode;
		var clone = txt.cloneNode(true);
		var nextChild = txt.nextSibling;
		p.removeChild(txt);
		
		if(val == "w"){
			field[0].value = "w";
			clone.innerHTML = "weiblich";
		}
		else{
			field[0].value = "m";
			clone.innerHTML = "m&auml;nnlich";
		}
		p.insertBefore(clone,nextChild);
	}
	else{
		if(val == "w"){
			field[0].value = "w";
			txt.innerHTML = "weiblich";
		}
		else{
			field[0].value = "m";
			txt.innerHTML = "m&auml;nnlich";
		}
	}
	switchVis("genders");
}

function showCityList(idx)
{
	var e = document.getElementById("airport"+idx);
	var xPos = e.offsetLeft;
	var yPos = e.offsetTop;
	
	if(idx > 0)
	{
	document.getElementById("cityList"+idx).style.left = (xPos-1)+"px";
	document.getElementById("cityList"+idx).style.top = (yPos+18)+"px";
	switchVis("cityList"+idx);
	}
	else
	{
	document.getElementById("cityList").style.left = (xPos-1)+"px";
	document.getElementById("cityList").style.top = (yPos+18)+"px";
	switchDis("cityList");
	}
}

function switchVis(obj){

	var vis = document.getElementById(obj).style.visibility;
	if(vis == '' || vis == 'hidden'){
		document.getElementById(obj).style.visibility = 'visible';
	}
	else{
		document.getElementById(obj).style.visibility = 'hidden';
	}
}

function changeRoom(idx,txt){
	if(document.getElementById){
		document.getElementById("room"+idx).innerHTML = txt;
		switchVis("list"+idx);
	}
	else{
	alert("Ihr Browser unterst�tzt notwendige Funktionen leider nicht.\n\nBitte aktualisieren Sie ihren Browser oder rufen uns ggf. an"); 
	}
}

function changeRoom2(p,idx,txt){
	if(document.getElementById){
		document.getElementById("p_"+p+"_room"+idx).innerHTML = txt;
		switchVis("p_"+p+"_list"+idx);
	}
	else{
	alert("Ihr Browser unterst�tzt notwendige Funktionen leider nicht.\n\nBitte aktualisieren Sie ihren Browser oder rufen uns ggf. an"); 
	}
}

function zoom(){
	document.createElement("div");
	var id = document.createAttribute("id");
	document.createElement("div");
	zoomWidth = (zoomWidth + 10);
	zoomHeight = (zoomHeight + 10);
	zoomFont = (zoomFont + 1);
	if(zoomWidth <= 180 && zoomHeight <= 180){
	document.getElementById(t).style.width = zoomWidth+"px";
	document.getElementById(t).style.height = zoomHeight+"px";
	document.getElementById(t).style.fontSize = zoomFont+"px";
	document.getElementById(t).style.background = "url('_dta/map_info_bg.png')";
	document.getElementById(t).style.backgroundRepeat = "no-repeat";
	document.getElementById(t).innerHTML = info;
	clicks++;
	}
	else{
	window.clearInterval(aktiv);
	zoomWidth = 0;
	zoomHeight = 0;
	zoomFont = 0;
	aktiv = '';
	}
}

function switchStat(obj,stat){
	if(obj == 'mapInfo' && clicks == 0){
	t = obj;
	info = document.getElementById(obj).innerHTML;
	
	document.getElementById(obj).style.height = "0px";

	aktiv = window.setInterval("zoom()", 40);

		if(navigator.appName == "Microsoft Internet Explorer"){
		var IE = true;
		}
		else{
		var IE = false;
		}

		function setMouseXY(e) {
			if (IE) { // grab the x-y pos.s if browser is IE
			posX = event.clientX + document.body.scrollLeft - 10
			posY = event.clientY + document.body.scrollTop
			} else {  // grab the x-y pos.s if browser is NS
			posX = e.pageX - 10
			posY = e.pageY
			}  
		
		
			document.getElementById(obj).style.left = (posX + 20)+"px";
			document.getElementById(obj).style.top = (posY - 10)+"px";
		}
		
		if (!IE) document.captureEvents(Event.CLICK)
		document.onclick = setMouseXY;
		
		var posX = 0
		var posY = 0
		
		// Main function to retrieve mouse x-y pos.s
		
	}
	
	if(stat == 3 || stat == 2){
	document.getElementById(obj).style.display = objStats[stat];
	}
	else{
	document.getElementById(obj).style.visibility = objStats[stat];
	}
}

function getPrices(page,hotel,room){
	var r = newXMLObject();
	var dval = document.getElementsByName("theDate")[0].value;
	var jid = document.getElementsByName("jid")[0].value;
	var uri = "/_custom/get_prices.php?_jsid="+_date.getDay()+_date.getTime()+"|"+page+"|"+hotel+"|"+room+"|"+window.location+"|"+jid+"|"+dval;
	
	r.onreadystatechange = function(){
		if(r.readyState == 4){
		document.getElementById("prices"+hotel).innerHTML = r.responseText;
		}
	}

	r.open("GET",uri,true);
	r.send(null);
}

function getExtPrices(page,hotel,room){
	var r = newXMLObject();
	var dval = document.getElementById("theDate").value;
	
	var jid = document.getElementById("jid").value;
	var loc = window.location.toString();
	loc = loc.replace(/#/ig,"%23");
	var uri = "/_custom/get_ext_prices.php?_jsid="+_date.getDay()+_date.getTime()+"|"+page+"|"+hotel+"|"+room+"|"+loc+"|"+jid+"|"+dval;

	r.onreadystatechange = function(){
		if(r.readyState == 4){
		document.getElementById("prices"+hotel).innerHTML = r.responseText;
		}
	}

	r.open("GET",uri,true);
	r.send(null);
}

function getExtPrices2(p,page,hotel,room){
	var r = newXMLObject();
	var dval = document.getElementById("theDate").value;
	
	var jid = document.getElementById("jid").value;
	var loc = window.location.toString();
	loc = loc.replace(/#/ig,"%23");
	var uri = "/_custom/get_ext_prices.php?_jsid="+_date.getDay()+_date.getTime()+"|"+page+"|"+hotel+"|"+room+"|"+loc+"|"+jid+"|"+dval;

	r.onreadystatechange = function(){
		if(r.readyState == 4){
		document.getElementById("p_"+p+"_prices"+hotel).innerHTML = r.responseText;
		}
	}

	r.open("GET",uri,true);
	r.send(null);
}

function checkData(theForm){
	var d = document.forms[theForm].elements["theDate"].value;
	if(d == ""){
	alert("Bitte markieren Sie ein Reisedatum!");
	}
	else{
		document.forms[theForm].submit();
	}
}

function setSortOrder(order){
	var r = newXMLObject();
	var uri = "/index.php?_jsid="+_date.getDay()+_date.getTime()+"|"+order;
	
	r.onreadystatechange = function(){
		if(r.readyState == 4){
		}
	}

	r.open("GET",uri,true);
	r.send(null);
}