
//from: basedef.js
var Class =
{ create: function()
  { return function()
    { this.initialize.apply(this, arguments);
    }
  }
}

var myWin;
var Abstract = new Object();

function isArray(a) {
    return isObject(a) && a.constructor == Array;
}

function isObject(a) {
   return (a && typeof a == 'object');
}

function hotelinfo(purl,path,width,height){
//  if (purl.substring(0,4)!='http')
//    purl='http://kunden.easy-pax.net/giata/hotelinfo.php?'+purl;
  if (!width)
    width=700;
  if (!height)
    height=680;
  var htlwin = window.open(purl,'hotelinfowindow','channelmode=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=1,status=1,titlebar=0,toolbar=0,width='+width+',height='+height);
  htlwin.focus();
}

//from: calendar.js
var week_days = new Array(1, 1, 1, 1, 1, 1, 1);
var days = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var next_mon_text = "&gt;&gt;";
var prev_mon_text = "&lt;&lt;";
var dt_format = "d.m.Y";
var date_ctrl = null;
var curr_date = null;
var from_date = null;
var till_date = null;
var draw_date = null;
var calendar;//  = null;  // Calendar div
var direction;
var isFromDeeplink = false;
var deeplikPath = '../white/';

function calendarShow2(_curr_date, _target, _direction, _from_date, _till_date)
{ if(calendar)
    calendar.style.display='none';
  closebuton = imgsrc('close')+'  style="border:0px; cursor:pointer; margin-right:18px; float:right;"';
  isFromDeeplink = true;
  deeplikPath = '';
  calendarShow(_curr_date, _target, _direction, _from_date, _till_date);
  calendar.style.display='block';
}

function incDate(_source,days)
{ var curr_date=parseDate(_source);
  var newdate=new Date(curr_date.getFullYear(),curr_date.getMonth(),curr_date.getDate()+days);
  return formatDate(newdate.getFullYear(),newdate.getMonth(),newdate.getDate());
}

function incDate2(_source,days)
{ var curr_date=parseDate(_source);
  var newdate=new Date(curr_date.getFullYear(),curr_date.getMonth(),curr_date.getDate()+days);
  return formatDate(newdate.getFullYear(),newdate.getMonth(),newdate.getDate());
}


function calendarShow(_curr_date, _target, _direction, _from_date, _till_date)
{ direction = _direction;
  if(direction=='go')
    calendar=document.getElementById('calendar_div');
  if(direction=='back')
    calendar=document.getElementById('calendar_div2');
  if(!calendar)
    return;
  if(_from_date == null)
  { var offsetedDate = new Date();
    offsetedDate.setDate(offsetedDate.getDate());
    _from_date = '0'+offsetedDate.getDate()+'0'+(offsetedDate.getYear()-100)+'0'+(offsetedDate.getMonth()+1);
  }
  date_ctrl = document.getElementById(_target);
  from_date = _from_date;
  till_date = _till_date;
  curr_date = parseDate(_curr_date);
  if (!curr_date)
    curr_date = new Date();

  if (curr_date<parseDate(document.getElementById('calInput1').value))
    curr_date=parseDate(document.getElementById('calInput1').value);
  from_date = parseDate(from_date);
  till_date = parseDate(till_date);
  setCalendar();
}


function setCalendar(year, month)
{ var mtable;
  if(!calendar)
    return;
  if (year == null)
    year = curr_date.getFullYear();
  if (month == null)
    month = curr_date.getMonth();
//  if (month == 1)
  days[1] = (isLeap(year) ? 29 : 28);
  draw_date = new Date(year, month, 1);
  mtable ='<div class="yui-calcontainer">';
  mtable += '<div class="title ep3ctitle">';
  if(isFromDeeplink)
  { 
    mtable += '<img '+imgsrc('close')+' onclick="if(calendar) class="close-icon ep3iclose" calendar.style.display=\'none\';" alt="[Close]" />';
    mtable += calHeader;
  }
  else
  { mtable += calHeader;
    if(direction == 'go')
    { mtable += '<a href="javascript:void(0)" onclick="return false;"><img '+imgsrc('help')+' class="help-icon ep3ihelp" style="margin-right:3px;" onmouseover="ep_show(this,'+"'calendar_tooltip1'"+')" onmouseout="ep_hide(this)"/></a>';
      mtable += '<img '+imgsrc('close')+' class="close-icon" onClick="document.startdatepopup.hide();" alt="" style="cursor:pointer; margin-right:3px;"/>';
    }
    if(direction == 'back')
    { mtable += '<img '+imgsrc('close')+' class="close-icon ep3iclose" onClick="document.enddatepopup.hide();" alt="" style="cursor:pointer; margin-right:3px;"/>';
      mtable += '<a href="javascript:void(0)" onclick="return false;"><img '+imgsrc('help')+' class="help-icon" style="margin-right:3px;" onmouseover="ep_show(this,'+"'calendar_tooltip2'"+')" onmouseout="ep_hide(this)"/></a>';
    }
  }
  mtable += '</div>';
  mtable += '<div style="width:335px"><div class="cal2up ep3cal2up" style="margin-right: 10px; float:left; width:155px;" >'+getMonthHTML('first')+'</div>';
  mtable += '<div class="cal2up" style="float:left; width:155px; margin-right: 3px;">'+getMonthHTML('second')+'</div></div>';
  mtable += '</div>';
  calendar.innerHTML = mtable;
  if(!isFromDeeplink)
  { if(direction == 'go')
      document.startdatepopup.setautoleftspace(120).show(document.getElementById('calInput1').parentNode.parentNode);
    if(direction == 'back')
      document.enddatepopup.setautoleftspace(120).show(document.getElementById('calInput2').parentNode.parentNode);
  }
  //calendar.style.display='block';
  //calendar.style.top='320px';
}
function parseDate(str)
{ if (!str)
    return null;
  var chr = '';
  var year = '';
  var mon = '';
  var mday = '';
  var idx = 0;
  for (var i = 0; i < dt_format.length; i++)
  { chr = dt_format.charAt(i)
    switch (chr)
    { case "m":
        mon = str.substr((idx), 2);
        idx += 2;
        break;
      case "Y":
        year=((year = Number(str.substr(idx, 4)))<100?year+2000:year);
        idx += 4;
        break;
      case "y":
        year = "20" + str.substr(idx, 2);
        idx += 2;
        break;
      case "d":
        mday = str.substr(idx, 2);
        idx += 2;
        break;
      default:
        idx += 1;
        break;
    }
  }
  return (new Date(year, mon-1, mday));
}

function insertDate(year, month, day)
{ if(day<10)
  day = '0'+(day);
  if((month+1)<10)
    month = '0'+(month+1);
  else
    month = month+1;
  date_ctrl.value = day+'.'+month+'.'+year;//formatDate(year, month, day);
 
  { if(direction == 'go')
    {
      document.startdatepopup.hide();
      document.getElementById('calInput2').value=incDate2(day+'.'+month+'.'+year,20);
    }
    if(direction == 'back')  
      document.enddatepopup.hide();
  }
  if(date_ctrl.onchange)
    date_ctrl.onchange();
}

function calendarSetFormat(fmt)
{ dt_format = fmt;
}

function formatDate(year, month, day) 
{ var chr = '';
  var ret = '';
  for (var i = 0; i < dt_format.length; i++)
  { chr = dt_format.charAt(i)
    switch (chr)
    { case "m":
        month++;
        ret += (month < 10 ? "0"+month : month);
        break;
      case "Y":
        ret += year;
        break;
      case "y":
        ret += (new String(year)).substr(2);
        break;
      case "d":
        ret += (day < 10 ? "0"+day : day);
        break;
      default:
        ret += chr;
    }
  }
  return ret
}

function isLeap(year)
{ //return ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0)));
  return (year % 4 == 0);
}

function changeMonth(direction)
{ var month = draw_date.getMonth()-2;
  var year = draw_date.getFullYear()
  if (direction)
  { if (++month > 11)
    { month = (month+1)%12;
      year++;
    }
  }
  else
  { if (--month == -1)
    { month = 11;
      year--;
    }
  }
  setCalendar(year, month);
}

function getMonthHTML(number)
{ var year = draw_date.getFullYear();
  var month = draw_date.getMonth();
  var day = 1;
  var d = draw_date.getDay()-1;
  if (d == -1)
    d = 6;
  var active = 0;
  var tmp = '';
  var bgr = '';
  result  = '<table class="yui-calendar" cellpadding="0" cellspacing="0" border="0" width="100%" align="center" style="margin-top:3px;margin-bottom:3px;">';
  result += '<thead>';
  result += '<tr><th colspan="7" class="calhead ep3_calhead"><div class="calheader ep3calheader">';
  if(number=='first')
    result += '<img '+imgsrc('calnavleft')+' class="calnavleft ep3iback" style="margin:1px" align="absbottom" onclick="changeMonth(0)" alt="'+prev_mon_text+'"/>';
  result += months[month]+'&nbsp;'+year;
  if(number=='second')
    result += '<img '+imgsrc('calnavright')+' class="calnavright ep3inext" style="margin:1px" align="absbottom" onclick="changeMonth(1)" alt="'+next_mon_text+'"/>';
  result += '</div></th>';
  result += '</tr>';
  result += '<tr>';
  for(var i =0; i<6; i++)
    result += '<th class="calweekdaycell">'+week_days_text[i]+'</th>';

  result += '<th class="calweekdaycell">'+week_days_text[6]+'</th>';
  result += '</tr></thead><tbody>';
  for (var i = 0; i < 7 && day <= days[month]; i++)
  { for (var j = 0; j < 7; j++)
    { if ((i == 0 && j < d) || (day > days[month]))
      { tmp += getDayHTML(year, month, 0, 'oom calcell', 0);
      }
      else
      { active = 1;
        if (!week_days[(j == 6) ? 0 : j+1])
        { active = 0;
        }
        else
        { 
        }
        if (active)
          bgr = (j == 6 ? 'calcell' : 'calcell');
        else
          bgr = 'oom calcell';
        tmp += getDayHTML(year, month, day, bgr, active);
        draw_date.setDate(++day);
      }
    }
    result += '<tr align="center">'+tmp+'</tr>';
    tmp = '';
  }
  result += '</tbody></table>';
  return result;
}

function getDayHTML(year, month, day, classname, active)
{ //var now = new Date();
  var events = '';
  var value = '&nbsp;'
  var d=new Date(year,month,day);
  var tmpToday = new Date();
  var today=new Date(tmpToday.getFullYear(),tmpToday.getMonth(),tmpToday.getDate());
  if(d<today)
    active=0;
  if(direction=='back')
  { var hin = parseDate(document.getElementById('calInput1').value);
    if(d<=hin)
      active=0;
  }
  //var _style;
  if (day)
  { if ((curr_date.getDate() == day) && (curr_date.getMonth() == month) && (curr_date.getFullYear() == year))
      classname = 'calcell selected';
    if (active)
    { events = ' onmouseover="this.className=\'calcell calcellhover\'" onmouseout="this.className=\''+classname+'\'" onclick="insertDate('+year+', '+month+', '+day+')"';
    }
    else if(classname != 'calendar_mark')
    { classname='oom calcell calcelltop';
    }
    value = day;
  }
  return '<td class="'+classname+'" '+events+'>'+value+'</td>';
}

//from: popup.class.js

var PopupControl = Class.create();
PopupControl.prototype = {
  
  initialize: function(callback, frequency) {
      this.callback = callback;
      this.frequency = frequency;
      this.currentlyExecuting = false;
      this.listcontrols=Array();
      this.selecteditems=Array();
      this.afterinit=false;
      this.target=false;
      this.targetid;
      this.mouseover=false;
      this.leftspace=0;
      this.mouseover=false;
      this.noiframe=false;
      this.oldclass=null;
      this.autoleftspace=true;
    },

  setvalues:function()
  { var args=this.setvalues.arguments;
    this.bcolor=args[2];
    this.popupname=args[0];
    this.visible=false;
    this.targetid=args[1];
//    this.blight=(args.length>=5?args[3]:'#999999');
//    this.bdark=(args.length>=5?args[4]:'#000000');
    this.blight='#000000';
    this.bdark='#999999';
    this.writebefore();
    this.noiframe=(navigator.userAgent.indexOf('MSIE')<0);
    return this;
  },

  setleftspace:function(num)
  { this.leftspace=num;
    return this;
  },

  setautoleftspace:function(num)
  { this.leftspace=num;
    this.autoleftspace=true;
    return this;
  },

  writebefore:function()
  { document.write(
     '<div id="'+this.popupname+'topdiv" style="display:none;z-index:99;overflow:hidden;height:2px;width:100px;background-Color:'+this.blight+';background-image: url('+iberooturl+'img/border/h.gif);background-position:top"><div align="left" style="width:2px;height:2px;overflow:hidden;background-Color:'+this.blight+';background-image: url('+iberooturl+'img/border/c.gif);background-position:top left"></div></div>'+
     '<div id="'+this.popupname+'rightdiv" style="display:none;z-index:99;overflow:hidden;height:100px;width:2px;background-Color:'+this.bdark+';background-image: url('+iberooturl+'img/border/v.gif);background-position:right"><div align="left" style="width:2px;height:2px;overflow:hidden;background-Color:'+this.blight+';background-image: url('+iberooturl+'img/border/c.gif);background-position:top right"></div></div>'+
     '<div id="'+this.popupname+'leftdiv" style="display:none;z-index:99;overflow:hidden;height:100px;width:2px;background-Color:'+this.blight+';background-image: url('+iberooturl+'img/border/v.gif);background-position:left"></div>'+
     '<table style="display:none;z-index:98" id="'+this.popupname+'popuptable" border="0" cellspacing="0" cellpadding="0">'+
     '<tr>'+
       '<td style="width:2px;height:2px;background-color:'+this.blight+';background-image: url('+iberooturl+'img/border/c.gif);background-position:top left"><img src="'+iberooturl+'img/pixel.gif" style="display:block;" /></td>'+
       '<td style="height:2px;background-color:'+this.blight+';background-image: url('+iberooturl+'img/border/h.gif);background-position:top"><img id="'+this.popupname+'spacex" class="depflight_clicked color11bg" style="left:10px;position:relative;height:2px;width:20px; display:block;" src="'+iberooturl+'img/pixel.gif" /></td>'+
       '<td id="'+this.popupname+'rightcorner" style="width:2px;height:2px;background-color:'+this.blight+';background-image: url('+iberooturl+'img/border/c.gif);background-position:top right"><img src="'+iberooturl+'img/pixel.gif" style="display:block;" /></td>'+
     '</tr>'+
     '<td style="width:2px;background-color:'+this.blight+';background-image: url('+iberooturl+'img/border/v.gif);background-position:left"><img src="'+iberooturl+'img/pixel.gif" style="width:2px; display:block;" /></td><td class="depflight_clicked color11bg"><div>');
    return this;
  },

  writeafter:function()
  { document.write(
      '</div></td>'+
        '<td style="width:2px;background-color:'+this.bdark+';background-image: url('+iberooturl+'img/border/v.gif);background-position:right"><img src="'+iberooturl+'img/pixel.gif" style="width:2px; display:block;" /></td>'+
      '<tr>'+
        '<td style="width:2px;height:2px;background-color:'+this.blight+';background-image: url('+iberooturl+'img/border/c.gif);background-position:bottom left"><img src="'+iberooturl+'img/pixel.gif" style="display:block;" /></td>'+
        '<td style="height:2px;background-color:'+this.bdark+';background-image: url('+iberooturl+'img/border/h.gif);background-position:bottom"><img src="'+iberooturl+'img/pixel.gif" style="display:block;" /></td>'+
        '<td style="width:2px;height:2px;background-color:'+this.bdark+';background-image: url('+iberooturl+'img/border/c.gif);background-position:bottom right"><img src="'+iberooturl+'img/pixel.gif" style="display:block;" /></td>'+
      '</tr>'+
      '</table><iframe src="about:blank" id="'+this.popupname+'backgroundframe" border="0" style="display:none;z-index:2;overflow:hidden"></iframe>');
  },

  initobjects:function()
  {
    this.divt=document.getElementById(this.popupname+'topdiv');
    this.divr=document.getElementById(this.popupname+'rightdiv');
    this.divl=document.getElementById(this.popupname+'leftdiv');
    this.tblrc=document.getElementById(this.popupname+'rightcorner');
    this.space=document.getElementById(this.popupname+'spacex');
    this.tbl=document.getElementById(this.popupname+'popuptable');
    if (!this.noiframe)
       this.iframe=document.getElementById(this.popupname+'backgroundframe');
    this.target=document.getElementById(this.targetid);
    this.afterinit=true;
    this.tbl.popup=this;
    this.tbl.onmouseover=function(){this.popup.mouseover=true};
    this.tbl.onmouseout=function(){this.popup.mouseover=false};
  },

  resize:function()
  {
    ((((this.tbl.offsetWidth+this.currentox)<document.body.clientWidth) ||(this.tbl.offsetWidth>(this.currentox+this.target.offsetWidth))) !=(this.leftspace==0)) && this.show();
  },

  show:function()
  {
    if (this.visible)
      document.currentpopup=null;
    else if (document.currentpopup)
      document.currentpopup.hide();
    if (!this.afterinit) this.initobjects();
    var args=this.show.arguments;
    if (args.length==1 && args[0])
    {
       if (isObject(args[0]))
         this.target=args[0];
       else
        this.target=(document.getElementById(this.targetid=args[0]));
    }
     var p=this.target;
     //for (var ox=0,oy=0;p!=null;ox+=p.offsetLeft,oy+=p.offsetTop,p=p.offsetParent);
     
     var pos = findPos(p, true);
     var ox = pos[0], oy = pos[1];
     
     if (this.autoleftspace)
     {
         if (!this.visible)
         {
           this.tbl.style.position='absolute';
           this.tbl.style.top='0px';
           this.tbl.style.left='0px';
           this.tbl.style.visibility='hidden';
           this.tbl.style.display='';
         }
         if (((this.tbl.offsetWidth+ox)<document.body.clientWidth) || (this.tbl.offsetWidth>(ox+this.target.offsetWidth)))
           this.leftspace=0;
         else
           this.leftspace=this.tbl.offsetWidth-(this.target.offsetWidth+4);
     }
     this.divt.style.position='absolute';
     this.divt.style.top=(oy+1)+'px';
     this.divt.style.left=(ox-1)+'px';
     this.divt.style.width=(this.target.offsetWidth+2)+'px';
     this.divr.style.position='absolute';
     this.divr.style.top=(oy+1)+'px';
     this.divr.style.left=(ox+this.target.offsetWidth)+'px';
     this.divr.style.height=(this.target.offsetHeight)+'px';
     this.divl.style.position='absolute';
     this.divl.style.top=(oy+2)+'px';
     this.divl.style.left=(ox-1)+'px';
     this.divl.style.height=(this.target.offsetHeight+1)+'px';
     this.tbl.style.position='absolute';
     this.tbl.style.top=(oy+this.target.offsetHeight)+'px';
     this.tbl.style.left=(ox-(1+this.leftspace))+'px';
     this.tblrc.style.backgroundColor=((this.leftspace>0) && (this.autoleftspace)?'transparent':this.blight);
     if (!this.noiframe) {
       this.iframe.style.position=this.tbl.style.position;
       this.iframe.style.top=this.tbl.style.top;
       this.iframe.style.left=this.tbl.style.left;
     }
     this.space.style.width=(this.target.offsetWidth)+'px';
     this.space.style.left=(this.leftspace)+'px';
     this.divl.style.display='';
     this.divr.style.display='';
     this.divt.style.display='';
     this.tbl.style.display='';
     if (this.autoleftspace)
       this.tbl.style.visibility='';
     if (!this.visible)
     {
       if (!this.oldclass)
         this.oldclass=this.target.className;
       this.target.className=this.target.className+' depflight_clicked color11bg';
     }  
     if (!this.noiframe)
       this.iframe.style.display='';
     this.visible=true;
     this.currentox=ox;
     this.fixframe();
     document.currentpopup=this;
     if (this.onshow)
       this.onshow();
  },
  
  fixframe:function()
  {  if (this.noiframe) return;
     if (!this.visible) return;
     this.iframe.style.width=(this.tbl.offsetWidth)+'px';
     this.iframe.style.height=(this.tbl.offsetHeight)+'px';
  },

  hide:function()
  { if (this.forcevisible) return;
    if (!this.afterinit) return true;
    this.visible=false;
     this.divl.style.display=
     this.divr.style.display=
     this.divt.style.display=
     this.tbl.style.display='none';
     if (!this.noiframe)
       this.iframe.style.display='none';
     this.target.className=this.oldclass;
     this.oldclass=null;
     if (this.onhide)
       this.onhide();
    document.currentpopup=null;
  },
  
  toggle:function()
  { if (this.visible)
      this.hide();
    else
     this.show(this.toggle.arguments.length==1?this.toggle.arguments[0]:null);
   if (this.ontoggle)
     this.ontoggle(this.visible);
  },
  
  focus:function()
  { this.show();
  },
  
  blur:function()
  { if (!this.mouseover)
    { this.hide();
      this.mouseover=false;
    }
  }

}

//from: tooltip.js
document.popuptimer=null;

function getStyle(el, style){
  var value = el.style[style];
  if (!value) {
    if (el.currentStyle)
      value = el.currentStyle[style];
    if (document.defaultView)
      value = document.defaultView.getComputedStyle(el, null).getPropertyValue(style);
  }
  if (style == 'opacity')
    return value ? parseFloat(value) : 1.0;
  return value == 'auto' ? null : value; 
}



function findPos(  obj, useRelative )
{
  var curleft=0;
  var curtop=-2;
  var pos = null;
  for (  var o=obj;o;o=o.offsetParent )
  {
    pos = getStyle(o,'position');
    if ((pos == 'relative' || pos == 'absolute') && useRelative===true) break;
    curleft += o.offsetLeft;
    if (o.offsetTop > 0 || (o.offsetTop < 0 && document.isOP !== true))
      curtop += o.offsetTop;
 
    if (o.style.overflow=='auto')
    {
     curleft-= o.scrollLeft;	    
     curtop-= o.scrollTop;
    }
    if (document.isFF && o.parentNode && (o.parentNode!=o.offsetParent) && (o.parentNode.style.overflow=='auto'))
    {
     curleft-= o.parentNode.scrollLeft;	    
     curtop-= o.parentNode.scrollTop;
    }
  }
  return [curleft,curtop];
}

function getInternetExplorerVersion()
{
  var rv = null; 

  if (navigator.appName=='Opera')
  {
  document.isOP=true;document.isFF=false;document.isIE=false;
  }
  else if (navigator.appName=='Netscape')
  {
  document.isOP=false;document.isFF=true;document.isIE=false;
  }
  else
  {
   document.isOP=false;document.isFF=false;document.isIE=true;	  
  }
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}


function ep_show( obj,from )
{
  if (document.popuptimer)
    clearTimeout(document.popuptimer);
  if(  document.getElementById )
    ttiframeobj = document.getElementById(  "ttiframe" );
  var left=0;
  var top=0;
  //if (isArray(from))
  //  var srctip=from;
  //else
    var srctip=tooltip_msg[from];
  var frame=document.getElementById(  "ttiframe" );
  var h=document.getElementById(  "tth" );
  var triangle=document.getElementById(  "triangle" );
  var triangle_top=document.getElementById(  "triangle_top" );
  var c=document.getElementById(  "ttc" );
  var mode=0;
  var tt_top_left=document.getElementById(  "tt_top_left" );
  var tt_top_right=document.getElementById(  "tt_top_right" );
  var iebody=(  document.compatMode && document.compatMode != "BackCompat" )  ? document.documentElement : document.body
  var sleft=document.all? iebody.scrollLeft : pageXOffset
  var stop=document.all? iebody.scrollTop : pageYOffset
  var direction=srctip[  2 ];
  h.style.left=0+'px';
  h.style.top=0+'px';
  h.style.display='inline';
  c.innerHTML=srctip[  0 ];
  if (srctip[1] != '')
    c.style.width=srctip[1]+'px';
  else
    c.style.width='';
  triangle.style.visibility='hidden';
  triangle_top.style.visibility='visible';
  if (  document.compatMode && document.compatMode != "BackCompat" )
  {
    theWidth = document.documentElement.clientWidth;
    theHeight = document.documentElement.clientHeight;
  }
  else
  {
    theWidth = document.body.clientWidth;
    theHeight = document.body.clientHeight;
  }


  if (  direction=='lt' )
  {
    mode=2;
    left=theWidth-h.offsetWidth-(  theWidth-findPos(  obj )  [  0 ]  )  +24;
    tt_top_left.style.width=( h.offsetWidth-45 >= 0 ? h.offsetWidth-45 : 0)+'px';
    tt_top_right.style.width=2+'px';
    triangle.className = 'ep3tooltip tth_arrow_bottom';
    triangle_top.className = 'ep3tooltip tth_arrow_top_left';

    top=findPos(  obj )  [  1 ]  -h.offsetHeight;
    triangle_top.style.visibility='hidden';
    triangle.style.visibility='visible';
  }
  if (  direction=='lb' )
  {
    mode=0;
    left=theWidth-h.offsetWidth-(  theWidth-findPos(  obj )  [  0 ]  )  +24;
    tt_top_left.style.width=( h.offsetWidth-45 >= 0 ? h.offsetWidth-45 : 0)+'px';
    tt_top_right.style.width=2+'px';
    triangle.className = 'ep3tooltip tth_arrow_bottom';
    triangle_top.className = 'ep3tooltip tth_arrow_top_left';

    top=findPos(  obj )  [  1 ]  +obj.offsetHeight;
    triangle_top.style.visibility='visible';
    triangle.style.visibility='hidden';
  }
  if (  direction=='rb' )
  {
    mode=3;
    left=findPos(  obj )  [  0 ];
    tt_top_left.style.width=2+'px';
    tt_top_right.style.width=( h.offsetWidth-45 >= 0 ? h.offsetWidth-45 : 0)+'px';
    triangle.className = 'ep3tooltip tth_arrow_bottom_right';
    triangle_top.className = 'ep3tooltip tth_arrow_top';

    top=findPos(  obj )  [  1 ]  +obj.offsetHeight;
    triangle_top.style.visibility='visible';
    triangle.style.visibility='hidden';
  }

  if (  direction=='rt' )
  {
    mode=1;
    left=findPos(  obj )  [  0 ];
    tt_top_left.style.width=2+'px';
    tt_top_right.style.width=( h.offsetWidth-45 >= 0 ? h.offsetWidth-45 : 0)+'px';
    triangle.className = 'ep3tooltip tth_arrow_bottom_right';
    triangle_top.className = 'ep3tooltip tth_arrow_top';

    top=findPos(  obj )  [  1 ]  -h.offsetHeight;
    triangle_top.style.visibility='hidden';
    triangle.style.visibility='visible';
  }
  var relPosFull = findPos(h);
  var relPosPart = findPos(h, true);
  var relPos = [relPosFull[0]-relPosPart[0], relPosFull[1]-relPosPart[1]];
  h.style.left=findPos(  obj )  [  0 ] -relPos[0] +'px';
  h.style.top=findPos(  obj )  [  1 ] -relPos[1] +20+'px';

  if (srctip[3]==1)
  {
    if ( ( findPos( obj ) [ 0 ] +h.offsetWidth ) >theWidth )
    {
      left=theWidth-h.offsetWidth-(  theWidth-findPos(  obj )  [  0 ]  )  +24;
      tt_top_left.style.width=( h.offsetWidth-45 >= 0 ? h.offsetWidth-45 : 0)+'px';
      tt_top_right.style.width=2+'px';
      triangle.className = 'ep3tooltip tth_arrow_bottom';
      triangle_top.className = 'ep3tooltip tth_arrow_top_left';
      if (direction=='rt') { mode=2; direction='lt';}//lt
      if (direction=='rb') { mode=0; direction='lb';}//lb
    }
    if ( left<0 )
    {
     
    left=findPos(  obj )  [  0 ];
    tt_top_left.style.width=2+'px';
      tt_top_right.style.width=( h.offsetWidth-45 >= 0 ? h.offsetWidth-45 : 0)+'px';
    triangle.className = 'ep3tooltip tth_arrow_bottom_right';
    triangle_top.className = 'ep3tooltip tth_arrow_top';
    if (direction=='lt') { mode=1;direction='rt';}//rt
    if (direction=='lb')  {mode=3;direction='rb';}// rb
    }
    
    if ( ( findPos( obj ) [ 1 ] -stop+obj.offsetHeight+h.offsetHeight ) >=theHeight )
    {
      top=findPos(  obj )  [  1 ]  -h.offsetHeight;
      triangle_top.style.visibility='hidden';
      triangle.style.visibility='visible';
      
      if (direction=='lb')  {mode=2;direction='lt';}//lt
      if (direction=='rb')  {mode=1;direction='rt';}// rt
    }
    if ( top <0 )
    {
     top=findPos(  obj )  [  1 ]  + 4 + obj.offsetHeight;
    triangle_top.style.visibility='visible';
    triangle.style.visibility='hidden';
    if (direction=='lt')  {mode=0;direction='lb';}//lb
    if (direction=='rt')  {mode=3;direction='rb';}// rb
    }
  }
  h.style.left=(left-relPos[0])+'px';
  h.style.top=(top-relPos[1])+'px';
  if ( (document.isIE) && (document.iever < 7) ) {
  renew(  mode,c.offsetWidth,c.offsetHeight,11 );
  }
}

function hide(obj)
{
//if (document.popuptimer)
//  clearTimeout(document.popuptimer);
//document.popuptimer=setTimeout('hide2()',500);
  ep_hide(obj);  
}

function show2()
{
  if (document.popuptimer)
    clearTimeout(document.popuptimer);
}

function ep_hide(obj)
{
  if (document.popuptimer)
    clearTimeout(document.popuptimer);
  var h=document.getElementById(  "tth" );
  var c=document.getElementById(  "ttc" );
  var tt_top_left=document.getElementById(  "tt_top_left" );
  var tt_top_right=document.getElementById(  "tt_top_right" );
  var triangle=document.getElementById(  "triangle" );
  var triangle_top=document.getElementById(  "triangle_top" );
  tt_top_right.style.width=0;
  tt_top_left.style.width=0;
  triangle_top.style.visibility='hidden';
  triangle.style.visibility='hidden';
  c.innerHTML='';
  h.style.display='none';
  h.style.left=0;
  h.style.top=0;
}

function renew(  mode,x,y,o )
{
  y+=2;
  //alert(mode+" "+x+" "+y+" "+o);
  var aaa=new Array(  5,20,x+3,1,3,21,x+7,1,2,22,x+9,1,1,23,x+11,2,0,25,x+14,y,1,y+25,x+12,2,2,y+27,x+10,1,3,y+28,x+7,1,5,y+29,x+3,2 );
  var arr = Array( // left:5px; top:20px; width:203px; height:1px;"
              /*0 lb*/     Array( x-o+3,18,1,2,x-o+1+3,16,1,4, x-o+2+3,14,1,6,x-o+3+3,12,1,8,x-o+4+3,9,1,11,x-o+5+3,7,1,13,x-o+6+3,5,1,15,x-o+7+3,2,1,18,x-o+8+3,0,2,20 ),
              /*1 rt*/     Array(  o-2,y+30,2,20,o,y+30,1,18,o+1,y+30,1,15,o+2,y+30,1,13,o+3,y+30,1,11,o+4,y+30,1,8,o+5,y+30,1,6,o+6,y+30,1,4,o+7,y+30,1,2 ),
              /*2 lt*/     Array(  x-o+2,y+30,1,2,x-o+2+2,y+30,1,4,x-o+3+2,y+30,1,6,x-o+4+2,y+30,1,8,x-o+5+2,y+30,1,11,x-o+6+2,y+30,1,13,x-o+7+2,y+30,1,15,x-o+8+2,y+30,1,18,x-o+9+2,y+30,2,20 ),
              /*3 rb*/     Array(  o+9,18,1,2,o+8,16,1,4,o+7,14,1,6,o+6,12,1,8,o+5,9,1,11,o+4,7,1,13,o+3,5,1,15,o+2,2,1,18,o,0,2,20 )  );

  for(  var i=1;i<=9;i++ )
  {
    var obj=document.getElementById(  'a'+i );
    //ALert(obj+aaa[ (  (  i-1 )  *4 )  ]+" "+aaa[ 1+ (  (  i-1 )  *4 )  ]+" "+aaa[ 2+ (  (  i-1 )  *4 )  ]+" "+aaa[3+  (  (  i-1 )  *4 )  ]);
    if (obj)
    {
      obj.style.left=aaa[  (  (  i-1 )  *4 )  ];
      obj.style.top=aaa[  1+(  (  i-1 )  *4 )  ];
      obj.style.width=aaa[  2+(  (  i-1 )  *4 )  ];
      obj.style.height=aaa[  3+(  (  i-1 )  *4 )  ];
      obj.style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
    }
  }
  for(  var i=10;i<=18;i++ )
  {
    var obj=document.getElementById(  'a'+i );
    if (obj)
    {
      obj.style.left=arr [   mode ][  (  (  i-10 )   * 4 )   ];
      obj.style.top=arr[  mode ][  1+(  (  i-10 )  *4 )  ];
      obj.style.width=arr[  mode ][  2+(  (  i-10 )  *4 )  ];
      obj.style.height=arr[  mode ][  3+(  (  i-10 )  *4 )  ];
      obj.style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
    }
  }
}

document.iever=getInternetExplorerVersion();

function showWaitMessage(msg,trgid)
{
 if (!msg)
 {
   msg='Bitte haben Sie einen Moment Geduld.<br/>Die Daten werden geladen...';
 }
  document.getElementById((!trgid)?'mctd':trgid).innerHTML=
'<div style="overflow-y: auto; overflow-x: hidden; height: 520px;" class="loader">'+
'<center style="position: relative; top: 190px;"><table><tbody>'+
'<tr><td style="text-align: center;"><br/></td></tr><tr><td style="text-align: center;">'+msg+'<br/> </td></tr> </tbody></table></center><div style="clear: both; display: none;" class="nofloat"/> </div>';
}


var Cookies = {
    set: function (name, value, seconds) {
        if (typeof(seconds) != 'undefined') {
            var date = new Date();
            date.setTime(date.getTime() + (seconds*1000));
            var expires = "; expires=" + date.toGMTString();
        }
        else {
            var expires = "";
        }
        document.cookie = name+"="
            +(typeof(encodeURI)!='undefined'?encodeURI(value):escape(value))
            +expires+"; path=/";
    },
    get: function (name, _default) {
        name = name + "=";
        var carray = document.cookie.split(';');

        for(var i=0;i < carray.length;i++) {
            var c = carray[i];
            while (c.charAt(0)==' ') c = c.substring(1,c.length);
            if (c.indexOf(name) == 0) 
              return typeof(decodeURI)!='undefined'
                       ?decodeURI(c.substring(name.length,c.length))
                       :unescape(c.substring(name.length,c.length));
        }
        return (typeof(_default)!='undefined')?_default:null;
    },
    del: function (name) {
        this.setCookie(name, "", -1);
    }
}



/**
  * Parse URL from easypax3.
  * @param: gate_var_name or null
  * @param: url, must have '?' in string
  * @return Array(nurl,gurl,url);
     where:
       url  (array)  list array params, eg: ['aa[]=2','aa[2]=2']
       nurl (object) list params, eg: {aa:1,bb:'q'}
       gurl (object) parsed ep3[] param: ep3[]=%3Fro%3DPA%26sd%3D*7  => {ro:'PA',sd:'*7'}
  */
function ep3_parseURL(gateparamname, inurl){
  if(inurl.indexOf('?') == -1)
    return [[],{},{}];
  
  var nurl={}, gurl={}, ep3url = '';
  var rex = /^([^\[]+)(\[([^\]]*)\])?=(.*)$/;
  var tmp = '';
  var url = [], turl = [];
  var ourl=inurl.replace(/^[^\?]*\?/,'').replace(/#.*$/,'').replace(/&amp;/g,'&').split('&');
  for(var i=0; i<ourl.length; i++)
  {
    if(ourl[i] == '')
      continue;
    tmp = rex.exec(ourl[i]);
    // arrays - ["aaaa[bbb]=xxx", "aaaa", "[bbb]", "bbb", "xxx"]
    if(typeof(tmp[2]) == 'undefined' || tmp[2] == '')
      nurl[tmp[1]] = unescape(tmp[4]);
    else if(gateparamname && tmp[1] == gateparamname)
      ep3url+='&'+unescape(tmp[4]).replace(/^[^\?]*\?/,'').replace(/#.*$/,'').replace(/&amp;/g,'&');
    else // javascript arrays
      url.pop(tmp[0]);
  }
  
  if (ep3url.length > 0){
    ourl = ep3url.split('&');
    for(var i=0; i<ourl.length; i++)
    {
      if(ourl[i] == '')
        continue;
      tmp = rex.exec(ourl[i]);
      if(typeof(tmp[2]) == 'undefined' || tmp[2] == '')
        gurl[tmp[1]] = unescape(tmp[4]);
    }
  }
  
  return [nurl,gurl,url];
}


function getpageWidth()
{
  if( typeof( window.innerWidth ) == 'number' ) {
    return window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    return document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    return document.body.clientWidth;
  }  
}


  function ep3_getAjaxData(url,cb)
  {
    var http_request;
    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text');
            // See note below about this line
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }
    if (!http_request) {
        return false;
    }


    switch(cb){
      default:
      http_request.onreadystatechange = function() { ep3_cbEvalData(http_request) };
    }
    http_request.open('GET', url, true);
    http_request.send(null);
    return http_request; 
  }
  
var   ep3_cbDesCounter = 0;  
function ep3_cbEvalData(http_request) {
  ep3_cbDesCounter--;
  if (http_request.readyState == 4) {
      if (http_request.status == 200){
        eval(http_request.responseText);
         http_request=null;
         return ;
      }
  }
}

function ess_getdep(gate)
{
  var url = '?'+ep3_getSearchURL().join('&');
  if(gate)
    url = '?'+gate+'[]='+encodeURIComponent(url);
  ep3_getAjaxData(valprefixurl+url+'&'+depurl);
}
function ep3_getSearchURL()
{
  var x=document.forms['form_params'].elements;
  var url=new Array();
  for (var i=0;i<x.length;i++)
  {
    if ((x[i].name!='') && (x[i].value!='') && (x[i].value!='0') && (!x[i].disabled) && ((x[i].type!='radio') || (x[i].checked)))
      url.push(x[i].name+'='+encodeURIComponent(x[i].value));
  }
  return url;
}


	function ep3_asg(sender_id,target,mode)
	{
		var sender=document.getElementById(sender_id);

		if (sender.timeout)
			clearTimeout(sender.timeout);
		if (sender.value!='')
    {
		  var trgt=document.getElementById(target);
			trgt.firstChild.innerHTML=WaitText;
			trgt.style.display='block';
			sender.timeout=setTimeout('ep3_asg_sendrq("'+sender_id+'","'+target+'","'+mode+'")',100);
		}
		else
	  {
			document.getElementById(target).style.display='none';
		}
	}

	function ep3_asg_sendrq(sender,target,mode)
	{
		var sender=document.getElementById(sender);
		if (sender.http_request)
			sender.http_request.abort();
		if (window.XMLHttpRequest) { // Mozilla, Safari,...
			sender.http_request = new XMLHttpRequest();
			if (sender.http_request.overrideMimeType) {
				sender.http_request.overrideMimeType('text');
			}
		} else if (window.ActiveXObject) { // IE
			try {
				sender.http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					sender.http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
		if (!sender.http_request) {
			return false;
		}
		ep3_stparam=ep3_stparam.substring(ep3_stparam.indexOf('?')+1);
		var url='?'+ep3_stparam;
		params="md="+mode+"&qt="+sender.value;
    if (valprefixurl!='')
    {
      url=url.substring(url.indexOf('?'));
      url=valprefixurl+url;
		}

    sender.http_request.open('POST', url, true);
		sender.http_request.onreadystatechange = function() { setASG(sender.http_request,target) };

    //Send the proper header information along with the request
    sender.http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    sender.http_request.setRequestHeader("Content-length", params.length);
    sender.http_request.setRequestHeader("Connection", "close");
    sender.http_request.send(params);

	}
	function setASG(http_request,target) {
    //var type=setresults.arguments[1];
    if (!http_request) return;
    if (http_request.readyState == 4) {
			if (http_request.status == 200)
			{
				document.getElementById(target).firstChild.innerHTML=http_request.responseText;
				http_request=null;
			}
    }
  }
  
  function ep3HideHotelHint()
  {
    var hotelfield = document.getElementById('hotelname_search');
    if (hotelfield)
      hotelfield.nextSibling.style.display='none';
  }

  function ep3ExpandMoreCriteria()
  {
    var moreCriteria = document.getElementById('moreCriteria');
    var moreCriteriaLink = document.getElementById('moreCriteriaLink');
    if (moreCriteria && moreCriteriaLink)
    {
      var criteria_inputs = moreCriteria.getElementsByTagName("input");
      if (criteria_inputs.length)
      {
        for (var i=0; i < criteria_inputs.length; i++)
        {
          if (criteria_inputs[i].name != '' && criteria_inputs[i].value != '' && criteria_inputs[i].value != '0')
            onClikMoreCriteria(moreCriteriaLink);
        }
      }
      var criteria_inputs = moreCriteria.getElementsByTagName("select");
      if (criteria_inputs.length)
      {
        for (var i=0; i < criteria_inputs.length; i++)
        {
          if (criteria_inputs[i].name != '' && criteria_inputs[i].value != '' && criteria_inputs[i].value != '0')
            if (criteria_inputs[i].name!='tt' || criteria_inputs[i].value!='F')
              onClikMoreCriteria(moreCriteriaLink);
        }
      }
    }
  }
  
  var ep3mapLoadedFlag = false;
  function expandMaps()
  {
    if (ep3mapsContainer = document.getElementById('moreMaps'))
    {
      if (ep3mapsContainer.style.display == 'none')
      {
        ep3mapsContainer.style.display = '';
        if(typeof ep3mainmap == 'object' && !ep3mapLoadedFlag)
        {
          ep3loadMap(ep3mainmap);
          ep3mapLoadedFlag = true;
        }
      }
      else
        ep3mapsContainer.style.display = 'none';
    }
  }
  
function inArray( elem, array ) {
  if ( array.indexOf ) {
    return array.indexOf( elem );
  }
  
  for ( var i = 0, length = array.length; i < length; i++ ) {
    if ( array[ i ] === elem ) {
      return i;
    }
  }
  
  return -1;
} 

var winRef;
function ep3LiveChat(id,af)
{
  var l_url = 'http://livechat.merlinx.pl/front.php?agent_id=' + id + '&agent_af=' + af;
  var l_windowName = 'LiveChat';
  var l_width = 780;
  var l_height = 600;
  var l_params = 'status=0' +
                 ',resizable=0' +
                 ',scrollbars=0' +
                 ',width=' + l_width +
                 ',height=' + l_height +
                 ',left=0' +
                 ',top=0';
  if (winRef == null || winRef.closed)
  {
    winRef = window.open(l_url, l_windowName, l_params);
    winRef.moveTo(0,0);
    winRef.resizeTo(l_width, l_height);
  }
  else
  {
    winRef.focus();
  }
}

