function fun_onload() { } 
var ep3_current_step = 1;
var ep3_searchform = true;


  var iberooturl='http://ibero.merlinx.pl/6688/accent/';
  var basecgurl='http://ibero.merlinx.pl/easypax3/';
  var valurl='ep3[]=action%3Dvalidate';
  var depurl='ep3[]=action%3Ddeplist%26sp%3D4';
  var valprefixurl='/validate/';
  document.imgn=new Object();
  document.imgn['submit']=new Array(1,'/customgraphics/submit/type1.gif');document.imgn['back']=new Array(2,'/customgraphics/back/type1.gif');document.imgn['listarrow']=new Array(3,'/customgraphics/listarrow/type1.gif');document.imgn['calnavleft']=new Array(4,'/customgraphics/calnavleft/type1.gif');document.imgn['calnavright']=new Array(5,'/customgraphics/calnavright/type1.gif');document.imgn['hotelstar']=new Array(6,'/customgraphics/hotelstar/type1.gif');document.imgn['calendar']=new Array(11,'/customgraphics/calendar/type1.gif');document.imgn['close']=new Array(8,'/customgraphics/close/type1.gif');document.imgn['clear']=new Array(22,'/customgraphics/clear/type1.gif');document.imgn['accept']=new Array(21,'/customgraphics/accept/type1.gif');document.imgn['help']=new Array(12,'/customgraphics/help/type1.gif');document.imgn['book']=new Array(13,'/customgraphics/book/type1.gif');document.imgn['tobook']=new Array(14,'/customgraphics/tobook/type1.gif');document.imgn['sun']=new Array(15,'/customgraphics/sun/type1.gif');document.imgn['water']=new Array(16,'/customgraphics/water/type1.gif');document.imgn['listarrowr']=new Array(17,'/customgraphics/listarrowr/type1.gif');document.imgn['listarrowd']=new Array(18,'/customgraphics/listarrowd/type1.gif');document.imgn['bullet']=new Array(19,'/customgraphics/bullet/type1.gif');document.imgn['info']=new Array(20,'/customgraphics/info/type1.gif');document.imgn['map']=new Array(23,'/customgraphics/map/type1.gif');document.imgn['zoover']=new Array(24,'/customgraphics/zoover/type1.gif');  function imgsrc(name)
  {
    return " in='"+name+"' src='http://ibero.merlinx.pl"+document.imgn[name][1]+"' ";
  }
  function setimgonobj(o,name)
  {
    o.src=document.imgn[name][1];
    o.setAttribute('in',name);
  }
//setup for JS objects:
  //calender, in ibe.js
  var calHeader = 'Alegeti o data';
  var months = new Array('Ianuarie','Februarie','Martie','Aprilie','Mai','Iunie','Iulie','August','Septembrie','Octombrie','Noiembrie','Decembrie');
  var week_days_text = Array('Lu','Ma','Mi','Jo','Vi','Sa','Du');
  //dest.class
  var imagespath = '';
  //all steps
  var searchtypeSubmit = '';
  var searchtypeRadio  = '';
  //tooltips, in ibe.js
  var directory="http://ibero.merlinx.pl/6688/accent/img/tooltip/green/";
  var tooltip_msg=new Array();
  tooltip_msg['calendar_tooltip1']    =new Array('Data plecarii. Aici puteti stabili cea mai apropiata data de plecare. Va rugam sa introduceti orice data',340,'lt',1);
  tooltip_msg['calendar_tooltip2']    =new Array('Data plecarii. Aici puteti stabili cea mai indepartata data de plecare. Va rugam sa introduceti orice data',340,'lt',1);
  tooltip_msg['destpanel_tooltip']    =new Array('Va rugam sa alegeti alta destinatie preferata pentru calatorie. Daca doriti sa cautati prin toate ofertele, va rugam sa selectati "oricare" sau sa lasati campul gol',340,'lt',1);
  tooltip_msg['departure_tooltip']    =new Array('Lista orase (aeroporturi) de plecare',340,'lt',1);
  tooltip_msg['flightpanel_tooltip']  =new Array('Aici va puteti alege pana la 3 aeroporturi pentru calatoria dvs. Ofertele propuse vor contine doar acele calatorii cu aeroporturile selectate.',350,'lt',1);
  tooltip_msg['kidsage_tooltip']      =new Array('Pentru a calcula costul corect al calatoriei este necesara varsta exacta a copilului',320,'lt',1);
  tooltip_msg['trippacket_tooltip']   =new Array('Pachetul dvs. de calatorie. Aici puteti gasi atat pachetul ales de dvs. cat si oferte viitoare pentru datele introduse. Dupa alegerea zborurilor dus-intors, puteti sa configurati mai multe combinatii de zboruri pentru a le compara. Dati click pe combinatia de zbor dorita pentru ca aceasta sa fie selectata pentru rezervare.',345,'lt',1);
  tooltip_msg['combineitself_tooltip']=new Array('Va rugam sa alegeti alt zbor dus-intors. Sistemul va calcula noul cost in concordanta cu noua dvs. alegere',345,'lt',1);
  tooltip_msg['pricechart_tooltip']=new Array('xxx',345,'lt',1);
  tooltip_msg['attr_tooltip']=new Array('Preferinte.Va rugam selectati preferintele Dumneavoastra. Daca doriti sa vedeti toate ofertele, lasati campurile nebifate.	',345,'lt',1);
  
  var AnyText='Oricare';
  
  function onChangeChildage(_el){
    var stChild = document.getElementById('child1AgeSel');
    var ndChild = document.getElementById('child2AgeSel');
    var rdChild = document.getElementById('child3AgeSel');
    if(_el.value =='')
    {
      if(_el.id=='child3AgeSel')
        return;
      if(_el.id=='child1AgeSel')
        stChild.value = ndChild.value;
      ndChild.value = rdChild.value;
      return rdChild.value = '';
    }
    if(_el.value =='' ||_el.id=='child1AgeSel')
      return;
    
    if(stChild.value == '')
    {
      stChild.value = _el.value;
      return _el.value='';
    }
    if(ndChild.value == '')
    {
      ndChild.value = _el.value;
      return _el.value='';
    }
    
  }
  
  
  function onClikMoreCriteria(_el){
    document.getElementById('moreCriteria').style.display = '';
    if (document.getElementById('moreAttributes') && document.getElementById('searchtype').value != 'RR')
      document.getElementById('moreAttributes').style.display = '';
    document.getElementById('lessCriteriaLink').style.display = '';
    _el.style.display = 'none';
    Cookies.set('ep3_fulsearchform',1,600);
    showHideCallPopups();
  }
  function onClikLessCriteria(_el){
    document.getElementById('moreCriteria').style.display = 'none';
    if (document.getElementById('moreAttributes'))
      document.getElementById('moreAttributes').style.display = 'none';
    document.getElementById('moreCriteriaLink').style.display = '';
    _el.style.display = 'none';
    Cookies.set('ep3_fulsearchform',0,600);
    showHideCallPopups();
  }
  
  function showHideCallPopups(){
  }
  
  function ep3_registerOver(tagName){
    tagName = tagName.toUpperCase();
    var els = document.getElementsByTagName(tagName);
    var atr = null;
    for(var i=0; i<els.length; i++)
    {
      atr = els[i].getAttribute('ep3_mouseover');
      if(atr){
        atr = atr.split('@');
        if(atr.length == 1){
          atr[1] = atr[0];
          atr[0] = els[i].className;
        }
        
        els[i].setAttribute('ep3_mouseout', els[i].className);
        els[i].setAttribute('ep3_mouseover', els[i].className.replace(atr[0], atr[1]) );
        els[i].onmouseover = function (){
          this.className=this.getAttribute('ep3_mouseover');
        };
        els[i].onmouseout  = function(){
          this.className=this.getAttribute('ep3_mouseout');
        };
      }
    }
  }
  
    var ep3_fakeElement = document.createElement('div');
  function byID(id){
    return document.getElementById(id)||ep3_fakeElement;
  }
  function showVByID(id){
    byID(id).style.visibility = '';
  }
  function hideVByID(id){
    byID(id).style.visibility = 'hidden';
  }
  function showByID(id){
    byID(id).style.display = '';
  }
  function hideByID(id){
    byID(id).style.display = 'none';
  }
  
  var __ifr;
function calendarShow(_curr_date, _target, _direction, _from_date, _till_date)
{ 
  calendarHide();
  direction = _direction;
  if(direction=='go')
    calendar=document.getElementById('calendar_div');
  if(direction=='back')
    calendar=document.getElementById('calendar_div2');
  if(!calendar)
    return;
  
  calendar.parentNode.style.position = 'relative';
  calendar.style.display = '';
  
  var pos = findPos(calendar.parentNode);
  if(getpageWidth()< pos[0]+355)
    calendar.style.right="0px";
  else 
    calendar.style.right = null;
  
  
  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();
  days[1] = (isLeap(year) ? 29 : 28);
  draw_date = new Date(year, month, 1);
  mtable ='<div class="yui-calcontainer color11bg color1bo" id="ep3_autogencal">';
  mtable += '<div class="title">';
  if(isFromDeeplink)
  { 
    mtable += '<img '+imgsrc('close')+' onclick="if(calendar) class="close-icon" 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" align="absmiddle" style="margin-right:3px;" onmouseover="ep_show(this,'+"'calendar_tooltip1'"+')" onmouseout="ep_hide(this)" /></a>';
      mtable += '<img '+imgsrc('close')+' class="close-icon" onClick="calendarHide();" alt="" align="absmiddle" style="cursor:pointer; margin-right:3px;"/>';
    }
    if(direction == 'back')
    { 
      mtable += '<img '+imgsrc('close')+' class="close-icon" onClick="calendarHide();" align="absmiddle" 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)" align="absmiddle" /></a>';
    }
  }
  mtable += '</div>';
  mtable += '<div style="width:325px; position:relative;"><div class="cal2up" style="margin-left:5px;" >'+getMonthHTML('first')+'</div>';
  mtable += '<div class="cal2up" style="right:5px;position:absolute;">'+getMonthHTML('second')+'</div></div>';
  mtable += '</div>';
  calendar.innerHTML = mtable;
  
  var myheight = document.getElementById('ep3_autogencal');
  if(myheight && myheight.style.pixelHeight != undefined){
    __ifr = document.getElementById(calendar.id + '_ie')
    if(__ifr){
      __ifr.style.height = Math.max(myheight.offsetHeight*1 - 2, 145)+'px';
      __ifr.style.display='';
      if(calendar.style.right)
        __ifr.style.right="0px";
      else 
        __ifr.style.right = null;
    }
  }//is IE
}

function calendarHide(){
  if(calendar)
  {
    calendar.parentNode.style.position = 'static';
    calendar.style.display = 'none';
  }
  if(__ifr){
    __ifr.style.display = 'none';
  }
}

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;
  {
    if(direction == 'go')
      document.getElementById('calInput2').value=incDate2(day+'.'+month+'.'+year,20);
  }
  calendarHide();
}

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"><div class="calheader">';
  if(number=='first')
    result += '<img '+imgsrc('calnavleft')+' class="calnavleft" 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" 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 (from_date && draw_date.getTime() < from_date.getTime())
          //  active = 0;
          //if (till_date && draw_date.getTime() > till_date.getTime())
          //  active = 0;
        }
        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 ep3_getSearchType(){
  return  document.getElementById('searchtype')?document.getElementById('searchtype').value:'PA';
}


function ep3_getSearchURLAccent()
{
  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].name!='') && (x[i].value!='') && (x[i].value!='0') && ((x[i].type!='radio') || (x[i].checked)))
    {
      url.push(x[i].name+'='+escape(x[i].value));
    }
  }
  return url;
}

function modifyDays()
{
    var departDate = document.forms['form_params'].calInput1.value.split('.');
    var returnDate = document.forms['form_params'].calInput2.value.split('.');

    departDate[1] = departDate[1].replace(/^0*/, "");
    departDate[0] = departDate[0].replace(/^0*/, "");

    returnDate[1] = returnDate[1].replace(/^0*/, "");
    returnDate[0] = returnDate[0].replace(/^0*/, "");

    var dd = new Date();
    dd.setYear( parseInt(departDate[2]) );
    dd.setMonth( parseInt(departDate[1]) - 1 );
    dd.setDate( parseInt(departDate[0]) - 5);

    var rd = new Date();
    rd.setYear( parseInt(returnDate[2]));
    rd.setMonth( parseInt(returnDate[1]) - 1 );
    rd.setDate( parseInt(returnDate[0]) + 5);

    var d = parseInt(dd.getDate()); d = d<10?('0'+d):d;
    var m = parseInt(dd.getMonth()+1); m = m<10?('0'+m):m;
    dd = d+'.'+m+'.'+dd.getFullYear();

    var d = parseInt(rd.getDate()); d = d<10?'0'+d:d;
    var m = parseInt(rd.getMonth()+1); m = m<10?'0'+m:m;
    rd = d+'.'+m+'.'+rd.getFullYear();

    document.forms['form_params'].calInput1.value = dd;
    document.forms['form_params'].calInput2.value = rd;
    
}

function merlinFrontpageFormSubmit()
{
    document.searchtypeSubmit = document.searchtypeRadio;
    document.getElementById("searchtype").value = document.searchtypeSubmit;
    document.getElementById("step").value = '2';
    document.forms['form_params'].sp.value = '2';
    if (document.getElementById('desCode').value.length != '')
    { 
        document.getElementById("step").value = '3';
    }

    modifyDays();
    
    var url=ep3_getSearchURLAccent();
    var gateparamname='ep3';
    if (gateparamname!=null)
    {
        //ourl = document.URL.replace(/#.*/,'').replace(/\+/g, ' ').split('&');
        ourl = [document.forms['form_params'].action];
        var nurl=Array();
  
        if(typeof(ourl[0]) != "undefined")
        {
            if(ourl[0].indexOf('?')>=0)
            {
                nurl.push(document.URL.replace(/\?.*$/,''));
            }
            ourl[0] = ourl[0].replace(/^[^\?]*\?/,'');
        }
        for (var i=0;i<ourl.length;i++)
        {
            if (ourl[i].split('=').shift()!=gateparamname+'[]')
            {
                nurl.push(ourl[i]);
            }
        }
        nurl.push(gateparamname+'[]='+escape('?'+url.join('&')));
        var l = '';     
        if ((nurl.length<3) && (nurl[0].substring(nurl[0].length-1)!='?'))       
        {
            l=nurl.join('?')+(typeof(ep3_gate_sf_param)!='undefined'?'&'+ep3_gate_sf_param:'');
        }
        else
        {
            if(nurl[0].substring(nurl[0].length-1)!='?')
            {
                nurl[0] += '?';
            }
            l=nurl.join('&')+(typeof(ep3_gate_sf_param)!='undefined'?'&'+ep3_gate_sf_param:'');
        }
        
        window.location = l;
    }
    else
    {
        try{
            window.location.href='?'+url.join('&')+(typeof(ep3_gate_sf_param)!='undefined'?+'&'+ep3_gate_sf_param:'');        
        }
        catch(e){
            //    window.document.forms['form_params'].submit();
        }
    }
}

