_action = "";
_countryname="";
_reiseartname="";
_countryID = 0;
_reiseartID = 0;
_id = 0;

function getTrafficsSA() {
	var remote_url = "/web/skripte/template/reiseshop_angebot_template.cfm"; 

	new Ajax.Request(remote_url, {  
	onCreate: function() {
		var doc = document;
		doc.getElementById("reiseshop_sonderangebote").style.display="block";
		doc.getElementById("reiseshop_sa_head").style.display="block";
	}, 
	onSuccess: function(transport) {
									var container = $('reiseshop_sonderangebote');
								   	var content = transport.responseText.strip(); 
								   	container.update(content);
								    },
	onFailure: function(transport) {
			var message="<div class='fehler'>Es ist leider ein Fehler aufgetreten</div>" + transport.responseText
			var container = $('reiseshop_sonderangebote');
			container.update(message);
	}

	}); 
}

function getTrafficsTopRegions() {
	var remote_url = "/web/skripte/template/reiseshop_top_region_template.cfm"; 

	new Ajax.Request(remote_url, {   
	onSuccess: function(transport) {
									var container = $('reiseshop_topregions');
								   	var content = transport.responseText.strip(); 
								   	container.update(content);
								    },
	onFailure: function() {
			var message="<div class='fehler'>Es ist leider ein Fehler aufgetreten</div>"
			var container = $('reiseshop_topregions');
			container.update(message);
	},
	onComplete: function() {
		
		getTrafficsSA();
	}

	}); 
}


function portalReisefinderShrink(idSelectBox) {
	var _url = "/web/skripte/portal/dsp_reisefinder.cfm"
	var _queryString = getQueryString(idSelectBox);

	new Ajax.Request("/web/skripte/session_updater.cfm"+getQueryString(idSelectBox)); 

	new Ajax.Request(_url+_queryString, {   
		onSuccess: ShrinkSuccess,
		onFailure: ShrinkFailure,
		onCreate : ShrinkCreate,
		onComplete:ShrinkComplete
	}); 
}

function reisenReisefinderShrink(idSelectBox) {
	var _url = "/web/skripte/reisen/dsp_reisefinder.cfm"
	var _queryString = getQueryString(idSelectBox);

		new Ajax.Request("/web/skripte/session_updater.cfm"+getQueryString(idSelectBox)); 

		new Ajax.Request(_url+_queryString, {   
		onSuccess: ShrinkSuccess,
		onFailure: ShrinkFailure,
		onCreate : ShrinkCreate,
		onComplete:ShrinkComplete
		}); 

}

function getKurzansicht(idSelectBox) {
	var _queryString = getQueryString(idSelectBox);
	var _url = "/web/skripte/template/kurzansicht_template.cfm/";

	new Ajax.Request("/web/skripte/session_updater.cfm"+_queryString); 

	new Ajax.Request(_url, {   
		onSuccess: KurzansichtSuccess,
		onFailure: KurzansichtFailure,
		onCreate : KurzansichtCreate,
		onComplete:KurzansichtComplete
		}); 
}

function ShrinkSuccess(transport)	{
	var container = $('reisefinder');
   	var content = transport.responseText; 
   	container.update(content);
}

function ShrinkFailure(transport)	{
	var container = $('reisefinder');
   	var content = transport.responseText; 
   	container.update(content);
}

function ShrinkCreate() {
	$("loader").show();
}

function ShrinkComplete() {
	$("loader").hide();
	
	this.tabController = new TabController(getIdLand(), getIdReiseart());
	this.tabController.update();
}

function KurzansichtSuccess(transport)	{
	var container = $('kurzansicht');
   	var content = transport.responseText; 
   	container.update(content);
	window.location.host = "/web/index.cfm/pm/uebersicht"
}
function KurzansichtFailure(transport)	{
	var container = $('error_message');
	var content = transport.statusText
   	container.update(content);
   	$('data_failure').show();
}
function KurzansichtCreate() {
	$("loader").show();
}

function KurzansichtComplete() {

	var breadcrumb_link = "";

/*
	if(_reiseartname != "") {
		breadcrumb_link = breadcrumb_link + " &raquo; <b>"+_reiseartname+"</b>"; 
	}
	$("loader").hide();
	$("breadcrumb_link").update(breadcrumb_link);
*/
	this.tabController = new TabController(getIdLand(),getIdReiseart());
	this.tabController.update();
}

/*
	Returns the id of Selected reiseart,
	from the shrinkingbox of Übersichtseite
*/
function getIdReiseart() {
	var selObj = document.getElementById('reiseartId');
	return selObj.options[selObj.selectedIndex].value
}

/*
	Returns the id of Selected Country,
	from the shrinkingbox of Übersichtseite
*/
function getIdLand() {
	var selObj = document.getElementById('landId');
	return selObj.options[selObj.selectedIndex].value
}

function getQueryString(idSelectBox) {

	var _queryString = "";
	if(idSelectBox == "landId") {
		var selObj = document.getElementById('landId');
		var countryID = selObj.options[selObj.selectedIndex].value;
		var countryname = selObj.options[selObj.selectedIndex].text;

		_queryString = _queryString +"/idLand/"+countryID+"/idReiseart/-1/abreisedatum/-1";			
		_countryname = countryname;
		_countryID = countryID
		_reiseartname = "";
	}
	else if(idSelectBox == "reiseartId") {
		var selObj = document.getElementById('landId');
		var countryID = selObj.options[selObj.selectedIndex].value;
		var countryname = selObj.options[selObj.selectedIndex].text;

		_queryString = _queryString +"/idLand/"+countryID;	
		selObj = document.getElementById('reiseartId');
		_queryString = _queryString +"/idReiseart/"+selObj.options[selObj.selectedIndex].value+"/abreisedatum/-1";	
		_reiseartname = selObj.options[selObj.selectedIndex].text;
		_reiseartID = selObj.options[selObj.selectedIndex].value;
		_countryID = countryID
		_countryname = countryname;
		
	}
	else {
		var selObj = document.getElementById('landId');
		_queryString = _queryString +"/idLand/"+selObj.options[selObj.selectedIndex].value;	
		selObj = document.getElementById('reiseartId');
		_queryString = _queryString +"/idReiseart/"+selObj.options[selObj.selectedIndex].value;	
		selObj = document.getElementById('abreisedatum');
		_queryString = _queryString +"/abreisedatum/"+selObj.options[selObj.selectedIndex].value;	
	}

	return _queryString+"/init/1";
}

 function getKurzansichtQueryString(changedBox) {
	var queryString = "";
	var selObj = {};

	// Include Reiseziel in QueryString.
	selObj = document.getElementById('reiseziel');
	queryString += "reiseziel/"+ selObj.options[selObj.selectedIndex].value;

	if(changedBox == "reiseziel") 
		return queryString;
	

	//Include hotelkategorie in QueryString
	selObj = document.getElementById('hotelkategorie');
	queryString += "/hotelkategorie/"+ selObj.options[selObj.selectedIndex].value;
	if(changedBox == "hotelkategorie") 
		return queryString;
	

	//Include hotelkategorie in QueryString
	selObj = document.getElementById('reisemonat');
	queryString += "/reisemonat/"+ selObj.options[selObj.selectedIndex].value;

	return queryString;
 }	

function pdflink(pdflink) 
{
	open(pdflink,'linkpdf','width=770,height=550,left=50,top=1,screenX=120,screenY=1,status=yes,menubar=no,toolbar=no,locationbar=no,resizable=yes,scrollbars=yes').focus();
} 

function buchungsformular(objektCode,idObjekt) 
	{
		self.open('/web/index.cfm?pm=buchung&objektCode=' + objektCode + '&idObjekt=' + idObjekt + '&anfrage=1','_self');
	}  

function buchung(idInfx, idObjekt, objektCode, startzeile) 
	{
		self.open('/web/index.cfm?pm=buchung&idInfx=' + idInfx + '&idObjekt=' + idObjekt + '&objektCode=' + objektCode + '&startzeile=' + startzeile + '&anfrage=0','_self'); 	
		
	}



function showBild(_url) {
	document.getElementById('detailgross').src = _url;
}
function scrollBild() {
var height = $$('div.detailansichtelement')[0].getHeight(); 
var top = parseInt(document.body.scrollTop ) < 178 ? 178:parseInt(document.body.scrollTop ) > height ? height:parseInt(document.body.scrollTop );
new Effect.Morph("scrollable", {
	  style: {
		top: top+'px'		
	  }, // CSS Properties
	  duration: 0.8// Core Effect properties
	});
return false;
}

function moveTo(container, element){
  Position.prepare();
  container_y = Position.cumulativeOffset($(container))[1]
  element_y = Position.cumulativeOffset($(element))[1]
  new Effect.Scroll(container, {x:0, y:(element_y-container_y)});
  return false;
}

function showDetail(idObject, idReiseart, reiseziel) {
	
	var _url = '/web/index.cfm/pm/detail/idobjekt/'+idObject+'/idreiseart/'+idReiseart+'/reiseziel/'+reiseziel;
	var selObjMonth = document.getElementById('reisemonat');
	var selvalueMonth = selObjMonth.options[selObjMonth.selectedIndex].value
	var selObjKat = document.getElementById('hotelkategorie');
	var selvalueKat = selObjKat.options[selObjKat.selectedIndex].value
	if(selvalueMonth != "") {
		_url += '/reisemonat/'+selvalueMonth;
	}
	if(selvalueKat != -1) {
		_url += '/hotelkategorie/'+selvalueKat;
	}
	window.location.href= _url;
}

defaultValue = "Webcode eingeben";

function setDefaultValue() {
	var oInput = document.getElementById("reisecodeEingabe");
	var _value = oInput.value.replace(/^\s+/, '').replace(/\s$/,'');

	if(_value.length == 0) {
		oInput.value =  defaultValue;
	} else {
		oInput.value = _value;
	}
}

function hasDefaultValue(oInput) {
	if(oInput.value == defaultValue)
		return true;
	else
		return false; 
}

function observeSubmit(e, idElem) {
		var characterCode 
		if(e && e.which){ 
		e = e
		characterCode = e.which 
		}
		else{
		e = event
		characterCode = e.keyCode 
		}
		if(document.getElementById("reisecode_error").style.display == 'block')
			document.getElementById("reisecode_error").style.display = 'none'
		if(characterCode == 13){ 
			getDetail(idElem)
		}
}

function getDetail(idElem) {
	var elem = document.getElementById(idElem)
	
	var objektCode = encodeURI(elem.value);
		if(objektCode.length == 0 || objektCode == 'Reisecode%20eingeben')	{
			elem.value = "Reisecode eingeben";
			elem.select();
		}
		else	{
			var _url = 
			new Ajax.Request('/web/skripte/qry_objektId.cfm/objektCode/'+objektCode, {   
			onSuccess: SucheSuccess,
			onFailure: SucheFailure
			}); 
	}	
}

function SucheSuccess(transport) {
	var idObjekt = transport.responseText.strip()
	if( idObjekt != -1) {
		window.location.href ="/web/index.cfm/pm/detail/idObjekt/"+idObjekt
	} else {
		document.getElementById("reisecode_error").style.display='block';
	}
	
}

function SucheFailure(transport) {
alert(transport.responseText.strip())
}

function suchen() {
	var _url = "/web/index.cfm/pm/uebersicht/init/0";
	var _queryString = "";
	var selObj = document.getElementById('landId');
	
	if(selObj.options[selObj.selectedIndex].value != -1)
		_queryString = _queryString +"/idLand/"+selObj.options[selObj.selectedIndex].value;	
	
	selObj = document.getElementById('reiseartId');
	if(selObj.options[selObj.selectedIndex].value != -1)
		_queryString = _queryString +"/idReiseart/"+selObj.options[selObj.selectedIndex].value;	
	
	selObj = document.getElementById('abreisedatum');
	if(selObj.options[selObj.selectedIndex].value != -1)
		_queryString = _queryString +"/abreisedatum/"+selObj.options[selObj.selectedIndex].value;	

	new Ajax.Request("/web/skripte/session_updater.cfm"+_queryString,
	{
		onComplete: function(){
			window.location.href=_url;
		}
	}); 
	
}

function displayKurzansicht(idLand, idReiseart, idMetareiseart) {
	new Ajax.Request("/web/skripte/session_updater.cfm/idLand/"+idLand+"/idReiseart/"+idReiseart+"/idMetareiseart/"+idMetareiseart); 
	window.location.href = "/web/index.cfm/pm/uebersicht";
}

function displayStart() {
	new Ajax.Request("/web/skripte/session_updater.cfm/idLand/-1/idReiseart/-1/idMetareiseart/-1"); 
	window.location.href='/';
}

/* function to toggle menu items */
function displaysubmenue(menue)
{
 	if(eval("document.getElementById('sub"+menue+"').style.display=='none'")) 
 	{
		eval("document.getElementById('sub"+menue+"').style.display='block'");
	}  
 	else 
 	{
		eval("document.getElementById('sub"+menue+"').style.display='none'");
	}  
 } 
 function newsletter(url) {
    fenster = window.open(url, "fenster2", "width=450,height=400,status=no,scrollbars=no,location=no,resizable=yes,search=no");
    fenster.focus();}
	
	function kontakt(url) {
    fenster = window.open(url, "fenster3", "width=615,height=575,status=no,scrollbars=no,location=no,resizable=yes,search=no");
    fenster.focus();}

function grossbild(idbild,breite,hoehe) {
		gesamtbreite = breite +25;
		gesamthoehe = hoehe +30;
		open('/web/skripte/grossbild.cfm?idbild=' + idbild,'grossbild' + idbild,'width=' + gesamtbreite + ',height=' + gesamthoehe + ',scrollbars=No,location=No,left=150,top=0,menubar=No,alwaysRaised=Yes,resizable=Yes,toolbar=No,status =No').focus();
}

function updateHistory() {
	var remote_url = "/web/skripte/template/history_template.cfm"; 

	new Ajax.Request(remote_url); 
}
function cancelBubble(e) {
		try{
			e.cancelBubble = true;
			if(e.stopPropagation)
				e.stopPropagation();
		} catch(error){
			
		}
}
