// Search ----------------------------------------------------------------------------------------------
function submitSuchFormByKey(x) { 
	if(document.all) { 
		if (event.keyCode==13) submitSuchForm();
	} else { 
		if (x.which==13) submitSuchForm(); 
	} 
} 

function submitSuchForm() { 
	if (document.getElementById('searchresult')){ 
		document.getElementById('searchresult').value=''; 
	} 
	document.form1.action='uebersicht.php'; setTimeout('document.form1.submit()',1);
}
// Favorites ----------------------------------------------------------------------------------------------
function putToMerkzettel(id, remove)
{
	var mPattern = /(^.+\/module\/\w+\/)/;
	var mStr = mPattern.exec(location.href);
	mArr = mStr[1].split("/");
	var module = mArr[(mArr.length - 2)];
	
	//pattern = /(^.+\/module\/)/;
	//var droot = pattern.exec(location.href);
	var url = mStr[1] + 'ajax_puttomerkzettel.php?id='+id+'&remove='+remove+'&module=' + module + '&rand='+ Math.random()*1000;

	new Ajax.Request(url, {   method: 'get',   onSuccess: function(transport){ onPutToMerkzettel(transport, id, remove); }   }); 
}

function onPutToMerkzettel(transport, id, remove){
	var favBox = jQuery('#favorites_box');
	var items = favBox.find('.favorite');
	var counter = favBox.find('#fav_count');
	var removeLnks = jQuery('#remove_fav_lnk_' + id);
	var insertLnks = jQuery('#insert_fav_lnk_' + id);		
	removeLnks.each(function(i, e){jQuery(e).removeClass('hidden');});
	insertLnks.each(function(i, e){jQuery(e).removeClass('hidden');});
	if(remove){		
		removeLnks.each(function(i, e){jQuery(e).hide();});
		insertLnks.each(function(i, e){jQuery(e).show();});
		favBox.find("#favorite_" + id).remove();
		toggleImage(favBox.find('.favorite').first(), "visible")
	}else{
		removeLnks.each(function(i, e){jQuery(e).show();});
		insertLnks.each(function(i, e){jQuery(e).hide();});
		if(items.length > 0){
			var item = favBox.find('.favorite').first();
			toggleImage(item, "hidden");
			item.before(transport.responseText);
		}else{
			favBox.find('.body').html(transport.responseText); 
		}
	}
	var items = favBox.find('.favorite');
	counter.html(items.length);
	toggleBox(favBox, items.length > 0 ? "visible" : "hidden");
}

function toggleImage(item, visibility){
	toggleElement(item.find(".image_wrapper"), visibility)
}
function toggleBox(favBox, visibility){
	toggleElement(favBox.find('.body'), visibility)
	toggleElement(favBox.find('.bottom'), visibility)
}
function toggleElement(item, visibility){
	item.removeClass("hidden visible");
	item.addClass(visibility);
}

// detail pages: ----------------------------------------------------------------------------------------------
// - change image:
function changeBild(x, id)
	{
		//document.images['dasbild'].src=x;
		var dib = $('detail_image_box');
		//dib.innerHTML = "<a href=" + x + " rel=lightbox[group" + id + "]><img src='" + x + "' border='0' id='dasbild' name='dasbild' <?=$addWidth?> alt=""></a>";
		dib.innerHTML = "<a href='" + x + "' rel='lightbox[group" + id + "]'><img src='" + x + "' id='dasbild' name='dasbild' alt=''></a>";
		initLightbox();
	}
// - accomodation calendar 

function checkFerienDatum()
{
	var von = document.getElementById('objekt_buchbar_von_jahr').value+""+document.getElementById('objekt_buchbar_von_monat').value+""+document.getElementById('objekt_buchbar_von_tag').value;
	var bis = document.getElementById('objekt_buchbar_bis_jahr').value+""+document.getElementById('objekt_buchbar_bis_monat').value+""+document.getElementById('objekt_buchbar_bis_tag').value;
	if (bis < von)
	{
		alert('<?=$text[223]?>');
		return false;
	}
	return true;
}


// ----------------------------------------------------------------------------------------------

function getWindowScrollTop() 
{
	if (document.documentElement && document.documentElement.scrollTop)
	{
		return document.documentElement.scrollTop;
	}
	else
	{
		return document.body.scrollTop;
	}
}

// ----------------------------------------------------------------------------------------------

