/** * Виджет калькуляции стоимости доставки * * @author Stas Lozitskiy */ if (undefined === Glavpunkt) { var Glavpunkt = {}; } if (undefined !== Glavpunkt.calculator) { throw('Glavpunkt.calculator allready defined'); } Glavpunkt.calculator = { coreDomElement: undefined, MAX_WEIGHT: 20, host: '//glavpunkt.ru', formHtml: '
Город отправки
Тип доставки
Город назначения
Способ оплаты
Вес заказа, кг.
Стоимость заказа
 
© Главпункт
', styleLink: "/widgets/css/calculator.v1.css", citiesFrom: ['Санкт-Петербург', 'Москва'], // Годода самовывоза citiesSimpleSpb: [{"name":"Санкт-Петербург","cities":[{"id":"SPB","name":"Санкт-Петербург"},{"id":"VLH","name":"Волхов"},{"id":"VSL","name":"Всеволожск"},{"id":"VBR","name":"Выборг"},{"id":"GTN","name":"Гатчина"},{"id":"KNP","name":"Кингисепп"},{"id":"KRSH","name":"Кириши"},{"id":"KRV","name":"Кировск"},{"id":"KLP","name":"Колпино"},{"id":"KRS","name":"Красное Село"},{"id":"KRN","name":"Кронштадт"},{"id":"LMN","name":"Ломоносов"},{"id":"LUG","name":"Луга"},{"id":"MURI","name":"Мурино"},{"id":"PTF","name":"Петергоф"},{"id":"PUSH","name":"Пушкин"},{"id":"SST","name":"Сестрорецк"},{"id":"SSB","name":"Сосновый Бор"},{"id":"TXV","name":"Тихвин"},{"id":"TSN","name":"Тосно"},{"id":"SHLS","name":"Шлиссельбург"},{"id":"SHSH","name":"Шушары"}]},{"name":"Москва","cities":[{"id":"MSK","name":"Москва"},{"id":"APR","name":"Апрелевка"},{"id":"BAL","name":"Балашиха"},{"id":"BTV","name":"Бутово"},{"id":"VDN","name":"Видное"},{"id":"VLM","name":"Волоколамск"},{"id":"VKS","name":"Воскресенск"},{"id":"DZER","name":"Дзержинский"},{"id":"DMT","name":"Дмитров"},{"id":"DGP","name":"Долгопрудный"},{"id":"DOM","name":"Домодедово"},{"id":"DBN","name":"Дубна"},{"id":"EGO","name":"Егорьевск"},{"id":"ZHLD","name":"Железнодорожный"},{"id":"ZHU","name":"Жуковский"},{"id":"ZVG","name":"Звенигород"},{"id":"ZLN","name":"Зеленоград"},{"id":"IVT","name":"Ивантеевка"},{"id":"IST","name":"Истра"},{"id":"KLM","name":"Климовск"},{"id":"KLN","name":"Клин"},{"id":"KOL","name":"Коломна"},{"id":"KMNR","name":"Коммунарка"},{"id":"KRL","name":"Королев"},{"id":"KOTE","name":"Котельники"},{"id":"KPHR","name":"Красная Пахра"},{"id":"KGS","name":"Красногорск"},{"id":"KRSK","name":"Краснознаменск"},{"id":"RU57","name":"Кубинка"},{"id":"LKN","name":"Ликино-Дулево"},{"id":"LBN","name":"Лобня"},{"id":"LIT","name":"Лыткарино"},{"id":"LYB","name":"Люберцы"},{"id":"MBSH","name":"Малаховка"},{"id":"MIT","name":"Митино"},{"id":"MIH","name":"Михнево"},{"id":"MOZ","name":"Можайск"},{"id":"MON","name":"Монино"},{"id":"MOK","name":"Московский"},{"id":"MYT","name":"Мытищи"},{"id":"NFM","name":"Наро-Фоминск"},{"id":"NHB","name":"Нахабино"},{"id":"NVP","name":"Ново-Переделкино"},{"id":"NOG","name":"Ногинск"},{"id":"ODC","name":"Одинцово"},{"id":"OZU","name":"Орехово-Зуево"},{"id":"OSTR","name":"Островцы"},{"id":"PPS","name":"Павловский Посад"},{"id":"POD","name":"Подольск"},{"id":"PUS","name":"Пушкино"},{"id":"RAM","name":"Раменское"},{"id":"RTK","name":"Реутов"},{"id":"SVRN","name":"Северный"},{"id":"SPD","name":"Сергиев Посад"},{"id":"SER","name":"Серпухов"},{"id":"SLG","name":"Солнечногорск"},{"id":"SLN","name":"Солнцево"},{"id":"STKP","name":"Старая Купавна"},{"id":"SKH","name":"Старые Химки"},{"id":"STP","name":"Ступино"},{"id":"SHD","name":"Сходня"},{"id":"TMLN","name":"Томилино"},{"id":"TRC2","name":"Троицк, Московская обл"},{"id":"FRY","name":"Фрязино"},{"id":"KHI","name":"Химки"},{"id":"CHXV","name":"Чехов"},{"id":"SHTR","name":"Шатура"},{"id":"WLK","name":"Щелково"},{"id":"SHRB","name":"Щербинка"},{"id":"EST","name":"Электросталь"},{"id":"UBL","name":"Юбилейный"},{"id":"YAM","name":"Ям"}]},{"name":"Адыгея Респ","cities":[{"id":"MKP","name":"Майкоп"}]},{"name":"Алтай Респ","cities":[{"id":"GOR","name":"Горно-Алтайск"},{"id":"MMA","name":"Майма"}]},{"name":"Алтайский край","cities":[{"id":"BRN","name":"Барнаул"},{"id":"BSK","name":"Бийск"},{"id":"ZRNK","name":"Заринск"},{"id":"RU75","name":"Камень-на-Оби"},{"id":"NVL","name":"Новоалтайск"},{"id":"RUB","name":"Рубцовск"}]},{"name":"Амурская обл","cities":[{"id":"BLGK","name":"Белогорск"},{"id":"BLG","name":"Благовещенск"}]},{"name":"Архангельская обл","cities":[{"id":"ARH","name":"Архангельск"},{"id":"RU77","name":"Вельск"},{"id":"RU30","name":"Новодвинск"},{"id":"RU73","name":"Няндома"},{"id":"SDV","name":"Северодвинск"}]},{"name":"Астраханская обл","cities":[{"id":"AST","name":"Астрахань"}]},{"name":"Башкортостан Респ","cities":[{"id":"BELE","name":"Белебей"},{"id":"ISI","name":"Ишимбай"},{"id":"KUM","name":"Кумертау"},{"id":"MLU","name":"Мелеуз"},{"id":"NKM","name":"Нефтекамск"},{"id":"OKT","name":"Октябрьский"},{"id":"SAL","name":"Салават"},{"id":"SBI","name":"Сибай"},{"id":"SLT","name":"Стерлитамак"},{"id":"TMZ","name":"Туймазы"},{"id":"UFA","name":"Уфа"},{"id":"UCHL","name":"Учалы"}]},{"name":"Белгородская обл","cities":[{"id":"BEL","name":"Белгород"},{"id":"GBK","name":"Губкин"},{"id":"SOL","name":"Старый Оскол"}]},{"name":"Брянская обл","cities":[{"id":"BRY","name":"Брянск"},{"id":"RU53","name":"Дятьково"},{"id":"KLC","name":"Клинцы"},{"id":"RU44","name":"Новозыбков"}]},{"name":"Бурятия Респ","cities":[{"id":"UUD","name":"Улан-Удэ"}]},{"name":"Владимирская обл","cities":[{"id":"ALK","name":"Александров"},{"id":"VLA","name":"Владимир"},{"id":"VZN","name":"Вязники"},{"id":"GRH","name":"Гороховец"},{"id":"GHR","name":"Гусь-Хрустальный"},{"id":"KRZH","name":"Киржач"},{"id":"KOV","name":"Ковров"},{"id":"RU40","name":"Кольчугино"},{"id":"MRM","name":"Муром"},{"id":"RU81","name":"Чудиново"}]},{"name":"Волгоградская обл","cities":[{"id":"VGG","name":"Волгоград"},{"id":"VOL","name":"Волжский"},{"id":"KMS","name":"Камышин"}]},{"name":"Вологодская обл","cities":[{"id":"VLG","name":"Вологда"},{"id":"RU6","name":"Сокол"},{"id":"CHR","name":"Череповец"}]},{"name":"Воронежская обл","cities":[{"id":"BBR","name":"Бобров"},{"id":"BRG","name":"Борисоглебск"},{"id":"VRN","name":"Воронеж"},{"id":"LIS","name":"Лиски"},{"id":"RSSH","name":"Россошь"},{"id":"RU66","name":"Семилуки"}]},{"name":"Дагестан Респ","cities":[{"id":"MKH","name":"Махачкала"}]},{"name":"Еврейская АО","cities":[{"id":"BRZH","name":"Биробиджан"}]},{"name":"Забайкальский край","cities":[{"id":"BRZ2","name":"Борзя"},{"id":"ZBK","name":"Забайкальск"},{"id":"CHI","name":"Чита"}]},{"name":"Ивановская обл","cities":[{"id":"RU14","name":"Вичуга"},{"id":"IVA","name":"Иваново"},{"id":"KIN","name":"Кинешма"},{"id":"RU19","name":"Родники"},{"id":"SHU","name":"Шуя"}]},{"name":"Ингушетия Респ","cities":[{"id":"NAZ","name":"Назрань"}]},{"name":"Иркутская обл","cities":[{"id":"ANG","name":"Ангарск"},{"id":"BRA","name":"Братск"},{"id":"IRK","name":"Иркутск"},{"id":"USL","name":"Усолье-Сибирское"},{"id":"UIL","name":"Усть-Илимск"}]},{"name":"Кабардино-Балкарская Респ","cities":[{"id":"NAL","name":"Нальчик"},{"id":"RU34","name":"Прохладный"}]},{"name":"Калининградская обл","cities":[{"id":"KLD","name":"Калининград"}]},{"name":"Калмыкия Респ","cities":[{"id":"ELS","name":"Элиста"}]},{"name":"Калужская обл","cities":[{"id":"BLB","name":"Балабаново"},{"id":"KAL","name":"Калуга"},{"id":"KIRV","name":"Киров, Калужская обл"},{"id":"LDN","name":"Людиново"},{"id":"MYR","name":"Малоярославец"},{"id":"OBN","name":"Обнинск"}]},{"name":"Камчатский край","cities":[{"id":"ELV","name":"Елизово"},{"id":"PTK","name":"Петропавловск-Камчатский"}]},{"name":"Карачаево-Черкесская Респ","cities":[{"id":"CHRK","name":"Черкесск"}]},{"name":"Карелия Респ","cities":[{"id":"PTR","name":"Петрозаводск"}]},{"name":"Кемеровская обл","cities":[{"id":"BLO","name":"Белово"},{"id":"BRZK","name":"Березовский, Кемеровская обл"},{"id":"KEM","name":"Кемерово"},{"id":"KSS","name":"Киселевск"},{"id":"LKC","name":"Ленинск-Кузнецкий"},{"id":"MZHR","name":"Междуреченск"},{"id":"MSKI","name":"Мыски"},{"id":"NKZ","name":"Новокузнецк"},{"id":"OSI","name":"Осинники"},{"id":"PRK","name":"Прокопьевск"},{"id":"RU76","name":"Таштагол"},{"id":"YURG","name":"Юрга"}]},{"name":"Кировская обл","cities":[{"id":"KIR","name":"Киров"},{"id":"KCH","name":"Кирово-Чепецк"}]},{"name":"Коми Респ","cities":[{"id":"VKT","name":"Воркута"},{"id":"INT","name":"Инта"},{"id":"STK","name":"Сыктывкар"},{"id":"UXT","name":"Ухта"}]},{"name":"Костромская обл","cities":[{"id":"KST","name":"Кострома"}]},{"name":"Краснодарский край","cities":[{"id":"ANP","name":"Анапа"},{"id":"ARM","name":"Армавир"},{"id":"BLR","name":"Белореченск"},{"id":"GLD","name":"Геленджик"},{"id":"ESK","name":"Ейск"},{"id":"KRD","name":"Краснодар"},{"id":"KRP","name":"Кропоткин"},{"id":"KRM","name":"Крымск"},{"id":"LBS","name":"Лабинск"},{"id":"NVR","name":"Новороссийск"},{"id":"SKB","name":"Славянск-на-Кубани"},{"id":"SCH","name":"Сочи"},{"id":"TMR","name":"Темрюк"},{"id":"TKH","name":"Тихорецк"},{"id":"RU56","name":"Туапсе"},{"id":"USTL","name":"Усть-Лабинск"}]},{"name":"Красноярский край","cities":[{"id":"ACH","name":"Ачинск"},{"id":"ZHEL","name":"Железногорск"},{"id":"ZLG","name":"Зеленогорск"},{"id":"KAN","name":"Канск"},{"id":"KRY","name":"Красноярск"},{"id":"RU23","name":"Лесосибирск"},{"id":"MIN","name":"Минусинск"},{"id":"NZR","name":"Назарово"},{"id":"NOR","name":"Норильск"}]},{"name":"Крым Респ","cities":[{"id":"ALSH","name":"Алушта"},{"id":"BCH","name":"Бахчисарай"},{"id":"DNK","name":"Джанкой"},{"id":"EVP","name":"Евпатория"},{"id":"KRC","name":"Керчь"},{"id":"KRPK","name":"Красноперекопск"},{"id":"SAK","name":"Саки"},{"id":"SMF","name":"Симферополь"},{"id":"SDK","name":"Судак"},{"id":"FDS","name":"Феодосия"},{"id":"YALT","name":"Ялта"}]},{"name":"Курганская обл","cities":[{"id":"KRG","name":"Курган"},{"id":"SHR","name":"Шадринск"},{"id":"RU20","name":"Шумиха"}]},{"name":"Курская обл","cities":[{"id":"ZHK","name":"Железногорск"},{"id":"KUR","name":"Курск"}]},{"name":"Липецкая обл","cities":[{"id":"RU84","name":"Грязи"},{"id":"ELC","name":"Елец"},{"id":"LIP","name":"Липецк"}]},{"name":"Магаданская обл","cities":[{"id":"MGD","name":"Магадан"}]},{"name":"Марий Эл Респ","cities":[{"id":"VLZK","name":"Волжск"},{"id":"YLA","name":"Йошкар-Ола"}]},{"name":"Мордовия Респ","cities":[{"id":"RUZ","name":"Рузаевка"},{"id":"SRN","name":"Саранск"}]},{"name":"Мурманская обл","cities":[{"id":"APT","name":"Апатиты"},{"id":"MNG","name":"Мончегорск"},{"id":"MUR","name":"Мурманск"}]},{"name":"Ненецкий АО","cities":[{"id":"NRM","name":"Нарьян-Мар"}]},{"name":"Нижегородская обл","cities":[{"id":"ARZ","name":"Арзамас"},{"id":"BLX","name":"Балахна"},{"id":"RU12","name":"Богородск"},{"id":"BOR","name":"Бор"},{"id":"VIK","name":"Выкса"},{"id":"DZE","name":"Дзержинск"},{"id":"RU4","name":"Заволжье"},{"id":"KSTV","name":"Кстово"},{"id":"NN","name":"Нижний Новгород"},{"id":"RU7","name":"Павлово"},{"id":"SARV","name":"Саров"}]},{"name":"Новгородская обл","cities":[{"id":"BRV","name":"Боровичи"},{"id":"VNG","name":"Великий Новгород"},{"id":"RU29","name":"Старая Русса"}]},{"name":"Новосибирская обл","cities":[{"id":"BRD","name":"Бердск"},{"id":"ISK","name":"Искитим"},{"id":"KLCV","name":"Кольцово"},{"id":"KSB","name":"Краснообск"},{"id":"NSK","name":"Новосибирск"}]},{"name":"Омская обл","cities":[{"id":"OMS","name":"Омск"}]},{"name":"Оренбургская обл","cities":[{"id":"BGR","name":"Бугуруслан"},{"id":"RU13","name":"Бузулук"},{"id":"RU1","name":"Гай"},{"id":"NVTR","name":"Новотроицк"},{"id":"ORB","name":"Оренбург"},{"id":"ORS","name":"Орск"},{"id":"RU50","name":"Сорочинск"}]},{"name":"Орловская обл","cities":[{"id":"RU16","name":"Ливны"},{"id":"RU72","name":"Мценск"},{"id":"OLR","name":"Орёл"}]},{"name":"Пензенская обл","cities":[{"id":"ZAR","name":"Заречный"},{"id":"PNZ","name":"Пенза"},{"id":"RU35","name":"Сердобск"}]},{"name":"Пермский край","cities":[{"id":"BER","name":"Березники"},{"id":"RU36","name":"Краснокамск"},{"id":"KDM","name":"Кудымкар"},{"id":"KUL","name":"Култаево"},{"id":"KNR","name":"Кунгур"},{"id":"LSV","name":"Лысьва"},{"id":"PRM","name":"Пермь"},{"id":"SOLK","name":"Соликамск"},{"id":"CHKS","name":"Чайковский"},{"id":"CHSV","name":"Чусовой"}]},{"name":"Приморский край","cities":[{"id":"VLK","name":"Артем"},{"id":"VLD","name":"Владивосток"},{"id":"RU74","name":"Лесозаводск"},{"id":"NKH","name":"Находка"},{"id":"PGN","name":"Пограничный"},{"id":"PKR","name":"Покровка"},{"id":"USR","name":"Уссурийск"}]},{"name":"Псковская обл","cities":[{"id":"VLL","name":"Великие Луки"},{"id":"PSK","name":"Псков"}]},{"name":"Ростовская обл","cities":[{"id":"AZV","name":"Азов"},{"id":"AKS","name":"Аксай"},{"id":"BTY","name":"Батайск"},{"id":"VGD","name":"Волгодонск"},{"id":"ZER","name":"Зерноград"},{"id":"KSHX","name":"Каменск-Шахтинский"},{"id":"NCK","name":"Новочеркасск"},{"id":"NSH","name":"Новошахтинск"},{"id":"RND","name":"Ростов-на-Дону"},{"id":"SLK","name":"Сальск"},{"id":"TGR","name":"Таганрог"},{"id":"SHT","name":"Шахты"}]},{"name":"Рязанская обл","cities":[{"id":"KAS","name":"Касимов"},{"id":"RYZ","name":"Рязань"},{"id":"RU69","name":"Сасово"}]},{"name":"Самарская обл","cities":[{"id":"RU31","name":"Кинель"},{"id":"NKU","name":"Новокуйбышевск"},{"id":"OTRN","name":"Отрадный"},{"id":"SAM","name":"Самара"},{"id":"SYZ","name":"Сызрань"},{"id":"RU79","name":"Тимофеевка"},{"id":"TOL","name":"Тольятти"},{"id":"CHP","name":"Чапаевск"},{"id":"RU85","name":"Южный город"}]},{"name":"Саратовская обл","cities":[{"id":"BLK","name":"Балаково"},{"id":"RU49","name":"Балашов"},{"id":"VSK","name":"Вольск"},{"id":"RU42","name":"Маркс"},{"id":"RU24","name":"Пугачев"},{"id":"SAR","name":"Саратов"},{"id":"ENG","name":"Энгельс"}]},{"name":"Саха Респ","cities":[{"id":"MRN","name":"Мирный"},{"id":"NRG","name":"Нерюнгри"},{"id":"YKT","name":"Якутск"}]},{"name":"Сахалинская обл","cities":[{"id":"USS","name":"Южно-Сахалинск"}]},{"name":"Свердловская обл","cities":[{"id":"ASB","name":"Асбест"},{"id":"BRZ","name":"Березовский"},{"id":"VPI","name":"Верхняя Пышма"},{"id":"VSLD","name":"Верхняя Салда"},{"id":"EKB","name":"Екатеринбург"},{"id":"ZRCH","name":"Заречный"},{"id":"IRB","name":"Ирбит"},{"id":"KMU","name":"Каменск-Уральский"},{"id":"KAR","name":"Карпинск"},{"id":"KCHK","name":"Качканар"},{"id":"KTU","name":"Краснотурьинск"},{"id":"KSF","name":"Красноуфимск"},{"id":"LES","name":"Лесной"},{"id":"NVK","name":"Невьянск"},{"id":"NTG","name":"Нижний Тагил"},{"id":"NTR","name":"Нижняя Тура"},{"id":"NUS","name":"Новоуральск"},{"id":"PVU","name":"Первоуральск"},{"id":"RU3","name":"Полевской"},{"id":"RVD","name":"Ревда"},{"id":"RU18","name":"Реж"},{"id":"CVK","name":"Североуральск"},{"id":"SRV","name":"Серов"},{"id":"SYS","name":"Сысерть"}]},{"name":"Севастополь","cities":[{"id":"SVS","name":"Севастополь"}]},{"name":"Северная Осетия - Алания Респ","cities":[{"id":"VKZ","name":"Владикавказ"},{"id":"RU62","name":"Моздок"}]},{"name":"Смоленская обл","cities":[{"id":"VZM","name":"Вязьма"},{"id":"RU67","name":"Рославль"},{"id":"RU41","name":"Сафоново"},{"id":"SMO","name":"Смоленск"},{"id":"YARC","name":"Ярцево"}]},{"name":"Ставропольский край","cities":[{"id":"BUD","name":"Буденновск"},{"id":"GRG","name":"Георгиевск"},{"id":"ESN","name":"Ессентуки"},{"id":"JLK","name":"Железноводск"},{"id":"ZLK","name":"Зеленокумск"},{"id":"IZO","name":"Изобильный"},{"id":"RU70","name":"Ипатово"},{"id":"KIS","name":"Кисловодск"},{"id":"LMV","name":"Лермонтов"},{"id":"MNV","name":"Минеральные Воды"},{"id":"MXV","name":"Михайловск"},{"id":"NEV","name":"Невинномысск"},{"id":"PTG","name":"Пятигорск"},{"id":"STA","name":"Ставрополь"}]},{"name":"Тамбовская обл","cities":[{"id":"ZRD","name":"Жердевка"},{"id":"RU61","name":"Кирсанов"},{"id":"KVK","name":"Котовск"},{"id":"MCH","name":"Мичуринск"},{"id":"RU32","name":"Моршанск"},{"id":"RSK","name":"Рассказово"},{"id":"TBV","name":"Тамбов"}]},{"name":"Татарстан Респ","cities":[{"id":"ALM","name":"Альметьевск"},{"id":"BLM","name":"Бугульма"},{"id":"ZLD","name":"Зеленодольск"},{"id":"KZN","name":"Казань"},{"id":"LGK","name":"Лениногорск"},{"id":"NCHL","name":"Набережные Челны"},{"id":"NIZ","name":"Нижнекамск"}]},{"name":"Тверская обл","cities":[{"id":"VV","name":"Вышний Волочек"},{"id":"KMR","name":"Кимры"},{"id":"KNK","name":"Конаково"},{"id":"RJV","name":"Ржев"},{"id":"TVE","name":"Тверь"},{"id":"TRJ","name":"Торжок"},{"id":"RU54","name":"Удомля"}]},{"name":"Томская обл","cities":[{"id":"SEV","name":"Северск"},{"id":"STZH","name":"Стрежевой"},{"id":"TOM","name":"Томск"}]},{"name":"Тульская обл","cities":[{"id":"ALCS","name":"Алексин"},{"id":"EFR","name":"Ефремов"},{"id":"RU80","name":"Заокский"},{"id":"KIRK","name":"Киреевск"},{"id":"NMK","name":"Новомосковск"},{"id":"YUL","name":"Тула"},{"id":"UZL","name":"Узловая"},{"id":"RU21","name":"Ясногорск"}]},{"name":"Тыва Респ","cities":[{"id":"KZL","name":"Кызыл"}]},{"name":"Тюменская обл","cities":[{"id":"ISM","name":"Ишим"},{"id":"TBL","name":"Тобольск"},{"id":"TYM","name":"Тюмень"},{"id":"RU22","name":"Ялуторовск"}]},{"name":"Удмуртская Респ","cities":[{"id":"VOT","name":"Воткинск"},{"id":"GLV","name":"Глазов"},{"id":"IZH","name":"Ижевск"},{"id":"SRP","name":"Сарапул"}]},{"name":"Ульяновская обл","cities":[{"id":"DMI","name":"Димитровград"},{"id":"ULY","name":"Ульяновск"}]},{"name":"Хабаровский край","cities":[{"id":"AMR","name":"Амурск"},{"id":"RU33","name":"Бикин"},{"id":"VAN","name":"Ванино"},{"id":"KNA","name":"Комсомольск-на-Амуре"},{"id":"RU47","name":"Советская Гавань"},{"id":"KHB","name":"Хабаровск"},{"id":"RU71","name":"Хурба"}]},{"name":"Хакасия Респ","cities":[{"id":"ABK","name":"Абакан"},{"id":"RU10","name":"Саяногорск"},{"id":"CHRN","name":"Черногорск"}]},{"name":"Ханты-Мансийский Автономный округ - Югра АО","cities":[{"id":"KGLM","name":"Когалым"},{"id":"LAN","name":"Лангепас"},{"id":"LTR","name":"Лянтор"},{"id":"MEG","name":"Мегион"},{"id":"NUG","name":"Нефтеюганск"},{"id":"NVT","name":"Нижневартовск"},{"id":"NGG","name":"Нягань"},{"id":"RU26","name":"Радужный"},{"id":"SVT","name":"Советский"},{"id":"SUR","name":"Сургут"},{"id":"URA","name":"Урай"},{"id":"XMS","name":"Ханты-Мансийск"},{"id":"UGO","name":"Югорск"}]},{"name":"Челябинская обл","cities":[{"id":"RU2","name":"Аша"},{"id":"ZLA","name":"Златоуст"},{"id":"KOP","name":"Копейск"},{"id":"KRK","name":"Коркино"},{"id":"KSH","name":"Кыштым"},{"id":"MGG","name":"Магнитогорск"},{"id":"MIS","name":"Миасс"},{"id":"OSK","name":"Озерск"},{"id":"RU5","name":"Сатка"},{"id":"SNZH","name":"Снежинск"},{"id":"RU9","name":"Трехгорный"},{"id":"TRC","name":"Троицк"},{"id":"RU11","name":"Чебаркуль"},{"id":"CHL","name":"Челябинск"},{"id":"YUZHU","name":"Южноуральск"},{"id":"YURZ","name":"Юрюзань"}]},{"name":"Чеченская Респ","cities":[{"id":"GRZ","name":"Грозный"}]},{"name":"Чувашская Респ","cities":[{"id":"NCB","name":"Новочебоксарск"},{"id":"CHB","name":"Чебоксары"}]},{"name":"Ямало-Ненецкий АО","cities":[{"id":"GUB","name":"Губкинский"},{"id":"RU82","name":"Лабытнанги"},{"id":"RU83","name":"Муравленко"},{"id":"NDM","name":"Надым"},{"id":"NUR","name":"Новый Уренгой"},{"id":"NOY","name":"Ноябрьск"},{"id":"SLX","name":"Салехард"}]},{"name":"Ярославская обл","cities":[{"id":"GVRL","name":"Гаврилов-Ям"},{"id":"RU17","name":"Переславль-Залесский"},{"id":"RU60","name":"Ростов"},{"id":"RYB","name":"Рыбинск"},{"id":"YAR","name":"Ярославль"}]}], // Города курьерки citiesCourierSpb: [{"name":"Санкт-Петербург","cities":[{"id":"SPB","name":"Санкт-Петербург"},{"id":"AVIA","name":"Авиагородок"},{"id":"AGL","name":"Агалатово"},{"id":"APSH","name":"Александровская, Пушкинский р-н"},{"id":"ANN","name":"Аннино, Ломоносовский р-н"},{"id":"BLV","name":"Белоостров"},{"id":"BLJ","name":"Большая Ижора"},{"id":"BUG","name":"Бугры, Всеволожский р-н"},{"id":"VAR","name":"Вартемяги"},{"id":"VSL","name":"Всеволожск"},{"id":"GTN","name":"Гатчина"},{"id":"GRB","name":"Горбунки"},{"id":"GRL","name":"Горелово"},{"id":"DVT","name":"Девяткино"},{"id":"KVG","name":"Кавголово"},{"id":"KLK","name":"Келколово"},{"id":"KLP","name":"Колпино"},{"id":"KLT","name":"Колтуши"},{"id":"KMN","name":"Коммунар"},{"id":"KRS","name":"Красное Село"},{"id":"KRN","name":"Кронштадт"},{"id":"KDRV","name":"Кудрово"},{"id":"KZML","name":"Кузьмоловский"},{"id":"LVR","name":"Лаврики"},{"id":"LHT","name":"Лахта-Ольгино"},{"id":"LVSH","name":"Левашово"},{"id":"LEN","name":"Ленсоветовский, Пушкинский р-н"},{"id":"LSN","name":"Лисий нос"},{"id":"LMN","name":"Ломоносов"},{"id":"MVR","name":"Малое верево"},{"id":"MTL","name":"Металлострой"},{"id":"MURI","name":"Мурино"},{"id":"MGL","name":"Мяглово, Всеволожский р-н"},{"id":"NZN","name":"Низино"},{"id":"NDV","name":"Новое Девяткино, Всеволожский р-н"},{"id":"NVSL","name":"Новоселье"},{"id":"OLG","name":"Ольгино"},{"id":"OTRD","name":"Отрадное"},{"id":"PVL","name":"Павловск, Пушкинский р-н"},{"id":"PAR","name":"Парголово"},{"id":"PRN","name":"Парнас"},{"id":"PSCH","name":"Песочный"},{"id":"PTF","name":"Петергоф"},{"id":"PTRS","name":"Петро-Славянка"},{"id":"PNT","name":"Понтонный"},{"id":"PRS","name":"Порошкино"},{"id":"SVR","name":"Пос. им.Свердлова, Всеволожский р-н"},{"id":"PDM","name":"Пудомяги"},{"id":"PUSH","name":"Пушкин"},{"id":"RBG","name":"Разбегаево"},{"id":"RZM","name":"Разметелево, Всеволожский р-н"},{"id":"RPN","name":"Репино"},{"id":"RPS","name":"Ропша"},{"id":"SAP","name":"Саперный"},{"id":"SRG","name":"Сергиево"},{"id":"SRT","name":"Сертолово, Всеволожский р-н"},{"id":"SST","name":"Сестрорецк"},{"id":"SCP","name":"Скандинавский Парк"},{"id":"SPR","name":"Славянка, Пушкинский р-н"},{"id":"SLNC","name":"Солнечное"},{"id":"SSB","name":"Сосновый Бор"},{"id":"STPK","name":"Старо-Паново, Красносельский р-н"},{"id":"STRL","name":"Стрельна"},{"id":"TAI","name":"Тайцы"},{"id":"TLM","name":"Тельмана поселок"},{"id":"TKS","name":"Токсово"},{"id":"TSN","name":"Тосно"},{"id":"UZG","name":"Узигонты"},{"id":"UST","name":"Усть-Ижора"},{"id":"SHSH","name":"Шушары"},{"id":"SHG","name":"Щеглово"},{"id":"ENK","name":"Энколово"},{"id":"UKK","name":"Юкки"},{"id":"UNT","name":"Юнтолово"},{"id":"YMI","name":"Ям-Ижора"},{"id":"YNN","name":"Янино"}]},{"name":"Москва","cities":[{"id":"MSK","name":"Москва"},{"id":"BAL","name":"Балашиха"},{"id":"BTV","name":"Бутово"},{"id":"VDN","name":"Видное"},{"id":"VLM","name":"Волоколамск"},{"id":"VKS","name":"Воскресенск"},{"id":"DZER","name":"Дзержинский"},{"id":"DMT","name":"Дмитров"},{"id":"DGP","name":"Долгопрудный"},{"id":"DOM","name":"Домодедово"},{"id":"DBN","name":"Дубна"},{"id":"ZHLD","name":"Железнодорожный"},{"id":"ZHU","name":"Жуковский"},{"id":"ZVG","name":"Звенигород"},{"id":"ZLN","name":"Зеленоград"},{"id":"IVT","name":"Ивантеевка"},{"id":"IST","name":"Истра"},{"id":"KLM","name":"Климовск"},{"id":"KLN","name":"Клин"},{"id":"KZH","name":"Кожухово"},{"id":"KOL","name":"Коломна"},{"id":"KRL","name":"Королев"},{"id":"KOTE","name":"Котельники"},{"id":"KGS","name":"Красногорск"},{"id":"LBN","name":"Лобня"},{"id":"LIT","name":"Лыткарино"},{"id":"LYB","name":"Люберцы"},{"id":"MBSH","name":"Малаховка"},{"id":"MIT","name":"Митино"},{"id":"MOZ","name":"Можайск"},{"id":"MOK","name":"Московский"},{"id":"MYT","name":"Мытищи"},{"id":"NFM","name":"Наро-Фоминск"},{"id":"NVP","name":"Ново-Переделкино"},{"id":"NOG","name":"Ногинск"},{"id":"ODC","name":"Одинцово"},{"id":"OZU","name":"Орехово-Зуево"},{"id":"OSTR","name":"Островцы"},{"id":"PPS","name":"Павловский Посад"},{"id":"PRL","name":"Переделкино"},{"id":"POD","name":"Подольск"},{"id":"PUS","name":"Пушкино"},{"id":"RAM","name":"Раменское"},{"id":"RTK","name":"Реутов"},{"id":"SPD","name":"Сергиев Посад"},{"id":"SER","name":"Серпухов"},{"id":"SLG","name":"Солнечногорск"},{"id":"SLN","name":"Солнцево"},{"id":"STP","name":"Ступино"},{"id":"TMLN","name":"Томилино"},{"id":"TRC2","name":"Троицк, Московская обл"},{"id":"FRY","name":"Фрязино"},{"id":"KHI","name":"Химки"},{"id":"CHXV","name":"Чехов"},{"id":"WLK","name":"Щелково"},{"id":"SHRB","name":"Щербинка"},{"id":"EST","name":"Электросталь"},{"id":"UBL","name":"Юбилейный"}]},{"name":"Адыгея Респ","cities":[{"id":"MKP","name":"Майкоп"}]},{"name":"Астраханская обл","cities":[{"id":"AST","name":"Астрахань"}]},{"name":"Башкортостан Респ","cities":[{"id":"NKM","name":"Нефтекамск"},{"id":"OKT","name":"Октябрьский"},{"id":"SAL","name":"Салават"},{"id":"SLT","name":"Стерлитамак"},{"id":"UFA","name":"Уфа"},{"id":"UCHL","name":"Учалы"}]},{"name":"Белгородская обл","cities":[{"id":"BEL","name":"Белгород"},{"id":"GBK","name":"Губкин"},{"id":"SOL","name":"Старый Оскол"}]},{"name":"Брянская обл","cities":[{"id":"BRY","name":"Брянск"},{"id":"KLC","name":"Клинцы"}]},{"name":"Владимирская обл","cities":[{"id":"ALK","name":"Александров"},{"id":"VLA","name":"Владимир"},{"id":"KRZH","name":"Киржач"},{"id":"KOV","name":"Ковров"},{"id":"MRM","name":"Муром"}]},{"name":"Волгоградская обл","cities":[{"id":"VGG","name":"Волгоград"},{"id":"VOL","name":"Волжский"}]},{"name":"Вологодская обл","cities":[{"id":"VLG","name":"Вологда"},{"id":"CHR","name":"Череповец"}]},{"name":"Воронежская обл","cities":[{"id":"BRG","name":"Борисоглебск"},{"id":"VRN","name":"Воронеж"}]},{"name":"Ивановская обл","cities":[{"id":"IVA","name":"Иваново"},{"id":"KIN","name":"Кинешма"}]},{"name":"Кабардино-Балкарская Респ","cities":[{"id":"NAL","name":"Нальчик"}]},{"name":"Калининградская обл","cities":[{"id":"KLD","name":"Калининград"}]},{"name":"Калмыкия Респ","cities":[{"id":"ELS","name":"Элиста"}]},{"name":"Калужская обл","cities":[{"id":"KAL","name":"Калуга"},{"id":"LDN","name":"Людиново"},{"id":"OBN","name":"Обнинск"}]},{"name":"Карачаево-Черкесская Респ","cities":[{"id":"CHRK","name":"Черкесск"}]},{"name":"Карелия Респ","cities":[{"id":"PTR","name":"Петрозаводск"}]},{"name":"Кировская обл","cities":[{"id":"KIR","name":"Киров"}]},{"name":"Коми Респ","cities":[{"id":"STK","name":"Сыктывкар"}]},{"name":"Костромская обл","cities":[{"id":"KST","name":"Кострома"}]},{"name":"Краснодарский край","cities":[{"id":"ANP","name":"Анапа"},{"id":"ARM","name":"Армавир"},{"id":"GLD","name":"Геленджик"},{"id":"KRD","name":"Краснодар"},{"id":"KRP","name":"Кропоткин"},{"id":"LBS","name":"Лабинск"},{"id":"NVR","name":"Новороссийск"},{"id":"SKB","name":"Славянск-на-Кубани"},{"id":"SCH","name":"Сочи"}]},{"name":"Курганская обл","cities":[{"id":"KRG","name":"Курган"}]},{"name":"Курская обл","cities":[{"id":"KUR","name":"Курск"}]},{"name":"Липецкая обл","cities":[{"id":"LIP","name":"Липецк"}]},{"name":"Марий Эл Респ","cities":[{"id":"YLA","name":"Йошкар-Ола"}]},{"name":"Мордовия Респ","cities":[{"id":"SRN","name":"Саранск"}]},{"name":"Мурманская обл","cities":[{"id":"MUR","name":"Мурманск"}]},{"name":"Нижегородская обл","cities":[{"id":"ARZ","name":"Арзамас"},{"id":"BLX","name":"Балахна"},{"id":"DZE","name":"Дзержинск"},{"id":"KSTV","name":"Кстово"},{"id":"NN","name":"Нижний Новгород"},{"id":"SARV","name":"Саров"}]},{"name":"Новгородская обл","cities":[{"id":"BRV","name":"Боровичи"},{"id":"VNG","name":"Великий Новгород"}]},{"name":"Оренбургская обл","cities":[{"id":"ORB","name":"Оренбург"},{"id":"ORS","name":"Орск"}]},{"name":"Орловская обл","cities":[{"id":"OLR","name":"Орёл"}]},{"name":"Пензенская обл","cities":[{"id":"PNZ","name":"Пенза"}]},{"name":"Пермский край","cities":[{"id":"BER","name":"Березники"},{"id":"KNR","name":"Кунгур"},{"id":"PRM","name":"Пермь"},{"id":"CHKS","name":"Чайковский"},{"id":"CHSV","name":"Чусовой"}]},{"name":"Псковская обл","cities":[{"id":"VLL","name":"Великие Луки"},{"id":"PSK","name":"Псков"}]},{"name":"Ростовская обл","cities":[{"id":"AZV","name":"Азов"},{"id":"AKS","name":"Аксай"},{"id":"BTY","name":"Батайск"},{"id":"VGD","name":"Волгодонск"},{"id":"ZER","name":"Зерноград"},{"id":"KSHX","name":"Каменск-Шахтинский"},{"id":"NCK","name":"Новочеркасск"},{"id":"NSH","name":"Новошахтинск"},{"id":"RND","name":"Ростов-на-Дону"},{"id":"TGR","name":"Таганрог"},{"id":"SHT","name":"Шахты"}]},{"name":"Рязанская обл","cities":[{"id":"RYZ","name":"Рязань"}]},{"name":"Самарская обл","cities":[{"id":"SAM","name":"Самара"},{"id":"SYZ","name":"Сызрань"},{"id":"TOL","name":"Тольятти"}]},{"name":"Саратовская обл","cities":[{"id":"BLK","name":"Балаково"},{"id":"SAR","name":"Саратов"},{"id":"ENG","name":"Энгельс"}]},{"name":"Свердловская обл","cities":[{"id":"EKB","name":"Екатеринбург"},{"id":"KTU","name":"Краснотурьинск"},{"id":"KSF","name":"Красноуфимск"},{"id":"LES","name":"Лесной"},{"id":"NTG","name":"Нижний Тагил"},{"id":"NTR","name":"Нижняя Тура"},{"id":"NUS","name":"Новоуральск"},{"id":"PVU","name":"Первоуральск"},{"id":"SRV","name":"Серов"}]},{"name":"Северная Осетия - Алания Респ","cities":[{"id":"VKZ","name":"Владикавказ"}]},{"name":"Смоленская обл","cities":[{"id":"VZM","name":"Вязьма"},{"id":"SMO","name":"Смоленск"},{"id":"YARC","name":"Ярцево"}]},{"name":"Ставропольский край","cities":[{"id":"GRG","name":"Георгиевск"},{"id":"ESN","name":"Ессентуки"},{"id":"KIS","name":"Кисловодск"},{"id":"LMV","name":"Лермонтов"},{"id":"MNV","name":"Минеральные Воды"},{"id":"MXV","name":"Михайловск"},{"id":"NEV","name":"Невинномысск"},{"id":"PTG","name":"Пятигорск"},{"id":"STA","name":"Ставрополь"}]},{"name":"Тамбовская обл","cities":[{"id":"RSK","name":"Рассказово"},{"id":"TBV","name":"Тамбов"}]},{"name":"Татарстан Респ","cities":[{"id":"ALM","name":"Альметьевск"},{"id":"KZN","name":"Казань"},{"id":"NCHL","name":"Набережные Челны"},{"id":"NIZ","name":"Нижнекамск"}]},{"name":"Тверская обл","cities":[{"id":"TVE","name":"Тверь"}]},{"name":"Тульская обл","cities":[{"id":"NMK","name":"Новомосковск"},{"id":"YUL","name":"Тула"}]},{"name":"Тюменская обл","cities":[{"id":"TBL","name":"Тобольск"},{"id":"TYM","name":"Тюмень"}]},{"name":"Удмуртская Респ","cities":[{"id":"GLV","name":"Глазов"},{"id":"IZH","name":"Ижевск"}]},{"name":"Ульяновская обл","cities":[{"id":"DMI","name":"Димитровград"},{"id":"ULY","name":"Ульяновск"}]},{"name":"Челябинская обл","cities":[{"id":"ZLA","name":"Златоуст"},{"id":"KOP","name":"Копейск"},{"id":"MGG","name":"Магнитогорск"},{"id":"MIS","name":"Миасс"},{"id":"OSK","name":"Озерск"},{"id":"SNZH","name":"Снежинск"},{"id":"CHL","name":"Челябинск"},{"id":"YUZHU","name":"Южноуральск"},{"id":"YURZ","name":"Юрюзань"}]},{"name":"Чувашская Респ","cities":[{"id":"CHB","name":"Чебоксары"}]},{"name":"Ярославская обл","cities":[{"id":"RYB","name":"Рыбинск"},{"id":"YAR","name":"Ярославль"}]}], citiesCourierMsk: [{"name":"Санкт-Петербург","cities":[{"id":"SPB","name":"Санкт-Петербург"},{"id":"AVIA","name":"Авиагородок"},{"id":"AGL","name":"Агалатово"},{"id":"APSH","name":"Александровская, Пушкинский р-н"},{"id":"ANN","name":"Аннино, Ломоносовский р-н"},{"id":"BLV","name":"Белоостров"},{"id":"BLJ","name":"Большая Ижора"},{"id":"BUG","name":"Бугры, Всеволожский р-н"},{"id":"VAR","name":"Вартемяги"},{"id":"VSL","name":"Всеволожск"},{"id":"GTN","name":"Гатчина"},{"id":"GRB","name":"Горбунки"},{"id":"GRL","name":"Горелово"},{"id":"DVT","name":"Девяткино"},{"id":"KVG","name":"Кавголово"},{"id":"KLK","name":"Келколово"},{"id":"KLP","name":"Колпино"},{"id":"KLT","name":"Колтуши"},{"id":"KMN","name":"Коммунар"},{"id":"KRS","name":"Красное Село"},{"id":"KRN","name":"Кронштадт"},{"id":"KDRV","name":"Кудрово"},{"id":"KZML","name":"Кузьмоловский"},{"id":"LVR","name":"Лаврики"},{"id":"LHT","name":"Лахта-Ольгино"},{"id":"LVSH","name":"Левашово"},{"id":"LEN","name":"Ленсоветовский, Пушкинский р-н"},{"id":"LSN","name":"Лисий нос"},{"id":"LMN","name":"Ломоносов"},{"id":"MVR","name":"Малое верево"},{"id":"MTL","name":"Металлострой"},{"id":"MURI","name":"Мурино"},{"id":"MGL","name":"Мяглово, Всеволожский р-н"},{"id":"NZN","name":"Низино"},{"id":"NDV","name":"Новое Девяткино, Всеволожский р-н"},{"id":"NVSL","name":"Новоселье"},{"id":"OLG","name":"Ольгино"},{"id":"OTRD","name":"Отрадное"},{"id":"PVL","name":"Павловск, Пушкинский р-н"},{"id":"PAR","name":"Парголово"},{"id":"PRN","name":"Парнас"},{"id":"PSCH","name":"Песочный"},{"id":"PTF","name":"Петергоф"},{"id":"PTRS","name":"Петро-Славянка"},{"id":"PNT","name":"Понтонный"},{"id":"PRS","name":"Порошкино"},{"id":"SVR","name":"Пос. им.Свердлова, Всеволожский р-н"},{"id":"PDM","name":"Пудомяги"},{"id":"PUSH","name":"Пушкин"},{"id":"RBG","name":"Разбегаево"},{"id":"RZM","name":"Разметелево, Всеволожский р-н"},{"id":"RPN","name":"Репино"},{"id":"RPS","name":"Ропша"},{"id":"SAP","name":"Саперный"},{"id":"SRG","name":"Сергиево"},{"id":"SRT","name":"Сертолово, Всеволожский р-н"},{"id":"SST","name":"Сестрорецк"},{"id":"SCP","name":"Скандинавский Парк"},{"id":"SPR","name":"Славянка, Пушкинский р-н"},{"id":"SLNC","name":"Солнечное"},{"id":"SSB","name":"Сосновый Бор"},{"id":"STRL","name":"Стрельна"},{"id":"TAI","name":"Тайцы"},{"id":"TLM","name":"Тельмана поселок"},{"id":"TKS","name":"Токсово"},{"id":"TSN","name":"Тосно"},{"id":"UZG","name":"Узигонты"},{"id":"UST","name":"Усть-Ижора"},{"id":"SHSH","name":"Шушары"},{"id":"SHG","name":"Щеглово"},{"id":"ENK","name":"Энколово"},{"id":"UKK","name":"Юкки"},{"id":"UNT","name":"Юнтолово"},{"id":"YMI","name":"Ям-Ижора"},{"id":"YNN","name":"Янино"}]},{"name":"Москва","cities":[{"id":"MSK","name":"Москва"},{"id":"BAL","name":"Балашиха"},{"id":"VDN","name":"Видное"},{"id":"DZER","name":"Дзержинский"},{"id":"DGP","name":"Долгопрудный"},{"id":"DOM","name":"Домодедово"},{"id":"ZHLD","name":"Железнодорожный"},{"id":"ZHU","name":"Жуковский"},{"id":"IVT","name":"Ивантеевка"},{"id":"KLM","name":"Климовск"},{"id":"KRL","name":"Королев"},{"id":"KOTE","name":"Котельники"},{"id":"KGS","name":"Красногорск"},{"id":"LBN","name":"Лобня"},{"id":"LIT","name":"Лыткарино"},{"id":"LYB","name":"Люберцы"},{"id":"MIT","name":"Митино"},{"id":"MOK","name":"Московский"},{"id":"MYT","name":"Мытищи"},{"id":"ODC","name":"Одинцово"},{"id":"OSTR","name":"Островцы"},{"id":"PRL","name":"Переделкино"},{"id":"POD","name":"Подольск"},{"id":"PUS","name":"Пушкино"},{"id":"RTK","name":"Реутов"},{"id":"TMLN","name":"Томилино"},{"id":"FRY","name":"Фрязино"},{"id":"KHI","name":"Химки"},{"id":"WLK","name":"Щелково"},{"id":"SHRB","name":"Щербинка"},{"id":"UBL","name":"Юбилейный"}]}], //Города назначение в зависимости от пары "Исходный город - услуга" currentCitiesTo: [], onlyCitiesTo: [], excludeCitiesTo: [], onCalcCallback: null, servList: { 'Самовывоз': 'выдача', 'Курьерская доставка': 'курьерская доставка' }, paymentTypes: { 'заказ оплачен': 'prepaid', 'наличными при получении': 'cash', 'картой при получении': 'credit' }, // Значения полей для расчета тарифа values: {}, domElements: {}, // Информация о рассчитанном тарифе tarifInfo: {}, /** * Инициализация модуля */ init: function(params) { this.coreDomElement = document.getElementById( params.elementId ); if ( !this.coreDomElement ) { throw('Glavpunkt.calculator can`t find core element!'); } if (undefined === params.isStyled || true == params.isStyled) { this.coreDomElement.innerHTML += ''; } this.coreDomElement.innerHTML += this.formHtml; this.cacheDomElemets(); this.initEvents(); if (undefined !== params.onCalcCallback && 'function' == typeof params.onCalcCallback) { this.onCalcCallback = params.onCalcCallback; } this.configureWidget(params); }, configureWidget: function(params) { var i, k; /************************************** Настройка городов назначения *************************************************/ if (undefined !== params.onlyCitiesTo && params.onlyCitiesTo instanceof Array) { this.onlyCitiesTo = params.onlyCitiesTo; } else if (undefined !== params.excludeCitiesTo && params.excludeCitiesTo instanceof Array) { this.excludeCitiesTo = params.excludeCitiesTo; } /************************************* Настройка this.citiesFrom ************************************************/ if (undefined !== params.onlyCitiesFrom && params.onlyCitiesFrom instanceof Array) { // Установка только определенных исходных городов var onlyCitiesFrom = []; for (k in params.onlyCitiesFrom) { if (-1 != this.citiesFrom.indexOf(params.onlyCitiesFrom[k])) { onlyCitiesFrom.push(params.onlyCitiesFrom[k]); } } if (onlyCitiesFrom.length > 0) { this.citiesFrom = onlyCitiesFrom; } } else if (undefined !== params.excludeCitiesFrom && params.excludeCitiesFrom instanceof Array) { // Удаление определенных исходных городов var filteredCitiesFrom = []; for (k in this.citiesFrom) { if (-1 == params.excludeCitiesFrom.indexOf(this.citiesFrom[k])) { filteredCitiesFrom.push(this.citiesFrom[k]); } } if (filteredCitiesFrom.length != this.citiesFrom.length) { this.citiesFrom = filteredCitiesFrom; } } if (!this.citiesFrom.length) { throw('Список исходных городов не может быть пустым'); } else if (1 == this.citiesFrom.length) { // Если исходный город 1, то выбрать его и скрыть весь блок params.defaultCityFrom = this.citiesFrom[0]; document.getElementsByClassName('Glavpunkt_calculator_city_from_container')[0].style.display = "none"; } /************************************* Заполнение this.citiesFrom ************************************************/ for (i in this.citiesFrom) { var opt = document.createElement('option'); opt.value = i; opt.innerHTML = this.citiesFrom[i]; this.domElements['cityFrom'].appendChild(opt); } if (undefined !== params.defaultCityFrom) { for (i in this.citiesFrom) { if (params.defaultCityFrom == this.citiesFrom[i]) { this.domElements['cityFrom'].value = i; // Вызов события выбора исходного города, чтобы подгрузились города назначения var evt = document.createEvent("HTMLEvents"); evt.initEvent("change", false, true); this.domElements['cityFrom'].dispatchEvent(evt); break; } } } /************************************** Настройка списка услуг *************************************************/ if (undefined !== params.onlyServes && params.onlyServes instanceof Array) { var onlyServes = {}; for (k in this.servList) { if (-1 != params.onlyServes.indexOf(this.servList[k])) { onlyServes[k] = this.servList[k]; } } this.servList = onlyServes; } if (!Object.keys(this.servList).length) { throw('Список услуг не может быть пустым'); } else if (1 == Object.keys(this.servList).length) { // Если услуга одна, то выбрать ее и скрыть весь блок params.defaultServ = this.servList[Object.keys(this.servList)[0]]; document.getElementsByClassName('Glavpunkt_calculator_serv_container')[0].style.display = "none"; } /************************************** Заполнение списка услуг *************************************************/ for (i in this.servList) { opt = document.createElement('option'); opt.value = this.servList[i]; opt.innerHTML = i; this.domElements['serv'].appendChild(opt); } /************************************** Выбор услуги *************************************************/ if (undefined !== params.defaultServ) { for (i in this.servList) { if (params.defaultServ == this.servList[i]) { for (k in this.domElements['serv'].options) { if (this.domElements['serv'].options[k].value == params.defaultServ) { this.domElements['serv'].value = params.defaultServ; // Вызов события выбора исходного города, чтобы подгрузились города назначения var evt = document.createEvent("HTMLEvents"); evt.initEvent("change", false, true); this.domElements['serv'].dispatchEvent(evt); break; } } } } } /************************************** Выбор города назначения *************************************************/ if (undefined !== params.defaultCityTo) { if (!this.domElements['cityFrom'].value || !this.domElements['serv'].value) { throw('Не указан исходный город или услуга. Параметр defaultCityTo должен использоваться совместно с defaultCityFrom и defaultServ.'); } for (i in this.currentCitiesTo) { for (c in this.currentCitiesTo[i].cities) { if (params.defaultCityTo == this.currentCitiesTo[i].cities[c].name) { this.domElements['cityTo'].value = this.currentCitiesTo[i].cities[c].id; break; } } } } /************************************** Настройка способов оплаты ***********************************************/ if (undefined !== params.onlyPaymentTypes && params.onlyPaymentTypes instanceof Array) { var onlyPaymentTypes = {}; for (k in this.paymentTypes) { if (-1 != params.onlyPaymentTypes.indexOf(this.paymentTypes[k])) { onlyPaymentTypes[k] = this.paymentTypes[k]; } } this.paymentTypes = onlyPaymentTypes; } if (!Object.keys(this.paymentTypes).length) { throw('Список способов оплаты не может быть пустым'); } /************************************** Заполнение способов оплаты ***********************************************/ for (i in this.paymentTypes) { opt = document.createElement('option'); opt.value = this.paymentTypes[i]; opt.innerHTML = i; this.domElements['paymentType'].appendChild(opt); } /************************************** Выбор способа оплаты *************************************************/ if (undefined !== params.defaultPaymentType) { for (i in this.paymentTypes) { if (params.defaultPaymentType == this.paymentTypes[i]) { this.domElements['paymentType'].value = params.defaultPaymentType; break; } } } /************************************** Заполнение веса и стоимости ********************************************/ if (undefined !== params.weight) { this.domElements['weight'].value = Math.abs(params.weight); } if (undefined !== params.price) { this.domElements['price'].value = Math.abs(params.price); } }, cacheDomElemets: function() { this.domElements['cityFrom'] = document.getElementById("Glavpunkt_calculator_city_from"); this.domElements['cityTo'] = document.getElementById("Glavpunkt_calculator_city_to"); this.domElements['serv'] = document.getElementById("Glavpunkt_calculator_serv"); this.domElements['paymentType'] = document.getElementById("Glavpunkt_calculator_payment_type"); this.domElements['price'] = document.getElementById("Glavpunkt_calculator_price"); this.domElements['weight'] = document.getElementById("Glavpunkt_calculator_weight"); this.domElements['submit'] = document.getElementById("Glavpunkt_calculator_submit"); this.domElements['finalPrice'] = document.getElementById("Glavpunkt_calculator_finalPrice"); this.domElements['allTarifs'] = document.getElementById("Glavpunkt_calculator_allTarifs"); this.domElements['deliveryDays'] = document.getElementById("Glavpunkt_calculator_deliveryDays"); }, initEvents: function() { this.domElements['cityFrom'].addEventListener('change', function(e) { this.initCitiesTo(); }.bind(this), false); this.domElements['serv'].addEventListener('change', function(e) { this.initCitiesTo(); }.bind(this), false); this.domElements['submit'].addEventListener('click', function(e) { this.onSubmit(e); }.bind(this), false); }, onSubmit: function () { this.filterValues(); this.finalPrice = ''; if ( this.isValid() ) { this.calcTarif(); } }, calcTarif: function() { this.domElements['finalPrice'].innerHTML = ''; this.domElements['deliveryDays'].innerHTML = ''; var xhr = new XMLHttpRequest(); xhr.open('GET', this.host + '/api/get_tarif?' + this.serialize(this.values), true); xhr.send(); var that = this; xhr.onreadystatechange = function() { if (xhr.readyState != 4) return; if (xhr.status != 200) { that.domElements['finalPrice'].innerHTML = xhr.status + ': ' + xhr.statusText; return; } var responseJson = JSON.parse(xhr.responseText); if ('ok' == responseJson.result) { that.domElements['allTarifs'].innerHTML = ''; that.tarifInfo = responseJson; if (that.onCalcCallback) { that.tarifInfo = that.onCalcCallback.apply(window, [that.tarifInfo]); } var from; if (undefined !== that.tarifInfo.tarifDescr) { from = 'от '; that.domElements['allTarifs'].innerHTML = that.tarifInfo.tarifDescr; } else { from = ''; } that.domElements['finalPrice'].innerHTML = from + parseFloat(that.tarifInfo.tarif + 0.001).toFixed(2) + ' руб.'; that.domElements['deliveryDays'].innerHTML = 'доставка от '+ parseInt(that.tarifInfo.period) +' до '+ (parseInt(that.tarifInfo.period) + 2) +' рабочих дней'; } else { that.domElements['deliveryDays'].innerHTML = responseJson.message; that.domElements['finalPrice'].innerHTML = ''; } that.domElements['submit'].disabled = false; }; that.domElements['deliveryDays'].innerHTML = 'Идет расчет стоимости...'; // (2) that.domElements['submit'].disabled = true; }, isValid: function() { if( this.values['weight'] > this.MAX_WEIGHT) { this.domElements['weight'].value = this.MAX_WEIGHT; this.values['weight'] = this.MAX_WEIGHT; } var valid = true; for (var i in this.values) { if (!this.values[i]) { this.domElements[i].className = 'Glavpunkt_calculator_formError'; valid = false; } else { this.domElements[i].className = ''; } } return valid; }, filterValues: function() { this.values['cityFrom'] = this.domElements['cityFrom'].options[this.domElements['cityFrom'].selectedIndex].innerHTML; this.values['cityTo'] = this.domElements['cityTo'].options[this.domElements['cityTo'].selectedIndex].innerHTML; this.values['serv'] = this.domElements['serv'].value; this.values['paymentType'] = this.domElements['paymentType'].value; this.values['weight'] = Math.abs(parseFloat(this.domElements['weight'].value)); this.values['price'] = Math.abs(parseFloat(this.domElements['price'].value)); this.weight = isNaN(this.weight) ? 0 : this.weight; this.price = isNaN(this.price) ? 0 : this.price; }, initCitiesTo: function() { var cityFromSelect = this.domElements['cityFrom']; var cityFrom = cityFromSelect.options[cityFromSelect.selectedIndex].text; var servSelect = this.domElements['serv']; var serv = servSelect.options[servSelect.selectedIndex].text; this.domElements['cityTo'].innerHTML = ''; if (cityFrom && serv) { this.domElements['cityTo'].disabled = false; } else { this.domElements['cityTo'].disabled = true; return false; } this.currentCitiesTo = []; if ('Санкт-Петербург' == cityFrom && 'Самовывоз' == serv) { this.currentCitiesTo = this.citiesSimpleSpb; } else if ('Санкт-Петербург' == cityFrom && 'Курьерская доставка' == serv) { this.currentCitiesTo = this.citiesCourierSpb; } else if ('Москва' == cityFrom && 'Самовывоз' == serv) { this.currentCitiesTo = [ {'name': 'Санкт-Петербург', 'cities': [{'id': 'SPB', 'name': 'Санкт-Петербург'}] }, {'name': 'Москва', 'cities': [{'id': 'MSK', 'name': 'Москва'}] } ]; } else {//if ('Москва' == cityFrom && 'Курьерская доставка' == serv) this.currentCitiesTo = this.citiesCourierMsk; } this.filterCitiesTo(); var gr,i; for (i in this.currentCitiesTo) { gr = document.createElement('optgroup'); gr.label = this.currentCitiesTo[i].name; for (var cid in this.currentCitiesTo[i].cities) { opt = document.createElement('option'); opt.value = this.currentCitiesTo[i].cities[cid].id; opt.textContent = this.currentCitiesTo[i].cities[cid].name; gr.appendChild(opt); } this.domElements['cityTo'].appendChild(gr); } }, // Фильтрация городов назначения согласно настройкам виджета filterCitiesTo: function() { var i,j,r; if (this.onlyCitiesTo.length) { // Установка только определенных городов назначения var onlyCitiesTo = []; for (k in this.onlyCitiesTo) { for (i in this.currentCitiesTo) { r = []; for (j in this.currentCitiesTo[i].cities) { if (this.onlyCitiesTo[k] == this.currentCitiesTo[i].cities[j].name) { r.push(this.currentCitiesTo[i].cities[j]); } } if (r.length > 0) { onlyCitiesTo.push({ 'name': this.currentCitiesTo[i].name, 'cities': r }); } } } if (onlyCitiesTo.length > 0) { this.currentCitiesTo = onlyCitiesTo; } } else if (this.excludeCitiesTo.length) { // Удаление определенных городов назначения var filteredCitiesTo = []; for (i in this.currentCitiesTo) { r = []; for (j in this.currentCitiesTo[i].cities) { if (-1 == this.excludeCitiesTo.indexOf(this.currentCitiesTo[i].cities[j].name)) { r.push(this.currentCitiesTo[i].cities[j]); } } if (r.length > 0) { filteredCitiesTo.push({ 'name': this.currentCitiesTo[i].name, 'cities': r }); } } this.currentCitiesTo = filteredCitiesTo; } }, serialize: function(obj) { var str = []; for(var p in obj) if (obj.hasOwnProperty(p)) { str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); } return str.join("&"); } };