var js_api;

function query(args, handl) {
    jQuery.post('/js_api', args, function(data) { handl(data); });
}
     
js_api = {

     change_loc: function(id, handl) {
         query({'id': id, 'act': 'change_loc'}, handl);
     },

     get_loc_info: function(id, handl) {
         query({'id': id, 'act': 'get_loc_info'}, handl);
     },

     get_country_info: function(id, handl) {
         query({'id': id, 'act': 'get_country_info'}, handl);
     },

     get_stock_info: function(handl) {
         query({'act': 'get_stock_info'}, handl);
     },

     get_filters_by_color: function(id, handl) {
         query({'act': 'get_filters', 'color': id}, handl);
     },

     
     get_filters_by_volume: function(id, handl) {
         query({'act': 'get_filters', 'volume': id}, handl);
     },

     reg_filter: function(name, filter, phone, email, date, d, a, b, c, captcha, handl) {
         query({'act': 'reg_filter', 'name': name, 'filter': filter, 'phone': phone, 'email': email, 'date': date, 'days': d, 'a': a, 'b': b, 'c': c, 'captcha': captcha}, handl);
     },

     check_nick: function(nick, email, handl) {
         query({'act': 'check_nick', 'nick': nick, 'email': email}, handl);
     },

     reg_user: function(name, nick, pass, email, captcha, handl, from_filter) {
         jQuery.get('/registration', {'n': name, 'nc': nick, 'pass': pass, 'e': email}, function(data) { handl(data); });
     },

     install_filter: function(name, filter, phone, adres, region, captcha, handl) {
         query({'act': 'install_filter', 'name': name, 'adres': adres, 'filter': filter, 'phone': phone, 'region': region, 'captcha': captcha}, handl);
     }, 

     login: function(login, pass, handl) {
         jQuery.get('/login', {'login': login, 'pass': pass}, function(data) { handl(data); });
     },

     diller_reg: function(name, geo, phone, email, person, quote, info, country, captcha, handl) {
         query({'act': 'diller_reg', 'name': name, 'geo': geo, 'email': email, 'person': person, 'country': country, 'quote': quote, 'info': info, 'phone': phone, 'captcha': captcha}, handl);
     },

     order_call: function(name, phone, date, time, captcha, handl) {
         query({'act': 'order_call', 'name': name, 'date': date, 'time': time, 'phone': phone, 'captcha': captcha}, handl);
     },

     conf_user: function(code, handl) {
         query({'act': 'conf_user', 'code': code}, handl);
     },

     conf_filter: function(code, handl) {
         query({'act': 'conf_filter', 'code': code}, handl);
     },

     set_filter_notice: function(c, e, i, date, mod_filter, d, handl) {
         query({'act': 'set_filter_notice', 'c': c, 'e': e, 'i': i, 'date': date, 'days': d, 'filter': mod_filter}, handl);
     },

     get_filter_capacity: function(filter, handl) {
         query({'act': 'get_filter_capacity', 'filter': filter}, handl);
     },

     no_notification: function(phone, handl) {
         query({'act': 'no_notification', 'phone': phone}, handl);
     },

     notification_conf: function(code, handl) {
         query({'act': 'notification_conf', 'code': code}, handl);
     },

     update_filter_notice: function(c, e, i, handl) {
         query({'act': 'update_filter_notice', 'c': c, 'e': e, 'i': i}, handl);
     },
     
     check_captcha: function(captcha, handl) {
         query({'act': 'check_captcha', 'captcha': captcha}, handl);
     },

     get_filters_by_id: function(filters, ctrdgs, handl) {
         query({'act': 'get_filters_by_id', 'filters': filters, 'catridges' : ctrdgs}, handl);
     },

     minus_comment_mark: function(id,handl) {
         query({'act': 'minus_comment_mark', 'id': id}, handl);
     },

     plus_comment_mark: function(id, handl) {
         query({'act': 'plus_comment_mark', 'id': id}, handl);
     },

     add_comment: function(text, rel_id, elem_id, handl) {
         query({'act': 'add_comment', 'rel_id': rel_id, 'text': text, 'elem_id': elem_id}, handl);
     },

     load_tpl: function(name, handl) {
         query({'act': 'load_tpl', 'name': name}, handl);
     },

     load_filters: function(handl) {
         query({'act': 'load_filters'}, handl);
     },

     load_cities: function(handl) {
         query({'act': 'load_cities'}, handl);
     },

     get_modifications: function(filter, phone, handl) {
         query({'act': 'get_modifications', 'filter': filter, 'phone': phone}, handl);
     },

     reg_user_with_filter: function(name, nick, pass, email, filter, phone, date, d, a, b, c,
        captcha, handl, from_filter) {
         jQuery.get('/registration', {'act': 'with_filter', 'n': name, 'nc': nick, 'pass': pass, 'e': email, 'f': filter, 'p': phone,
             'dt': date, 'ds': d, 'a': a, 'b': b, 'c': c}, function(data) { handl(data); });
     },

     trackCatalogPage: function(id) {
         query({'act': 'trackCatalogPage', 'id': id}, function(data){});
     }
}
