ar1 = new Image();
ar1.src = '/img/ar1.gif';
$(document).ready(function()
{
$('.ix-country > a[href="#"]').on('click', function(e)
{
var block = $(this).parent().next('div');
if (block.is(':hidden'))
{
block.slideDown();
$('.ix-arrow', this).addClass('ix-arrow-expanded');
}
else
{
block.slideUp();
$('.ix-arrow', this).removeClass('ix-arrow-expanded');
}
return false;
});
$(window).on('load resize', function()
{
var list = $('#idx-regions-list');
var h = list.closest('table').height() - list.position().top + 40;
list.css('height', h + 'px');
});
$('#loadmore').on('click', LoadRecentPhotos).click();
$('#newrand' ).on('click', LoadRandomPhotos).click();
updateInterval = setInterval(LoadPubPhotos, 60000);
//$('#cname').citySelector('cid', { defaultLabel: _text['IX_ANY'] });
$('#type').on('change', function() { $('#type').attr('class', $('#type option:selected').attr('class')); }).change();
$('#num').on('change keyup', function() { $('#qsearch').prop('disabled', $('#num').val().trim() == ''); }).on('keypress', function(event) { if (event.keyCode == 13) { searchVehicles(); return false; } }).change();
$('#searchbtn').on('click', searchVehicles);
/*$('#qcity').citySelector(null, {
selectCallback: function(item) { window.open('/city/' + item.value + '/'); },
clearField: true
});*/
$(document).on('click', function(e)
{
var target = $(e.target);
if (target.closest('#cars_list').length > 0 ||
target.closest('#idx-column-menu').length > 0 ||
target.is('#mobile-menu') ||
target.is('button')) return;
$('#cars_list').hide().html('');
var menu = $('div#idx-column-menu');
if (menu.is(':visible'))
{
menu.hide();
$('#backgr').hide();
}
e.stopPropagation();
});
$('#loginbtn').on('click', function()
{
var username = $('#username').val().trim();
var password = $('#password').val().trim();
if (username != '' && username != '')
{
$('#loginbtn').prop('disabled', true).val(_text['IX_LOGGING']);
$.post('/api.php?action=check-login', { username: username, password: password, remember: $('#remember').is('checked') }, function(r)
{
if (r == 0)
$('#loginform').submit();
else window.location.reload();
})
.fail(function(jx) { if (jx.responseText != '') alert(jx.responseText); });
}
});
$('#mobile-menu').on('click', function()
{
$('#idx-column-menu, #backgr').toggle();
return false;
});
$('.ix-plus, .ix-minus').on('click', function()
{
$(this).toggleClass('ix-plus ix-minus');
var block = $(this).closest('.ix-region');
$('.ix-hideable-citylist, .ix-hideable-cname', block).toggle();
return false;
});
});
function searchVehicles()
{
$('#cars_list').html('').show();
$.get('/api.php', { action: 'index-qsearch', cid: $('#cid').val(), type: $('#type').val(), num: $('#num').val() }, function (r) { $('#cars_list').html(r); });
return false;
}
function AddPhotoToBlock(block, arr, prepend)
{
block[prepend ? 'prepend' : 'append']('