function init()
{
    if (document.getElementById('cal'))
    {
        window.vpa_cal=new VPA_calendar("vpa_cal","cal");
    }
    //show_search_forms();
    try {
    vpa_sg=new VPA_singleton;
    vpa_sg.add('ajax',new VPA_AJAX);
    if (!window['ob_country']) window.ob_country=new Array();
    if (!window['ob_resort']) window.ob_resort=new Array();
    window.ob_country[0]={name:'resort', method:'resorts_for_country',local_id:'id',remote_id:'country_id',show_values:'name',show_pattern:'%0'};
    window.ob_resort[0]={name:'hotel_name', method:'hotels_with_null',local_id:'hotel_id',remote_id:'resort_id',show_values:'name',show_pattern:'%0'};

    init_field_handler('country','handler_country');
    init_field_handler('resort','handler_resort');

    /** сейчас у нас letun.ru корзина не работает (не выводим форму поиска и заказа)
    window.setInterval(get_recycle_small_info,1000);
    */
    } catch (e) { alert(e.message);}
    
    if (document.getElementById('scroller'))
    {
        var scroll=new VPA_vscroller('scroller',0,5);
    }
}

function show_search_forms()
{
    var rd=document.getElementById('search_radio');
    var rds=rd.getElementsByTagName('input');
    for (var i=0;i<rds.length;i++)
    {
        rds[i].onfocus=function ()
        {
            var rds=document.getElementById('search_radio').getElementsByTagName('input');
            for (var i=0;i<rds.length;i++)
            {
                document.getElementById(rds[i].value).style.display='none';
            }
            this.checked=true;
            document.getElementById(this.value).style.display='block';
            return true;
        }
    }
}

function show_search_form(obj)
{
    var rds=document.getElementById('search_radio').getElementsByTagName('input');
    for (var i=0;i<rds.length;i++)
    {
        document.getElementById(rds[i].value).style.display='none';
    }
    this.checked=true;
    document.getElementById(obj.value).style.display='block';
    return true;
}

function vpa_calendar_day_click(day,month,year,obj)
{
    document.getElementById(obj).value=day+'/'+month+'/'+year;
}


function show_added_params()
{
    document.getElementById('added_params').style.display='none';
    document.getElementById('added_params_show').style.display='block';
}
var last_pnode=null;
function hide_info_abrev()
{
    if(!last_pnode) return false;
    els=last_pnode.getElementsByTagName('div');
    if(!els.length) return false;
    last_pnode.removeChild(els[0]);
    return true;
}
function show_info_abrev(obj)
{
    hide_info_abrev();
    if(!obj) return false;
    pnode=obj.parentNode;
    if(!pnode) return false;
    clone=document.getElementById('info_abrev').cloneNode(true);
    if(!clone) return false;
    clone.id='';
    clone.style.display='block';
    pnode.appendChild(clone);
    last_pnode=pnode;
    return true;
}
function sort_result(obj)
{
    //if(!obj.checked) return false;
    wl=window.location.toString();
    window.location=wl.replace(/(([^\/]*?::)+)(\w+)/,"$1"+obj.value);
}
function confirm_del(name)
{
    return window.confirm('Вы действительно хотите удалить \''+name+'\' ?');
}