/**
 * Created by JetBrains PhpStorm.
 * User: jerum
 * Date: 15.04.11
 * Time: 13:58
 * To change this template use File | Settings | File Templates.
 */





function deletePhoto(photo_id, hash) {
    if (confirm('Вы уверены что хотите удалить фото?')) {
        $.post('/ajax/deletePhoto', {'photo_id':photo_id, 'hash':hash}, function(data) {
            $('#photo_' + photo_id).fadeOut('slow', function() {
                $('#photo_' + photo_id).remove();
            })

        })
    }
}


function getDistricts(cities_obj, districts_obj, adv_type) {
    var city_id = $(cities_obj + ' :selected').val();

    if(city_id==3){
        $('dl.district').fadeOut();
        var name = $('dl.district select').attr('name');
        $('<input type="hidden" name="'+name+'" value="" id="district_hidden">').appendTo('.eform');


    }else{
        $('dl.district').show();
        $('#district_hidden').remove();
        $.post('/ajax/getDistricts',{'city_id':city_id, 'adv_type':adv_type},
            function(data) {
                var obj = eval('(' + data + ')');
                $(districts_obj).empty();
                for (i in obj.items) {
                    var district = obj.items[i];
                    $(districts_obj).append('<option value="' + district.id + '">' + district.name + '</option>');
                }
            });
    }
}


function saveGoodsOnPage(value) {
    $.cookie('goods_on_page', value, {path: "/"});
    window.location.reload(true);
    return false;
}

function setAdvMode(value) {
    $.cookie('adv_mode', value, {path: "/"});
    window.location.reload(true);
    return false;
}


function setPriceLabel(){
    var value = $('.is_for_rent input:radio:checked').val();

    if(value==1){
        $('#price_label').html('руб/мес');
    }else{
        $('#price_label').html('тыс. руб');
    }
}
