/** Copyright Eberhardt TRAVEL GmbH **/
var bilder = new Array();
var zaehler = 0;
var blender = 0;

jQuery(document).ready(function () {
if (jQuery('#slot_suche').length > 0)
{
suchtoggle('#slot_suche div.slotsuche .auswahl');
suchauswahl('#slot_suche div.slotsuche li a');
}
headtoggle();
  if(jQuery('#staedtereisen_logo').length > 0)
  {
    jQuery("#stadt").autocomplete("/suche/action/autocompleteStaedte", {
      minChars: 3,max: 25,autoFill: false,mustMatch: false,matchContains: true,
      selectFirst: false,scrollHeight:200,width:184,scroll:false, formatItem: formatItemS});
  }
  jQuery('#stadt').result(function (res, data)
  {
    jQuery('#suchfeldform').submit();
  });
  jQuery('#stadt').click(function () {
    jQuery('#stadt').val('');
  });
});
function formatItemS(row) {
  return row[0];
}

function entferne_suchbegriff() {
  var data = {};
  jQuery.post('/entferneSuchbegriff', data, function(){
    jQuery('#suchbegriff').val(''); 
    jQuery('#such_link').hide(); 
    
  });
  return false;
}

tout = 0;
function headtoggle() {
jQuery('#head .header li .n_top').click(
function () {
jQuery('#head .header li .n_top').next().hide();
jQuery(this).next().show();
tout = setTimeout('headertimer()', 500);
mouseov();
return false;
});
return false;
}
aktiv = 0;
function mouseov() {
jQuery('#head .header li:has(.n_top)').hover(function () {
clearTimeout(tout);
aktiv = 1;
},
function () {
clearTimeout(tout);
tout = setTimeout('headertimer()', 500);
aktiv = 2;
});
}
function headertimer() {
if (aktiv == 2)
{
jQuery('#head .header li .n_top').next().hide();
jQuery('#head .header li:has(.n_top)').unbind('hover');
}
}

lastobj = '';
var such_ids = new Array();
var clicksuche = 2;

function suchtoggle (tog) {
jQuery(tog).click(function () {
id = jQuery(this).attr('id');
click_all(tog);
var counter = 0;
jQuery(this).next().children('li').each(function () {
counter++;
});
 jQuery(tog).next().height('0.0em');
if (such_ids[id] == '1')
{
jQuery(this).next().animate({scrollTop: 0},100);
jQuery(this).next().height('0.0em');
such_ids[id] = 0;
}
else if (such_ids[id] == undefined || such_ids[id] == '0')
{
if (id.substr(0, 5) !== 'side_')
{
if (counter > 8)
{jQuery(this).next().height('190px');}
else
{jQuery(this).next().height('auto');}
}
else
{
var position_top = (jQuery(this).next().offset().top - jQuery(this).parent().parent().offset().top);
if (counter*17 > ((180-20)-position_top))
{jQuery(this).next().height(((180-20)-position_top)+'px');}
else
{jQuery(this).next().height((counter*20)+'px');}
}
such_ids =new Array();
such_ids[id] = 1;
}
lastobj = id;
});
}

function click_all(tog) {
jQuery(tog).next().hover(function ()
{clicksuche = 2;},
function ()
{clicksuche = 1;}
);
jQuery(tog).hover(function ()
{clicksuche = 2;},
function ()
{}
);
jQuery('body').click(function () {
if (clicksuche == 1 && jQuery('#'+lastobj).length > 0)
{
jQuery('body').unbind('click');
such_ids = new Array();
jQuery('.auswahl').next().height('0em');
clicksuche = 2;
jQuery(tog).unbind('hover');
}
});
}

function suchauswahl(auswahl) {
jQuery(auswahl).click(function () {
jQuery.ajax({
type: "get",
url: this.href,
data: "",
dataType: "html",
beforeSend: function() {jQuery('#ind').css('display', 'block');},
success: function(htmlResponse){
document.getElementById('slotsuche_bereich').innerHTML = htmlResponse;
suchtoggle('#slot_suche div.slotsuche .auswahl');
suchauswahl('#slot_suche div.slotsuche li a');
jQuery('#slot_suche div.slotsuche .auswahl').addClass('hintergrund');
jQuery('#ind').css('display', 'none');
jQuery('#such_button2').addClass('hintergrund_suchbutton');
setTimeout("blink()", 800);
such_ids = new Array();
}
});
return false;
});
}
function erw_suchauswahl(auswahl, tog) {
jQuery(auswahl).click(function () {
termin_von = jQuery('#termin_von').datePicker().val();
termin_bis = jQuery('#termin_bis').datePicker().val();
url = this.href;
sw_id = jQuery(this).parent().parent().attr('id');
if (sw_id == 'schwierigkeit')
{
  top.location.href = url.replace('suche', 'suchen');
}
jQuery.ajax({
type: "post",
url: this.href,
data: "",
dataType: "html",
beforeSend: function() {jQuery('#ind').css('display', 'block');},
success: function(htmlResponse){
document.getElementById('suchkrit').innerHTML = htmlResponse;
such_ids = new Array();
suchtoggle(tog);
erw_suchauswahl(auswahl, tog);
date_picker(termin_von, termin_bis);
jQuery('#suchkrit div.slotsuche .auswahl').addClass('hintergrund');
jQuery('#such_button2').addClass('hintergrund_suchbutton');
jQuery('.auswahl').next().height('0em');
jQuery('#ind').css('display', 'none');
setTimeout("erw_blink()", 800);
jQuery(function () {
  jQuery('.tipp').tooltip({delay: 100, showBody:"%", track: true, showURL:false});
});}
});
return false;
});}

function blink() {
jQuery('#slot_suche .auswahl').removeClass('hintergrund');
jQuery('#such_button2').removeClass('hintergrund_suchbutton');
}
function erw_blink() {
jQuery('#suchkrit div.slotsuche .auswahl').removeClass('hintergrund');
jQuery('#such_button2').removeClass('hintergrund_suchbutton');
}

function date_picker(termin_von, termin_bis)
{
jQuery(function()
{jQuery('.date-pick').datePicker();
jQuery('#termin_von').bind('dpClosed',function(e,selectedDates){var d=selectedDates[0];
  if(d){d=new Date(d);jQuery('#termin_bis').dpSetStartDate(d.addDays(1).asString());}});
jQuery('#termin_bis').bind('dpClosed',function(e,selectedDates)
{var d=selectedDates[0];if(d){d=new Date(d);jQuery('#termin_von').dpSetEndDate(d.addDays(-1).asString());}});});
jQuery('#termin_von').datePicker().val(termin_von);
jQuery('#termin_bis').datePicker().val(termin_bis);
var links = 0;
var breite_fest = 105;
var breite = 0;
jQuery.dpText = {
TEXT_PREV_YEAR: 'vorheriges Jahr',
TEXT_PREV_MONTH : 'vorheriger Monat',
TEXT_NEXT_YEAR: 'n&auml;chstes Jahr',
TEXT_NEXT_MONTH : 'n&auml;chster Monat',
TEXT_CLOSE: 'Schlie&szlig;en',
TEXT_CHOOSE_DATE: 'Bitte Datum w&auml;hlen',
HEADER_FORMAT:'mmmm yyyy'
}}

jQuery(document).ready(function () {
jQuery("#suchfeld").click(function () {jQuery(this).val('');});
jQuery("#suchfeld").autocomplete("/suche/action/autocompleteSuche", {
minChars: 3,max: 25,autoFill: false,mustMatch: false,matchContains: true,width: 185,
selectFirst: false,scrollHeight:200,width:184,scroll:false,formatItem: formatItem});
function formatItem(row) {
if (row[0] != row[1]){return row[0]+' - '+row[1];}
else
{return row[0];}}
jQuery('#suchfeld').result(function (res, data)
{if (data[0] == data[1])
{jQuery('#suchfeldformular').attr('action','/suchen/land/'+data[1]);}
else{jQuery('#suchfeldformular').attr('action','/suchen/land/'+data[1]+'/suchbegriff/'+data[0]);}
jQuery('#suchfeld').remove();jQuery('#suchfeldformular').submit();});});
