Subversion Repositories munaweb

Rev

Rev 170 | Rev 175 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
<!DOCTYPE html>
2
<html lang="en">
3
 
4
<head>
5
    <title>eBay Listing Search</title>
6
    <meta charset="UTF-8">
7
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
8
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
9
    <link rel="icon" href="favicon.ico" type="image/x-icon">
10
 
30 - 11
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
12
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
13
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
14
    <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.min.js"></script>
15
    <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.23.0/moment.min.js"></script>
16
    <script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.23/moment-timezone-with-data-2012-2022.min.js"></script>
17
    <link rel="stylesheet" href="css/chosen.min.css">
2 - 18
    <link rel="stylesheet" href="css/style.css">
19
    <script src="js/muna-tools.js"></script>
53 - 20
    <script src="js/barcoder.js"></script>
2 - 21
</head>
22
 
23
<body onload="readParameters()">
30 - 24
    <div>
25
        <div>
26
            <div class="container-fluid bg-secondary">
27
                <div class="clearfix">
28
                    <img class="img-fluid float-right" src="images/MUNA%20-%20Logo%20100x100.png" alt="MUNA Trading Logo" />
29
                    <h1>eBay Listing Search</h1>
30
                </div>
2 - 31
            </div>
32
 
30 - 33
            <form id="searchForm" class="container-fluid bg-light" onsubmit="eBaySearch(1);return false;">
2 - 34
 
30 - 35
                <div class="row">
36
                    <div class="container-fluid border col col-12 col-md-6 col-lg-6">
37
                        <h4>Keyword <button type="button" class="btn" data-toggle="modal" data-target="#keywordHelp">&#128712;</button></h4>
2 - 38
 
30 - 39
                        <div class="input-group">
40
                            <input id="keyword" name="keyword" class="form-control" type="text" autofocus="autofocus">
41
                            <div class="input-group-append">
42
                                <button type="button" id="keywordRecommendations" class="btn btn-secondary" onclick="getKeywordRecommendations()">Keyword</button>
53 - 43
                                <button type="button" class="btn btn-secondary" onclick="checkBarcode()">Barcode</button>
30 - 44
                            </div>
6 - 45
                        </div>
8 - 46
                        <p id="recommendation"></p>
2 - 47
                    </div>
30 - 48
                    <div class="container-fluid border col col-12 col-md-6 col-lg-3">
2 - 49
                        <h4>Category</h4>
8 - 50
                        <select id="category" name="category" data-placeholder="Choose up to 3 Categories..." class="chosen-container chosen-select-3 chosen-select-label chosen-search-contains" multiple="multiple">
2 - 51
                            <option value="0">All</option>
52
                            <option value="20081">Antiques</option>
53
                            <option value="550">Art</option>
54
                            <option value="2984">Baby</option>
55
                            <option value="267">Books</option>
56
                            <option value="12576">Business Industrial</option>
57
                            <option value="625">Cameras Photo</option>
58
                            <option value="15032">Cell Phones Accessories</option>
59
                            <option value="11450">Clothing, Shoes Accessories</option>
60
                            <option value="11116">Coins Paper Money</option>
61
                            <option value="1">Collectibles</option>
62
                            <option value="58058">Computers/Tablets Networking</option>
63
                            <option value="293">Consumer Electronics</option>
64
                            <option value="14339">Crafts</option>
65
                            <option value="237">Dolls Bears</option>
66
                            <option value="11232">DVDs Movies</option>
67
                            <option value="45100">Entertainment Memorabilia</option>
68
                            <option value="172008">Gift Cards Coupons</option>
69
                            <option value="26395">Health Beauty</option>
70
                            <option value="11700">Home Garden</option>
71
                            <option value="281">Jewelry Watches</option>
72
                            <option value="11233">Music</option>
73
                            <option value="619">Musical Instruments Gear</option>
74
                            <option value="1281">Pet Supplies</option>
75
                            <option value="870">Pottery Glass</option>
76
                            <option value="10542">Real Estate</option>
77
                            <option value="316">Specialty Services</option>
78
                            <option value="888">Sporting Goods</option>
79
                            <option value="64482">Sports Mem, Cards Fan Shop</option>
80
                            <option value="260">Stamps</option>
81
                            <option value="1305">Tickets Experiences</option>
82
                            <option value="220">Toys Hobbies</option>
83
                            <option value="3252">Travel</option>
84
                            <option value="1249">Video Games Consoles</option>
85
                            <option value="99">Everything Else</option>
86
                            <optgroup label="Antiques">
87
                                <option value="37903">Antiquities</option>
88
                                <option value="4707">Architectural Garden</option>
89
                                <option value="20082">Asian Antiques</option>
90
                                <option value="20086">Decorative Arts</option>
91
                                <option value="2207">Ethnographic</option>
92
                                <option value="20091">Furniture</option>
93
                                <option value="163008">Home Hearth</option>
94
                                <option value="22422">Incunabula</option>
95
                                <option value="181677">Linens Textiles (Pre-1930)</option>
96
                                <option value="23048">Manuscripts</option>
97
                                <option value="37958">Maps, Atlases Globes</option>
98
                                <option value="37965">Maritime</option>
99
                                <option value="163091">Mercantile, Trades Factories</option>
100
                                <option value="181726">Musical Instruments (Pre-1930)</option>
101
                                <option value="100927">Periods Styles</option>
102
                                <option value="1217">Primitives</option>
103
                                <option value="163101">Restoration Care</option>
104
                                <option value="37978">Rugs Carpets</option>
105
                                <option value="20094">Science Medicine (Pre-1930)</option>
106
                                <option value="156323">Sewing (Pre-1930)</option>
107
                                <option value="20096">Silver</option>
108
                                <option value="22608">Reproduction Antiques</option>
109
                                <option value="12">Other Antiques</option>
110
                            </optgroup>
111
                            <optgroup label="Art">
112
                                <option value="28009">Art Posters</option>
113
                                <option value="552">Art Drawings</option>
114
                                <option value="2211">Art Photographs</option>
115
                                <option value="360">Art Prints</option>
116
                                <option value="553">Art Sculptures</option>
117
                                <option value="357">Folk Art Indigenous Art</option>
118
                                <option value="554">Mixed Media Art Collage Art</option>
119
                                <option value="551">Paintings</option>
120
                                <option value="156196">Textile Art Fiber Art</option>
121
                                <option value="20158">Other Art</option>
122
                            </optgroup>
123
                            <optgroup label="Baby">
124
                                <option value="100223">Baby Gear</option>
125
                                <option value="20433">Baby Safety Health</option>
126
                                <option value="20394">Bathing Grooming</option>
127
                                <option value="66692">Car Safety Seats</option>
128
                                <option value="100982">Carriers, Slings Backpacks</option>
129
                                <option value="45455">Diapering</option>
130
                                <option value="20400">Feeding</option>
131
                                <option value="117388">Keepsakes Baby Announcements</option>
132
                                <option value="20416">Nursery Bedding</option>
133
                                <option value="66697">Nursery Decor</option>
134
                                <option value="20422">Nursery Furniture</option>
135
                                <option value="37631">Potty Training</option>
136
                                <option value="66698">Strollers Accessories</option>
137
                                <option value="19068">Toys for Baby</option>
138
                                <option value="1261">Other Baby</option>
139
                                <option value="48757">Wholesale Lots</option>
140
                            </optgroup>
141
                            <optgroup label="Books">
142
                                <option value="45110">Accessories</option>
143
                                <option value="29223">Antiquarian Collectible</option>
144
                                <option value="29792">Audiobooks</option>
145
                                <option value="118254">Catalogs</option>
146
                                <option value="182882">Children Young Adults</option>
147
                                <option value="11104">Cookbooks</option>
148
                                <option value="171228">Fiction Literature</option>
149
                                <option value="280">Magazine Back Issues</option>
150
                                <option value="171243">Nonfiction</option>
151
                                <option value="2228">Textbooks, Education</option>
152
                                <option value="29399">Wholesale Bulk Lots</option>
153
                                <option value="268">Other Books</option>
154
                            </optgroup>
155
                            <optgroup label="Business Industrial">
156
                                <option value="109471">Adhesives, Sealants Tapes</option>
157
                                <option value="11748">Agriculture Forestry</option>
158
                                <option value="42892">Automation, Motors Drives</option>
159
                                <option value="46534">Cleaning Janitorial Supplies</option>
160
                                <option value="11765">Construction</option>
161
                                <option value="92074">Electrical Test Equipment</option>
162
                                <option value="11897">Facility Maintenance Safety</option>
163
                                <option value="183900">Fasteners Hardware</option>
164
                                <option value="159693">Fuel Energy</option>
165
                                <option value="11815">Healthcare, Lab Life Science</option>
166
                                <option value="177641">Heavy Equipment</option>
167
                                <option value="177647">Heavy Equipment Attachments</option>
168
                                <option value="41489">Heavy Equipment Parts Accs</option>
169
                                <option value="42909">HVAC</option>
170
                                <option value="183978">Hydraulics, Pneumatics Pumps</option>
171
                                <option value="61573">Light Equipment Tools</option>
172
                                <option value="11804">Manufacturing Metalworking</option>
173
                                <option value="26221">Material Handling</option>
174
                                <option value="25298">Office</option>
175
                                <option value="26238">Printing Graphic Arts</option>
176
                                <option value="11874">Restaurant Catering</option>
177
                                <option value="11890">Retail Services</option>
178
                                <option value="11759">Websites Businesses for Sale</option>
179
                                <option value="26261">Other Business Industrial</option>
180
                            </optgroup>
181
                            <optgroup label="Cameras Photo">
182
                                <option value="28179">Binoculars Telescopes</option>
183
                                <option value="11724">Camcorders</option>
184
                                <option value="15200">Camera Photo Accessories</option>
185
                                <option value="179697">Camera Drones</option>
186
                                <option value="182969">Camera Drone Parts Accs</option>
187
                                <option value="4684">Camera Manuals Guides</option>
188
                                <option value="31388">Digital Cameras</option>
189
                                <option value="150044">Digital Photo Frames</option>
190
                                <option value="69323">Film Photography</option>
191
                                <option value="64353">Flashes Flash Accessories</option>
192
                                <option value="78997">Lenses Filters</option>
193
                                <option value="30078">Lighting Studio</option>
194
                                <option value="182074">Replacement Parts Tools</option>
195
                                <option value="30090">Tripods Supports</option>
196
                                <option value="21162">Video Production Editing</option>
197
                                <option value="3326">Vintage Movie Photography</option>
198
                                <option value="45086">Wholesale Lots</option>
199
                                <option value="27432">Other Cameras Photo</option>
200
                            </optgroup>
201
                            <optgroup label="Cell Phones Accessories">
202
                                <option value="9355">Cell Phones Smartphones</option>
203
                                <option value="178893">Smart Watches</option>
204
                                <option value="182064">Smart Watch Accessories</option>
205
                                <option value="9394">Cell Phone Accessories</option>
206
                                <option value="136699">Display Phones</option>
207
                                <option value="146492">Phone Cards SIM Cards</option>
208
                                <option value="m43304">Cell Phone Smartphone Parts</option>
209
                                <option value="182073">Vintage Cell Phones</option>
210
                                <option value="45065">Wholesale Lots</option>
211
                                <option value="42428">Other Cell Phones Accs</option>
212
                            </optgroup>
213
                            <optgroup label="Clothing, Shoes Accessories">
214
                                <option value="3082">Baby Toddler Clothing</option>
215
                                <option value="171146">Kids' Clothing, Shoes Accs</option>
216
                                <option value="163147">Costumes, Reenactment, Theater</option>
217
                                <option value="155240">Cultural Ethnic Clothing</option>
218
                                <option value="112425">Dancewear</option>
219
                                <option value="4250">Men's Accessories</option>
220
                                <option value="1059">Men's Clothing</option>
221
                                <option value="93427">Men's Shoes</option>
222
                                <option value="28015">Uniforms Work Clothing</option>
223
                                <option value="155184">Unisex Clothing, Shoes Accs</option>
224
                                <option value="3259">Wedding Formal Occasion</option>
225
                                <option value="4251">Women's Accessories</option>
226
                                <option value="15724">Women's Clothing</option>
227
                                <option value="169291">Women's Handbags Bags</option>
228
                                <option value="3034">Women's Shoes</option>
229
                                <option value="175759">Vintage</option>
230
                                <option value="41964">Wholesale, Large Small Lots</option>
231
                            </optgroup>
232
                            <optgroup label="Coins Paper Money">
233
                                <option value="39482">Bullion</option>
234
                                <option value="253">Coins: US</option>
235
                                <option value="3377">Coins: Canada</option>
236
                                <option value="4733">Coins: Ancient</option>
237
                                <option value="18466">Coins: Medieval</option>
238
                                <option value="256">Coins: World</option>
239
                                <option value="3452">Exonumia</option>
240
                                <option value="3412">Paper Money: US</option>
241
                                <option value="3411">Paper Money: World</option>
242
                                <option value="83274">Publications Supplies</option>
243
                                <option value="3444">Stocks Bonds, Scripophily</option>
244
                                <option value="179197">Virtual Currency</option>
245
                                <option value="169305">Other Coins Paper Money</option>
246
                            </optgroup>
247
                            <optgroup label="Collectibles">
248
                                <option value="34">Advertising</option>
249
                                <option value="1335">Animals</option>
250
                                <option value="13658">Animation Art Characters</option>
251
                                <option value="66502">Arcade, Jukeboxes Pinball</option>
252
                                <option value="14429">Autographs</option>
253
                                <option value="66503">Banks, Registers Vending</option>
254
                                <option value="3265">Barware</option>
255
                                <option value="156277">Beads</option>
256
                                <option value="29797">Bottles Insulators</option>
257
                                <option value="562">Breweriana, Beer</option>
258
                                <option value="898">Casino</option>
259
                                <option value="397">Clocks</option>
260
                                <option value="63">Comics</option>
261
                                <option value="1462">Credit, Charge Cards</option>
262
                                <option value="3913">Cultures Ethnicities</option>
263
                                <option value="13777">Decorative Collectibles</option>
264
                                <option value="137">Disneyana</option>
265
                                <option value="m10860">Fantasy, Mythical Magic</option>
266
                                <option value="13877">Historical Memorabilia</option>
267
                                <option value="907">Holiday Seasonal</option>
268
                                <option value="13905">Kitchen Home</option>
269
                                <option value="1401">Knives, Swords Blades</option>
270
                                <option value="1404">Lamps, Lighting</option>
271
                                <option value="940">Linens Textiles (1930-Now)</option>
272
                                <option value="1430">Metalware</option>
273
                                <option value="13956">Militaria</option>
274
                                <option value="182982">Non-Sport Trading Cards</option>
275
                                <option value="124">Paper</option>
276
                                <option value="966">Pens Writing Instruments</option>
277
                                <option value="14005">Pez, Keychains, Promo Glasses</option>
278
                                <option value="1463">Phone Cards</option>
279
                                <option value="14277">Photographic Images</option>
280
                                <option value="39507">Pinbacks, Bobbles, Lunchboxes</option>
281
                                <option value="914">Postcards</option>
282
                                <option value="29832">Radio, Phonograph, TV, Phone</option>
283
                                <option value="1446">Religion Spirituality</option>
284
                                <option value="3213">Rocks, Fossils Minerals</option>
285
                                <option value="152">Science Fiction Horror</option>
286
                                <option value="412">Science Medicine (1930-Now)</option>
287
                                <option value="113">Sewing (1930-Now)</option>
288
                                <option value="165800">Souvenirs Travel Memorabilia</option>
289
                                <option value="593">Tobacciana</option>
290
                                <option value="13849">Tools, Hardware Locks</option>
291
                                <option value="417">Transportation</option>
292
                                <option value="597">Vanity, Perfume Shaving</option>
293
                                <option value="69851">Vintage, Retro, Mid-Century</option>
294
                                <option value="45058">Wholesale Lots</option>
295
                            </optgroup>
296
                            <optgroup label="Computers/Tablets Networking">
297
                                <option value="183062">3D Printers Supplies</option>
298
                                <option value="171485">Tablets eBook Readers</option>
299
                                <option value="176970">Tablet eBook Reader Accs</option>
300
                                <option value="180235">Tablet eBook Reader Parts</option>
301
                                <option value="175672">Laptops Netbooks</option>
302
                                <option value="171957">Desktops All-In-Ones</option>
303
                                <option value="31530">Laptop Desktop Accessories</option>
304
                                <option value="182094">Computer Cables Connectors</option>
305
                                <option value="175673">Computer Components Parts</option>
306
                                <option value="165">Drives, Storage Blank Media</option>
307
                                <option value="175698">Enterprise Networking, Servers</option>
308
                                <option value="11176">Home Networking Connectivity</option>
309
                                <option value="3676">Keyboards, Mice Pointers</option>
310
                                <option value="162497">Monitors, Projectors Accs</option>
311
                                <option value="86722">Power Protection, Distribution</option>
312
                                <option value="171961">Printers, Scanners Supplies</option>
313
                                <option value="18793">Software</option>
314
                                <option value="3516">Manuals Resources</option>
315
                                <option value="11189">Vintage Computing</option>
316
                                <option value="159260">Wholesale Lots</option>
317
                                <option value="162">Other Computers Networking</option>
318
                            </optgroup>
319
                            <optgroup label="Consumer Electronics">
320
                                <option value="184435">Voice-Enabled Smart Assistants</option>
321
                                <option value="183067">Virtual Reality</option>
322
                                <option value="15052">Portable Audio Headphones</option>
323
                                <option value="32852">TV, Video Home Audio</option>
324
                                <option value="3270">Vehicle Electronics GPS</option>
325
                                <option value="50582">Home Automation</option>
326
                                <option value="48633">Home Surveillance</option>
327
                                <option value="3286">Home Telephones Accessories</option>
328
                                <option value="48446">Multipurpose Batteries Power</option>
329
                                <option value="1500">Radio Communication</option>
330
                                <option value="14948">Gadgets Other Electronics</option>
331
                                <option value="183077">Vintage Electronics</option>
332
                                <option value="61494">Wholesale Lots</option>
333
                            </optgroup>
334
                            <optgroup label="Crafts">
335
                                <option value="11783">Art Supplies</option>
336
                                <option value="31723">Beads Jewelry Making</option>
337
                                <option value="28162">Fabric</option>
338
                                <option value="183118">Fabric Painting Decorating</option>
339
                                <option value="163778">Glass Mosaics</option>
340
                                <option value="71183">Handcrafted Finished Pieces</option>
341
                                <option value="160667">Home Arts Crafts</option>
342
                                <option value="116652">Kids' Crafts</option>
343
                                <option value="28131">Leathercrafts</option>
344
                                <option value="28102">Multi-Purpose Craft Supplies</option>
345
                                <option value="160706">Needlecrafts Yarn</option>
346
                                <option value="11788">Scrapbooking Paper Crafts</option>
347
                                <option value="160737">Sewing</option>
348
                                <option value="183302">Sculpting, Molding Ceramics</option>
349
                                <option value="3122">Stamping Embossing</option>
350
                                <option value="75576">Other Crafts</option>
351
                                <option value="45074">Wholesale Lots</option>
352
                            </optgroup>
353
                            <optgroup label="Dolls Bears">
354
                                <option value="50253">Bear Making Supplies</option>
355
                                <option value="386">Bears</option>
356
                                <option value="238">Dolls</option>
357
                                <option value="1202">Dollhouse Miniatures</option>
358
                                <option value="2440">Paper Dolls</option>
359
                                <option value="52546">Wholesale Lots</option>
360
                            </optgroup>
361
                            <optgroup label="DVDs Movies">
362
                                <option value="617">DVDs Blu-ray Discs</option>
363
                                <option value="63821">Film Stock</option>
364
                                <option value="381">Laserdiscs</option>
365
                                <option value="132975">UMDs</option>
366
                                <option value="309">VHS Tapes</option>
367
                                <option value="41676">Other Formats</option>
368
                                <option value="52554">Storage Media Accessories</option>
369
                                <option value="31606">Wholesale Lots</option>
370
                            </optgroup>
371
                            <optgroup label="Entertainment Memorabilia">
372
                                <option value="57">Autographs-Original</option>
373
                                <option value="104412">Autographs-Reprints</option>
374
                                <option value="196">Movie Memorabilia</option>
375
                                <option value="2329">Music Memorabilia</option>
376
                                <option value="1424">Television Memorabilia</option>
377
                                <option value="2362">Theater Memorabilia</option>
378
                                <option value="45101">Video Game Memorabilia</option>
379
                                <option value="2312">Other Entertainment Mem</option>
380
                            </optgroup>
381
                            <optgroup label="Gift Cards Coupons">
382
                                <option value="172009">Gift Cards</option>
383
                                <option value="172036">eBay Gift Cards</option>
384
                                <option value="31411">Gift Certificates</option>
385
                                <option value="172010">Coupons</option>
386
                                <option value="176950">Digital Gifts</option>
387
                            </optgroup>
388
                            <optgroup label="Health Beauty">
389
                                <option value="11838">Bath Body</option>
390
                                <option value="180345">Fragrances</option>
391
                                <option value="11854">Hair Care Styling</option>
392
                                <option value="67588">Health Care</option>
393
                                <option value="31786">Makeup</option>
394
                                <option value="36447">Massage</option>
395
                                <option value="11778">Medical, Mobility Disability</option>
396
                                <option value="47945">Nail Care, Manicure Pedicure</option>
397
                                <option value="67659">Natural Alternative Remedies</option>
398
                                <option value="31769">Oral Care</option>
399
                                <option value="177731">Salon Spa Equipment</option>
400
                                <option value="31762">Shaving Hair Removal</option>
401
                                <option value="11863">Skin Care</option>
402
                                <option value="31772">Sun Protection Tanning</option>
403
                                <option value="33914">Tattoos Body Art</option>
404
                                <option value="31414">Vision Care</option>
405
                                <option value="180959">Vitamins Dietary Supplements</option>
406
                                <option value="40965">Wholesale Lots</option>
407
                                <option value="1277">Other Health Beauty</option>
408
                            </optgroup>
409
                            <optgroup label="Home Garden">
410
                                <option value="26677">Bath</option>
411
                                <option value="20444">Bedding</option>
412
                                <option value="14308">Food Beverages</option>
413
                                <option value="178069">Fresh Cut Flowers Supplies</option>
414
                                <option value="3197">Furniture</option>
415
                                <option value="16086">Greeting Cards Party Supply</option>
416
                                <option value="38227">Holiday Seasonal Decor</option>
417
                                <option value="10033">Home Decor</option>
418
                                <option value="159907">Home Improvement</option>
419
                                <option value="299">Household Supplies Cleaning</option>
420
                                <option value="176988">Kids Teens at Home</option>
421
                                <option value="20625">Kitchen, Dining Bar</option>
422
                                <option value="20697">Lamps, Lighting Ceiling Fans</option>
423
                                <option value="20710">Major Appliances</option>
424
                                <option value="20571">Rugs Carpets</option>
425
                                <option value="631">Tools</option>
426
                                <option value="11827">Wedding Supplies</option>
427
                                <option value="63514">Window Treatments Hardware</option>
428
                                <option value="159912">Yard, Garden Outdoor Living</option>
429
                                <option value="31605">Wholesale Lots</option>
430
                                <option value="181076">Other Home Garden</option>
431
                            </optgroup>
432
                            <optgroup label="Jewelry Watches">
433
                                <option value="84605">Children's Jewelry</option>
434
                                <option value="91427">Engagement Wedding</option>
435
                                <option value="11312">Ethnic, Regional Tribal</option>
436
                                <option value="10968">Fashion Jewelry</option>
437
                                <option value="4196">Fine Jewelry</option>
438
                                <option value="110633">Handcrafted, Artisan Jewelry</option>
439
                                <option value="10321">Jewelry Boxes Organizers</option>
440
                                <option value="164352">Jewelry Design Repair</option>
441
                                <option value="179264">Loose Beads</option>
442
                                <option value="491">Loose Diamonds Gemstones</option>
443
                                <option value="10290">Men's Jewelry</option>
444
                                <option value="48579">Vintage Antique Jewelry</option>
445
                                <option value="14324">Watches, Parts Accessories</option>
446
                                <option value="98863">Other Jewelry Watches</option>
447
                                <option value="40131">Wholesale Lots</option>
448
                            </optgroup>
449
                            <optgroup label="Music">
450
                                <option value="176983">Cassettes</option>
451
                                <option value="176984">CDs</option>
452
                                <option value="176985">Records</option>
453
                                <option value="618">Other Formats</option>
454
                                <option value="52473">Storage Media Accessories</option>
455
                                <option value="31608">Wholesale Lots</option>
456
                            </optgroup>
457
                            <optgroup label="Musical Instruments Gear">
458
                                <option value="16212">Brass</option>
459
                                <option value="48458">DJ Equipment</option>
460
                                <option value="3858">Guitars Basses</option>
461
                                <option value="182150">Instruction Books, CDs Video</option>
462
                                <option value="175696">Karaoke Entertainment</option>
463
                                <option value="180012">Percussion</option>
464
                                <option value="180010">Pianos, Keyboards Organs</option>
465
                                <option value="180014">Pro Audio Equipment</option>
466
                                <option value="180015">Sheet Music Song Books</option>
467
                                <option value="12922">Stage Lighting Effects</option>
468
                                <option value="180016">String</option>
469
                                <option value="10181">Wind Woodwind</option>
470
                                <option value="180008">Equipment</option>
471
                                <option value="181162">Vintage Musical Instruments</option>
472
                                <option value="52555">Wholesale Lots</option>
473
                                <option value="308">Other Musical Instruments</option>
474
                            </optgroup>
475
                            <optgroup label="Pet Supplies">
476
                                <option value="177801">Backyard Poultry Supplies</option>
477
                                <option value="20734">Bird Supplies</option>
478
                                <option value="20737">Cat Supplies</option>
479
                                <option value="20742">Dog Supplies</option>
480
                                <option value="20754">Fish Aquariums</option>
481
                                <option value="1285">Reptile Supplies</option>
482
                                <option value="26696">Small Animal Supplies</option>
483
                                <option value="116391">Pet Memorials Urns</option>
484
                                <option value="48760">Wholesale Lots</option>
485
                                <option value="301">Other Pet Supplies</option>
486
                            </optgroup>
487
                            <optgroup label="Pottery Glass">
488
                                <option value="50693">Glass</option>
489
                                <option value="18875">Pottery China</option>
490
                            </optgroup>
491
                            <optgroup label="Real Estate">
492
                                <option value="15825">Commercial</option>
493
                                <option value="15841">Land</option>
494
                                <option value="94825">Manufactured Homes</option>
495
                                <option value="12605">Residential</option>
496
                                <option value="15897">Timeshares for Sale</option>
497
                                <option value="1607">Other Real Estate</option>
498
                            </optgroup>
499
                            <optgroup label="Specialty Services">
500
                                <option value="47126">Artistic Services</option>
501
                                <option value="50343">Custom Clothing Jewelry</option>
502
                                <option value="50349">eBay Auction Services</option>
503
                                <option value="47131">Graphic Logo Design</option>
504
                                <option value="170048">Home Improvement Services</option>
505
                                <option value="175814">Item Based Services</option>
506
                                <option value="50355">Media Editing Duplication</option>
507
                                <option value="20943">Printing Personalization</option>
508
                                <option value="47119">Restoration Repair</option>
509
                                <option value="47104">Web Computer Services</option>
510
                                <option value="317">Other Specialty Services</option>
511
                            </optgroup>
512
                            <optgroup label="Sporting Goods">
513
                                <option value="179767">Boxing, Martial Arts MMA</option>
514
                                <option value="7294">Cycling</option>
515
                                <option value="1492">Fishing</option>
516
                                <option value="15273">Fitness, Running Yoga</option>
517
                                <option value="1513">Golf</option>
518
                                <option value="7301">Hunting</option>
519
                                <option value="36274">Indoor Games</option>
520
                                <option value="159043">Outdoor Sports</option>
521
                                <option value="159049">Team Sports</option>
522
                                <option value="159134">Tennis Racquet Sports</option>
523
                                <option value="159136">Water Sports</option>
524
                                <option value="36259">Winter Sports</option>
525
                                <option value="310">Other Sporting Goods</option>
526
                                <option value="40146">Wholesale Lots</option>
527
                            </optgroup>
528
                            <optgroup label="Sports Mem, Cards Fan Shop">
529
                                <option value="51">Autographs-Original</option>
530
                                <option value="50115">Autographs-Reprints</option>
531
                                <option value="24409">Fan Apparel Souvenirs</option>
532
                                <option value="50116">Game Used Memorabilia</option>
533
                                <option value="50123">Vintage Sports Memorabilia</option>
534
                                <option value="56080">Wholesale Lots</option>
535
                                <option value="141755">Sports Stickers, Sets Albums</option>
536
                                <option value="212">Sports Trading Cards</option>
537
                            </optgroup>
538
                            <optgroup label="Stamps">
539
                                <option value="261">United States</option>
540
                                <option value="3478">Canada</option>
541
                                <option value="3499">Great Britain</option>
542
                                <option value="181423">Africa</option>
543
                                <option value="181416">Asia</option>
544
                                <option value="181424">Australia Oceania</option>
545
                                <option value="65174">British Colonies Territories</option>
546
                                <option value="179377">Caribbean</option>
547
                                <option value="4742">Europe</option>
548
                                <option value="181417">Latin America</option>
549
                                <option value="181422">Middle East</option>
550
                                <option value="181420">Worldwide</option>
551
                                <option value="4752">Topical Stamps</option>
552
                                <option value="7898">Specialty Philately</option>
553
                                <option value="181421">Publications Supplies</option>
554
                                <option value="170137">Other Stamps</option>
555
                            </optgroup>
556
                            <optgroup label="Tickets Experiences">
557
                                <option value="173633">Sports Tickets</option>
558
                                <option value="173634">Concert Tickets</option>
559
                                <option value="173635">Theater Tickets</option>
560
                                <option value="170594">Theme Park Club Passes</option>
561
                                <option value="178892">Parking Passes</option>
562
                                <option value="170591">Special Experiences</option>
563
                                <option value="1306">Other Tickets Experiences</option>
564
                            </optgroup>
565
                            <optgroup label="Toys Hobbies">
566
                                <option value="246">Action Figures</option>
567
                                <option value="49019">Beanbag Plush</option>
568
                                <option value="183446">Building Toys</option>
569
                                <option value="19016">Classic Toys</option>
570
                                <option value="2536">Collectible Card Games</option>
571
                                <option value="222">Diecast Toy Vehicles</option>
572
                                <option value="11731">Educational</option>
573
                                <option value="19071">Electronic, Battery Wind-Up</option>
574
                                <option value="19077">Fast Food Cereal Premiums</option>
575
                                <option value="233">Games</option>
576
                                <option value="58799">Marbles</option>
577
                                <option value="180250">Model Railroads Trains</option>
578
                                <option value="1188">Models Kits</option>
579
                                <option value="11743">Outdoor Toys Structures</option>
580
                                <option value="19169">Preschool Toys Pretend Play</option>
581
                                <option value="2613">Puzzles</option>
582
                                <option value="m2562">Radio Control Control Line</option>
583
                                <option value="19192">Robots, Monsters Space Toys</option>
584
                                <option value="2616">Slot Cars</option>
585
                                <option value="436">Stuffed Animals</option>
586
                                <option value="2631">Toy Soldiers</option>
587
                                <option value="2624">TV, Movie Character Toys</option>
588
                                <option value="717">Vintage Antique Toys</option>
589
                                <option value="40149">Wholesale Lots</option>
590
                            </optgroup>
591
                            <optgroup label="Travel">
592
                                <option value="3253">Airline</option>
593
                                <option value="164802">Campground RV Parks</option>
594
                                <option value="147399">Car Rental</option>
595
                                <option value="16078">Cruises</option>
596
                                <option value="16123">Lodging</option>
597
                                <option value="16080">Luggage</option>
598
                                <option value="173520">Luggage Accessories</option>
599
                                <option value="164803">Maps</option>
600
                                <option value="98982">Rail</option>
601
                                <option value="93838">Travel Accessories</option>
602
                                <option value="29578">Vacation Packages</option>
603
                                <option value="183477">Vintage Luggage Travel Accs</option>
604
                                <option value="1310">Other Travel</option>
605
                            </optgroup>
606
                            <optgroup label="Video Games Consoles">
607
                                <option value="139973">Video Games</option>
608
                                <option value="139971">Video Game Consoles</option>
609
                                <option value="54968">Video Game Accessories</option>
610
                                <option value="182174">Manuals, Inserts Box Art</option>
611
                                <option value="182175">Original Game Cases Boxes</option>
612
                                <option value="156597">Prepaid Gaming Cards</option>
613
                                <option value="171833">Replacement Parts Tools</option>
614
                                <option value="156595">Strategy Guides Cheats</option>
615
                                <option value="38583">Video Game Merchandise</option>
616
                                <option value="187">Other Video Games Consoles</option>
617
                                <option value="48749">Wholesale Lots</option>
618
                            </optgroup>
619
                            <optgroup label="Everything Else">
620
                                <option value="319">Adult Only</option>
621
                                <option value="3143">Career Development Education</option>
622
                                <option value="177600">eBay Special Offers</option>
623
                                <option value="20924">eBay User Tools</option>
624
                                <option value="88739">Funeral Cemetery</option>
625
                                <option value="20925">Genealogy</option>
626
                                <option value="102480">Information Products</option>
627
                                <option value="19266">Metaphysical</option>
628
                                <option value="102329">Personal Development</option>
629
                                <option value="102535">Personal Security</option>
630
                                <option value="102545">Religious Products Supplies</option>
631
                                <option value="102553">Reward Points Incentives</option>
632
                                <option value="1466">Weird Stuff</option>
633
                            </optgroup>
634
                            <optgroup label="Hunting">
635
                                <option value="177909">Blinds Treestands</option>
636
                                <option value="7304">Books Video</option>
637
                                <option value="159037">Bow</option>
638
                                <option value="36239">Clothing, Shoes Accessories</option>
639
                                <option value="36249">Decoys</option>
640
                                <option value="36252">Game Calls</option>
641
                                <option value="52505">Game Trail Cameras</option>
642
                                <option value="73943">Gun Parts</option>
643
                                <option value="177880">Gun Smithing Maintenance</option>
644
                                <option value="73937">Gun Storage</option>
645
                                <option value="73963">Holsters, Belts Pouches</option>
646
                                <option value="52502">Accessories</option>
647
                                <option value="71110">Dog Supplies</option>
648
                                <option value="14110">Trips Leases</option>
649
                                <option value="42574">Knives Tools</option>
650
                                <option value="31823">Reloading Equipment</option>
651
                                <option value="177904">Range Shooting Accessories</option>
652
                                <option value="31710">Scopes, Optics Lasers</option>
653
                                <option value="177890">Tactical Duty Gear</option>
654
                                <option value="36271">Taxidermy</option>
655
                                <option value="71131">Vintage Hunting</option>
656
                                <option value="383">Other</option>
657
                            </optgroup>
658
                            <optgroup label="Outdoor Sports">
659
                                <option value="20835">Archery</option>
660
                            </optgroup>
661
                            <optgroup label="Sports Trading Cards">
662
                                <option value="666">Auto Racing Cards</option>
663
                                <option value="213">Baseball Cards</option>
664
                                <option value="214">Basketball Cards</option>
665
                                <option value="133072">College Cards</option>
666
                                <option value="215">Football Cards</option>
667
                                <option value="4240">Golf Cards</option>
668
                                <option value="216">Ice Hockey Cards</option>
669
                                <option value="183444">Soccer Cards</option>
670
                            </optgroup>
671
                        </select>
30 - 672
                    </div>
673
                    <div class="container-fluid border col col-12 col-md-6 col-lg-3">
7 - 674
                        <div>
675
                            <h4>Duplicate Checking</h4>
30 - 676
                            <div class="form-check">
677
                                <label class="form-check-label">
678
                                    <input id="duplicateCheck" name="duplicateCheck" value="Duplicate" class="form-check-input" type="checkbox">Show Duplicates
679
                                </label>
680
                            </div>
7 - 681
                        </div>
2 - 682
                    </div>
30 - 683
                </div>
2 - 684
 
30 - 685
                <div class="row">
686
                    <div class="container-fluid border col col-6 col-md-4 col-lg-2">
2 - 687
                        <h4>Price</h4>
30 - 688
                        <div class="input-group mb-3">
689
                          <div class="input-group-prepend">
690
                            <span class="input-group-text bg-light">&#9655;</span>
691
                          </div>
692
                          <input type="text" class="form-control" id="minPrice" name="minPrice">
693
                        </div>
694
                        <div class="input-group">
695
                          <div class="input-group-prepend">
696
                            <span class="input-group-text bg-light">&#9665;</span>
697
                          </div>
698
                          <input type="text" class="form-control" id="maxPrice" name="maxPrice">
699
                        </div>
2 - 700
                    </div>
701
 
30 - 702
                    <div class="container-fluid border col col-6 col-md-4 col-lg-2">
2 - 703
                        <h4>Bids</h4>
30 - 704
                        <div class="input-group mb-3">
705
                          <div class="input-group-prepend">
706
                            <span class="input-group-text bg-light">&#9655;</span>
707
                          </div>
708
                          <input type="number" class="form-control" id="minBids" name="minBids">
709
                        </div>
710
                        <div class="input-group">
711
                          <div class="input-group-prepend">
712
                            <span class="input-group-text bg-light">&#9665;</span>
713
                          </div>
714
                          <input type="number" class="form-control" id="maxBids" name="maxBids">
715
                        </div>
2 - 716
                    </div>
717
 
30 - 718
                    <div class="container-fluid border col col-6 col-md-4 col-lg-2">
2 - 719
                        <h4>Feedback</h4>
30 - 720
                        <div class="input-group mb-3">
721
                          <div class="input-group-prepend">
722
                            <span class="input-group-text bg-light">&#9655;</span>
723
                          </div>
724
                          <input type="number" class="form-control" id="minFeedback" name="minFeedback">
725
                        </div>
726
                        <div class="input-group">
727
                          <div class="input-group-prepend">
728
                            <span class="input-group-text bg-light">&#9665;</span>
729
                          </div>
730
                          <input type="number" class="form-control" id="maxFeedback" name="maxFeedback">
731
                        </div>
2 - 732
                    </div>
733
 
30 - 734
                    <div class="container-fluid border col col-6 col-md-4 col-lg-2">
2 - 735
                        <h4>Quantity</h4>
30 - 736
                        <div class="input-group mb-3">
737
                          <div class="input-group-prepend">
738
                            <span class="input-group-text bg-light">&#9655;</span>
739
                          </div>
740
                          <input type="number" class="form-control" id="minQuantity" name="minQuantity">
741
                        </div>
742
                        <div class="input-group">
743
                          <div class="input-group-prepend">
744
                            <span class="input-group-text bg-light">&#9665;</span>
745
                          </div>
746
                          <input type="number" class="form-control" id="maxQuantity" name="maxQuantity">
747
                        </div>
2 - 748
                    </div>
749
 
30 - 750
                    <div class="container-fluid border col col-6 col-md-4 col-lg-2">
2 - 751
                        <h4>Start Date</h4>
30 - 752
                        <div class="input-group mb-3">
753
                          <div class="input-group-prepend">
754
                            <span class="input-group-text bg-light"> &#9655;</span>
755
                          </div>
756
                          <input type="date" class="form-control" id="minStartDate" name="minStartDate">
757
                        </div>
758
                        <div class="input-group">
759
                          <div class="input-group-prepend">
760
                            <span class="input-group-text bg-light"> &#9665;</span>
761
                          </div>
762
                          <input type="date" class="form-control" id="maxStartDate" name="maxStartDate">
763
                        </div>
2 - 764
                    </div>
7 - 765
 
30 - 766
                    <div class="container-fluid border col col-6 col-md-4 col-lg-2">
2 - 767
                        <h4>End Date</h4>
30 - 768
                        <div class="input-group mb-3">
769
                          <div class="input-group-prepend">
770
                            <span class="input-group-text bg-light"> &#9655;</span>
771
                          </div>
772
                          <input type="date" class="form-control" id="minEndDate" name="minEndDate">
773
                        </div>
774
                        <div class="input-group">
775
                          <div class="input-group-prepend">
776
                            <span class="input-group-text bg-light"> &#9665;</span>
777
                          </div>
778
                          <input type="date" class="form-control" id="maxEndDate" name="maxEndDate">
779
                        </div>
2 - 780
                    </div>
781
                </div>
782
 
8 - 783
                <!-- https://developer.ebay.com/DevZone/finding/Concepts/FindingAPIGuide.html#advopers -->
30 - 784
                <div class="modal fade" id="keywordHelp">
785
                    <div class="modal-dialog modal-lg">
786
                        <div class="modal-content">
787
                            <div class="modal-header">
788
                                <h4>Advanced Keyword Search Operators</h4>
789
                                <button type="button" class="close" data-dismiss="modal">×</button>
790
                            </div>
791
                            <div class="modal-body">
792
                                <p>The value specified in the keywords field can contain one or more keywords. The words "and" and "or" are treated like any other word. Only use "and," "or," or "the" if you are searching for listings containing these words. You can
793
                                    use AND or OR logic by including certain modifiers. Be careful when using spaces before or after modifiers, such as plus signs ("+") or minus signs ("-").</p>
794
                                <p>The following table shows the operators and character punctuation that can be used in keyword queries, and the effects they have.</p>
795
                                <table class="table table-bordered table-striped">
796
                                    <thead class="thead-dark">
797
                                        <tr>
798
                                            <th>Operator</th>
799
                                            <th>Description</th>
800
                                            <th>Example</th>
801
                                            <th>Returns</th>
802
                                        </tr>
803
                                    </thead>
804
                                    <tbody>
805
                                        <tr>
806
                                            <td>Space between words</td>
807
                                            <td>Applies AND logic to multiple keywords.</td>
808
                                            <td>baseball card</td>
809
                                            <td>Items with both the words "baseball" and "card".
810
                                                <br/>Note: Keyword queries consisting of keywords separated by spaces only are subject to automatic keyword expansions.</td>
811
                                        </tr>
812
                                        <tr>
813
                                            <td>Comma (,) between words, with no parentheses or spaces</td>
814
                                            <td>Requires an exact sequence of words.</td>
815
                                            <td>baseball,card</td>
816
                                            <td>Items with the exact phrase "baseball card" in the title. This is equivalent to specifying the keywords, separated by spaces, in order within quotation marks (e.g., "baseball card").</td>
817
                                        </tr>
818
                                        <tr>
819
                                            <td>Comma between words in parentheses with no spaces</td>
820
                                            <td>Applies OR logic to multiple keywords.</td>
821
                                            <td>(baseball,card)</td>
822
                                            <td>Items with either the word "baseball" or the word "card" in the title.</td>
823
                                        </tr>
824
                                        <tr>
825
                                            <td>Quoted (" ") words</td>
826
                                            <td>Requires an exact sequence of words.</td>
827
                                            <td>"baseball card"</td>
828
                                            <td>Items with the exact phrase "baseball card" in the title.</td>
829
                                        </tr>
830
                                        <tr>
831
                                            <td>Minus ("-") sign before a word</td>
832
                                            <td>Applies NOT logic to a single word. Specified word cannot be present.</td>
833
                                            <td>baseball -autograph</td>
834
                                            <td>Items that have the word "baseball" but not "autograph".
835
                                                <br/>Note: A keyword query cannot consist of excluded words only. You must include one or more search terms in order to use the NOT operator ("-"). For example, "-autograph" is not a valid keywords value on its own, but
836
                                                "baseball -autograph" (i.e., &lt;keywords&gt;baseball -autograph&lt;/keywords&gt;) will work.
837
                                                <br/>When excluding words, you must have a space before the minus sign and no space between the minus sign and the word you are excluding.</td>
838
                                        </tr>
839
                                        <tr>
840
                                            <td>Minus ("-") sign before a group of words in parentheses</td>
841
                                            <td>Applies NOT logic to a group of words. Specified words cannot be present.</td>
842
                                            <td>baseball -(autograph,card,star)</td>
843
                                            <td>Items with the word "baseball" but not "autograph," "card," or "star".</td>
844
                                        </tr>
845
                                        <tr>
846
                                            <td>At sign ("@")</td>
847
                                            <td>Search must find two of three words from a list.</td>
848
                                            <td>@1 baseball autograph card</td>
849
                                            <td>Items with two of the three words "baseball," "autograph," and "card". For a "3 out of 4" search, use @2 and a list of four words.</td>
850
                                        </tr>
851
                                        <tr>
852
                                            <td>Plus sign ("+")</td>
853
                                            <td>Concatenates a query string using AND logic with another keyword.</td>
854
                                            <td>@1 baseball autograph card +star</td>
855
                                            <td>Items with any two of the three words "baseball," "autograph," or "card" in the title plus the word "star".</td>
856
                                        </tr>
857
                                    </tbody>
858
                                </table>
859
                                <p>With the exception of the advanced search operators, punctuation marks, such as hyphens (-), commas followed by spaces (, ), exclamation points (!), question marks (?), slashes (/), and forward slashes (\) are excluded from matching.
860
                                    For example, a search for "3/4 sleeve" (i.e., &lt;keywords&gt;"3/4 sleeve"&lt;/keywords&gt;) will match "3-4 sleeve", "3\4 sleeve", "3/4-sleeve", etc.</p>
861
                                <h3>Automatic Keyword Expansions</h3>
862
                                <p>Keyword queries always search item titles for words or phrases that match exactly the keywords you specified. In some cases, eBay automatically expands keyword queries to increase the number of relevant results in the response. Keyword
863
                                    searches can be expanded by expanding the query and/or expanding the places in which to search for matching terms. This is why search results may contain items with titles that do not have all the keywords you specified in your
864
                                    query.
865
                                </p>
866
                                <p>Using advanced search operators (e.g., " ", ( ), -, +, *, or @) in your keyword query disables automatic keyword expansions. For example, an exact phrase search, such as &lt;keywords&gt;"baseball card"&lt;/keywords&gt; will limit the
867
                                    search results to items with the exact phrase in the title only.</p>
868
                                <table class="table table-bordered table-striped">
869
                                    <thead  class="thead-dark">
870
                                        <tr>
871
                                            <th>Expansion Type</th>
872
                                            <th>Description</th>
873
                                        </tr>
874
                                    </thead>
875
                                    <tbody>
876
                                        <tr>
877
                                            <td>Keyword to keyword</td>
878
                                            <td>Modifies your keyword query to search for either your original keywords, or a synonymous keyword from eBay's dictionary, such as a root word or a plural form.</td>
879
                                        </tr>
880
                                        <tr>
881
                                            <td>Keyword to category</td>
882
                                            <td>Modifies your query to search for items that have a specific keyword in the title or for items listed in a specific related category.</td>
883
                                        </tr>
884
                                        <tr>
885
                                            <td>Keyword to structured item data</td>
886
                                            <td>Modifies your query to search for items that have the keywords from the original query in the title or in the item's structured data, such as item specifics or parts compatibility information.</td>
887
                                        </tr>
888
                                    </tbody>
889
                                </table>
890
                            </div>
891
                            <div class="modal-footer">
892
                                <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
893
                            </div>
894
                        </div>
895
                    </div>
2 - 896
                </div>
897
 
30 - 898
                <div class="row">
899
                    <div class="container-fluid border col">
900
                        <div class="mb-3">
2 - 901
                        <h4>Listing Type</h4>
30 - 902
                        <div class="form-check">
903
                            <label class="form-check-label">
904
                                <input id="ltAll" name="listingType" value="All" class="form-check-input" type="checkbox" checked="checked">All
905
                            </label>
906
                        </div>
907
                        <div class="form-check">
908
                            <label class="form-check-label">
909
                                <input id="ltAuction" name="listingType" value="Auction" class="form-check-input" type="checkbox">Auction
910
                            </label>
911
                        </div>
912
                        <div class="form-check">
913
                            <label class="form-check-label">
914
                                <input id="ltAuctionWithBIN" name="listingType" value="AuctionWithBIN" class="form-check-input" type="checkbox">Auction with BIN
915
                            </label>
916
                        </div>
917
                        <div class="form-check">
918
                            <label class="form-check-label">
919
                                <input id="ltClassified" name="listingType" value="Classified" class="form-check-input" type="checkbox">Classified
920
                            </label>
921
                        </div>
922
                        <div class="form-check">
923
                            <label class="form-check-label">
924
                                <input id="ltFixedPrice" name="listingType" value="FixedPrice" class="form-check-input" type="checkbox">Fixed Price
925
                            </label>
926
                        </div>
927
                        <div class="form-check">
928
                            <label class="form-check-label">
929
                                <input id="ltStoreInventory" name="listingType" value="StoreInventory" class="form-check-input" type="checkbox">Store Inventory
930
                            </label>
931
                        </div>
932
                        </div>
933
                        <div class="mb-3">
2 - 934
                        <h4>Seller</h4>
30 - 935
                        <div class="form-group">
936
                            <input id="sellerName" name="sellerName" class="form-control" type="text">
937
                        </div>
938
                        </div>
2 - 939
 
940
                    </div>
30 - 941
                    <div class="container-fluid border col">
942
                        <div class="mb-3">
2 - 943
                        <h4>Condition</h4>
30 - 944
                        <div class="form-check">
945
                            <label class="form-check-label">
946
                                <input id="condNew" name="condition" value="New" class="form-check-input" type="checkbox">New
947
                            </label>
948
                        </div>
949
                        <div class="form-check">
950
                            <label class="form-check-label">
951
                                <input id="condUsed" name="condition" value="Used" class="form-check-input" type="checkbox">Used
952
                            </label>
953
                        </div>
954
                        <div class="form-check">
955
                            <label class="form-check-label">
956
                                <input id="condUnspecified" name="condition" value="Unspecified" class="form-check-input" type="checkbox">Unspecified
957
                            </label>
958
                        </div>
959
                        </div>
960
                        <div class="mb-3">
2 - 961
                        <h4>Located</h4>
30 - 962
                        <div class="form-group">
963
                            <select class="form-control" id="locatedIn" name="locatedIn">
170 - 964
                                <option value="North America" selected="selected">North America</option>
30 - 965
                                <option value="WorldWide">World Wide</option>
966
                            </select>
967
                        </div>
968
                        </div>
969
                        <div class="mb-3">
970
                        <h4>Local Search Only</h4>
971
                        <div class="input-group mb-3">
972
                            <div class="input-group-prepend">
973
                                <div class="input-group-text bg-light">
974
                                    <input id="localSearchOnly" name="localSearchOnly" type="checkbox">
975
                                </div>
976
                            </div>
977
                            <input id="maxDistance" name="maxDistance" class="form-control" type="number" placeholder="Maximum Distance (Miles)">
978
                        </div>
979
                        </div>
2 - 980
                    </div>
7 - 981
 
30 - 982
                    <div class="container-fluid border col">
2 - 983
                        <h4>Detail Condition</h4>
30 - 984
                        <div class="form-check">
985
                            <label class="form-check-label">
986
                                <input id="cond1000" name="conditionDetail" value="1000" class="form-check-input" type="checkbox">1000 - New
987
                            </label>
988
                        </div>
989
                        <div class="form-check">
990
                            <label class="form-check-label">
991
                                <input id="cond1500" name="conditionDetail" value="1500" class="form-check-input" type="checkbox">1500 - New other (see details)
992
                            </label>
993
                        </div>
994
                        <div class="form-check">
995
                            <label class="form-check-label">
996
                                <input id="cond1750" name="conditionDetail" value="1750" class="form-check-input" type="checkbox">1750 - New with defects
997
                            </label>
998
                        </div>
999
                        <div class="form-check">
1000
                            <label class="form-check-label">
1001
                                <input id="cond2000" name="conditionDetail" value="2000" class="form-check-input" type="checkbox">2000 - Manufacturer refurbished
1002
                            </label>
1003
                        </div>
1004
                        <div class="form-check">
1005
                            <label class="form-check-label">
1006
                                <input id="cond2500" name="conditionDetail" value="2500" class="form-check-input" type="checkbox">2500 - Seller refurbished
1007
                            </label>
1008
                        </div>
1009
                        <div class="form-check">
1010
                            <label class="form-check-label">
1011
                                <input id="cond2750" name="conditionDetail" value="2750" class="form-check-input" type="checkbox">2750 - Like New
1012
                            </label>
1013
                        </div>
1014
                        <div class="form-check">
1015
                            <label class="form-check-label">
1016
                                <input id="cond3000" name="conditionDetail" value="3000" class="form-check-input" type="checkbox">3000 - Used / Pre-owned
1017
                            </label>
1018
                        </div>
1019
                        <div class="form-check">
1020
                            <label class="form-check-label">
1021
                                <input id="cond4000" name="conditionDetail" value="4000" class="form-check-input" type="checkbox">4000 - Very Good
1022
                            </label>
1023
                        </div>
1024
                        <div class="form-check">
1025
                            <label class="form-check-label">
1026
                                <input id="cond5000" name="conditionDetail" value="5000" class="form-check-input" type="checkbox">5000 - Good
1027
                            </label>
1028
                        </div>
1029
                        <div class="form-check">
1030
                            <label class="form-check-label">
1031
                                <input id="cond6000" name="conditionDetail" value="6000" class="form-check-input" type="checkbox">6000 - Acceptable
1032
                            </label>
1033
                        </div>
1034
                        <div class="form-check">
1035
                            <label class="form-check-label">
1036
                                <input id="cond7000" name="conditionDetail" value="7000" class="form-check-input" type="checkbox">7000 - For parts or not working
1037
                            </label>
1038
                        </div>
2 - 1039
                    </div>
7 - 1040
 
30 - 1041
                    <div class="container-fluid border col">
2 - 1042
                        <h4>Miscellaneous</h4>
30 - 1043
                        <div class="form-check">
1044
                            <label class="form-check-label">
1045
                                <input id="freeShippingOnly" name="freeShippingOnly" class="form-check-input" type="checkbox">Free Shipping Only
1046
                            </label>
1047
                        </div>
1048
                        <div class="form-check">
1049
                            <label class="form-check-label">
1050
                                <input id="bestOfferOnly" name="bestOfferOnly" class="form-check-input" type="checkbox">Best Offer Only
1051
                            </label>
1052
                        </div>
1053
                        <div class="form-check">
1054
                            <label class="form-check-label">
1055
                                <input id="lotsOnly" name="lotsOnly" class="form-check-input" type="checkbox">Lots Only
1056
                            </label>
1057
                        </div>
1058
                        <div class="form-check">
1059
                            <label class="form-check-label">
1060
                                <input id="hideDuplicateItems" name="hideDuplicateItems" class="form-check-input" type="checkbox" checked="checked">Hide Duplicate Items
1061
                            </label>
1062
                        </div>
1063
                        <div class="form-check">
1064
                            <label class="form-check-label">
1065
                                <input id="outletSellerOnly" name="outletSellerOnly" class="form-check-input" type="checkbox">Outlet Seller Only
1066
                            </label>
1067
                        </div>
1068
                        <div class="form-check">
1069
                            <label class="form-check-label">
1070
                                <input id="completedItemsOnly" name="completedItemsOnly" class="form-check-input" type="checkbox">Completed Items
1071
                            </label>
1072
                        </div>
1073
                        <div class="form-check">
1074
                            <label class="form-check-label">
1075
                                <input id="searchDescription" name="searchDescription" class="form-check-input" type="checkbox">Search Description
1076
                            </label>
1077
                        </div>
1078
                        <div class="form-check">
1079
                            <label class="form-check-label">
1080
                                <input id="soldOnly" name="soldOnly" type="checkbox" class="form-check-input" disabled="disabled">Sold Items Only
1081
                            </label>
1082
                        </div>
1083
                        <div class="form-check">
1084
                            <label class="form-check-label">
1085
                                <input id="localPickupOnly" name="localPickupOnly" type="checkbox" class="form-check-input">Local Pickup Only
1086
                            </label>
1087
                        </div>
2 - 1088
                    </div>
7 - 1089
 
30 - 1090
                    <div class="container-fluid border col">
2 - 1091
                        <h4>Sort Order</h4>
30 - 1092
                        <div class="form-check">
1093
                            <label class="form-check-label">
1094
                                <input id="soBestMatch" name="sortOrder" value="BestMatch" class="form-check-input" type="radio">Best Match
1095
                            </label>
1096
                        </div>
1097
                        <div class="form-check">
1098
                            <label class="form-check-label">
1099
                                <input id="soBidCountFewest" name="sortOrder" value="BidCountFewest" class="form-check-input" type="radio">Bid Count Fewest (Auctions Only)
1100
                            </label>
1101
                        </div>
1102
                        <div class="form-check">
1103
                            <label class="form-check-label">
1104
                                <input id="soBidCountMost" name="sortOrder" value="BidCountMost" class="form-check-input" type="radio">Bid Count Most (Auctions Only)
1105
                            </label>
1106
                        </div>
1107
                        <div class="form-check">
1108
                            <label class="form-check-label">
1109
                                <input id="soCurrentPriceHighest" name="sortOrder" value="CurrentPriceHighest" class="form-check-input" type="radio">Current Price Highest
1110
                            </label>
1111
                        </div>
1112
                        <div class="form-check">
1113
                            <label class="form-check-label">
1114
                                <input id="soEndTimeSoonest" name="sortOrder" value="EndTimeSoonest" class="form-check-input" type="radio">End Time Soonest
1115
                            </label>
1116
                        </div>
1117
                        <div class="form-check">
1118
                            <label class="form-check-label">
1119
                                <input id="soPricePlusShippingHighest" name="sortOrder" value="PricePlusShippingHighest" class="form-check-input" type="radio">Price Plus Shipping Highest
1120
                            </label>
1121
                        </div>
1122
                        <div class="form-check">
1123
                            <label class="form-check-label">
1124
                                <input id="soPricePlusShippingLowest" name="sortOrder" value="PricePlusShippingLowest" class="form-check-input" type="radio" checked="checked">Price Plus Shipping Lowest
1125
                            </label>
1126
                        </div>
1127
                        <div class="form-check">
1128
                            <label class="form-check-label">
1129
                                <input id="soStartTimeNewest" name="sortOrder" value="StartTimeNewest" class="form-check-input" type="radio">Start Time Newest
1130
                            </label>
1131
                        </div>
1132
                        <div class="form-check">
1133
                            <label class="form-check-label">
1134
                                <input id="soWatchCountDecreaseSort" name="sortOrder" value="WatchCountDecreaseSort" class="form-check-input" type="radio">Watch Count Decrease Sort
1135
                            </label>
1136
                        </div>
1137
                        <div class="form-check">
1138
                            <label class="form-check-label">
1139
                                <input id="soDistance" name="sortOrder" value="Distance" class="form-check-input" type="radio">Distance
1140
                            </label>
1141
                        </div>
2 - 1142
                    </div>
1143
                </div>
1144
 
30 - 1145
                <div class="container-fluid row border">
1146
                    <div class="col clearfix">
1147
                        <div class="float-left">
1148
                            <input type="submit" class="btn btn-primary" value="Search" />
1149
                            <input type="button" class="btn btn-secondary" onclick="resetForm()" value="Reset form">
1150
                        </div>
1151
                        <div class="float-right">
1152
                            <input type="button" id="pricing" class="btn btn-secondary" onclick="getPricing()" value="Pricing" disabled>
1153
                            <input type="button" id="download" class="btn btn-secondary" onclick="downloadAsCSV()" value="Download" disabled>
1154
                        </div>
1155
                    </div>
1156
                </div>
2 - 1157
            </form>
1158
        </div>
1159
 
30 - 1160
        <div id="warnings" class="container-fluid invisible"></div>
1161
        <div class="modal" id="progressBarDiv">
1162
            <div class="modal-dialog">
1163
                <div class="modal-content">
1164
                    <div class="modal-header">
1165
                        <h4 id="progressBarHeader"></h4>
1166
                    </div>
1167
                    <div class="modal-body">
1168
                        <div class="progress">
1169
                            <div id="progressBar" class="progress-bar" style="width:0%">0%</div>
1170
                        </div>
1171
                    </div>
1172
                </div>
2 - 1173
            </div>
1174
        </div>
30 - 1175
        <div id="duplicates" class="container-fluid border invisible">
7 - 1176
            <h2>Duplicates</h2>
1177
            <p id="duplicatesText"></p>
1178
        </div>
30 - 1179
        <div id="prices" class="container-fluid border invisible"></div>
1180
        <div id="results" class="border "></div>
1181
        <div id="csv" class="w3-hide"></div>
1182
        <div id="parameter" class="container-fluid border invisible"></div>
2 - 1183
 
30 - 1184
        <footer class="container-fluid text-center border border-bottom-0 border-left-0 border-right-0">
1185
            <div w3-include-html="php/footer.php"></div>
2 - 1186
        </footer>
1187
 
1188
    </div>
1189
 
1190
    <script>
1191
 
1192
// Globals
1193
var pagenumber = 1;
1194
var totalEntries = 0;
1195
var asyncFlag = false;
1196
var maxPages = 0;
1197
var currentPage = 0;
1198
var valueStartMin;
1199
var valueStartMax;
1200
var valueEndMin;
1201
var valueEndMax;
1202
var getShippingCostsDone = false;
1203
var ship_str = "";
1204
var ship_str_cost = "";
1205
var ship_str_tax = "";
1206
var maxPricingPages = [-1, -1];
1207
var totalPricingEntries = [0, 0];
1208
 
1209
 
1210
function paginationNav(strCurrentPage, strMaxPage) {
1211
	var str = "";
1212
 
1213
	var currentPage = parseInt(strCurrentPage);
1214
	var maxPage = parseInt(strMaxPage);
1215
 
1216
	if (maxPage == 1) {
1217
		return str;
1218
	}
1219
 
1220
	if (currentPage > 1) {
30 - 1221
		str += '<button type="button" class="btn" onclick="prevPage()">&laquo;</button>';
2 - 1222
	} else {
30 - 1223
		str += '<button type="button" class="btn" disabled>&laquo;</button>';
2 - 1224
	}
1225
 
1226
	if (currentPage < 100 && currentPage < maxPage) {
30 - 1227
		str += '<button type="button" class="btn" onclick="nextPage()">&raquo;</button>';
2 - 1228
	} else {
30 - 1229
		str += '<button type="button" class="btn" disabled>&raquo;</button>';
2 - 1230
	}
1231
 
1232
	return str;
1233
}
1234
 
1235
function prevPage() {
1236
	pagenumber--;
1237
	eBaySearch(pagenumber);
1238
}
1239
 
1240
function nextPage() {
1241
	pagenumber++;
1242
	eBaySearch(pagenumber);
1243
}
1244
 
1245
// Parse the response and build an HTML table to display search results
1246
function _cb_findItemsAdvanced(root) {
1247
	var response;
1248
 
1249
	// Error Handling
1250
	if (root.findItemsAdvancedResponse !== undefined) {
1251
		response = root.findItemsAdvancedResponse[0];
1252
	} else if (root.findItemsByProductResponse !== undefined) {
1253
		response = root.findItemsByProductResponse[0];
1254
	} else {
1255
		return;
1256
	}
1257
 
1258
	var ack = response.ack;
1259
	if (ack != 'Success') {
1260
		printeBayAPIError(response);
1261
 
1262
		if (ack == 'Failure' || ack == 'PartialFailure') {
1263
			return;
1264
		}
1265
	}
1266
 
1267
	var i;
30 - 1268
	var items = getJsonArray(response.searchResult[0].item);
2 - 1269
	var html = [];
1270
 
30 - 1271
	var pageNumber = Number(getJsonValue(response.paginationOutput[0].pageNumber));
1272
	var totalPages = Number(getJsonValue(response.paginationOutput[0].totalPages));
1273
	totalEntries = Number(getJsonValue(response.paginationOutput[0].totalEntries));
1274
	html.push('<p class="text-center">Page ' + pageNumber + ' of ' + totalPages + ' ' + paginationNav(pageNumber, totalPages) + ' | Total Entries: ' + totalEntries + '</p>');
1275
	html.push('<div class="table-responsive"><table class="table table-hover table-striped table-bordered">');
1276
	html.push('<thead class="thead-dark"><tr><th>Picture</th><th>Description</th><th>Price</th><th>Duration</th><th>Style</th><th>Seller</th><th>Shipping</th></tr></thead><tbody>');
2 - 1277
 
1278
	for (i = 0; i < items.length; ++i) {
1279
		var item = items[i];
30 - 1280
		var title = getJsonValue(item.title);
1281
		var pic = (item.galleryURL !== undefined ? item.galleryURL[0] : '');
1282
		var pic = pic.replace('http:', 'https:');
1283
		var viewitem = getJsonValue(item.viewItemURL);
1284
		var price = Number(getJsonValue(item.sellingStatus[0].convertedCurrentPrice[0].__value__));
152 - 1285
		var shPrice = item.shippingInfo[0].shippingServiceCost !== undefined ? Number(getJsonValue(item.shippingInfo[0].shippingServiceCost[0].__value__)) : 0.00;
30 - 1286
		var timeleftStr = formatTimeleft(moment.duration(getJsonValue(item.sellingStatus[0].timeLeft)).asSeconds());
1287
		var startTime = moment(getJsonValue(item.listingInfo[0].startTime), moment.ISO_8601).format("YYYY-MM-DD hh:MMA");
1288
		var endTime = moment(getJsonValue(item.listingInfo[0].endTime), moment.ISO_8601).format("YYYY-MM-DD hh:MMA");
1289
		var condition = getJsonValue(item.condition) != '' ? getJsonValue(item.condition[0].conditionDisplayName) : "Unknown";
1290
		var bidCount = getJsonValue(item.sellingStatus[0].bidCount);
1291
		var sellingState = getJsonValue(item.sellingStatus[0].sellingState);
1292
		var listingType = getJsonValue(item.listingInfo[0].listingType);
1293
		var BO = getJsonValue(item.listingInfo[0].bestOfferEnabled);
1294
		var location = getJsonValue(item.location);
1295
		var shippingType = getJsonValue(item.shippingInfo[0].shippingType);
1296
		var shippingLocation = getJsonValue(item.shippingInfo[0].shipToLocations);
1297
		var sellerUserName = getJsonValue(item.sellerInfo[0].sellerUserName);
1298
		var feedbackScore = getJsonValue(item.sellerInfo[0].feedbackScore);
1299
		var positiveFeedbackPercent = getJsonValue(item.sellerInfo[0].positiveFeedbackPercent);
1300
		var convertedBuyItNowPrice = getJsonValue(item.listingInfo[0].convertedBuyItNowPrice);
1301
		var	distance = item.distance === undefined ? 0 : Number(getJsonValue(item.distance[0].__value__));
1302
		var distanceUnit = item.distance === undefined ? "" : getJsonValue(item.distance[0]["@unit"]);
1303
		var watchCount = Number(getJsonValue(item.listingInfo[0].watchCount));
1304
		var itemId = getJsonValue(item.itemId);
1305
		var subtitle = getJsonValue(item.subtitle);
2 - 1306
 
1307
		if (title && viewitem) {
30 - 1308
			var str = '<tr><td> (' + (i + 1) + ') ' + '<a href="javascript:void(0)" onclick="findSingleItem(' + itemId + ')"><img class="img-fluid" src="' + pic + '" alt="Gallery Image"></a></td>' + '<td><a href="javascript:void(0)" onclick="findSingleItem(' + itemId + ')">' + title + '</a>';
1309
			if (subtitle != '') {
1310
				str += '<br/>' + subtitle;
2 - 1311
			}
1312
			str += '<br/>';
30 - 1313
			str += '<a class="text-danger" href="' + viewitem + '" target="_blank">EBAY ' + itemId + '</a>';
1314
			str += '<br/>';
1315
			str += '<a href="' + window.location.protocol + "//" + window.location.hostname + window.location.pathname + '?keyword=' + String(title).replace(/ /g, "+").replace(/\"/g, "").replace(/#/g, "") + '&listingType=All&hideDuplicateItems=on&completedItemsOnly=on&locatedIn=North+America&sortOrder=BestMatch" class="btn btn-secondary btn-sm" role="button" target="_blank">Search Completed</a>';
2 - 1316
			str += '</td><td>$' + price.toFixed(2);
1317
			if (convertedBuyItNowPrice) {
30 - 1318
				str += '<br/>BIN $' + Number(getJsonValue(convertedBuyItNowPrice[0].__value__)).toFixed(2);
2 - 1319
			}
1320
			if (item.shippingInfo[0].shippingServiceCost && shPrice) {
1321
				str += '<br/>S&H $' + shPrice.toFixed(2);
1322
			}
1323
			str += "<br/>" + condition;
1324
			if (item.sellingStatus[0].bidCount) {
1325
				str += '<br/>' + bidCount + ' Bid(s)';
1326
			}
1327
 
1328
			str += '</td><td>' + timeleftStr + '<br/>' + startTime + '<br/>' + endTime;
1329
			if (item.listingInfo[0].watchCount) {
1330
				str += '<br/>' + watchCount + ' Watcher(s)';
1331
			}
1332
			str += '</td>';
1333
			str += '<td>' + sellingState + '<br/>' + listingType;
1334
			if (BO == 'true') {
1335
				str += '<br/>Best Offer';
1336
			}
1337
			str += '</td><td>' + sellerUserName + '<br/>' + feedbackScore + '<br/>' + positiveFeedbackPercent + '%</td>';
1338
			str += '<td>' + location;
1339
			if (item.distance) {
1340
				str += ' (' + distance + ' ' + distanceUnit + ')';
1341
			}
1342
			str += '<br/>' + shippingType + '<br/>' + shippingLocation + '</td>';
1343
			str += '</tr>';
1344
 
1345
			html.push(str);
1346
		}
1347
	}
30 - 1348
	html.push('</tbody></table></div>');
1349
	html.push('<p class="text-center">Page ' + pageNumber + ' of ' + totalPages + ' ' + paginationNav(pageNumber, totalPages) + ' | Total Entries: ' + totalEntries + '</p>');
2 - 1350
 
1351
	var x = document.getElementById("results");
1352
	x.innerHTML = html.join("");
30 - 1353
	x.className = x.className.replace(" invisible", " visible");
2 - 1354
	x.scrollIntoView(true);
30 - 1355
    document.getElementById("searchForm").style.opacity = "1.0";
2 - 1356
 
30 - 1357
	if (totalEntries > 0) {
1358
		document.getElementById("download").disabled = false;
1359
		document.getElementById("pricing").disabled = false;
2 - 1360
	}
1361
} // End _cb_findItemsAdvanced() function
1362
 
1363
// Parse the response and build an HTML table to display search results
1364
function _cb_findCompletedItems(root) {
1365
	// Error Handling
1366
	var i;
1367
	var response = root.findCompletedItemsResponse[0];
1368
	var ack = response.ack;
1369
	if (ack != 'Success') {
1370
		printeBayAPIError(response);
1371
 
1372
		if (ack == 'Failure' || ack == 'PartialFailure') {
1373
			return;
1374
		}
1375
	}
1376
 
30 - 1377
	var items = getJsonArray(response.searchResult[0].item);
2 - 1378
	var html = [];
1379
	var distance;
1380
	var distanceUnit;
1381
 
30 - 1382
	var pageNumber = Number(getJsonValue(response.paginationOutput[0].pageNumber));
1383
	var totalPages = Number(getJsonValue(response.paginationOutput[0].totalPages));
2 - 1384
	totalEntries = Number(response.paginationOutput[0].totalEntries);
30 - 1385
	html.push('<p class="text-center">Page ' + pageNumber + ' of ' + totalPages + ' ' + paginationNav(pageNumber, totalPages) + ' | Total Entries: ' + totalEntries + '</p>');
1386
	html.push('<div class="table-responsive"><table class="table table-hover table-striped table-bordered">');
1387
	html.push('<thead class="thead-dark"><tr><th>Picture</th><th>Description</th><th>Price</th><th>Duration</th><th>Seller</th><th>Shipping</th></tr></thead><tbody>');
2 - 1388
 
1389
	for (i = 0; i < items.length; ++i) {
1390
		var item = items[i];
30 - 1391
		var title = getJsonValue(item.title);
1392
		var pic = (item.galleryURL !== undefined ? item.galleryURL[0] : '');
1393
		var pic = pic.replace('http:', 'https:');
1394
		var viewitem = getJsonValue(item.viewItemURL);
1395
		var price = Number(getJsonValue(item.sellingStatus[0].convertedCurrentPrice[0].__value__));
2 - 1396
		var shPrice = 0;
1397
		if (item.shippingInfo[0].shippingServiceCost) {
30 - 1398
			shPrice = Number(getJsonValue(item.shippingInfo[0].shippingServiceCost[0].__value__));
2 - 1399
		}
30 - 1400
		var startTime = moment(getJsonValue(item.listingInfo[0].startTime), moment.ISO_8601).format("YYYY-MM-DD hh:MMA");
1401
		var endTime = moment(getJsonValue(item.listingInfo[0].endTime), moment.ISO_8601).format("YYYY-MM-DD hh:MMA");
1402
		var condition = item.condition ? getJsonValue(item.condition[0].conditionDisplayName) : "Unknown";
1403
		var bidCount = getJsonValue(item.sellingStatus[0].bidCount);
1404
		var sellingState = getJsonValue(item.sellingStatus[0].sellingState);
2 - 1405
		var sold = (sellingState == "EndedWithSales");
30 - 1406
		var listingType = getJsonValue(item.listingInfo[0].listingType);
1407
		var BO = getJsonValue(item.listingInfo[0].bestOfferEnabled);
1408
		var location = getJsonValue(item.location);
1409
		var shippingType = getJsonValue(item.shippingInfo[0].shippingType);
1410
		var shippingLocation = getJsonValue(item.shippingInfo[0].shipToLocations);
1411
		var sellerUserName = getJsonValue(item.sellerInfo[0].sellerUserName);
1412
		var feedbackScore = getJsonValue(item.sellerInfo[0].feedbackScore);
1413
		var positiveFeedbackPercent = getJsonValue(item.sellerInfo[0].positiveFeedbackPercent);
1414
		var convertedBuyItNowPrice = getJsonValue(item.listingInfo[0].convertedBuyItNowPrice);
2 - 1415
		if (item.distance) {
30 - 1416
			distance = getJsonValue(item.distance[0].__value__);
1417
			distanceUnit = getJsonValue(item.distance[0]["@unit"]);
2 - 1418
		}
30 - 1419
		var watchCount = Number(getJsonValue(item.listingInfo[0].watchCount));;
1420
		var itemId = getJsonValue(item.itemId);
1421
		var subtitle = getJsonValue(item.subtitle);
2 - 1422
 
1423
		if (title && viewitem) {
30 - 1424
			var str = '<tr><td>(' + (i + 1) + ') ' + '<a href="javascript:void(0)" onclick="findSingleItem(' + itemId + ')"><img class="img-fluid" src="' + pic + '" alt="Gallery Image"></a></td><td><a href="javascript:void(0)" onclick="findSingleItem(' + itemId + ')">' + title + '</a><br/>';
1425
			str += '<a class="text-danger" href="' + viewitem + '" target="_blank">EBAY ' + itemId + '</a>';
1426
			str += '</td><td class="' + (sold ? 'text-success' : 'text-danger') + '">';
1427
			str += '$' + price.toFixed(2);
2 - 1428
			if (convertedBuyItNowPrice) {
1429
				str += '<br/>BIN $' + Number(convertedBuyItNowPrice[0].__value__).toFixed(2);
1430
			}
1431
			if (item.shippingInfo[0].shippingServiceCost && shPrice) {
1432
				str += '<br/>S&H $' + shPrice.toFixed(2);
1433
			}
1434
			str += "<br/>" + condition;
1435
			if (item.sellingStatus[0].bidCount) {
1436
				str += '<br/>' + bidCount + ' Bid(s)';
1437
			}
1438
			str += '</td><td>' + startTime + '<br/>' + endTime + '<br/>';
1439
			str += listingType;
1440
			if (BO == 'true') {
1441
				str += '<br/>Best Offer';
1442
			}
1443
			if (item.listingInfo[0].watchCount) {
1444
				str += '<br/>' + watchCount + ' Watcher(s)';
1445
			}
1446
			str += '</td><td>' + sellerUserName + '<br/>' + feedbackScore + '<br/>' + positiveFeedbackPercent + '%</td>';
1447
			str += '<td>' + location;
1448
			if (item.distance) {
1449
				str += ' (' + distance + ' ' + distanceUnit + ')';
1450
			}
1451
			str += '<br/>' + shippingType + '<br/>' + shippingLocation + '</td>';
1452
			str += '</tr>';
1453
 
1454
			html.push(str);
1455
		}
1456
	}
30 - 1457
	html.push('</tbody></table></div>');
1458
	html.push('<p class="text-center">Page ' + pageNumber + ' of ' + totalPages + ' ' + paginationNav(pageNumber, totalPages) + ' | Total Entries: ' + totalEntries + '</p>');
2 - 1459
 
1460
 
1461
	var x = document.getElementById("results");
1462
	x.innerHTML = html.join("");
30 - 1463
	x.className = x.className.replace(" invisible", " visible");
2 - 1464
	x.scrollIntoView(true);
30 - 1465
    document.getElementById("searchForm").style.opacity = "1.0";
2 - 1466
 
30 - 1467
	if (totalEntries > 0) {
1468
		document.getElementById("download").disabled = false;
1469
		document.getElementById("pricing").disabled = false;
2 - 1470
	}
1471
} // End _cb_findCompletedItems() function
1472
 
1473
var ebayRecommendedKeywords = "";
1474
 
1475
// Parse the response and build an HTML table to display search results
1476
function _cb_getKeywordRecommendations(root) {
1477
	// Error Handling
1478
	var response = root.getSearchKeywordsRecommendationResponse[0];
1479
	var ack = response.ack;
1480
	var x;
1481
	if (ack == 'Success') {
1482
		x = document.getElementById("recommendation");
30 - 1483
		x.innerHTML = 'Keyword Recommendation: <a href="javascript:void(0)" onclick="copyKeywordRecommendations()">' + response.keywords + '</a>';
1484
		x.className = 'text-success';
2 - 1485
		ebayRecommendedKeywords = response.keywords;
1486
	} else if (ack == 'Warning' && response.errorMessage[0].error[0].errorId == 59) {
1487
		x = document.getElementById("recommendation");
1488
		x.innerHTML = "No Keyword Recommendations";
30 - 1489
		x.className = 'text-info';
2 - 1490
	} else {
1491
		printeBayAPIError(response);
1492
 
1493
		if (ack == 'Failure' || ack == 'PartialFailure') {
1494
			return;
1495
		}
1496
	}
1497
} // End _cb_getKeywordRecommendations() function
1498
 
1499
function copyKeywordRecommendations() {
1500
	document.getElementById("keyword").value = ebayRecommendedKeywords;
1501
	document.getElementById("recommendation").innerHTML = "";
1502
}
1503
 
1504
function printeBayAPIError(root) {
1505
	var x = document.getElementById("warnings");
30 - 1506
    var str;
2 - 1507
 
30 - 1508
    str = '<div class="alert alert-danger alert-dismissible">';
1509
    str += '<button type="button" class="close" data-dismiss="alert">×</button>';
1510
    str += "<h2>eBay API Error</h2>";
1511
    str += "<ul>"
1512
	str += "<li>Id: " + root.errorMessage[0].error[0].errorId + "</li>";
1513
	str += "<li>Domain: " + root.errorMessage[0].error[0].domain + "</li>";
1514
	str += "<li>Severity: " + root.errorMessage[0].error[0].severity + "</li>";
1515
	str += "<li>Category: " + root.errorMessage[0].error[0].category + "</li>";
1516
	str += "<li>Message: " + root.errorMessage[0].error[0].message + "</li>";
1517
	str += "<li>Subdomain: " + root.errorMessage[0].error[0].subdomain + "</li>";
1518
	str += "<li>Parameter: " + root.errorMessage[0].error[0].parameter + "</li>";
1519
    str += "</ul>"
1520
	str += "<p>URL: " + "<a href=\"" + url + "\" target=\"_blank\">" + url + "</a>" + "</p>";
1521
    str += '</div>';
2 - 1522
 
30 - 1523
	x.innerHTML = str;
1524
	x.className = x.className.replace(" invisible", " visible");
1525
 
2 - 1526
	if (root.ack == 'Failure' || root.ack == 'PartialFailure') {
1527
		x.scrollIntoView(true);
1528
	}
30 - 1529
 
1530
    document.getElementById("searchForm").style.opacity = "1.0";
1531
	document.getElementById("results").innerHTML = "";
2 - 1532
}
1533
 
1534
// item filters for request
1535
var filterarray = [];
1536
 
1537
// Fill the array of item filters from input form
1538
function fillFilterArray() {
1539
	var value = "";
1540
	var listingType = [];
1541
	var conditions = [];
1542
	var obj = [{
1543
		"name": "",
1544
		"value": "",
1545
		"paramName": "",
1546
		"paramValue": ""
1547
	}];
1548
 
1549
	filterarray = [{
1550
		"name": "AvailableTo",
1551
		"value": "US",
1552
		"paramName": "",
1553
		"paramValue": ""
1554
	}];
1555
 
1556
	value = document.getElementById('sellerName').value;
1557
	if (value) {
1558
		obj = {
1559
			"name": "Seller",
1560
			"value": value,
1561
			"paramName": "",
1562
			"paramValue": ""
1563
		};
1564
		filterarray.push(obj);
1565
	}
1566
 
1567
	value = document.getElementById('minPrice').value;
1568
	if (value > 0) {
1569
		obj = {
1570
			"name": "MinPrice",
1571
			"value": Number(value).toFixed(2),
1572
			"paramName": "Currency",
1573
			"paramValue": "USD"
1574
		};
1575
		filterarray.push(obj);
1576
	}
1577
 
1578
	value = document.getElementById('maxPrice').value;
1579
	if (value > 0) {
1580
		obj = {
1581
			"name": "MaxPrice",
1582
			"value": Number(value).toFixed(2),
1583
			"paramName": "Currency",
1584
			"paramValue": "USD"
1585
		};
1586
		filterarray.push(obj);
1587
	}
1588
 
1589
	value = document.getElementById('minBids').value;
1590
	if (value > 0) {
1591
		obj = {
1592
			"name": "MinBids",
1593
			"value": Number(value).toFixed(0),
1594
			"paramName": "",
1595
			"paramValue": ""
1596
		};
1597
		filterarray.push(obj);
1598
	}
1599
 
1600
	value = document.getElementById('maxBids').value;
1601
	if (value && value >= 0) {
1602
		obj = {
1603
			"name": "MaxBids",
1604
			"value": Number(value).toFixed(0),
1605
			"paramName": "",
1606
			"paramValue": ""
1607
		};
1608
		filterarray.push(obj);
1609
	}
1610
 
1611
	value = document.getElementById('minFeedback').value;
1612
	if (value > 0) {
1613
		obj = {
1614
			"name": "FeedbackScoreMin",
1615
			"value": Number(value).toFixed(0),
1616
			"paramName": "",
1617
			"paramValue": ""
1618
		};
1619
		filterarray.push(obj);
1620
	}
1621
 
1622
	value = document.getElementById('maxFeedback').value;
1623
	if (value && value >= 0) {
1624
		obj = {
1625
			"name": "FeedbackScoreMax",
1626
			"value": Number(value).toFixed(0),
1627
			"paramName": "",
1628
			"paramValue": ""
1629
		};
1630
		filterarray.push(obj);
1631
	}
1632
 
1633
	value = document.getElementById('minQuantity').value;
1634
	if (value > 0) {
1635
		obj = {
1636
			"name": "MinQuantity",
1637
			"value": Number(value).toFixed(0),
1638
			"paramName": "",
1639
			"paramValue": ""
1640
		};
1641
		filterarray.push(obj);
1642
	}
1643
 
1644
	value = document.getElementById('maxQuantity').value;
1645
	if (value && value >= 0) {
1646
		obj = {
1647
			"name": "MaxQuantity",
1648
			"value": Number(value).toFixed(0),
1649
			"paramName": "",
1650
			"paramValue": ""
1651
		};
1652
		filterarray.push(obj);
1653
	}
1654
 
1655
	if (document.getElementById('freeShippingOnly').checked) {
1656
		obj = {
1657
			"name": "FreeShippingOnly",
1658
			"value": "true",
1659
			"paramName": "",
1660
			"paramValue": ""
1661
		};
1662
		filterarray.push(obj);
1663
	}
1664
 
1665
	if (document.getElementById('bestOfferOnly').checked) {
1666
		obj = {
1667
			"name": "BestOfferOnly",
1668
			"value": "true",
1669
			"paramName": "",
1670
			"paramValue": ""
1671
		};
1672
		filterarray.push(obj);
1673
	}
1674
 
1675
	if (document.getElementById('lotsOnly').checked) {
1676
		obj = {
1677
			"name": "LotsOnly",
1678
			"value": "true",
1679
			"paramName": "",
1680
			"paramValue": ""
1681
		};
1682
		filterarray.push(obj);
1683
	}
1684
 
1685
	if (document.getElementById('hideDuplicateItems').checked) {
1686
		obj = {
1687
			"name": "HideDuplicateItems",
1688
			"value": "true",
1689
			"paramName": "",
1690
			"paramValue": ""
1691
		};
1692
		filterarray.push(obj);
1693
	}
1694
 
1695
	if (document.getElementById('outletSellerOnly').checked) {
1696
		obj = {
1697
			"name": "OutletSellerOnly",
1698
			"value": "true",
1699
			"paramName": "",
1700
			"paramValue": ""
1701
		};
1702
		filterarray.push(obj);
1703
	}
1704
 
1705
	if (document.getElementById('soldOnly').checked) {
1706
		obj = {
1707
			"name": "SoldOnly",
1708
			"value": "true",
1709
			"paramName": "",
1710
			"paramValue": ""
1711
		};
1712
		filterarray.push(obj);
1713
	}
1714
 
1715
	if (document.getElementById('localPickupOnly').checked) {
1716
		obj = {
1717
			"name": "LocalPickupOnly",
1718
			"value": "true",
1719
			"paramName": "",
1720
			"paramValue": ""
1721
		};
1722
		filterarray.push(obj);
1723
	}
1724
 
1725
	if (document.getElementById('localSearchOnly').checked) {
1726
		obj = {
1727
			"name": "LocalSearchOnly",
1728
			"value": "true",
1729
			"paramName": "",
1730
			"paramValue": ""
1731
		};
1732
		filterarray.push(obj);
1733
 
1734
		value = document.getElementById('maxDistance').value;
1735
		if (value && value >= 0) {
1736
			obj = {
1737
				"name": "MaxDistance",
1738
				"value": Number(value).toFixed(0),
1739
				"paramName": "",
1740
				"paramValue": ""
1741
			};
1742
			filterarray.push(obj);
1743
		}
1744
	}
1745
 
1746
	if (document.getElementById('ltAll').checked) {
1747
		listingType.push("All");
1748
	}
1749
 
1750
	if (document.getElementById('ltAuction').checked) {
1751
		listingType.push("Auction");
1752
	}
1753
 
1754
	if (document.getElementById('ltAuctionWithBIN').checked) {
1755
		listingType.push("AuctionWithBIN");
1756
	}
1757
 
1758
	if (document.getElementById('ltClassified').checked) {
1759
		listingType.push("Classified");
1760
	}
1761
 
1762
	if (document.getElementById('ltFixedPrice').checked) {
1763
		listingType.push("FixedPrice");
1764
	}
1765
 
1766
	if (document.getElementById('ltStoreInventory').checked) {
1767
		listingType.push("StoreInventory");
1768
	}
1769
 
1770
	if (listingType.length) {
1771
		obj = {
1772
			"name": "ListingType",
1773
			"value": listingType,
1774
			"paramName": "",
1775
			"paramValue": ""
1776
		};
1777
		filterarray.push(obj);
1778
	}
1779
 
1780
	if (document.getElementById('condNew').checked) {
1781
		conditions.push("New");
1782
	}
1783
 
1784
	if (document.getElementById('condUsed').checked) {
1785
		conditions.push("Used");
1786
	}
1787
 
1788
	if (document.getElementById('condUnspecified').checked) {
1789
		conditions.push("Unspecified");
1790
	}
1791
 
1792
	if (document.getElementById('cond1000').checked) {
1793
		conditions.push("1000");
1794
	}
1795
 
1796
	if (document.getElementById('cond1500').checked) {
1797
		conditions.push("1500");
1798
	}
1799
 
1800
	if (document.getElementById('cond1750').checked) {
1801
		conditions.push("1750");
1802
	}
1803
 
1804
	if (document.getElementById('cond2000').checked) {
1805
		conditions.push("2000");
1806
	}
1807
 
1808
	if (document.getElementById('cond2500').checked) {
1809
		conditions.push("2500");
1810
	}
1811
 
1812
	if (document.getElementById('cond2750').checked) {
1813
		conditions.push("2750");
1814
	}
1815
 
1816
	if (document.getElementById('cond3000').checked) {
1817
		conditions.push("3000");
1818
	}
1819
 
1820
	if (document.getElementById('cond4000').checked) {
1821
		conditions.push("4000");
1822
	}
1823
 
1824
	if (document.getElementById('cond5000').checked) {
1825
		conditions.push("5000");
1826
	}
1827
 
1828
	if (document.getElementById('cond6000').checked) {
1829
		conditions.push("6000");
1830
	}
1831
 
1832
	if (document.getElementById('cond7000').checked) {
1833
		conditions.push("7000");
1834
	}
1835
 
1836
	if (conditions.length) {
1837
		obj = {
1838
			"name": "Condition",
1839
			"value": conditions,
1840
			"paramName": "",
1841
			"paramValue": ""
1842
		};
1843
		filterarray.push(obj);
1844
	}
1845
 
1846
	if (document.getElementById('locatedIn').options[0].selected) {
1847
		obj = {
1848
			"name": "LocatedIn",
1849
			"value": document.getElementById('locatedIn').options[0].value,
1850
			"paramName": "",
1851
			"paramValue": ""
1852
		};
1853
		filterarray.push(obj);
1854
	} else {
1855
		obj = {
1856
			"name": "LocatedIn",
1857
			"value": document.getElementById('locatedIn').options[1].value,
1858
			"paramName": "",
1859
			"paramValue": ""
1860
		};
1861
		filterarray.push(obj);
1862
	}
1863
 
1864
	if (valueStartMin) {
1865
		obj = {
1866
			"name": "StartTimeFrom",
1867
			"value": valueStartMin,
1868
			"paramName": "",
1869
			"paramValue": ""
1870
		};
1871
		filterarray.push(obj);
1872
	}
1873
 
1874
	if (valueStartMax) {
1875
		obj = {
1876
			"name": "StartTimeTo",
1877
			"value": valueStartMax,
1878
			"paramName": "",
1879
			"paramValue": ""
1880
		};
1881
		filterarray.push(obj);
1882
	}
1883
 
1884
	if (valueEndMin) {
1885
		obj = {
1886
			"name": "EndTimeFrom",
1887
			"value": valueEndMin,
1888
			"paramName": "",
1889
			"paramValue": ""
1890
		};
1891
		filterarray.push(obj);
1892
	}
1893
 
1894
	if (valueEndMax) {
1895
		obj = {
1896
			"name": "EndTimeTo",
1897
			"value": valueEndMax,
1898
			"paramName": "",
1899
			"paramValue": ""
1900
		};
1901
		filterarray.push(obj);
1902
	}
1903
}
1904
 
1905
// Check the item filter parameters from input form
1906
function checkFilterArray() {
1907
	var x = document.getElementById("warnings");
1908
	var warnings = 0;
1909
	var value = "";
1910
	var value2 = "";
1911
	var valueMin = 0;
1912
	var valueMax = 0;
1913
	var html = [];
1914
	var categoryCounter = 0;
1915
 
1916
	x.innerHTML = "";
1917
 
1918
	value = document.getElementById('keyword').value;
1919
	value2 = document.getElementById('sellerName').value;
1920
	for (var categoryIndex = 1; categoryIndex < document.getElementById('category').options.length; categoryIndex++) {
1921
		if (document.getElementById('category').options[categoryIndex].selected) {
1922
			categoryCounter++;
1923
		}
1924
	}
1925
 
1926
	if (!value && !value2 && !categoryCounter) {
1927
		warnings++;
30 - 1928
		html.push(alertStyle("No Keyword, Category or Seller Name specified"));
2 - 1929
	}
1930
 
1931
	if (categoryCounter > 3) {
1932
		warnings++;
30 - 1933
		html.push(alertStyle("Only up to 3 categories allowed"));
2 - 1934
	}
1935
 
1936
	valueMin = document.getElementById('minPrice').value;
1937
	valueMax = document.getElementById('maxPrice').value;
1938
 
1939
	if (valueMin && valueMin < 0) {
1940
		warnings++;
30 - 1941
		html.push(alertStyle("Minimum Price under $0"));
2 - 1942
	}
1943
 
1944
	if (valueMax && valueMax <= 0) {
1945
		warnings++;
30 - 1946
		html.push(alertStyle("Maximum Price at or under $0"));
2 - 1947
	}
1948
 
1949
	if (valueMin && valueMax) {
1950
		if (Number(valueMin) > Number(valueMax)) {
1951
			warnings++;
30 - 1952
			html.push(alertStyle("Minimum Price " + Number(valueMin).toFixed(0) + " greater than Maximum Price " + Number(valueMax).toFixed(0)));
2 - 1953
		}
1954
	}
1955
 
1956
	valueMin = document.getElementById('minBids').value;
1957
	valueMax = document.getElementById('maxBids').value;
1958
 
1959
	if (valueMin && valueMin < 0) {
1960
		warnings++;
30 - 1961
		html.push(alertStyle("Minimum Bids under 0"));
2 - 1962
	}
1963
 
1964
	if (valueMax && valueMax < 0) {
1965
		warnings++;
30 - 1966
		html.push(alertStyle("Maximum Bids under 0"));
2 - 1967
	}
1968
 
1969
	if (valueMin && valueMax) {
1970
		if (Number(valueMin) > Number(valueMax)) {
1971
			warnings++;
30 - 1972
			html.push(alertStyle("Minimum Bids greater than Maximum Bids"));
2 - 1973
		}
1974
	}
1975
 
1976
	valueMin = document.getElementById('minFeedback').value;
1977
	valueMax = document.getElementById('maxFeedback').value;
1978
 
1979
	if (valueMin && valueMin < 0) {
1980
		warnings++;
30 - 1981
		html.push(alertStyle("Minimum Feedback under 0"));
2 - 1982
	}
1983
 
1984
	if (valueMax && valueMax < 0) {
1985
		warnings++;
30 - 1986
		html.push(alertStyle("Maximum Feedback under 0"));
2 - 1987
	}
1988
 
1989
	if (valueMin && valueMax) {
1990
		if (Number(valueMin) > Number(valueMax)) {
1991
			warnings++;
30 - 1992
			html.push(alertStyle("Minimum Feedback greater than Maximum Feedback"));
2 - 1993
		}
1994
	}
1995
 
1996
	valueMin = document.getElementById('minQuantity').value;
1997
	valueMax = document.getElementById('maxQuantity').value;
1998
 
1999
	if (valueMin && valueMin <= 0) {
2000
		warnings++;
30 - 2001
		html.push(alertStyle("Minimum Quantity at or under 0"));
2 - 2002
	}
2003
 
2004
	if (valueMax && valueMax <= 0) {
2005
		warnings++;
30 - 2006
		html.push(alertStyle("Maximum Quantity at or under 0"));
2 - 2007
	}
2008
 
2009
	if (valueMin && valueMax) {
2010
		if (Number(valueMin) > Number(valueMax)) {
2011
			warnings++;
30 - 2012
			html.push(alertStyle("Minimum Quantity greater than Maximum Quantity"));
2 - 2013
		}
2014
	}
2015
 
2016
	if (document.getElementById('ltAll').checked &&
2017
		(document.getElementById('ltAuction').checked ||
2018
			document.getElementById('ltAuctionWithBIN').checked ||
2019
			document.getElementById('ltClassified').checked ||
2020
			document.getElementById('ltFixedPrice').checked ||
2021
			document.getElementById('ltStoreInventory').checked)) {
2022
		warnings++;
30 - 2023
		html.push(alertStyle("Listing Type All Combined with other Type(s)"));
2 - 2024
	}
2025
 
2026
	if (document.getElementById('completedItemsOnly').checked &&
2027
		document.getElementById('searchDescription').checked) {
2028
		warnings++;
30 - 2029
		html.push(alertStyle("Completeted Items does work together with Search Description"));
2 - 2030
	}
2031
 
2032
	valueStartMin = document.getElementById('minStartDate').value;
2033
 
2034
	if (valueStartMin) {
2035
		if (isNaN(valueStartMin)) {
2036
			valueStartMin = moment(valueStartMin).format('YYYY-MM-DD');
2037
			if (!moment(valueStartMin).isValid) {
2038
				warnings++;
30 - 2039
				html.push(alertStyle("Invalid Minimum Start Date"));
2 - 2040
			} else if (moment(valueStartMin).isAfter()) {
2041
				warnings++;
30 - 2042
				html.push(alertStyle("Minimum Start Date in future"));
2 - 2043
			}
2044
		} else {
2045
			var valueStartMinNumber = Number(valueStartMin);
2046
			if (valueStartMinNumber > 0) {
2047
				warnings++;
30 - 2048
				html.push(alertStyle("Minimum Start Date in future"));
2 - 2049
			} else {
2050
				valueStartMin = moment().add(valueStartMinNumber, "days").format('YYYY-MM-DD');
2051
			}
2052
		}
2053
	}
2054
 
2055
	valueStartMax = document.getElementById('maxStartDate').value;
2056
 
2057
	if (valueStartMax) {
2058
		if (isNaN(valueStartMax)) {
2059
			valueStartMax = moment(valueStartMax).format('YYYY-MM-DD');
2060
			if (!moment(valueStartMax).isValid) {
2061
				warnings++;
30 - 2062
				html.push(alertStyle("Invalid Maximum Start Date"));
2 - 2063
			} else if (moment(valueStartMax).isAfter()) {
2064
				warnings++;
30 - 2065
				html.push(alertStyle("Maximum Start Date in future"));
2 - 2066
			}
2067
		} else {
2068
			var valueStartMaxNumber = Number(valueStartMax);
2069
			if (valueStartMaxNumber > 0) {
2070
				warnings++;
30 - 2071
				html.push(alertStyle("Maximum Start Date in future"));
2 - 2072
			} else {
2073
				valueStartMax = moment().add(valueStartMaxNumber, "days").format('YYYY-MM-DD');
2074
			}
2075
		}
2076
	}
2077
 
2078
	valueEndMin = document.getElementById('minEndDate').value;
2079
 
2080
	if (valueEndMin) {
2081
		if (isNaN(valueEndMin)) {
2082
			valueEndMin = moment(valueEndMin).format('YYYY-MM-DD');
2083
			if (!moment(valueEndMin).isValid) {
2084
				warnings++;
30 - 2085
				html.push(alertStyle("Invalid Minimum End Date"));
2 - 2086
			} else if (!document.getElementById('completedItemsOnly').checked && moment(valueEndMin).isBefore()) {
2087
				warnings++;
30 - 2088
				html.push(alertStyle("Minimum End Date in past"));
2 - 2089
			}
2090
		} else {
2091
			var valueEndMinNumber = Number(valueEndMin);
2092
			if (!document.getElementById('completedItemsOnly').checked && valueEndMinNumber < 0) {
2093
				warnings++;
30 - 2094
				html.push(alertStyle("Minimum End Date in past"));
2 - 2095
			} else {
2096
				valueEndMin = moment().add(valueEndMinNumber, "days").format('YYYY-MM-DD');
2097
			}
2098
		}
2099
	}
2100
 
2101
	valueEndMax = document.getElementById('maxEndDate').value;
2102
 
2103
	if (valueEndMax) {
2104
		if (isNaN(valueEndMax)) {
2105
			valueEndMax = moment(valueEndMax).format('YYYY-MM-DD');
2106
			if (!moment(valueEndMax).isValid) {
2107
				warnings++;
30 - 2108
				html.push(alertStyle("Invalid Maximum End Date"));
2 - 2109
			} else if (!document.getElementById('completedItemsOnly').checked && moment(valueEndMax).isBefore()) {
2110
				warnings++;
30 - 2111
				html.push(alertStyle("Maximum End Date in past"));
2 - 2112
			}
2113
		} else {
2114
			var valueEndMaxNumber = Number(valueEndMax);
2115
			if (!document.getElementById('completedItemsOnly').checked && valueEndMaxNumber < 0) {
2116
				warnings++;
30 - 2117
				html.push(alertStyle("Maximum End Date in past"));
2 - 2118
			} else {
2119
				valueEndMax = moment().add(valueEndMaxNumber, "days").format('YYYY-MM-DD');
2120
			}
2121
		}
2122
	}
2123
 
2124
	if (valueStartMin && valueStartMax && valueStartMin > valueStartMax) {
2125
		warnings++;
30 - 2126
		html.push(alertStyle("Maximum Start Date less than Minimum Start Date"));
2 - 2127
	}
2128
 
2129
	if (valueEndMin && valueEndMax && valueEndMin > valueEndMax) {
2130
		warnings++;
30 - 2131
		html.push(alertStyle("Maximum End Date less than Minimum End Date"));
2 - 2132
	}
2133
 
2134
	if (valueStartMin && valueEndMin && valueStartMin > valueEndMin) {
2135
		warnings++;
30 - 2136
		html.push(alertStyle("Minimum End Date less than Minimum Start Date"));
2 - 2137
	}
2138
 
2139
	if (valueStartMin && valueEndMax && valueStartMin > valueEndMax) {
2140
		warnings++;
30 - 2141
		html.push(alertStyle("Maximum End Date less than Minimum Start Date"));
2 - 2142
	}
2143
 
2144
	if (valueStartMax && valueEndMin && valueStartMax > valueEndMin) {
2145
		warnings++;
30 - 2146
		html.push(alertStyle("Minimum End Date less than Maximum Start Date"));
2 - 2147
	}
2148
 
2149
	if (valueStartMax && valueEndMax && valueStartMax > valueEndMax) {
2150
		warnings++;
30 - 2151
		html.push(alertStyle("Maximum End Date less than Maximum Start Date"));
2 - 2152
	}
2153
 
2154
	// Generate ISO dates
2155
	if (valueStartMin) {
2156
		valueStartMin = moment(valueStartMin + " 00:00:00", "YYYY-MM-DD HH:mm:ss").tz("UTC").toISOString();
2157
	}
2158
 
2159
	if (valueStartMax) {
2160
		if (moment().isBefore(valueStartMax + "T23:59:59.999Z")) {
2161
			valueStartMax = moment().tz("UTC").toISOString();
2162
		} else {
2163
			valueStartMax = moment(valueStartMax + " 23:59:59", "YYYY-MM-DD HH:mm:ss").tz("UTC").toISOString();
2164
		}
2165
	}
2166
 
2167
	if (document.getElementById('completedItemsOnly').checked) {
2168
		if (valueEndMin) {
2169
			valueEndMin = moment(valueEndMin + " 00:00:00", "YYYY-MM-DD HH:mm:ss").tz("UTC").toISOString();
2170
		}
2171
 
2172
		if (valueEndMax) {
2173
			if (moment().isBefore(valueEndMax + "T23:59:59.999Z")) {
2174
				valueEndMax = moment().subtract(1, 'minute').tz("UTC").toISOString();
2175
			} else {
2176
				valueEndMax = moment(valueEndMax + " 23:59:59", "YYYY-MM-DD HH:mm:ss").tz("UTC").toISOString();
2177
			}
2178
		}
2179
	} else {
2180
		if (valueEndMin) {
2181
			if (moment().isAfter(valueEndMin + "T00:00:00.000Z")) {
2182
				var valueEndMinMoment = new moment().add(1, 'minute');
2183
				valueEndMin = valueEndMinMoment.tz("UTC").toISOString();
2184
			} else {
2185
				valueEndMin = moment(valueEndMin + " 00:00:00", "YYYY-MM-DD HH:mm:ss").tz("UTC").toISOString();
2186
			}
2187
		}
2188
 
2189
		if (valueEndMax) {
2190
			valueEndMax = moment(valueEndMax + " 23:59:59", "YYYY-MM-DD HH:mm:ss").tz("UTC").toISOString();
2191
		}
2192
	}
2193
 
2194
	if (document.getElementById('localSearchOnly').checked) {
2195
		value = document.getElementById('maxDistance').value;
2196
		if (value === undefined || value <= 0) {
2197
			warnings++;
30 - 2198
			html.push(alertStyle("Local Search Only requires Maximum Distance"));
2 - 2199
		}
2200
	}
2201
 
2202
	// Print warnings
2203
	if (warnings) {
2204
		x.innerHTML = html.join("");
30 - 2205
    	x.className = x.className.replace(" invisible", " visible");
2 - 2206
		x.scrollIntoView();
2207
	} else {
30 - 2208
		x.className = x.className.replace(" visible", " invisible");
2 - 2209
	}
2210
 
2211
	return warnings;
2212
}
2213
 
30 - 2214
function alertStyle(message) {
2215
    var str = '<div class="alert alert-danger alert-dismissible">';
2216
    str += '<button type="button" class="close" data-dismiss="alert">×</button>';
2217
    str += '<p><strong>' + message + '</strong></p>';
2218
    str += '</div>';
2219
 
2220
    return str;
2221
}
2222
 
2 - 2223
// Define global variable for the URL filter
2224
var urlfilter = "";
2225
 
2226
// Generates an indexed URL snippet from the array of item filters
2227
function buildURLArray() {
2228
	urlfilter = "";
2229
	// Iterate through each filter in the array
2230
	for (var i = 0; i < filterarray.length; i++) {
2231
		//Index each item filter in filterarray
2232
		var itemfilter = filterarray[i];
2233
		// Iterate through each parameter in each item filter
2234
		for (var index in itemfilter) {
2235
			// Check to see if the paramter has a value (some don't)
2236
			if (itemfilter[index] !== "") {
2237
				if (itemfilter[index] instanceof Array) {
2238
					for (var r = 0; r < itemfilter[index].length; r++) {
2239
						var value = itemfilter[index][r];
2240
						urlfilter += "&itemFilter\(" + i + "\)." + index + "\(" + r + "\)=" + value;
2241
					}
2242
				} else {
2243
					urlfilter += "&itemFilter\(" + i + "\)." + index + "=" + itemfilter[index];
2244
				}
2245
			}
2246
		}
2247
	}
2248
} // End buildURLArray() function
2249
 
2250
var url = "";
2251
var searchUrl = "";
2252
 
2253
function eBaySearch(paramPage) {
2254
	pagenumber = paramPage;
2255
 
2256
	// Clear results outputs and download button
2257
	var x = document.getElementById("results");
30 - 2258
	x.innerHTML = '<div id="loader"></div>';
2259
	x.className = x.className.replace(" visible", " invisible");
2 - 2260
 
30 - 2261
    document.getElementById("searchForm").style.opacity = "0.2";
2 - 2262
 
30 - 2263
	x = document.getElementById("loader");
2264
	x.className = x.className.replace(" invisible", " visible");
2 - 2265
 
30 - 2266
	document.getElementById("download").disabled = true;
2267
	document.getElementById("pricing").disabled = true;
2268
 
2 - 2269
	x = document.getElementById("prices");
30 - 2270
	x.className = x.className.replace(" visible", " invisible");
2 - 2271
 
7 - 2272
	x = document.getElementById("duplicates");
30 - 2273
	x.className = x.className.replace(" visible", " invisible");
7 - 2274
    document.getElementById("duplicatesText").innerHTML = "";
2 - 2275
 
30 - 2276
	endProgressBarModal();
2277
 
2 - 2278
	x = document.getElementById("recommendation");
2279
	x.innerHTML = "";
2280
 
7 - 2281
	if (document.getElementById("duplicateCheck").checked) {
2282
		findDuplicateListing();
2283
		findPotentialDuplicateListing();
2284
		findShopifyDuplicateListing();
2285
	}
2286
 
2 - 2287
	// Print serialized search parameters
2288
	if (pagenumber == 1) {
2289
		x = document.getElementById("parameter");
30 - 2290
    	x.className = x.className.replace(" invisible", " visible");
2 - 2291
		searchUrl = window.location.protocol + "//" + window.location.hostname + window.location.pathname + '?' + $("form").serialize();
2292
		x.innerHTML = "<a href=\"" + searchUrl + "\" target=\"_blank\" title=\"eBay Search\">" + searchUrl + "</a>";
2293
	}
2294
 
2295
	// Check Parameters
2296
	if (checkFilterArray()) {
30 - 2297
        document.getElementById("searchForm").style.opacity = "1.0";
2298
        document.getElementById("results").innerHTML = "";
2 - 2299
		return false;
2300
	}
2301
 
2302
	// Fill the filter array from form input
2303
	fillFilterArray();
2304
	// Execute the function to build the URL filter
2305
	buildURLArray(filterarray);
2306
 
2307
	var keyword = document.getElementById('keyword').value;
2308
 
2309
	// Construct the request
2310
	url = configeBayFinding + "?";
2311
	if (document.getElementById('completedItemsOnly').checked) {
2312
		url += "OPERATION-NAME=findCompletedItems";
2313
	} else if (keyword.includes("ReferenceID:")) {
2314
		url += "OPERATION-NAME=findItemsByProduct";
2315
	} else {
2316
		url += "OPERATION-NAME=findItemsAdvanced";
2317
	}
2318
    url += "&SERVICE-VERSION=" + configeBayFindingVersion;
2319
	url += "&SECURITY-APPNAME=" + configAppid;
2320
	url += "&GLOBAL-ID=EBAY-US";
2321
	url += "&RESPONSE-DATA-FORMAT=JSON";
2322
	url += "&REST-PAYLOAD";
2323
	if (keyword.length > 0) {
2324
		if (keyword.includes("ReferenceID:")) {
2325
			url += "&productId.@type=ReferenceID";
2326
			url += "&productId=";
2327
			url += keyword.substr(12);
2328
		} else {
2329
			url += "&keywords=";
2330
			url += encodeURIComponent(keyword.trim().replace(/ /g, "+"));
2331
		}
2332
	}
2333
 
2334
	var catNo = 0;
2335
	for (var index = 1; index < document.getElementById('category').options.length; index++) {
2336
		if (document.getElementById('category').options[index].selected) {
2337
			url += "&categoryId(" + catNo + ")=";
2338
			url += document.getElementById('category').options[index].value;
2339
			++catNo;
2340
		}
2341
	}
2342
 
7 - 2343
	url += "&paginationInput.entriesPerPage=100";
2 - 2344
	url += "&paginationInput.pageNumber=";
2345
	if (pagenumber === undefined) {
2346
		pagenumber = 1;
2347
	}
2348
	url += pagenumber;
2349
	url += "&sortOrder=";
2350
	url += getSortOrder();
2351
	url += "&buyerPostalCode=";
2352
	url += configZip;
2353
	url += "&outputSelector=SellerInfo";
2354
	if (document.getElementById('searchDescription').checked) {
2355
		url += "&descriptionSearch=true";
2356
	}
2357
	url += urlfilter;
2358
 
2359
	var xhttp = new XMLHttpRequest();
2360
 
2361
	xhttp.onreadystatechange = function() {
172 - 2362
    	if (this.readyState == 4) {
2363
    	    if (this.status == 200) {
2364
    			if (document.getElementById('completedItemsOnly').checked) {
2365
    				_cb_findCompletedItems(JSON.parse(this.responseText));
2366
    			} else {
2367
    				_cb_findItemsAdvanced(JSON.parse(this.responseText));
2368
    			}
2369
    		} else {
2370
                eBaySearch(paramPage);
2371
    		}
2 - 2372
        }
2373
    };
2374
 
2375
	xhttp.open("GET", configProxyUrl, true);
2376
	xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
2377
   	xhttp.send();
2378
 
30 - 2379
    // avoid form reload
2380
   	return false;
2 - 2381
}
2382
 
2383
function getKeywordRecommendations() {
30 - 2384
    var x = document.getElementById("keyword");
2385
    x.focus();
2386
	if (x.value.length < 2) {
2387
		return;
2 - 2388
	}
2389
 
2390
	// Clear results outputs and download button
30 - 2391
	x = document.getElementById("results");
2 - 2392
	x.innerHTML = "";
30 - 2393
	x.className = x.className.replace(" visible", " invisible");
2 - 2394
 
30 - 2395
	document.getElementById("download").disabled = true;
2396
	document.getElementById("pricing").disabled = true;
2 - 2397
 
2398
	x = document.getElementById("prices");
30 - 2399
	x.innerHTML = "";
2400
	x.className = x.className.replace(" visible", " invisible");
2 - 2401
 
30 - 2402
	endProgressBarModal();
2 - 2403
 
2404
	// Construct the request
2405
	url = configeBayFinding + "?";
2406
	url += "OPERATION-NAME=getSearchKeywordsRecommendation";
2407
	url += "&SERVICE-VERSION=" + configeBayFindingVersion;
2408
	url += "&SECURITY-APPNAME=" + configAppid;
2409
	url += "&RESPONSE-DATA-FORMAT=JSON";
2410
	url += "&REST-PAYLOAD";
2411
	url += "&keywords=";
2412
	url += encodeURIComponent(document.getElementById('keyword').value.trim().replace(/ /g, "+"));
2413
 
2414
	// Submit the request
2415
	var xhttp = new XMLHttpRequest();
2416
 
2417
	xhttp.onreadystatechange = function() {
170 - 2418
    	if (this.readyState == 4 && this.status == 200) {
2 - 2419
    		_cb_getKeywordRecommendations(JSON.parse(this.responseText));
2420
        }
2421
    };
2422
 
2423
	xhttp.open("GET", configProxyUrl, true);
2424
	xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
2425
   	xhttp.send();
2426
 
30 - 2427
	return;
2 - 2428
}
2429
 
2430
function formatTimeleft(timeleft) {
2431
	var timeleftDays = Math.floor(timeleft / 86400);
2432
	timeleft = timeleft % 86400;
2433
	var timeleftHours = Math.floor(timeleft / 3600);
2434
	timeleft = timeleft % 3600;
2435
	var timeleftMinutes = Math.floor(timeleft / 60);
2436
	return timeleftDays + ' days ' + timeleftHours + ' hours ' + timeleftMinutes + ' minutes';
2437
}
2438
 
2439
function getSortOrder() {
2440
	if (document.getElementById("soBestMatch").checked) {
2441
		return "BestMatch";
2442
	} else if (document.getElementById("soCurrentPriceHighest").checked) {
2443
		return "CurrentPriceHighest";
2444
	} else if (document.getElementById("soEndTimeSoonest").checked) {
2445
		return "EndTimeSoonest";
2446
	} else if (document.getElementById("soPricePlusShippingHighest").checked) {
2447
		return "PricePlusShippingHighest";
2448
	} else if (document.getElementById("soPricePlusShippingLowest").checked) {
2449
		return "PricePlusShippingLowest";
2450
	} else if (document.getElementById("soStartTimeNewest").checked) {
2451
		return "StartTimeNewest";
2452
	} else if (document.getElementById("soWatchCountDecreaseSort").checked) {
2453
		return "WatchCountDecreaseSort";
2454
	} else if (document.getElementById("soDistance").checked) {
2455
		return "DistanceNearest";
2456
	}
2457
	// Auctions Only!
2458
	else if (document.getElementById("soBidCountFewest").checked) {
2459
		return "BidCountFewest";
2460
	}
2461
	// Auctions Only!
2462
	else if (document.getElementById("soBidCountMost").checked) {
2463
		return "BidCountMost";
2464
	}
2465
 
2466
	return "BestMatch";
2467
}
2468
 
2469
function downloadAsCSV() {
2470
	var categoryIndex = 0;
2471
	asyncFlag = false;
2472
 
30 - 2473
	initProgressBarModal('Creating CSV Download File');
2 - 2474
 
2475
	var x = document.getElementById("csv");
2476
	x.innerHTML = ConvertToCSVHeader();
2477
 
2478
	maxPages = (totalEntries / 100) > 100 ? 100 : Math.trunc(totalEntries / 100.0) + 1;
2479
	currentPage = 0;
2480
 
2481
	var keyword = document.getElementById('keyword').value;
2482
 
2483
	for (var index = 0; index < maxPages; ++index) {
2484
		// Construct the request
2485
		var url = configeBayFinding + "?";
2486
		if (document.getElementById('completedItemsOnly').checked) {
2487
			url += "OPERATION-NAME=findCompletedItems";
2488
		} else if (keyword.includes("ReferenceID:")) {
2489
			url += "OPERATION-NAME=findItemsByProduct";
2490
		} else {
2491
			url += "OPERATION-NAME=findItemsAdvanced";
2492
		}
2493
		url += "&SECURITY-APPNAME=" + configAppid;
2494
		url += "&GLOBAL-ID=EBAY-US";
2495
		url += "&RESPONSE-DATA-FORMAT=JSON";
2496
		url += "&SERVICE-VERSION=" + configeBayFindingVersion;
2497
		url += "&REST-PAYLOAD";
2498
		if (keyword.length > 0) {
2499
			if (keyword.includes("ReferenceID:")) {
2500
				url += "&productId.@type=ReferenceID";
2501
				url += "&productId=";
2502
				url += keyword.substr(12);
2503
			} else {
2504
				url += "&keywords=";
2505
				url += encodeURIComponent(keyword.trim().replace(/ /g, "+"));
2506
			}
2507
		}
2508
 
2509
		var catNo = 0;
2510
		for (categoryIndex = 1; categoryIndex < document.getElementById('category').options.length; categoryIndex++) {
2511
			if (document.getElementById('category').options[categoryIndex].selected) {
2512
				url += "&categoryId(" + catNo + ")=";
2513
				url += document.getElementById('category').options[categoryIndex].value;
2514
				++catNo;
2515
			}
2516
		}
2517
 
2518
		url += "&paginationInput.entriesPerPage=100";
2519
		url += "&paginationInput.pageNumber=";
2520
		url += (index + 1);
2521
		url += "&sortOrder=";
2522
		url += getSortOrder();
2523
		url += "&buyerPostalCode=";
2524
		url += configZip;
2525
		url += "&outputSelector(0)=SellerInfo&outputSelector(1)=StoreInfo";
2526
		if (document.getElementById('searchDescription').checked) {
2527
			url += "&descriptionSearch=true";
2528
		}
2529
 
2530
		url += urlfilter;
2531
 
2532
		var xhttp = new XMLHttpRequest();
2533
 
2534
		xhttp.onreadystatechange = function() {
170 - 2535
	    	if (this.readyState == 4 && this.status == 200) {
172 - 2536
// bugbug
2 - 2537
				if (document.getElementById('completedItemsOnly').checked) {
2538
					_cb_ConvertToCSVfindCompletedItems(JSON.parse(this.responseText));
2539
				} else {
2540
					_cb_ConvertToCSVfindItemsAdvanced(JSON.parse(this.responseText));
2541
				}
2542
	        }
2543
	    };
2544
 
2545
		xhttp.open("GET", configProxyUrl, true);
172 - 2546
		//xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
2547
		xhttp.setRequestHeader("X-Proxy-Url", url);
2 - 2548
	   	xhttp.send();
2549
   	}
2550
 
2551
	function checkAsyncFlag() {
2552
		if (asyncFlag === false) {
2553
			window.setTimeout(checkAsyncFlag, 100); // wait 100 milliseconds
2554
		} else {
2555
			var textToSaveAsBlob = new Blob([String(document.getElementById("csv").innerHTML)], {
2556
				type: "text/csv"
2557
			});
2558
			var textToSaveAsURL = window.URL.createObjectURL(textToSaveAsBlob);
2559
			var fileNameToSaveAs = "eBaySearch.csv";
2560
 
2561
			var downloadLink = document.createElement("a");
2562
			downloadLink.download = fileNameToSaveAs;
2563
			downloadLink.innerHTML = "Download File";
2564
			downloadLink.href = textToSaveAsURL;
2565
			downloadLink.onclick = destroyClickedElement;
2566
			downloadLink.style.display = "none";
2567
			document.body.appendChild(downloadLink);
2568
 
30 - 2569
			endProgressBarModal();
2 - 2570
			downloadLink.click();
2571
		}
2572
	}
2573
 
2574
	checkAsyncFlag();
2575
}
2576
 
2577
function destroyClickedElement(event) {
2578
	document.body.removeChild(event.target);
2579
}
2580
 
2581
function _cb_ConvertToCSVfindItemsAdvanced(objArray) {
2582
	var array;
2583
 
2584
	if (objArray.findItemsAdvancedResponse !== undefined) {
2585
		array = typeof objArray.findItemsAdvancedResponse[0] != 'object' ? JSON.parse(objArray.findItemsAdvancedResponse[0]) : objArray.findItemsAdvancedResponse[0].searchResult[0].item;
2586
	} else if (objArray.findItemsByProductResponse !== undefined) {
2587
		array = typeof objArray.findItemsByProductResponse[0] != 'object' ? JSON.parse(objArray.findItemsByProductResponse[0]) : objArray.findItemsByProductResponse[0].searchResult[0].item;
2588
	} else {
2589
		return;
2590
	}
2591
 
2592
	ConvertToCSV(array);
2593
}
2594
 
2595
function _cb_ConvertToCSVfindCompletedItems(objArray) {
2596
	var array = typeof objArray.findCompletedItemsResponse[0] != 'object' ? JSON.parse(objArray.findCompletedItemsResponse[0]) : objArray.findCompletedItemsResponse[0].searchResult[0].item;
2597
	ConvertToCSV(array);
2598
}
2599
 
2600
function findSingleItem(itemId) {
2601
	// Construct the getShippingCosts request
2602
	getShippingCostsDone = false;
2603
 
2604
	url = configeBayShopping + "?";
2605
	url += "callname=GetShippingCosts";
2606
	url += "&responseencoding=JSON";
2607
	url += "&appid=" + configAppid;
2608
	url += "&version=" + configeBayShoppingVersion;
2609
	url += "&DestinationCountryCode=US";
2610
	url += "&DestinationPostalCode=";
2611
	url += configZip;
2612
	url += "&IncludeDetails=true";
2613
	url += "&QuantitySold=1";
2614
	url += "&ItemID=";
2615
	url += itemId;
2616
 
2617
	var xhttp = new XMLHttpRequest();
2618
 
2619
	xhttp.onreadystatechange = function() {
170 - 2620
    	if (this.readyState == 4 && this.status == 200) {
2 - 2621
    		_cb_GetShippingCosts(JSON.parse(this.responseText));
2622
        }
2623
    };
2624
 
2625
	xhttp.open("GET", configProxyUrl, true);
2626
	xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
2627
   	xhttp.send();
2628
 
2629
	function checkAsyncFlag() {
2630
		if (getShippingCostsDone !== true) {
2631
			window.setTimeout(function() {
2632
				checkAsyncFlag();
2633
			}, 100); // wait 100 milliseconds
2634
		} else {
2635
			// Construct the getSingleItem request
2636
			url = configeBayShopping + "?";
2637
			url += "callname=GetSingleItem";
2638
			url += "&responseencoding=JSON";
2639
			url += "&appid=" + configAppid;
2640
			url += "&version=" + configeBayShoppingVersion;
2641
			url += "&IncludeSelector=Details,Description,ItemSpecifics";
2642
			url += "&ItemID=";
2643
			url += itemId;
2644
 
2645
			var xhttp = new XMLHttpRequest();
2646
 
2647
			xhttp.onreadystatechange = function() {
170 - 2648
		    	if (this.readyState == 4 && this.status == 200) {
2 - 2649
		    		_cb_GetSingleItem(JSON.parse(this.responseText));
2650
		        }
2651
		    };
2652
 
2653
			xhttp.open("GET", configProxyUrl, true);
2654
			xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
2655
		   	xhttp.send();
2656
		}
2657
	}
2658
 
2659
	checkAsyncFlag();
2660
}
2661
 
2662
// Create new page for single item
2663
function _cb_GetSingleItem(root) {
2664
	var ack = root.Ack;
2665
	if (ack != 'Success') {
2666
		var x = document.getElementById("warnings");
2667
 
30 - 2668
        var str = '<div class="alert alert-danger alert-dismissible">';
2669
        str += '<button type="button" class="close" data-dismiss="alert">×</button>';
2670
		str += "<h2>eBay API Error</h2>";
2671
		str += "<ul>"
2672
		str += "<li>Id: " + root.Errors[0].ErrorCode + "</li>";
2673
		str += "<li>Domain: " + root.Errors[0].ErrorClassification + "</li>";
2674
		str += "<li>Severity: " + root.Errors[0].SeverityCode + "</li>";
2675
		str += "<li>Category: " + root.Errors[0].category + "</li>";
2676
		str += "<li>Short Message: " + root.Errors[0].ShortMessage + "</li>";
2677
		str += "<li>Long Message: " + root.Errors[0].LongMessage + "</li>";
2678
		str += "<li>Build/Version: " + root.Build + '/' + root.Version + "</li>";
2679
		str += "</ul>"
2680
		str += "<p>URL: " + "<a href=\"" + url + "\" target=\"_blank\">" + url + "</a>" + "</p>";
2681
		str += "</div>"
2 - 2682
 
30 - 2683
    	x.innerHTML = str;
2684
    	x.className = x.className.replace(" invisible", " visible");
2685
 
2 - 2686
		if (ack == 'Failure' || ack == 'PartialFailure') {
2687
			x.scrollIntoView(true);
2688
			return;
2689
		}
2690
	}
2691
 
2692
	var str = "";
2693
	var i = 0;
2694
	var JsonObj = typeof root.Item != 'object' ? JSON.parse(root.Item) : root.Item;
2695
 
2696
	var autoPay = JsonObj.autoPay;
2697
	var BestOfferEnabled = JsonObj.BestOfferEnabled;
2698
	var BidCount = JsonObj.BidCount;
2699
	var BusinessSellerDetails = JsonObj.BusinessSellerDetails;
2700
	if (BusinessSellerDetails) { // not yet
2701
	}
2702
	var BuyItNowAvailable = JsonObj.BuyItNowAvailable;
2703
	var BuyItNowPrice = JsonObj.BuyItNowPrice;
2704
	var BuyItNowPriceValue = BuyItNowPrice === undefined ? 0.00 : BuyItNowPrice.Value;
2705
	var BuyItNowPriceCurrencyID = BuyItNowPrice === undefined ? "" : BuyItNowPrice.CurrencyID;
2706
	var Charity = JsonObj.Charity;
2707
	if (Charity) { // not yet
2708
	}
2709
	var ConditionDescription = JsonObj.ConditionDescription;
2710
	var ConditionDisplayName = JsonObj.ConditionDisplayName;
2711
	var ConditionID = JsonObj.ConditionID;
2712
	var ConvertedBuyItNowPrice = JsonObj.ConvertedBuyItNowPrice;
2713
	var ConvertedBuyItNowPriceValue = ConvertedBuyItNowPrice === undefined ? 0.00 : ConvertedBuyItNowPrice.Value;
2714
	var ConvertedBuyItNowPriceCurrencyID = ConvertedBuyItNowPrice === undefined ? "" : ConvertedBuyItNowPrice.CurrencyID;
2715
	var ConvertedCurrentPrice = JsonObj.ConvertedCurrentPrice;
2716
	var ConvertedCurrentPriceValue = ConvertedCurrentPrice === undefined ? 0.00 : ConvertedCurrentPrice.Value;
2717
	var ConvertedCurrentPriceCurrencyID = ConvertedCurrentPrice === undefined ? "" : ConvertedCurrentPrice.CurrencyID;
2718
	var Country = JsonObj.Country;
2719
	var CurrentPrice = JsonObj.CurrentPrice;
2720
	var CurrentPriceValue = CurrentPrice === undefined ? 0.00 : CurrentPrice.Value;
2721
	var CurrentPriceCurrencyID = CurrentPrice === undefined ? "" : CurrentPrice.CurrencyID;
2722
	var Description = JsonObj.Description;
2723
	var DiscountPriceInfo = JsonObj.DiscountPriceInfo;
2724
	if (DiscountPriceInfo) { // not yet
2725
	}
2726
	var EndTime = JsonObj.EndTime;
2727
	var GalleryURL = JsonObj.GalleryURL;
2728
	var HandlingTime = JsonObj.HandlingTime;
2729
	var HighBidder = JsonObj.HighBidder;
2730
	var HighBidderFeedbackPrivate = HighBidder === undefined ? "" : HighBidder.FeedbackPrivate;
2731
	var HighBidderFeedbackScore = HighBidder === undefined ? "" : HighBidder.FeedbackScore;
2732
	var HighBidderUserAnonymized = HighBidder === undefined ? "" : HighBidder.UserAnonymized;
2733
	var HighBidderUserID = HighBidder === undefined ? "" : HighBidder.UserID;
2734
	var HitCount = JsonObj.HitCount;
2735
	var IgnoreQuantity = JsonObj.IgnoreQuantity;
2736
	var IntegratedMerchantCreditCardEnabled = JsonObj.IntegratedMerchantCreditCardEnabled;
2737
	var ItemID = JsonObj.ItemID;
2738
	var ItemSpecifics = JsonObj.ItemSpecifics;
2739
	var ListingStatus = JsonObj.ListingStatus;
2740
	var ListingType = JsonObj.ListingType;
2741
	var Location = JsonObj.Location;
2742
	var LotSize = JsonObj.LotSize;
2743
	var MinimumToBid = JsonObj.MinimumToBid;
2744
	var MinimumToBidCurrencyID = MinimumToBid === undefined ? "" : MinimumToBid.CurrencyID;
2745
	var MinimumToBidValue = MinimumToBid === undefined ? 0.00 : MinimumToBid.Value;
2746
	var PaymentAllowedSite = JsonObj.PaymentAllowedSite;
2747
	if (PaymentAllowedSite) { // not yet
2748
	}
2749
	var PaymentMethods = JsonObj.PaymentMethods;
2750
	var PictureURL = JsonObj.PictureURL;
2751
	var PostalCode = JsonObj.PostalCode;
2752
	var PrimaryCategoryID = JsonObj.PrimaryCategoryID;
2753
	var PrimaryCategoryIDPath = JsonObj.PrimaryCategoryIDPath;
2754
	var PrimaryCategoryName = JsonObj.PrimaryCategoryName;
2755
	var ProductIDValue = JsonObj.ProductID ? JsonObj.ProductID.Value : undefined;
2756
	var ProductIDType = JsonObj.ProductID ? JsonObj.ProductID.Type : undefined;
2757
	var Quantity = JsonObj.Quantity;
2758
	var QuantitySold = JsonObj.QuantitySold;
2759
	var QuantitySoldByPickupInStore = JsonObj.QuantitySoldByPickupInStore;
2760
	var ReserveMet = JsonObj.ReserveMet;
2761
	var ReturnPolicy = JsonObj.ReturnPolicy;
2762
	var ReturnPolicyRefund = ReturnPolicy === undefined ? "" : ReturnPolicy.Refund;
2763
	var ReturnPolicyReturnsWithin = ReturnPolicy === undefined ? "" : ReturnPolicy.ReturnsWithin;
2764
	var ReturnPolicyReturnsAccepted = ReturnPolicy === undefined ? "" : ReturnPolicy.ReturnsAccepted;
2765
	var ReturnPolicyDescription = ReturnPolicy === undefined ? "" : ReturnPolicy.Description;
2766
	var ReturnPolicyShippingCostPaidBy = ReturnPolicy === undefined ? "" : ReturnPolicy.ShippingCostPaidBy;
2767
	var ReturnPolicyRestockingFeeValue = ReturnPolicy === undefined ? "" : ReturnPolicy.RestockingFeeValue;
2768
	var ReturnPolicyRestockingFeeValueOption = ReturnPolicy === undefined ? "" : ReturnPolicy.RestockingFeeValueOption;
2769
	var ReturnPolicyWarrantyDuration = ReturnPolicy === undefined ? "" : ReturnPolicy.WarrantyDuration;
2770
	var ReturnPolicyWarrantyOffered = ReturnPolicy === undefined ? "" : ReturnPolicy.WarrantyOffered;
2771
	var ReturnPolicyWarrantyType = ReturnPolicy === undefined ? "" : ReturnPolicy.WarrantyType;
2772
	var SecondaryCategoryID = JsonObj.SecondaryCategoryID;
2773
	var SecondaryCategoryIDPath = JsonObj.SecondaryCategoryIDPath;
2774
	var SecondaryCategoryName = JsonObj.SecondaryCategoryName;
2775
	var Seller = JsonObj.Seller;
2776
	var SellerFeedbackScore = Seller === undefined ? 0 : Seller.FeedbackScore;
2777
	var SellerPositiveFeedbackPercent = Seller === undefined ? 0.00 : Seller.PositiveFeedbackPercent;
2778
	var SellerTopRatedSeller = Seller === undefined ? "" : Seller.TopRatedSeller;
2779
	var SellerUserID = Seller === undefined ? "" : Seller.UserID;
2780
	var Site = JsonObj.Site;
2781
	var SKU = JsonObj.SKU;
2782
	var StartTime = JsonObj.StartTime;
2783
	var Storefront = JsonObj.Storefront;
2784
	var StorefrontStoreName = Storefront === undefined ? "" : Storefront.StoreName;
2785
	var StorefrontStoreURL = Storefront === undefined ? "" : Storefront.StoreURL;
2786
	var Subtitle = JsonObj.Subtitle;
2787
	var TimeLeft = JsonObj.TimeLeft;
2788
	var Title = JsonObj.Title;
2789
	var TopRatedListing = JsonObj.TopRatedListing;
2790
	var UnitInfo = JsonObj.UnitInfo;
2791
	var UnitInfoUnitQuantity = UnitInfo === undefined ? 0 : UnitInfo.UnitQuantity;
2792
	var UnitInfoUnitType = UnitInfo === undefined ? 0 : UnitInfo.UnitType;
53 - 2793
	var ViewItemURLForNaturalSearch = JsonObj.ViewItemURLForNaturalSearch; // contains Barcode
30 - 2794
	var categoryTitle = '';
2 - 2795
 
2796
	str = '<!DOCTYPE html>';
2797
	str += '<html lang="en">';
2798
	str += '<head>';
2799
	str += '<title>' + ItemID + ' - ' + Title + '</title>';
2800
	str += '<meta charset="UTF-8">';
2801
	str += '<meta name="viewport" content="width=device-width, initial-scale=1.0">';
2802
	str += '<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">';
2803
	str += '<link rel="icon" href="favicon.ico" type="image/x-icon">';
30 - 2804
	str += '<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">';
2805
	str += '<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"><\/script>';
2806
	str += '<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"><\/script>';
2 - 2807
	str += '<link rel="stylesheet" href="css/style.css">';
2808
	str += '<script src="js/muna-tools.js"><\/script>';
2809
	str += '<script src="js/ebayProduct.js"><\/script>';
30 - 2810
	str += '<script src="js/iframeResizer.min.js"><\/script>';
2 - 2811
	str += '</head>';
2812
	str += '<body>';
30 - 2813
	str += '<div class="container-fluid">';
2814
	str += '<div class="container-fluid border bg-secondary">';
2815
	str += '<div class="clearfix">';
2816
	str += '<img class="img-fluid float-right" src="images/MUNA%20-%20Logo%20100x100.png" alt="MUNA Trading Logo" />';
2817
	str += '<h2>' + Title + ' (EBAY-' + Site + '<a href="' + ViewItemURLForNaturalSearch + '" target="_blank">' + ' #' + ItemID + '</a>' + ')</h2>';
2 - 2818
 
2819
	if (Subtitle) {
30 - 2820
		str += '<h3>' + Subtitle + '</h3>';
2 - 2821
	}
2822
	if (PrimaryCategoryID) {
30 - 2823
		categoryTitle += PrimaryCategoryName + ' (' + PrimaryCategoryIDPath + ')';
2 - 2824
	}
2825
	if (SecondaryCategoryID) {
30 - 2826
		str += '<br/>' + SecondaryCategoryName + ' (' + SecondaryCategoryIDPath + ')';
2 - 2827
	}
30 - 2828
    str += '<h4>' + categoryTitle + '</h4>';
2 - 2829
	str += '</div>';
30 - 2830
	str += '</div>';
2 - 2831
 
30 - 2832
	str += '<div class="container-fluid border small">';
2833
	str += '<div class="row bg-light">';
2834
	str += '<div class="container-fluid border col">';
2 - 2835
	if (GalleryURL) {
30 - 2836
		str += '<img class="img-fluid float-right" src="' + GalleryURL + '" alt="Gallery Image" style="max-height:100px;max-width:100px;">';
2 - 2837
	} else if (PictureURL) {
30 - 2838
		str += '<img class="img-fluid float-right" src="' + PictureURL[0].replace('http:', 'https:') + '" alt="Gallery Image" style="max-height:100px;max-width:100px;">';
2 - 2839
	}
2840
	str += '<h2>Item</h2>';
30 - 2841
	str += '<table class="table table-bordered table-sm"><tbody>';
2 - 2842
 
2843
	if (ConditionID) {
30 - 2844
		str += '<tr><td>Condition</td><td>' + ConditionDisplayName + ' (' + ConditionID + ')</td></tr>';
2 - 2845
	}
30 - 2846
	str += '<tr><td>Condition Description</td><td>' + (ConditionDescription ? ConditionDescription : 'None entered') + '</td></tr>';
2 - 2847
 
2848
	if (ProductIDValue) {
2849
		str += '<tr><td>ProductID</td><td><a href="javascript:void(0)" onclick="findProductInfo(' + ProductIDValue + ')">' + ProductIDValue + ' (' + ProductIDType + ')</a></td></tr>';
2850
	}
2851
 
2852
	if (SKU) {
2853
		str += '<tr><td>SKU</td><td>' + SKU + '</td></tr>';
2854
	}
2855
 
2856
	if (ItemSpecifics) {
2857
		for (i = 0; i < ItemSpecifics.NameValueList.length; i++) {
2858
			str += '<tr><td>' + ItemSpecifics.NameValueList[i].Name + '</td><td>' + ItemSpecifics.NameValueList[i].Value + '</td></tr>';
2859
		}
2860
	}
2861
 
30 - 2862
	str += '</tbody></table>';
2 - 2863
 
2864
	str += '</div>';
2865
 
30 - 2866
	str += '<div class="container-fluid border col ">';
2 - 2867
	str += '<h2>Payment</h2>';
30 - 2868
	str += '<table class="table table-bordered table-sm"><tbody>';
2 - 2869
	if (autoPay && autoPay == 'true' && BidCount && BidCount === 0) {
30 - 2870
		str += '<tr><td colspan="2">Requires Immediate Payment</td></tr>';
2 - 2871
	}
2872
	if (IntegratedMerchantCreditCardEnabled && IntegratedMerchantCreditCardEnabled == 'true') {
30 - 2873
		str += '<tr><td>Merchant Credit Cards</td><td>Enabled</td></tr>';
2 - 2874
	}
2875
 
2876
	str += '<tr><td>Payment Methods</td><td>';
2877
	var paymentsArray = String(PaymentMethods).split(',');
2878
	for (i = 0; i < PaymentMethods.length; i++) {
2879
		str += (i > 0 ? ', ' : '') + paymentsArray[i];
2880
	}
2881
	str += '</td></tr>';
2882
 
30 - 2883
	str += '</tbody></table>';
2 - 2884
 
2885
	if (HandlingTime !== undefined) {
2886
		str += '<h2>Shipping/Handling:</h2>';
30 - 2887
    	str += '<table class="table table-bordered table-sm"><tbody>';
2 - 2888
		str += '<colgroup><col span="1" style="width:35%;"><col span="1" style="width:65%;"></colgroup>';
30 - 2889
    	str += '<tbody>';
2 - 2890
		str += '<tr><td>Handling Time</td><td>' + HandlingTime + ' ' + (HandlingTime == 1 ? 'day' : 'days') + '</td></tr>';
2891
		str += ship_str;
30 - 2892
		str += '</tbody></table>';
2 - 2893
	}
2894
 
2895
	if (ReturnPolicy) {
2896
		str += '<h2>Return Policy</h2><p>';
30 - 2897
    	str += '<table class="table table-bordered table-sm"><tbody>';
2898
		str += '<tr><td>Returns Accepted</td><td>' + (ReturnPolicyReturnsAccepted ? 'Yes' : 'No') + '</td></tr>';
2 - 2899
		str += ReturnPolicyDescription ? '<tr><td>Return Policy Description</td><td>' + ReturnPolicyDescription + '</td></tr>' : '';
2900
		str += ReturnPolicyReturnsWithin ? '<tr><td>Returns Within</td><td>' + ReturnPolicyReturnsWithin + '</td></tr>' : '';
2901
		str += ReturnPolicyRefund ? '<tr><td>Refund</td><td>' + ReturnPolicyRefund + '</td></tr>' : '';
2902
		str += ReturnPolicyShippingCostPaidBy ? '<tr><td>Shipping Cost Paid By</td><td>' + ReturnPolicyShippingCostPaidBy + '</td></tr>' : '';
2903
		str += ReturnPolicyRestockingFeeValueOption ? '<tr><td>Restocking Fee Value Option</td><td>' + ReturnPolicyRestockingFeeValueOption + '</td></tr>' : '';
2904
		str += ReturnPolicyRestockingFeeValue ? '<tr><td>Restocking Fee Value</td><td>' + ReturnPolicyRestockingFeeValue + '</td></tr>' : '';
30 - 2905
		str += ReturnPolicyWarrantyOffered ? '<tr><td>Warranty Offered</td><td>' + ReturnPolicyWarrantyOffered + '</td></tr>' : '<tr><td>Warranty</td><td>No</td></tr>';
2 - 2906
		str += ReturnPolicyWarrantyType ? '<tr><td>Warranty Type</td><td>' + ReturnPolicyWarrantyType + '</td></tr>' : '';
2907
		str += ReturnPolicyWarrantyDuration ? '<tr><td>Warranty Duration</td><td>' + ReturnPolicyWarrantyType + '</td></tr>' : '';
30 - 2908
    	str += '</tbody></table>';
2 - 2909
	}
2910
	str += '</div>';
2911
 
30 - 2912
	str += '<div class="container-fluid border col ">';
2 - 2913
	str += '<h2>Listing</h2>';
30 - 2914
	str += '<table class="table table-bordered table-sm"><tbody>';
2 - 2915
	str += '<tr><td>Status</td><td>' + ListingStatus + '</td></tr>';
2916
	if (TopRatedListing === true) {
30 - 2917
		str += '<tr><td colspan="2">Top Rated Listing</td></tr>';
2 - 2918
	}
2919
	str += '<tr><td>Listing Type</td><td>' + ListingType + '</td></tr>';
2920
	str += '<tr><td>Current Price</td><td>' + (CurrentPriceCurrencyID == 'USD' ? '$' : CurrentPriceCurrencyID + ' ') + CurrentPriceValue.toFixed(2) + '</td></tr>';
2921
	if (CurrentPriceCurrencyID != ConvertedCurrentPriceCurrencyID || CurrentPriceValue != ConvertedCurrentPriceValue) {
2922
		str += '<tr><td>Converted Current Price</td><td>' + (ConvertedCurrentPriceCurrencyID = 'USD' ? '$' : ConvertedCurrentPriceCurrencyID + ' ') + ConvertedCurrentPriceValue.toFixed(2) + '</td></tr>';
2923
	}
2924
	str += ship_str_cost;
2925
	str += ship_str_tax;
2926
	if (BuyItNowAvailable === true) {
2927
		str += '<tr><td>Buy It Now Price</td><td>' + (BuyItNowPriceCurrencyID == 'USD' ? '$' : BuyItNowPriceCurrencyID + ' ') + BuyItNowPriceValue.toFixed(2) + '</td></tr>';
2928
		if (BuyItNowPriceCurrencyID != ConvertedBuyItNowPriceCurrencyID || BuyItNowPriceValue != ConvertedBuyItNowPriceValue) {
2929
			str += '<tr><td>Converted Buy It Now Price</td><td>' + (ConvertedBuyItNowPriceCurrencyID = 'USD' ? '$' : ConvertedBuyItNowPriceCurrencyID + ' ') + ConvertedBuyItNowPriceValue.toFixed(2) + '</td></tr>';
2930
		}
2931
	}
2932
	if (LotSize) {
2933
		str += '<tr><td>LotSize</td><td>' + LotSize + '</td></tr>';
2934
	}
2935
 
2936
	if (IgnoreQuantity === undefined) {
2937
		str += '<tr><td>Quantity</td><td>' + Quantity + '</td></tr>';
2938
		str += '<tr><td>Quantity Sold</td><td>' + QuantitySold + '</td></tr>';
2939
		str += '<tr><td>Quantity Sold Store Pickup</td><td>' + QuantitySoldByPickupInStore + '</td></tr>';
2940
	}
2941
 
2942
	if (UnitInfo) {
2943
		str += '<tr><td>Unit Info: ' + UnitInfoUnitQuantity + ' ' + UnitInfoUnitType + '</td></tr>';
2944
	}
2945
 
2946
	str += '<tr><td>Start</td><td>' + moment(StartTime, moment.ISO_8601).format("YYYY-MM-DD hh:MMA") + '</td></tr>';
2947
	str += '<tr><td>End</td><td>' + moment(EndTime, moment.ISO_8601).format("YYYY-MM-DD hh:MMA") + '</td></tr>';
2948
	str += '<tr><td>Time Left</td><td>' + formatTimeleft(moment.duration(TimeLeft).asSeconds()) + '</td></tr>';
2949
	if (BestOfferEnabled === true) {
30 - 2950
		str += '<tr><td>Best Offer</td><td>Enabled</td></tr>';
2 - 2951
	}
2952
 
2953
	if (ReserveMet === false) {
30 - 2954
		str += '<tr><td colspan="2">Reserve not met</td></tr>';
2 - 2955
	}
2956
	if (HitCount) {
2957
		str += '<tr><td>Views</td><td>' + HitCount + '</td></tr>';
2958
	}
2959
	if (BidCount) {
2960
		str += '<tr><td>Bids</td><td>' + BidCount + '</td></tr>';
2961
	}
2962
	if (MinimumToBid) {
2963
		str += '<tr><td>Minimum to Bid</td><td>' + (MinimumToBidCurrencyID == 'USD' ? '$' : MinimumToBidCurrencyID + ' ') + MinimumToBidValue.toFixed(2) + '</td></tr>';
2964
	}
2965
	if (HighBidder) {
2966
		str += '<tr><td>High Bidder</td><td>' + HighBidderUserID;
2967
		if (HighBidderFeedbackPrivate === false) {
2968
			str += feebackStarImage(HighBidderFeedbackScore) + ' (' + HighBidderFeedbackScore + ')';
2969
		}
2970
		str += '</td></tr>';
2971
		if (HighBidderUserAnonymized === true) {
30 - 2972
			str += '<tr><td colspan="2">High Bidder User Anonymized</td></tr>';
2 - 2973
		}
2974
	}
30 - 2975
	str += '</tbody></table>';
2 - 2976
 
30 - 2977
	if (Seller) {
2978
		str += '<h2>Seller</h2>';
2979
		str += '<p>' + SellerUserID + feebackStarImage(SellerFeedbackScore);
2980
		str += ' (' + SellerFeedbackScore + ' / ' + SellerPositiveFeedbackPercent + '%)';
2981
		if (SellerTopRatedSeller) {
2982
			str += '<br/>Top Rated Seller';
2983
		}
2984
		str += '<br/>' + Location + ' ' + (PostalCode ? PostalCode + ' ' : '') + Country;
2985
		if (Storefront) {
2986
			str += '<br/>Store: <a href="' + StorefrontStoreURL + '" target="_blank">' + StorefrontStoreName + '</a>';
2987
		}
2988
		str += '</p>';
2989
 
2990
		str += '<div id="map" style="width:100%;height:300px;"></div>';
2991
		str += '<script>';
2992
		str += '  function initMap() {';
2993
		str += '    var address = \'' + Location + ' ' + (PostalCode ? PostalCode + ' ' : '') + Country + '\';';
2994
		str += '	var geocoder = new google.maps.Geocoder;';
2995
		str += '    geocoder.geocode({"address": address}, function(results, status) {';
2996
		str += '    if (status === "OK") {';
2997
		str += '        if (results[0]) {';
2998
		str += '			var infowindow = new google.maps.InfoWindow;';
2999
		str += '	        var map = new google.maps.Map(document.getElementById("map"), {';
3000
		str += '	          zoom: 10,';
3001
		str += '	          center: {lat: 40.72, lng: -73.96}';
3002
		str += '	        });';
3003
		str += '            map.setCenter(results[0].geometry.location);';
3004
		str += '            var marker = new google.maps.Marker({';
3005
		str += '              map: map,';
3006
		str += '              position: results[0].geometry.location';
3007
		str += '            });';
3008
		str += '            infowindow.setContent(results[0].formatted_address);';
3009
		str += '            infowindow.open(map, marker);';
3010
		str += '        } else {';
3011
		str += '            document.getElementById("map").style.display = "none";';
3012
		str += '        }';
3013
		str += '    } else {';
3014
		str += '        document.getElementById("map").style.display = "none";';
3015
		str += '    }';
3016
		str += '  });';
3017
		str += '  }';
3018
		str += '<\/script>';
3019
	}
3020
 
3021
 
2 - 3022
	str += '</div>';
3023
	str += '</div>';
3024
	str += '</div>';
3025
 
3026
	if (PictureURL.length > 1) {
30 - 3027
		str += '<div class="container-fluid border">';
2 - 3028
		str += '<h2>Pictures</h2>';
3029
		for (i = 0; i < PictureURL.length; i++) {
30 - 3030
			str += '<img class="img-fluid" src="' + PictureURL[i].replace('http:', 'https:') + '" alt="Item Image ' + (i + 1) + '">';
2 - 3031
		}
3032
		str += '</div>';
3033
	}
3034
 
3035
	if (Description) {
30 - 3036
	    if (Description.includes("<link")) {
3037
            var htmlStr = '<!DOCTYPE html>';
3038
            htmlStr += '<html lang="en">';
3039
            htmlStr += '<head>';
3040
            htmlStr += '<title>' + ItemID + ' Description</title>';
3041
            htmlStr += '<meta charset="UTF-8">';
3042
            htmlStr += '<meta name="viewport" content="width=device-width, initial-scale=1.0">';
3043
            htmlStr += '</head>';
3044
            htmlStr += '<body>';
3045
            htmlStr += Description;
72 - 3046
	    htmlStr += '<script src="https://munatrading.linkpc.net/ebay/js/iframeResizer.contentWindow.min.js"><\/script>';
30 - 3047
            htmlStr += '</body>';
3048
            htmlStr += '</html>';
3049
       	    str += '<div class="container-fluid border"><h2>Description</h2><iframe style="width:100%" scrolling="no" src="data:text/html;base64,' + htmlStr.b64encode() + '">Browser does not support iframes</iframe></div>';
3050
    	} else {
3051
    		str += '<div class="container-fluid border"><h2>Description</h2>' + Description + '</div>';
3052
	    }
2 - 3053
	}
3054
 
30 - 3055
	str += '<div id="warnings" class="container-fluid border bg-danger"></div>';
3056
	str += '<footer class="container-fluid text-center border border-bottom-0 border-left-0 border-right-0">';
2 - 3057
	str += 'Copyright &#169; ' + new Date().getFullYear() + ' MUNA Trading. All rights reserved.';
3058
	str += '</footer>';
3059
	str += '<script async defer src="https://maps.googleapis.com/maps/api/js?key=' + configGoogleMapsKey + '&callback=initMap"><\/script>';
30 - 3060
	str += '<script>iFrameResize({log:false,checkOrigin:false})<\/script>';
2 - 3061
	str += '</div>';
3062
	str += '</body>';
3063
	str += '</html>';
3064
 
3065
	var newWin = window.open("", ItemID + ' ' + Title);
3066
	if (newWin) {
3067
		newWin.document.open().write(str);
3068
		newWin.document.close();
3069
	}
3070
}
3071
 
3072
function _cb_GetShippingCosts(root) {
3073
	var ack = root.Ack;
3074
	var i;
3075
	var j;
3076
	var taxTableEntries = 0;
3077
	ship_str = "";
3078
 
3079
	if (ack != 'Success') {
3080
		var x = document.getElementById("warnings");
30 - 3081
		var str = '<div class="alert alert-danger alert-dismissible">';
3082
        str += '<button type="button" class="close" data-dismiss="alert">×</button>';
3083
		str += "<h2>eBay API Error</h2>";
3084
		str += "<ul>";
3085
		str += "<li>Id: " + root.Errors[0].ErrorCode + "</li>";
3086
		str += "<li>Domain: " + root.Errors[0].ErrorClassification + "/li>";
3087
		str += "<li>Severity: " + root.Errors[0].SeverityCode + "</li>";
3088
		str += "<li>Short Message: " + root.Errors[0].ShortMessage + "</li>";
3089
		str += "<li>Long Message: " + root.Errors[0].LongMessage + "</li>";
3090
		str += "<li>Build/Version: " + root.Build + '/' + root.Version + "</li>";
3091
		str += "</ul>";
3092
		str += "<p>URL: " + "<a href=\"" + url + "\" target=\"_blank\">" + url + "</a>" + "</p>";
3093
		str += "</div>";
2 - 3094
 
30 - 3095
        x.innerHTML = str;
3096
    	x.className = x.className.replace(" invisible", " visible");
2 - 3097
 
3098
		if (ack == 'Failure' || ack == 'PartialFailure') {
3099
			x.scrollIntoView(true);
3100
			getShippingCostsDone = true;
3101
			return;
3102
		}
3103
	}
3104
 
30 - 3105
	ship_str += '<tr><td colspan="2"><strong>Shipping Cost Summary</strong></td></tr>';
2 - 3106
	ship_str_cost = "";
3107
	if (root.ShippingCostSummary.ShippingServiceCost) {
3108
		if (root.ShippingCostSummary.ShippingServiceCost.Value === 0) {
3109
			ship_str += '<tr><td>Shipping Service Cost</td><td>Free</td></tr>';
3110
			ship_str_cost = '<tr><td>Shipping</td><td>Free (' + root.ShippingCostSummary.ShippingServiceName + ')</td></tr>';
3111
		} else {
3112
			ship_str += '<tr><td>Shipping Service Cost</td><td>' + (root.ShippingCostSummary.ShippingServiceCost.CurrencyID == 'USD' ? '$' : root.ShippingCostSummary.ShippingServiceCost.CurrencyID + ' ') + root.ShippingCostSummary.ShippingServiceCost.Value.toFixed(2) + '</td></tr>';
3113
			ship_str_cost = '<tr><td>Shipping</td><td>' + (root.ShippingCostSummary.ShippingServiceCost.CurrencyID == 'USD' ? '$' : root.ShippingCostSummary.ShippingServiceCost.CurrencyID + ' ') + root.ShippingCostSummary.ShippingServiceCost.Value.toFixed(2) + ' (' + root.ShippingCostSummary.ShippingServiceName + ')</td></tr>';
3114
		}
3115
	}
3116
 
3117
	if (root.ShippingCostSummary.ShippingServiceName) {
3118
		ship_str += '<tr><td>Shipping Service Name</td><td>' + root.ShippingCostSummary.ShippingServiceName + '</td></tr>';
3119
	}
3120
 
3121
	if (root.ShippingCostSummary.ShippingType) {
3122
		ship_str += '<tr><td>Shipping Type</td><td>' + root.ShippingCostSummary.ShippingType + '</td></tr>';
3123
	}
3124
 
3125
	if (root.ShippingCostSummary.ImportCharge) {
3126
		ship_str += '<tr><td>Import Charge</td><td>' + (root.ShippingCostSummary.ImportCharge.CurrencyID == 'USD' ? '$' : root.ShippingCostSummary.ImportCharge.CurrencyID + ' ') + root.ShippingCostSummary.ImportCharge.Value.toFixed(2) + '</td></tr>';
3127
	}
3128
 
3129
	if (root.ShippingCostSummary.InsuranceCost) {
3130
		ship_str += '<tr><td>Insurance Cost</td><td>' + (root.ShippingCostSummary.InsuranceCost.CurrencyID == 'USD' ? '$' : root.ShippingCostSummary.InsuranceCost.CurrencyID + ' ') + root.ShippingCostSummary.InsuranceCost.Value.toFixed(2) + '</td></tr>';
3131
	}
3132
 
3133
	if (root.ShippingCostSummary.InsuranceOption) {
3134
		ship_str += '<tr><td>Insurance Option</td><td>' + root.ShippingCostSummary.InsuranceOption + '</td></tr>';
3135
	}
3136
 
3137
	if (root.ShippingCostSummary.InternationalInsuranceCost) {
3138
		ship_str += '<tr><td>International Insurance Cost</td><td>' + (root.ShippingCostSummary.InternationalInsuranceCost.CurrencyID == 'USD' ? '$' : root.ShippingCostSummary.InternationalInsuranceCost.CurrencyID + ' ') + root.ShippingCostSummary.InternationalInsuranceCost.Value.toFixed(2) + '</td></tr>';
3139
	}
3140
 
3141
	if (root.ShippingCostSummary.InternationalInsuranceOption) {
3142
		ship_str += '<tr><td>International Insurance Option</td><td>' + root.ShippingCostSummary.InternationalInsuranceOption + '</td></tr>';
3143
	}
3144
 
3145
	if (root.ShippingDetails.ExcludeShipToLocation) {
3146
		var excludeArray = String(root.ShippingDetails.ExcludeShipToLocation).split(',');
3147
		ship_str += '<tr><td>Exclude Ship to Location</td><td>';
3148
		for (i = 0; i < excludeArray.length; i++) {
3149
			ship_str += (i > 0 ? ', ' : '') + mapCountryCode(excludeArray[i]);
3150
		}
3151
		ship_str += '</td></tr>';
3152
	}
3153
 
3154
	if (root.ShippingDetails.SalesTax) {
3155
		if (root.ShippingDetails.SalesTax.SalesTaxAmount) {
3156
			ship_str += '<tr><td>Sales Tax Amount</td><td>' + (root.ShippingDetails.SalesTax.SalesTaxAmount.CurrencyID == 'USD' ? '$' : root.ShippingDetails.SalesTax.SalesTaxAmount.CurrencyID + ' ') + root.ShippingDetails.SalesTax.SalesTaxAmount.Value.toFixed(2) + '</td></tr>';
3157
		}
3158
		if (root.ShippingDetails.SalesTax.SalesTaxPercent) {
3159
			ship_str += '<tr><td>Sales Tax Percentage</td><td>' + root.ShippingDetails.SalesTax.SalesTaxPercent.toFixed(3) + '%</td></tr>';
3160
		}
3161
		if (root.ShippingDetails.SalesTax.SalesTaxState) {
3162
			ship_str += '<tr><td>Sales Tax State</td><td>' + root.ShippingDetails.SalesTax.SalesTaxState + '</td></tr>';
3163
		}
3164
		if (root.ShippingDetails.SalesTax.ShippingIncludedInTax === true) {
30 - 3165
			ship_str += '<tr><td colspan="2">Shipping Included In Tax</td></tr>';
2 - 3166
		}
3167
	}
3168
 
3169
	ship_str_tax = "";
3170
	if (root.ShippingDetails.TaxTable && root.ShippingDetails.TaxTable.TaxJurisdiction.length > 0) {
3171
		for (i = 0; i < root.ShippingDetails.TaxTable.TaxJurisdiction.length; i++) {
3172
			if (root.ShippingDetails.TaxTable.TaxJurisdiction[i].JurisdictionID !== undefined) {
3173
				taxTableEntries++;
3174
			}
3175
		}
3176
	}
3177
 
3178
	if (taxTableEntries) {
30 - 3179
		ship_str += '<tr><td colspan="2"><strong>Tax Table</strong></td></tr>';
2 - 3180
		for (i = 0; i < root.ShippingDetails.TaxTable.TaxJurisdiction.length; i++) {
3181
			if (root.ShippingDetails.TaxTable.TaxJurisdiction[i].JurisdictionID !== undefined) {
3182
				if (root.ShippingDetails.TaxTable.TaxJurisdiction[i].JurisdictionID == configTaxStateId) {
3183
					ship_str_tax += '<tr><td>Tax</td><td>' + root.ShippingDetails.TaxTable.TaxJurisdiction[i].JurisdictionID + ' ' + root.ShippingDetails.TaxTable.TaxJurisdiction[i].SalesTaxPercent.toFixed(3) + '%';
3184
					if (root.ShippingDetails.TaxTable.TaxJurisdiction[i].ShippingIncludedInTax && root.ShippingDetails.TaxTable.TaxJurisdiction[i].ShippingIncludedInTax === true) {
3185
						ship_str_tax += '<br/>Shipping included in Tax';
3186
					}
3187
					ship_str_tax += '</td></tr>';
3188
				}
3189
				ship_str += '<tr><td>' + root.ShippingDetails.TaxTable.TaxJurisdiction[i].JurisdictionID + '</td><td>' + root.ShippingDetails.TaxTable.TaxJurisdiction[i].SalesTaxPercent.toFixed(3) + '%';
3190
				if (root.ShippingDetails.TaxTable.TaxJurisdiction[i].ShippingIncludedInTax && root.ShippingDetails.TaxTable.TaxJurisdiction[i].ShippingIncludedInTax === true) {
3191
					ship_str += '<br/>Shipping included in Tax';
3192
				}
3193
				ship_str += '</td></tr>';
3194
			}
3195
		}
3196
	}
3197
 
3198
	for (i = 0; root.ShippingDetails.ShippingServiceOption && i < root.ShippingDetails.ShippingServiceOption.length; i++) {
30 - 3199
		ship_str += '<tr><td colspan="2"><strong>Shipping Option ' + root.ShippingDetails.ShippingServiceOption[i].ShippingServicePriority + '</strong></td></tr>';
2 - 3200
 
3201
		if (root.ShippingDetails.ShippingServiceOption[i].ShippingServiceCost) {
3202
			if (root.ShippingDetails.ShippingServiceOption[i].ShippingServiceCost.Value === 0) {
3203
				ship_str += '<tr><td>Shipping Service Cost</td><td>Free</td></tr>';
3204
			} else {
3205
				ship_str += '<tr><td>Shipping Service Cost</td><td>' + (root.ShippingDetails.ShippingServiceOption[i].ShippingServiceCost.CurrencyID == 'USD' ? '$' : root.ShippingDetails.ShippingServiceOption[i].ShippingServiceCost.CurrencyID + ' ') + root.ShippingDetails.ShippingServiceOption[i].ShippingServiceCost.Value.toFixed(2) + '</td></tr>';
3206
			}
3207
		}
3208
 
3209
		if (root.ShippingDetails.ShippingServiceOption[i].ShippingInsuranceCost) {
3210
			ship_str += '<tr><td>Shipping Insurance Cost</td><td>' + (root.ShippingDetails.ShippingServiceOption[i].ShippingInsuranceCost.CurrencyID == 'USD' ? '$' : root.ShippingDetails.ShippingServiceOption[i].ShippingInsuranceCost.CurrencyID + ' ') + root.ShippingDetails.ShippingServiceOption[i].ShippingInsuranceCost.Value.toFixed(2) + '</td></tr>';
3211
		}
3212
 
3213
		if (root.ShippingDetails.ShippingServiceOption[i].ShippingServiceAdditionalCost) {
3214
			ship_str += '<tr><td>Shipping Additional Item Cost</td><td>' + (root.ShippingDetails.ShippingServiceOption[i].ShippingServiceAdditionalCost.CurrencyID == 'USD' ? '$' : root.ShippingDetails.ShippingServiceOption[i].ShippingServiceAdditionalCost.CurrencyID + ' ') + root.ShippingDetails.ShippingServiceOption[i].ShippingServiceAdditionalCost.Value.toFixed(2) + '</td></tr>';
3215
		}
3216
 
3217
		if (root.ShippingDetails.ShippingServiceOption[i].ShippingSurcharge) {
3218
			ship_str += '<tr><td>Shipping Surcharge</td><td>' + (root.ShippingDetails.ShippingServiceOption[i].ShippingSurcharge.CurrencyID == 'USD' ? '$' : root.ShippingDetails.ShippingServiceOption[i].ShippingSurcharge.CurrencyID + ' ') + root.ShippingDetails.ShippingServiceOption[i].ShippingSurcharge.Value.toFixed(2) + '</td></tr>';
3219
		}
3220
 
3221
		if (root.ShippingDetails.ShippingServiceOption[i].ShippingServiceName) {
3222
			ship_str += '<tr><td>Shipping Service Name</td><td>' + root.ShippingDetails.ShippingServiceOption[i].ShippingServiceName + '</td></tr>';
3223
		}
3224
 
3225
		if (root.ShippingDetails.ShippingServiceOption[i].ShippingServiceOptionType) {
3226
			ship_str += '<tr><td>Shipping Type</td><td>' + root.ShippingDetails.ShippingServiceOption[i].ShippingServiceOptionType + '</td></tr>';
3227
		}
3228
 
3229
		if (root.ShippingDetails.ShippingServiceOption[i].ShippingTimeMin && root.ShippingDetails.ShippingServiceOption[i].ShippingTimeMax) {
3230
			ship_str += '<tr><td>Delivery Time</td><td>';
3231
			if (root.ShippingDetails.ShippingServiceOption[i].ShippingTimeMin != root.ShippingDetails.ShippingServiceOption[i].ShippingTimeMax) {
3232
				ship_str += 'Between ' + root.ShippingDetails.ShippingServiceOption[i].ShippingTimeMin + ' and ';
3233
			}
3234
			ship_str += root.ShippingDetails.ShippingServiceOption[i].ShippingTimeMax + ' days</td></tr>';
3235
		}
3236
 
3237
		if (root.ShippingDetails.ShippingServiceOption[i].ShippingServiceCutOffTime) {
3238
			ship_str += '<tr><td>Shipping Type</td><td>' + root.ShippingDetails.ShippingServiceOption[i].ShippingServiceCutOffTime + '</td></tr>';
3239
		}
3240
 
3241
		if (root.ShippingDetails.ShippingServiceOption[i].ExpeditedService && root.ShippingDetails.ShippingServiceOption[i].ExpeditedService === true) {
30 - 3242
			ship_str += '<tr><td colspan="2">Expedited Service</td></tr>';
2 - 3243
		}
3244
 
3245
		if (root.ShippingDetails.ShippingServiceOption[i].FastAndFree && root.ShippingDetails.ShippingServiceOption[i].FastAndFree === true) {
30 - 3246
			ship_str += '<tr><td colspan="2">Fast and Free</td></tr>';
2 - 3247
		}
3248
 
3249
		if (root.ShippingDetails.ShippingServiceOption[i].ShipsTo) {
3250
			var includeArray = String(root.ShippingDetails.ShippingServiceOption[i].ShipsTo).split(',');
3251
			ship_str += '<tr><td>Ship to Location</td><td>';
3252
			for (j = 0; j < includeArray.length; j++) {
3253
				ship_str += (j > 0 ? ', ' : '') + includeArray[j];
3254
			}
3255
			ship_str += '</td></tr>';
3256
		}
3257
	}
3258
 
3259
	for (i = 0; root.ShippingDetails.InternationalShippingServiceOption && i < root.ShippingDetails.InternationalShippingServiceOption.length; i++) {
30 - 3260
		ship_str += '<tr><td colspan="2"><strong>International Shipping Option ' + root.ShippingDetails.InternationalShippingServiceOption[i].ShippingServicePriority + '</strong></td></tr>';
2 - 3261
 
3262
		if (root.ShippingDetails.InternationalShippingServiceOption[i].ShippingServiceCost) {
3263
			if (root.ShippingDetails.InternationalShippingServiceOption[i].ShippingServiceCost.Value === 0) {
3264
				ship_str += '<tr><td>Shipping Service Cost</td><td>Free</td></tr>';
3265
			} else {
3266
				ship_str += '<tr><td>Shipping Service Cost</td><td>' + (root.ShippingDetails.InternationalShippingServiceOption[i].ShippingServiceCost.CurrencyID == 'USD' ? '$' : root.ShippingDetails.InternationalShippingServiceOption[i].ShippingServiceCost.CurrencyID + ' ') + root.ShippingDetails.InternationalShippingServiceOption[i].ShippingServiceCost.Value.toFixed(2) + '</td></tr>';
3267
			}
3268
		}
3269
 
3270
		if (root.ShippingDetails.InternationalShippingServiceOption[i].ShippingInsuranceCost) {
3271
			ship_str += '<tr><td>Shipping Insurance Cost</td><td>' + (root.ShippingDetails.InternationalShippingServiceOption[i].ShippingInsuranceCost.CurrencyID == 'USD' ? '$' : root.ShippingDetails.InternationalShippingServiceOption[i].ShippingInsuranceCost.CurrencyID + ' ') + root.ShippingDetails.InternationalShippingServiceOption[i].ShippingInsuranceCost.Value.toFixed(2) + '</td></tr>';
3272
		}
3273
 
3274
		if (root.ShippingDetails.InternationalShippingServiceOption[i].ShippingServiceAdditionalCost) {
3275
			ship_str += '<tr><td>Shipping Additional Item Cost</td><td>' + (root.ShippingDetails.InternationalShippingServiceOption[i].ShippingServiceAdditionalCost.CurrencyID == 'USD' ? '$' : root.ShippingDetails.InternationalShippingServiceOption[i].ShippingServiceAdditionalCost.CurrencyID + ' ') + root.ShippingDetails.InternationalShippingServiceOption[i].ShippingServiceAdditionalCost.Value.toFixed(2) + '</td></tr>';
3276
		}
3277
 
3278
		if (root.ShippingDetails.InternationalShippingServiceOption[i].ImportCharge) {
3279
			ship_str += '<tr><td>Import Charge</td><td>' + (root.ShippingDetails.InternationalShippingServiceOption[i].ImportCharge.CurrencyID == 'USD' ? '$' : root.ShippingDetails.InternationalShippingServiceOption[i].ImportCharge.CurrencyID + ' ') + root.ShippingDetails.InternationalShippingServiceOption[i].ImportCharge.Value.toFixed(2) + '</td></tr>';
3280
		}
3281
 
3282
		if (root.ShippingDetails.InternationalShippingServiceOption[i].ShippingServiceName) {
3283
			ship_str += '<tr><td>Shipping Service Name</td><td>' + root.ShippingDetails.InternationalShippingServiceOption[i].ShippingServiceName + '</td></tr>';
3284
		}
3285
 
3286
		if (root.ShippingDetails.InternationalShippingServiceOption[i].InternationalShippingServiceOptionType) {
3287
			ship_str += '<tr><td>Shipping Type</td><td>' + root.ShippingDetails.InternationalShippingServiceOption[i].InternationalShippingServiceOptionType + '</td></tr>';
3288
		}
3289
 
3290
		if (root.ShippingDetails.InternationalShippingServiceOption[i].EstimatedDeliveryMinTime && root.ShippingDetails.InternationalShippingServiceOption[i].EstimatedDeliveryMaxTime) {
3291
			ship_str += '<tr><td>Delivery Time</td><td>';
3292
			if (root.ShippingDetails.InternationalShippingServiceOption[i].EstimatedDeliveryMinTime != root.ShippingDetails.InternationalShippingServiceOption[i].EstimatedDeliveryMaxTime) {
3293
				ship_str += 'Between ' + moment(root.ShippingDetails.InternationalShippingServiceOption[i].EstimatedDeliveryMinTime, moment.ISO_8601).format("YYYY-MM-DD") + ' and ';
3294
			}
3295
			ship_str += moment(root.ShippingDetails.InternationalShippingServiceOption[i].EstimatedDeliveryMinTime, moment.ISO_8601).format("YYYY-MM-DD");
3296
			ship_str += (moment(root.ShippingDetails.InternationalShippingServiceOption[i].EstimatedDeliveryMaxTime).isValid() ? '' : ' days') + '</td></tr>';
3297
		}
3298
 
3299
		if (root.ShippingDetails.InternationalShippingServiceOption[i].ShippingServiceCutOffTime) {
3300
			ship_str += '<tr><td>Shipping Type</td><td>' + root.ShippingDetails.InternationalShippingServiceOption[i].ShippingServiceCutOffTime + '</td></tr>';
3301
		}
3302
 
3303
		if (root.ShippingDetails.InternationalShippingServiceOption[i].ShipsTo) {
3304
			var includeInternationalArray = String(root.ShippingDetails.InternationalShippingServiceOption[i].ShipsTo).split(',');
3305
			ship_str += '<tr><td>Ship to Location</td><td>';
3306
			for (j = 0; j < includeInternationalArray.length; j++) {
3307
				ship_str += (j > 0 ? ', ' : '') + includeInternationalArray[j];
3308
			}
3309
			ship_str += '</td></tr>';
3310
		}
3311
	}
3312
 
3313
	getShippingCostsDone = true;
3314
}
3315
 
3316
function ConvertToCSVHeader() {
3317
	var header = "";
3318
 
3319
	header += "itemId,";
3320
	header += "title,";
3321
	header += "subtitle,";
3322
	header += "globalId,";
3323
	header += "primaryCategory.categoryId,";
3324
	header += "primaryCategory.categoryName,";
3325
	header += "galleryURL,";
3326
	header += "viewItemURL,";
3327
	header += "paymentMethod,";
3328
	header += "autoPay,";
3329
	header += "location,";
3330
	header += "country,";
3331
	header += "sellerUserName,";
3332
	header += "feedbackScore,";
3333
	header += "positiveFeedbackPercent,";
3334
	header += "feedbackRatingStar,";
3335
	header += "topRatedSeller,";
3336
	header += "storeName,";
3337
	header += "storeURL,";
3338
	header += "shippingInfo.shippingServiceCost.currencyId,";
3339
	header += "shippingInfo.shippingServiceCost.value,";
3340
	header += "shippingInfo.shippingType,";
3341
	header += "shippingInfo.shipToLocations,";
3342
	header += "shippingInfo.expeditedShipping,";
3343
	header += "shippingInfo.oneDayShippingAvailable,";
3344
	header += "shippingInfo.handlingTime,";
3345
	header += "sellingStatus.currentPrice.currencyId,";
3346
	header += "sellingStatus.currentPrice.value,";
3347
	header += "sellingStatus.convertedCurrentPrice.currencyId,";
3348
	header += "sellingStatus.convertedCurrentPrice.value,";
3349
	header += "sellingStatus.bidCount,";
3350
	header += "sellingStatus.sellingState,";
3351
	header += "sellingStatus.timeLeft,";
3352
	header += "listingInfo.bestOfferEnabled,";
3353
	header += "listingInfo.buyItNowAvailable,";
3354
	header += "listingInfo.convertedBuyItNowPrice.currencyId,";
3355
	header += "listingInfo.convertedBuyItNowPrice.value,";
3356
	header += "listingInfo.startTime,";
3357
	header += "listingInfo.endTime,";
3358
	header += "listingInfo.listingType,";
3359
	header += "listingInfo.gift,";
3360
	header += "listingInfo.watchCount,";
3361
	header += "returnsAccepted,";
3362
	header += "galleryPlusPictureURL,";
3363
	header += "condition.conditionId,";
3364
	header += "condition.conditionDisplayName,";
3365
	header += "isMultiVariationListing,";
3366
	header += "topRatedListing,";
3367
	header += "distance,";
3368
	header += "distance unit";
3369
	header += "\r\n";
3370
 
3371
	return header;
3372
}
3373
 
3374
function readParameters() {
3375
	if (window.location.search[0] == '?') {
30 - 3376
        var str = window.location.search.split('?')[1];
8 - 3377
   		$('form').deserialize(str);
30 - 3378
    	$('#category').trigger("chosen:updated");
8 - 3379
	    eBaySearch(1);
3380
   	}
2 - 3381
}
3382
 
3383
jQuery.fn.deserialize = function(data) {
3384
	var f = this,
3385
		map = {},
3386
		find = function(selector) {
3387
			return f.is("form") ? f.find(selector) : f.filter(selector);
3388
		};
3389
	// Get map of values
3390
	data = data.replace(/\+/g, " ");
3391
	jQuery.each(data.split("&"), function() {
3392
		var nv = this.split("="),
3393
			n = decodeURIComponent(nv[0]),
3394
			v = nv.length > 1 ? decodeURIComponent(nv[1]) : null;
3395
		if (!(n in map)) {
3396
			map[n] = [];
3397
		}
3398
		map[n].push(v);
3399
	});
3400
	// Set values for all form elements in the data
3401
	jQuery.each(map, function(n, v) {
3402
		find("[name='" + n + "']").val(v);
3403
	});
3404
	// Clear all form elements not in form data
3405
	find("input:text,select,textarea").each(function() {
3406
		if (!(jQuery(this).attr("name") in map)) {
3407
			jQuery(this).val("");
3408
		}
3409
	});
3410
	find("input:checkbox:checked,input:radio:checked").each(function() {
3411
		if (!(jQuery(this).attr("name") in map)) {
3412
			this.checked = false;
3413
		}
3414
	});
3415
	return this;
3416
};
3417
 
3418
// Function to convert eBay JSON item to CSV format.
3419
function ConvertToCSV(array) {
3420
	var str = "";
3421
 
3422
	++currentPage;
3423
	updateProgressBar(maxPages, currentPage);
3424
 
3425
	for (var i = 0; i < array.length; i++) {
3426
		var line = "";
3427
 
3428
		var JsonObj = array[i];
3429
		line += "'" + JsonObj.itemId + ",";
3430
 
3431
		var title = String(JsonObj.title).replace(/\"/g, "");
3432
		line += "\"" + title + "\",";
3433
 
3434
		if (JsonObj.subtitle) {
3435
			var subtitle = String(JsonObj.subtitle).replace(/\"/g, "");
3436
			line += "\"" + subtitle + "\",";
3437
		} else {
3438
			line += ",";
3439
		}
3440
 
3441
		line += JsonObj.globalId + ",";
3442
 
3443
		var primaryCategory = JsonObj.primaryCategory;
3444
		line += primaryCategory[0].categoryId + ",";
3445
		var categoryName = String(primaryCategory[0].categoryName).replace(/\"/g, "");
3446
		line += "\"" + categoryName + "\",";
3447
 
3448
		line += JsonObj.galleryURL + ",";
3449
		line += "\"" + JsonObj.viewItemURL + "\",";
3450
		line += "\"" + JsonObj.paymentMethod + "\",";
3451
		line += JsonObj.autoPay + ",";
3452
		line += "\"" + JsonObj.location + "\",";
3453
		line += JsonObj.country + ",";
3454
 
3455
		var sellerInfo = JsonObj.sellerInfo;
3456
		line += sellerInfo[0].sellerUserName + ",";
3457
		line += sellerInfo[0].feedbackScore + ",";
3458
		line += sellerInfo[0].positiveFeedbackPercent + ",";
3459
		line += sellerInfo[0].feedbackRatingStar + ",";
3460
		line += sellerInfo[0].topRatedSeller + ",";
3461
 
3462
		var storeInfo = JsonObj.storeInfo;
3463
		if (storeInfo) {
3464
			var storeName = String(storeInfo[0].storeName).replace(/\"/g, "");
3465
			line += "\"" + storeName + "\",";
3466
			line += storeInfo[0].storeURL + ",";
3467
		} else {
3468
			line += ",";
3469
			line += ",";
3470
		}
3471
		var shippingInfo = JsonObj.shippingInfo;
3472
		var shippingServiceCost = shippingInfo[0].shippingServiceCost;
3473
		if (shippingServiceCost) {
3474
			line += shippingServiceCost[0]["@currencyId"] + ",";
3475
			line += shippingServiceCost[0].__value__ + ",";
3476
		} else {
3477
			line += ",";
3478
			line += ",";
3479
		}
3480
		line += shippingInfo[0].shippingType + ",";
3481
		line += shippingInfo[0].shipToLocations + ",";
3482
		line += shippingInfo[0].expeditedShipping + ",";
3483
		line += shippingInfo[0].oneDayShippingAvailable + ",";
3484
		line += shippingInfo[0].handlingTime + ",";
3485
 
3486
		var sellingStatus = JsonObj.sellingStatus;
3487
		var currentPrice = sellingStatus[0].currentPrice;
3488
		var convertedCurrentPrice = sellingStatus[0].convertedCurrentPrice;
3489
		line += currentPrice[0]["@currencyId"] + ",";
3490
		line += currentPrice[0].__value__ + ",";
3491
		line += convertedCurrentPrice[0]["@currencyId"] + ",";
3492
		line += convertedCurrentPrice[0].__value__ + ",";
3493
		if (sellingStatus[0].bidCount) {
3494
			line += sellingStatus[0].bidCount + ",";
3495
		} else {
3496
			line += ",";
3497
		}
3498
		line += sellingStatus[0].sellingState + ",";
3499
		line += formatTimeleft(moment.duration(sellingStatus[0].timeLeft).asSeconds()) + ",";
3500
 
3501
		var listingInfo = JsonObj.listingInfo;
3502
		line += listingInfo[0].bestOfferEnabled + ",";
3503
		line += listingInfo[0].buyItNowAvailable + ",";
3504
 
3505
		var convertedBuyItNowPrice = listingInfo[0].convertedBuyItNowPrice;
3506
		if (convertedBuyItNowPrice) {
3507
			line += convertedBuyItNowPrice[0]["@currencyId"] + ",";
3508
			line += convertedBuyItNowPrice[0].__value__ + ",";
3509
		} else {
3510
			line += ",";
3511
			line += ",";
3512
		}
3513
		line += listingInfo[0].startTime + ",";
3514
		line += listingInfo[0].endTime + ",";
3515
		line += listingInfo[0].listingType + ",";
3516
		line += listingInfo[0].gift + ",";
3517
		if (listingInfo[0].watchCount) {
3518
			line += listingInfo[0].watchCount + ",";
3519
		} else {
3520
			line += ",";
3521
		}
3522
 
3523
		line += JsonObj.returnsAccepted + ",";
3524
		if (JsonObj.galleryPlusPictureURL) {
3525
			line += JsonObj.galleryPlusPictureURL + ",";
3526
		} else {
3527
			line += ",";
3528
		}
3529
 
3530
		var condition = JsonObj.condition;
3531
		if (condition) {
3532
			line += condition[0].conditionId + ",";
3533
			line += condition[0].conditionDisplayName + ",";
3534
			line += JsonObj.isMultiVariationListing + ",";
3535
			line += JsonObj.topRatedListing + ",";
3536
		} else {
3537
			line += ",";
3538
			line += ",";
3539
			line += ",";
3540
			line += ",";
3541
		}
3542
 
3543
		if (JsonObj.distance !== undefined) {
3544
			line += JsonObj.distance[0].__value__ + ",";
3545
			line += JsonObj.distance[0]["@unit"] + ",";
3546
		} else {
3547
			line += ",";
3548
			line += ",";
3549
		}
3550
 
3551
		line += '\r\n';
3552
 
3553
		str += line;
3554
	}
3555
 
3556
	var x = document.getElementById("csv");
3557
	x.innerHTML += str;
3558
 
3559
	if (currentPage >= maxPages) {
3560
		asyncFlag = true;
3561
	}
3562
}
3563
 
3564
function resetForm() {
3565
	document.getElementById("searchForm").reset();
3566
	$(document.getElementById("category")).trigger("chosen:updated");
3567
}
3568
 
3569
function mapCountryCode(code) {
3570
	var mappedCode = code;
3571
	var countryCodes = {};
3572
 
3573
	countryCodes.AA = "APO/FPO";
3574
	countryCodes.AD = "Andorra";
3575
	countryCodes.AE = "United Arab Emirates";
3576
	countryCodes.AF = "Afghanistan";
3577
	countryCodes.AG = "Antigua and Barbuda";
3578
	countryCodes.AI = "Anguilla";
3579
	countryCodes.AL = "Albania";
3580
	countryCodes.AM = "Armenia";
3581
	countryCodes.AN = "Netherlands Antilles";
3582
	countryCodes.AO = "Angola";
3583
	countryCodes.AQ = "Antarctica";
3584
	countryCodes.AR = "Argentina";
3585
	countryCodes.AS = "American Samoa";
3586
	countryCodes.AT = "Austria";
3587
	countryCodes.AU = "Australia";
3588
	countryCodes.AW = "Aruba";
3589
	countryCodes.AZ = "Azerbaijan";
3590
	countryCodes.BA = "Bosnia and Herzegovina";
3591
	countryCodes.BB = "Barbados";
3592
	countryCodes.BD = "Bangladesh";
3593
	countryCodes.BE = "Belgium";
3594
	countryCodes.BF = "Burkina Faso";
3595
	countryCodes.BG = "Bulgaria";
3596
	countryCodes.BH = "Bahrain";
3597
	countryCodes.BI = "Burundi";
3598
	countryCodes.BJ = "Benin";
3599
	countryCodes.BM = "Bermuda";
3600
	countryCodes.BN = "Brunei Darussalam";
3601
	countryCodes.BO = "Bolivia";
3602
	countryCodes.BR = "Brazil";
3603
	countryCodes.BS = "Bahamas";
3604
	countryCodes.BT = "Bhutan";
3605
	countryCodes.BV = "Bouvet Island";
3606
	countryCodes.BW = "Botswana";
3607
	countryCodes.BY = "Belarus";
3608
	countryCodes.BZ = "Belize";
3609
	countryCodes.CA = "Canada";
3610
	countryCodes.CC = "Cocos (Keeling) Islands";
3611
	countryCodes.CD = "The Democratic Republic of the Congo";
3612
	countryCodes.CF = "Central African Republic";
3613
	countryCodes.CG = "Congo";
3614
	countryCodes.CH = "Switzerland";
3615
	countryCodes.CI = "Cote d'Ivoire";
3616
	countryCodes.CK = "Cook Islands";
3617
	countryCodes.CL = "Chile";
3618
	countryCodes.CM = "Cameroon";
3619
	countryCodes.CN = "China";
3620
	countryCodes.CO = "Colombia";
3621
	countryCodes.CR = "Costa Rica";
3622
	countryCodes.CU = "Cuba";
3623
	countryCodes.CV = "Cape Verde";
3624
	countryCodes.CX = "Christmas Island";
3625
	countryCodes.CY = "Cyprus";
3626
	countryCodes.CZ = "Czech Republic";
3627
	countryCodes.DE = "Germany";
3628
	countryCodes.DJ = "Djibouti";
3629
	countryCodes.DK = "Denmark";
3630
	countryCodes.DM = "Dominica";
3631
	countryCodes.DO = "Dominican Republic";
3632
	countryCodes.DZ = "Algeria";
3633
	countryCodes.EC = "Ecuador";
3634
	countryCodes.EE = "Estonia";
3635
	countryCodes.EG = "Egypt";
3636
	countryCodes.EH = "Western Sahara";
3637
	countryCodes.ER = "Eritrea";
3638
	countryCodes.ES = "Spain";
3639
	countryCodes.ET = "Ethiopia";
3640
	countryCodes.FI = "Finland";
3641
	countryCodes.FJ = "Fiji";
3642
	countryCodes.FK = "Falkland Islands (Malvinas)";
3643
	countryCodes.FM = "Federated States of Micronesia";
3644
	countryCodes.FO = "Faroe Islands";
3645
	countryCodes.FR = "France";
3646
	countryCodes.GA = "Gabon";
3647
	countryCodes.GB = "United Kingdom";
3648
	countryCodes.GD = "Grenada";
3649
	countryCodes.GE = "Georgia";
3650
	countryCodes.GF = "French Guiana";
3651
	countryCodes.GG = "Guernsey";
3652
	countryCodes.GH = "Ghana";
3653
	countryCodes.GI = "Gibraltar";
3654
	countryCodes.GL = "Greenland";
3655
	countryCodes.GM = "Gambia";
3656
	countryCodes.GN = "Guinea";
3657
	countryCodes.GP = "Guadeloupe";
3658
	countryCodes.GQ = "Equatorial Guinea";
3659
	countryCodes.GR = "Greece";
3660
	countryCodes.GS = "South Georgia and the South Sandwich Islands";
3661
	countryCodes.GT = "Guatemala";
3662
	countryCodes.GU = "Guam";
3663
	countryCodes.GW = "Guinea-Bissau";
3664
	countryCodes.GY = "Guyana";
3665
	countryCodes.HK = "Hong Kong";
3666
	countryCodes.HM = "Heard Island and McDonald Islands";
3667
	countryCodes.HN = "Honduras";
3668
	countryCodes.HR = "Croatia";
3669
	countryCodes.HT = "Haiti";
3670
	countryCodes.HU = "Hungary";
3671
	countryCodes.ID = "Indonesia";
3672
	countryCodes.IE = "Ireland";
3673
	countryCodes.IL = "Israel";
3674
	countryCodes.IN = "India";
3675
	countryCodes.IO = "British Indian Ocean Territory";
3676
	countryCodes.IQ = "Iraq";
3677
	countryCodes.IR = "Islamic Republic of Iran";
3678
	countryCodes.IS = "Iceland";
3679
	countryCodes.IT = "Italy";
3680
	countryCodes.JE = "Jersey";
3681
	countryCodes.JM = "Jamaica";
3682
	countryCodes.JO = "Jordan";
3683
	countryCodes.JP = "Japan";
3684
	countryCodes.KE = "Kenya";
3685
	countryCodes.KG = "Kyrgyzstan";
3686
	countryCodes.KH = "Cambodia";
3687
	countryCodes.KI = "Kiribati";
3688
	countryCodes.KM = "Comoros";
3689
	countryCodes.KN = "Saint Kitts and Nevis";
3690
	countryCodes.KP = "Democratic People's Republic of Korea";
3691
	countryCodes.KR = "Republic of Korea";
3692
	countryCodes.KW = "Kuwait";
3693
	countryCodes.KY = "Cayman Islands";
3694
	countryCodes.KZ = "Kazakhstan";
3695
	countryCodes.LA = "Lao People's Democratic Republic";
3696
	countryCodes.LB = "Lebanon";
3697
	countryCodes.LC = "Saint Lucia";
3698
	countryCodes.LI = "Liechtenstein";
3699
	countryCodes.LK = "Sri Lanka";
3700
	countryCodes.LR = "Liberia";
3701
	countryCodes.LS = "Lesotho";
3702
	countryCodes.LT = "Lithuania";
3703
	countryCodes.LU = "Luxembourg";
3704
	countryCodes.LV = "Latvia";
3705
	countryCodes.LY = "Libyan Arab Jamahiriya";
3706
	countryCodes.MA = "Morocco";
3707
	countryCodes.MC = "Monaco";
3708
	countryCodes.MD = "Republic of Moldova";
3709
	countryCodes.ME = "Montenegro";
3710
	countryCodes.MG = "Madagascar";
3711
	countryCodes.MH = "Marshall Islands";
3712
	countryCodes.MK = "The Former Yugoslav Republic of Macedonia";
3713
	countryCodes.ML = "Mali";
3714
	countryCodes.MM = "Myanmar";
3715
	countryCodes.MN = "Mongolia";
3716
	countryCodes.MO = "Macao";
3717
	countryCodes.MP = "Northern Mariana Islands";
3718
	countryCodes.MQ = "Martinique";
3719
	countryCodes.MR = "Mauritania";
3720
	countryCodes.MS = "Montserrat";
3721
	countryCodes.MT = "Malta";
3722
	countryCodes.MU = "Mauritius";
3723
	countryCodes.MV = "Maldives";
3724
	countryCodes.MW = "Malawi";
3725
	countryCodes.MX = "Mexico";
3726
	countryCodes.MY = "Malaysia";
3727
	countryCodes.MZ = "Mozambique";
3728
	countryCodes.NA = "Namibia";
3729
	countryCodes.NC = "New Caledonia";
3730
	countryCodes.NE = "Niger";
3731
	countryCodes.NF = "Norfolk Island";
3732
	countryCodes.NG = "Nigeria";
3733
	countryCodes.NI = "Nicaragua";
3734
	countryCodes.NL = "Netherlands";
3735
	countryCodes.NO = "Norway";
3736
	countryCodes.NP = "Nepal";
3737
	countryCodes.NR = "Nauru";
3738
	countryCodes.NU = "Niue";
3739
	countryCodes.NZ = "New Zealand";
3740
	countryCodes.OM = "Oman";
3741
	countryCodes.PA = "Panama";
3742
	countryCodes.PE = "Peru";
3743
	countryCodes.PF = "French Polynesia Includes Tahiti";
3744
	countryCodes.PG = "Papua New Guinea";
3745
	countryCodes.PH = "Philippines";
3746
	countryCodes.PK = "Pakistan";
3747
	countryCodes.PL = "Poland";
3748
	countryCodes.PM = "Saint Pierre and Miquelon";
3749
	countryCodes.PN = "Pitcairn";
3750
	countryCodes.PR = "Puerto Rico";
3751
	countryCodes.PS = "Palestinian territory, Occupied";
3752
	countryCodes.PT = "Portugal";
3753
	countryCodes.PW = "Palau";
3754
	countryCodes.PY = "Paraguay";
3755
	countryCodes.QA = "Qatar";
3756
	countryCodes.QM = "Guernsey";
3757
	countryCodes.QN = "Jan Mayen";
3758
	countryCodes.QO = "Jersey";
3759
	countryCodes.RE = "Reunion";
3760
	countryCodes.RO = "Romania";
3761
	countryCodes.RS = "Serbia";
3762
	countryCodes.RU = "Russian Federation";
3763
	countryCodes.RW = "Rwanda";
3764
	countryCodes.SA = "Saudi Arabia";
3765
	countryCodes.SB = "Solomon Islands";
3766
	countryCodes.SC = "Seychelles";
3767
	countryCodes.SD = "Sudan";
3768
	countryCodes.SE = "Sweden";
3769
	countryCodes.SG = "Singapore";
3770
	countryCodes.SH = "Saint Helena";
3771
	countryCodes.SI = "Slovenia";
3772
	countryCodes.SJ = "Svalbard and Jan Mayen";
3773
	countryCodes.SK = "Slovakia";
3774
	countryCodes.SL = "Sierra Leone";
3775
	countryCodes.SM = "San Marino";
3776
	countryCodes.SN = "Senegal";
3777
	countryCodes.SO = "Somalia";
3778
	countryCodes.SR = "Suriname";
3779
	countryCodes.ST = "Sao Tome and Principe";
3780
	countryCodes.SV = "El Salvador";
3781
	countryCodes.SY = "Syrian Arab Republic";
3782
	countryCodes.SZ = "Swaziland";
3783
	countryCodes.TA = "Tristan da Cunha";
3784
	countryCodes.TC = "Turks and Caicos Islands";
3785
	countryCodes.TD = "Chad";
3786
	countryCodes.TF = "French Southern Territories";
3787
	countryCodes.TG = "Togo";
3788
	countryCodes.TH = "Thailand";
3789
	countryCodes.TJ = "Tajikistan";
3790
	countryCodes.TK = "Tokelau";
3791
	countryCodes.TM = "Turkmenistan";
3792
	countryCodes.TN = "Tunisia";
3793
	countryCodes.TO = "Tonga";
3794
	countryCodes.TR = "Turkey";
3795
	countryCodes.TT = "Trinidad and Tobago";
3796
	countryCodes.TV = "Tuvalu";
3797
	countryCodes.TW = "Taiwan, Province of China";
3798
	countryCodes.TZ = "Tanzania, United Republic of";
3799
	countryCodes.UA = "Ukraine";
3800
	countryCodes.UG = "Uganda";
3801
	countryCodes.UM = "United States Minor Outlying Islands";
3802
	countryCodes.US = "United States";
3803
	countryCodes.UY = "Uruguay";
3804
	countryCodes.UZ = "Uzbekistan";
3805
	countryCodes.VA = "Holy See (Vatican City state)";
3806
	countryCodes.VC = "Saint Vincent and the Grenadines";
3807
	countryCodes.VE = "Venezuela";
3808
	countryCodes.VG = "Virgin Islands, British";
3809
	countryCodes.VI = "Virgin Islands, US";
3810
	countryCodes.VN = "Vietnam";
3811
	countryCodes.VU = "Vanuatu";
3812
	countryCodes.WF = "Wallis and Futuna";
3813
	countryCodes.WS = "Samoa";
3814
	countryCodes.YE = "Yemen";
3815
	countryCodes.YT = "Mayotte";
3816
	countryCodes.ZA = "South Africa";
3817
	countryCodes.ZM = "Zambia";
3818
	countryCodes.ZW = "Zimbabwe";
3819
 
3820
	if (countryCodes[code] !== undefined) {
3821
		mappedCode = countryCodes[code];
3822
	}
3823
 
3824
	return mappedCode;
3825
}
3826
 
3827
var minActive = [0.0, 0.0, 0.0];
3828
var maxActive = [0.0, 0.0, 0.0];
3829
var avgActive = [0.0, 0.0, 0.0];
3830
var noActive = [0, 0, 0];
3831
var minSold = [0.0, 0.0, 0.0];
3832
var maxSold = [0.0, 0.0, 0.0];
3833
var avgSold = [0.0, 0.0, 0.0];
3834
var noSold = [0, 0, 0];
3835
var minUnsold = [0.0, 0.0, 0.0];
3836
var maxUnsold = [0.0, 0.0, 0.0];
3837
var avgUnsold = [0.0, 0.0, 0.0];
3838
var noUnsold = [0, 0, 0];
3839
var newActiveBreakdown = [];
3840
var usedActiveBreakdown = [];
3841
var newSoldBreakdown = [];
3842
var usedSoldBreakdown = [];
3843
 
3844
function getPricing() {
3845
	minActive = [0.0, 0.0, 0.0];
3846
	maxActive = [0.0, 0.0, 0.0];
3847
	avgActive = [0.0, 0.0, 0.0];
3848
	noActive = [0, 0, 0];
3849
	minSold = [0.0, 0.0, 0.0];
3850
	maxSold = [0.0, 0.0, 0.0];
3851
	avgSold = [0.0, 0.0, 0.0];
3852
	noSold = [0, 0, 0];
3853
	minUnsold = [0.0, 0.0, 0.0];
3854
	maxUnsold = [0.0, 0.0, 0.0];
3855
	avgUnsold = [0.0, 0.0, 0.0];
3856
	noUnsold = [0, 0, 0];
3857
	maxPricingPages = [-1, -1];
3858
	totalPricingEntries = [0, 0];
3859
	newActiveBreakdown = [];
3860
	usedActiveBreakdown = [];
3861
	newSoldBreakdown = [];
3862
	usedSoldBreakdown = [];
3863
 
3864
	getPricingData(0);
3865
	getPricingData(1);
3866
}
3867
 
3868
function getPricingData(searchIndex) {
3869
	var index = 0;
3870
	var keyword = document.getElementById('keyword').value;
3871
 
3872
	// Construct the request
3873
	var url = configeBayFinding + "?";
3874
	if (searchIndex === 0) {
3875
		if (keyword.includes("ReferenceID:")) {
3876
			url += "OPERATION-NAME=findItemsByProduct";
3877
		} else {
3878
			url += "OPERATION-NAME=findItemsAdvanced";
3879
		}
3880
	} else {
3881
		url += "OPERATION-NAME=findCompletedItems";
3882
	}
3883
	url += "&SECURITY-APPNAME=" + configAppid;
3884
	url += "&GLOBAL-ID=EBAY-US";
3885
	url += "&RESPONSE-DATA-FORMAT=JSON";
3886
	url += "&SERVICE-VERSION=" + configeBayFindingVersion;
3887
	url += "&REST-PAYLOAD";
3888
	if (keyword.length > 0) {
3889
		if (keyword.includes("ReferenceID:")) {
3890
			url += "&productId.@type=ReferenceID";
3891
			url += "&productId=";
3892
			url += keyword.substr(12);
3893
		} else {
3894
			url += "&keywords=";
3895
			url += encodeURIComponent(keyword.trim().replace(/ /g, "+"));
3896
		}
3897
	}
3898
 
3899
	var catNo = 0;
3900
	for (var categoryIndex = 1; categoryIndex < document.getElementById('category').options.length; categoryIndex++) {
3901
		if (document.getElementById('category').options[categoryIndex].selected) {
3902
			url += "&categoryId(" + catNo + ")=";
3903
			url += document.getElementById('category').options[categoryIndex].value;
3904
			++catNo;
3905
		}
3906
	}
3907
 
3908
	url += "&paginationInput.entriesPerPage=100";
3909
	url += "&paginationInput.pageNumber=";
3910
	url += (index + 1);
3911
	url += "&sortOrder=";
3912
	url += getSortOrder();
3913
	url += "&buyerPostalCode=";
3914
	url += configZip;
3915
	url += "&outputSelector(0)=SellerInfo&outputSelector(1)=StoreInfo";
3916
	if (document.getElementById('searchDescription').checked) {
3917
		url += "&descriptionSearch=true";
3918
	}
3919
 
3920
	url += urlfilter;
3921
 
3922
	var xhttp = new XMLHttpRequest();
3923
 
3924
	xhttp.onreadystatechange = function() {
170 - 3925
    	if (this.readyState == 4 && this.status == 200) {
2 - 3926
			if (searchIndex === 0) {
3927
				_cb_PriceActiveItems(JSON.parse(this.responseText));
3928
			} else {
3929
				_cb_PriceCompletedItems(JSON.parse(this.responseText));
3930
			}
3931
        }
3932
    };
3933
 
3934
	xhttp.open("GET", configProxyUrl, true);
3935
	xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
3936
   	xhttp.send();
3937
 
3938
	function waitForMaxPricingPages(i) {
3939
		if (maxPricingPages[i] < 0) {
3940
			window.setTimeout(waitForMaxPricingPages, 500, i); // wait 500 milliseconds
3941
		} else {
3942
			for (index = 1; index < maxPricingPages[searchIndex]; index++) {
3943
				// Construct the request
3944
				var url = configeBayFinding + "?";
3945
				if (searchIndex === 0) {
3946
					if (keyword.includes("ReferenceID:")) {
3947
						url += "OPERATION-NAME=findItemsByProduct";
3948
					} else {
3949
						url += "OPERATION-NAME=findItemsAdvanced";
3950
					}
3951
				} else {
3952
					url += "OPERATION-NAME=findCompletedItems";
3953
				}
3954
				url += "&SECURITY-APPNAME=" + configAppid;
3955
				url += "&GLOBAL-ID=EBAY-US";
3956
				url += "&RESPONSE-DATA-FORMAT=JSON";
3957
				url += "&SERVICE-VERSION=" + configeBayFindingVersion;
3958
				url += "&REST-PAYLOAD";
3959
				keyword = document.getElementById('keyword').value;
3960
				if (keyword.length > 0) {
3961
					if (keyword.includes("ReferenceID:")) {
3962
						url += "&productId.@type=ReferenceID";
3963
						url += "&productId=";
3964
						url += keyword.substr(12);
3965
					} else {
3966
						url += "&keywords=";
3967
						url += encodeURIComponent(keyword.trim().replace(/ /g, "+"));
3968
					}
3969
				}
3970
 
3971
				var catNo = 0;
3972
				for (var categoryIndex = 1; categoryIndex < document.getElementById('category').options.length; categoryIndex++) {
3973
					if (document.getElementById('category').options[categoryIndex].selected) {
3974
						url += "&categoryId(" + catNo + ")=";
3975
						url += document.getElementById('category').options[categoryIndex].value;
3976
						++catNo;
3977
					}
3978
				}
3979
 
3980
				url += "&paginationInput.entriesPerPage=100";
3981
				url += "&paginationInput.pageNumber=";
3982
				url += (index + 1);
3983
				url += "&sortOrder=";
3984
				url += getSortOrder();
3985
				url += "&buyerPostalCode=";
3986
				url += configZip;
3987
				url += "&outputSelector(0)=SellerInfo&outputSelector(1)=StoreInfo";
3988
				if (document.getElementById('searchDescription').checked) {
3989
					url += "&descriptionSearch=true";
3990
				}
3991
 
3992
				url += urlfilter;
3993
 
3994
				var xhttp = new XMLHttpRequest();
3995
 
3996
				xhttp.onreadystatechange = function() {
170 - 3997
			    	if (this.readyState == 4 && this.status == 200) {
2 - 3998
						if (searchIndex === 0) {
3999
							_cb_PriceActiveItems(JSON.parse(this.responseText));
4000
						} else {
4001
							_cb_PriceCompletedItems(JSON.parse(this.responseText));
4002
						}
4003
			        }
4004
			    };
4005
 
4006
				xhttp.open("GET", configProxyUrl, true);
4007
				xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
4008
			   	xhttp.send();			}
4009
		}
4010
	}
4011
 
4012
	waitForMaxPricingPages(searchIndex);
4013
}
4014
 
4015
function _cb_PriceActiveItems(objArray) {
4016
	var array;
4017
 
4018
	if (objArray.findItemsAdvancedResponse !== undefined) {
4019
		array = typeof objArray.findItemsAdvancedResponse[0] != 'object' ? JSON.parse(objArray.findItemsAdvancedResponse[0]) : objArray.findItemsAdvancedResponse[0].searchResult[0].item;
4020
		totalPricingEntries[0] = Number(objArray.findItemsAdvancedResponse[0].paginationOutput[0].totalEntries);
4021
	} else if (objArray.findItemsByProductResponse !== undefined) {
4022
		array = typeof objArray.findItemsByProductResponse[0] != 'object' ? JSON.parse(objArray.findItemsByProductResponse[0]) : objArray.findItemsByProductResponse[0].searchResult[0].item;
4023
		totalPricingEntries[0] = Number(objArray.findItemsByProductResponse[0].paginationOutput[0].totalEntries);
4024
	} else {
4025
		return;
4026
	}
4027
	//	var array = typeof objArray.findItemsAdvancedResponse[0] != 'object' ? JSON.parse(objArray.findItemsAdvancedResponse[0]) : objArray.findItemsAdvancedResponse[0].searchResult[0].item;
4028
	if (totalPricingEntries[0] > 0) {
4029
		priceItem(array, 0);
4030
	}
4031
}
4032
 
4033
function _cb_PriceCompletedItems(objArray) {
30 - 4034
//	var array = typeof objArray.findCompletedItemsResponse[0] != 'object' ? JSON.parse(objArray.findCompletedItemsResponse[0]) : objArray.findCompletedItemsResponse[0].searchResult[0].item;
4035
    var array;
4036
    if (objArray.findCompletedItemsResponse[0].searchResult !== undefined) {
4037
    	array = objArray.findCompletedItemsResponse[0].searchResult[0].item;
4038
 
4039
    	totalPricingEntries[1] = Number(objArray.findCompletedItemsResponse[0].paginationOutput[0].totalEntries);
4040
	    if (totalPricingEntries[1] > 0) {
4041
    		priceItem(array, 1);
4042
	    }
2 - 4043
	}
4044
}
4045
 
4046
function priceItem(array, index) {
4047
	var shippingCost = 0.0;
4048
	var itemCost = 0.0;
4049
	var totalCost = 0.0;
4050
	var totalCostInt = 0;
4051
	var sellingStatus;
4052
	var sellingState;
4053
	var bidCount;
4054
	var condInd;
4055
	var conditionId;
4056
 
4057
	if (totalPricingEntries[index] < 1) {
4058
		maxPricingPages[index] = 0;
4059
	} else {
4060
		maxPricingPages[index] = (totalPricingEntries[index] / 100) > 100 ? 100 : Math.trunc(totalPricingEntries[index] / 100.0) + 1;
4061
	}
4062
 
4063
	for (var i = 0; i < array.length; i++) {
4064
		var JsonObj = array[i];
4065
 
4066
		var shippingInfo = JsonObj.shippingInfo;
4067
		var shippingServiceCost = shippingInfo[0].shippingServiceCost;
4068
		if (shippingServiceCost) {
4069
			shippingCost = Number(shippingServiceCost[0].__value__);
4070
		} else {
4071
			shippingCost = 0.0;
4072
		}
4073
 
4074
		sellingStatus = JsonObj.sellingStatus;
4075
		sellingState = sellingStatus[0].sellingState;
4076
		bidCount = sellingStatus[0].bidCount;
4077
		var convertedCurrentPrice = sellingStatus[0].convertedCurrentPrice;
4078
		itemCost = Number(convertedCurrentPrice[0].__value__);
4079
 
4080
		var listingInfo = JsonObj.listingInfo;
4081
		var convertedBuyItNowPrice = listingInfo[0].convertedBuyItNowPrice;
4082
		if (bidCount === 0 && convertedBuyItNowPrice) {
4083
			itemCost = Number(convertedBuyItNowPrice[0].__value__);
4084
		}
4085
 
4086
		var condition = JsonObj.condition;
4087
		if (condition) {
4088
			conditionId = condition[0].conditionId;
4089
			if (conditionId == 1000 || conditionId == 1500 || conditionId == 2750) {
4090
				condInd = 1;
4091
			} else {
4092
				condInd = 2;
4093
			}
4094
		} else {
4095
			condInd = 2;
4096
		}
4097
 
4098
		totalCost = itemCost + shippingCost;
4099
		totalCostInt = Math.ceil(totalCost);
4100
 
4101
		if (sellingState == "Active") {
4102
			if (totalCost < minActive[0] || !minActive[0]) {
4103
				minActive[0] = totalCost;
4104
			}
4105
			if (totalCost > maxActive[0]) {
4106
				maxActive[0] = totalCost;
4107
			}
4108
			avgActive[0] += totalCost;
4109
			++noActive[0];
4110
 
4111
			if (totalCost < minActive[condInd] || !minActive[condInd]) {
4112
				minActive[condInd] = totalCost;
4113
			}
4114
			if (totalCost > maxActive[condInd]) {
4115
				maxActive[condInd] = totalCost;
4116
			}
4117
			avgActive[condInd] += totalCost;
4118
			++noActive[condInd];
4119
 
4120
			if (condInd == 1) {
4121
				if (newActiveBreakdown[totalCostInt] === undefined) {
4122
					newActiveBreakdown[totalCostInt] = 0;
4123
				}
4124
				++newActiveBreakdown[totalCostInt];
4125
			} else {
4126
				if (usedActiveBreakdown[totalCostInt] === undefined) {
4127
					usedActiveBreakdown[totalCostInt] = 0;
4128
				}
4129
				++usedActiveBreakdown[totalCostInt];
4130
			}
4131
		} else if (sellingState == "EndedWithSales") {
4132
			if (totalCost < minSold[0] || !minSold[0]) {
4133
				minSold[0] = totalCost;
4134
			}
4135
			if (totalCost > maxSold[0]) {
4136
				maxSold[0] = totalCost;
4137
			}
4138
			avgSold[0] += totalCost;
4139
			++noSold[0];
4140
 
4141
			if (totalCost < minSold[condInd] || !minSold[condInd]) {
4142
				minSold[condInd] = totalCost;
4143
			}
4144
			if (totalCost > maxSold[condInd]) {
4145
				maxSold[condInd] = totalCost;
4146
			}
4147
			avgSold[condInd] += totalCost;
4148
			++noSold[condInd];
4149
 
4150
			if (condInd == 1) {
4151
				if (newSoldBreakdown[totalCostInt] === undefined) {
4152
					newSoldBreakdown[totalCostInt] = 0;
4153
				}
4154
				++newSoldBreakdown[totalCostInt];
4155
			} else {
4156
				if (usedSoldBreakdown[totalCostInt] === undefined) {
4157
					usedSoldBreakdown[totalCostInt] = 0;
4158
				}
4159
				++usedSoldBreakdown[totalCostInt];
4160
			}
4161
		} else {
4162
			if (totalCost < minUnsold[0] || !minUnsold[0]) {
4163
				minUnsold[0] = totalCost;
4164
			}
4165
			if (totalCost > maxUnsold[0]) {
4166
				maxUnsold[0] = totalCost;
4167
			}
4168
			avgUnsold[0] += totalCost;
4169
			++noUnsold[0];
4170
 
4171
			if (totalCost < minUnsold[condInd] || !minUnsold[condInd]) {
4172
				minUnsold[condInd] = totalCost;
4173
			}
4174
			if (totalCost > maxUnsold[condInd]) {
4175
				maxUnsold[condInd] = totalCost;
4176
			}
4177
			avgUnsold[condInd] += totalCost;
4178
			++noUnsold[condInd];
4179
		}
4180
	}
4181
 
4182
	var x = document.getElementById("prices");
30 - 4183
	x.className = x.className.replace(" invisible", " visible");
2 - 4184
 
4185
	var str = '<h2>Pricing Information (Shipping included)</h2>';
30 - 4186
	str += '<table class="table table-striped table-bordered">';
4187
	str += '  <thead class="thead-dark">';
2 - 4188
	str += '	<tr>';
4189
	str += '		<th></th>';
4190
	str += '		<th>Number</th>';
4191
	str += '        <th>Minimum</th>';
4192
	str += '        <th>Maximum</th>';
4193
	str += '        <th>Average</th>';
4194
	str += '	</tr>';
30 - 4195
	str += '  </thead>';
4196
	str += '  <tbody>';
2 - 4197
	str += '	<tr>';
4198
	str += '		<td>Active</td>';
4199
	str += '		<td>' + noActive[0] + '<br/>' + noActive[1] + ' / ' + noActive[2] + '</td>';
4200
	str += '		<td>$' + Number(minActive[0]).toFixed(2) + '<br/>$' + Number(minActive[1]).toFixed(2) + ' / $' + Number(minActive[2]).toFixed(2) + '</td>';
4201
	str += '		<td>$' + Number(maxActive[0]).toFixed(2) + '<br/>$' + Number(maxActive[1]).toFixed(2) + ' / $' + Number(maxActive[2]).toFixed(2) + '</td>';
4202
	str += '		<td>';
4203
	if (noActive[0]) {
4204
		str += '$' + Number(avgActive[0] / noActive[0]).toFixed(2);
4205
		str += '<br/>$' + (noActive[1] > 0 ? Number(avgActive[1] / noActive[1]).toFixed(2) : 0.00);
4206
		str += ' / $' + (noActive[2] > 0 ? Number(avgActive[2] / noActive[2]).toFixed(2) : 0.00);
4207
	}
30 - 4208
	str += '        </td>';
2 - 4209
	str += '	</tr>';
4210
 
4211
	str += '<tr><td colspan="5">';
4212
	str += '<canvas id="activeChart"></canvas>';
4213
	str += '</td></tr>';
4214
 
4215
	str += '	<tr>';
4216
	str += '		<td>Sold</td>';
4217
	str += '		<td>' + noSold[0] + '<br/>' + noSold[1] + ' / ' + noSold[2] + '</td>';
4218
	str += '		<td>$' + Number(minSold[0]).toFixed(2) + '<br/>$' + Number(minSold[1]).toFixed(2) + ' / $' + Number(minSold[2]).toFixed(2) + '</td>';
4219
	str += '		<td>$' + Number(maxSold[0]).toFixed(2) + '<br/>$' + Number(maxSold[1]).toFixed(2) + ' / $' + Number(maxSold[2]).toFixed(2) + '</td>';
4220
	str += '		<td>';
4221
	if (noSold[0]) {
4222
		str += '$' + Number(avgSold[0] / noSold[0]).toFixed(2);
4223
		str += '<br/>$' + (noSold[1] > 0 ? Number(avgSold[1] / noSold[1]).toFixed(2) : 0.00);
4224
		str += ' / $' + (noSold[2] > 0 ? Number(avgSold[2] / noSold[2]).toFixed(2) : 0.00);
4225
	}
30 - 4226
	str += '        </td>';
2 - 4227
	str += '	</tr>';
4228
 
4229
	str += '<tr><td colspan="5">';
4230
	str += '<canvas id="soldChart"></canvas>';
4231
	str += '</td></tr>';
4232
 
4233
	str += '	<tr>';
4234
	str += '		<td>Unsold</td>';
4235
	str += '		<td>' + noUnsold[0] + '<br/>' + noUnsold[1] + ' / ' + noUnsold[2] + '</td>';
4236
	str += '		<td>$' + Number(minUnsold[0]).toFixed(2) + '<br/>$' + Number(minUnsold[1]).toFixed(2) + ' / $' + Number(minUnsold[2]).toFixed(2) + '</td>';
4237
	str += '		<td>$' + Number(maxUnsold[0]).toFixed(2) + '<br/>$' + Number(maxUnsold[1]).toFixed(2) + ' / $' + Number(maxUnsold[2]).toFixed(2) + '</td>';
4238
	str += '		<td>';
4239
	if (noUnsold[0]) {
4240
		str += '$' + Number(avgUnsold[0] / noUnsold[0]).toFixed(2);
4241
		str += '<br/>$' + (noUnsold[1] > 0 ? Number(avgUnsold[1] / noUnsold[1]).toFixed(2) : 0.00);
4242
		str += ' / $' + (noUnsold[2] > 0 ? Number(avgUnsold[2] / noUnsold[2]).toFixed(2) : 0.00);
4243
	}
30 - 4244
	str += '        </td>';
2 - 4245
	str += '	</tr>';
30 - 4246
	str += '  </tbody>';
2 - 4247
	str += '</table>';
4248
 
4249
	x.innerHTML = str;
4250
 
4251
	pricingGraphs(0, usedActiveBreakdown, newActiveBreakdown);
4252
	pricingGraphs(1, usedSoldBreakdown, newSoldBreakdown);
4253
}
4254
 
4255
function pricingGraphs(index, usedBreakdown, newBreakdown) {
4256
	var i;
4257
	var newData = [];
4258
	var usedData = [];
4259
	var labelData = [];
4260
	var ctx = document.getElementById(index === 0 ? 'activeChart' : 'soldChart').getContext('2d');
4261
	var min = findMin(usedBreakdown, newBreakdown);
4262
	var max = findMax(usedBreakdown, newBreakdown);
4263
 
4264
	for (i = min; i < max; i++) {
4265
		labelData.push('<$' + i);
4266
 
4267
		if (usedBreakdown[i] === undefined) {
4268
			usedData.push(0);
4269
		} else {
4270
			usedData.push(usedBreakdown[i]);
4271
		}
4272
 
4273
		if (newBreakdown[i] === undefined) {
4274
			newData.push(0);
4275
		} else {
4276
			newData.push(newBreakdown[i]);
4277
		}
4278
	}
4279
 
4280
	var myChart = new Chart(ctx, {
4281
	  type: 'bar',
4282
	  options: {
4283
	    scales: {
4284
	        yAxes: [{
4285
	            ticks: {
4286
	                fixedStepSize: 1
4287
	            }
4288
	        }],
4289
	    },
4290
	  },
4291
	  data: {
4292
    	labels: labelData,
4293
	    datasets: [{
4294
    	  label: 'Used',
4295
		  data: usedData,
4296
    	  backgroundColor: "rgba(0,102,0,1)"
4297
	    }, {
4298
    	  label: 'New',
4299
	      data: newData,
4300
    	  backgroundColor: "rgba(204,0,0,1)"
4301
	    }]
4302
	  }
4303
	});
4304
}
4305
 
4306
function findMin(Used, New) {
4307
	var i;
4308
	var minUsed = 0, minNew = 0;
4309
	var min = 0;
4310
 
4311
	for (i = 0; i < Used.length; i++) {
4312
		if (Used[i] !== undefined) {
4313
			minUsed = i;
4314
			break;
4315
		}
4316
	}
4317
 
4318
	for (i = 0; i < New.length; i++) {
4319
		if (New[i] !== undefined) {
4320
			minNew = i;
4321
			break;
4322
		}
4323
	}
4324
 
4325
	if (minUsed > 0 && minUsed <= minNew) {
4326
		min = minUsed;
4327
	} else if (minNew > 0 && minNew <= minUsed) {
4328
		min = minNew;
4329
	}
4330
 
4331
	return min;
4332
}
4333
 
4334
function findMax(Used, New) {
4335
	var max = 0;
4336
 
4337
	if (Used.length >= New.length) {
4338
		max = Used.length;
4339
	} else if (New.length >= Used.length) {
4340
		max = New.length;
4341
	}
4342
 
4343
	return max;
4344
}
4345
 
4346
function _cb_findDuplicateListing(root) {
4347
	var x;
4348
	var txt;
4349
	var response = root.findItemsAdvancedResponse[0];
4350
	var ack = response.ack;
4351
	if (ack != 'Success') {
4352
		if (ack == 'Failure' || ack == 'PartialFailure') {
4353
			return;
4354
		}
4355
	}
4356
 
4357
	var items = response.searchResult[0].item || [];
4358
 
4359
	if (Number(response.paginationOutput[0].totalEntries) > 0) {
30 - 4360
		var txt = '<p class="bg-danger"><strong>Duplicate, see Item Id <a href="https://www.ebay.com/itm/' + items[0].itemId + '" target="_blank">' + items[0].itemId + '</a></strong></p>';
7 - 4361
		document.getElementById("duplicatesText").innerHTML += txt;
4362
		x = document.getElementById("duplicates");
30 - 4363
    	x.className = x.className.replace(" invisible", " visible");
2 - 4364
	}
4365
}
4366
 
4367
function findDuplicateListing() {
4368
	var keywordURL;
4369
	var keyword = document.getElementById('keyword').value;
4370
 
4371
	// Construct the request
4372
	url = configeBayFinding + "?";
4373
	url += "OPERATION-NAME=findItemsAdvanced";
4374
	url += "&SERVICE-VERSION=" + configeBayFindingVersion;
4375
	url += "&SECURITY-APPNAME=" + configAppid;
4376
	url += "&GLOBAL-ID=EBAY-US";
4377
	url += "&RESPONSE-DATA-FORMAT=JSON";
4378
	url += "&REST-PAYLOAD";
4379
 
4380
	if (keyword.length > 0) {
4381
		if (keyword.includes("ReferenceID:")) {
4382
			url += "&productId.@type=ReferenceID";
4383
			url += "&productId=";
4384
			url += keyword.substr(12);
4385
		} else {
4386
			url += "&keywords=";
4387
			url += encodeURIComponent(keyword.trim().replace(/ /g, "+"));
4388
		}
4389
	}
4390
 
4391
	url += "&paginationInput.entriesPerPage=1";
4392
	url += "&paginationInput.pageNumber=1";
4393
	url += "&itemFilter(0).name=Seller";
4394
	url += "&itemFilter(0).value=";
4395
	url += configeBaySellerName;
4396
	url += "&outputSelector=SellerInfo";
4397
 
4398
	// Submit the request
4399
	var xhttp = new XMLHttpRequest();
4400
 
4401
	xhttp.onreadystatechange = function() {
170 - 4402
    	if (this.readyState == 4 && this.status == 200) {
2 - 4403
    		_cb_findDuplicateListing(JSON.parse(this.responseText));
4404
        }
4405
    };
4406
 
4407
	xhttp.open("GET", configProxyUrl, true);
4408
	xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
4409
   	xhttp.send();
4410
}
4411
 
4412
function _cb_findPotentialDuplicateListing(root) {
4413
	var x;
4414
	var response = root.findCompletedItemsResponse[0];
4415
	var ack = response.ack;
4416
	if (ack != 'Success') {
4417
		if (ack == 'Failure' || ack == 'PartialFailure') {
4418
			return;
4419
		}
4420
	}
4421
 
4422
	var items = response.searchResult[0].item || [];
4423
 
4424
	if (Number(response.paginationOutput[0].totalEntries) > 0) {
30 - 4425
		var txt = '<p class="bg-warning"><strong>Potential Duplicate, see Item Id <a href="https://www.ebay.com/itm/' + items[0].itemId + '" target="_blank">' + items[0].itemId + '</a></strong></p>';
7 - 4426
		document.getElementById("duplicatesText").innerHTML += txt;
4427
		x = document.getElementById("duplicates");
30 - 4428
    	x.className = x.className.replace(" invisible", " visible");
2 - 4429
	}
4430
}
4431
 
4432
function findPotentialDuplicateListing() {
4433
	var keywordURL;
4434
	var keyword = document.getElementById('keyword').value;
4435
 
4436
	// Construct the request
4437
	url = configeBayFinding + "?";
4438
	url += "OPERATION-NAME=findCompletedItems";
4439
	url += "&SERVICE-VERSION=" + configeBayFindingVersion;
4440
	url += "&SECURITY-APPNAME=" + configAppid;
4441
	url += "&GLOBAL-ID=EBAY-US";
4442
	url += "&RESPONSE-DATA-FORMAT=JSON";
4443
	url += "&REST-PAYLOAD";
4444
	url += "&keywords=";
4445
	url += encodeURIComponent(keyword.trim().replace(/ /g, "+"));
4446
	url += "&paginationInput.entriesPerPage=1";
4447
	url += "&paginationInput.pageNumber=1";
4448
	url += "&itemFilter(0).name=Seller";
4449
	url += "&itemFilter(0).value=";
4450
	url += configeBaySellerName;
4451
	url += "&outputSelector=SellerInfo";
4452
 
4453
	var xhttp = new XMLHttpRequest();
4454
 
4455
	xhttp.onreadystatechange = function() {
170 - 4456
    	if (this.readyState == 4 && this.status == 200) {
2 - 4457
    		_cb_findPotentialDuplicateListing(JSON.parse(this.responseText));
4458
        }
4459
    };
4460
 
4461
	xhttp.open("GET", configProxyUrl, true);
4462
	xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
4463
   	xhttp.send();
4464
}
4465
 
7 - 4466
function findShopifyDuplicateListing() { // Barcode Search Only
2 - 4467
	var handle;
4468
	var xhttp = new XMLHttpRequest();
4469
	xhttp.onreadystatechange = function() {
4470
		if (this.readyState == 4 && this.status == 200) {
4471
			//window.alert(this.responseText);
4472
			var json = JSON.parse(this.responseText);
4473
			if (json.products[0] !== undefined) {
7 - 4474
			    var sku = getJsonValue(json.products[0].variants[0].sku);
30 - 4475
				var txt = '<p class="bg-warning"><strong>Potential Duplicate, see Shopify Item Id <a href="https://munatrading.com/products/b' + handle + '" target="_blank">' + handle + '</a> (SKU=' + sku + ')</strong></p>';
7 - 4476
				document.getElementById("duplicatesText").innerHTML += txt;
4477
        		x = document.getElementById("duplicates");
30 - 4478
            	x.className = x.className.replace(" invisible", " visible");
2 - 4479
			}
4480
		}
4481
	};
4482
 
4483
	handle = parseInt(document.getElementById('keyword').value, 10);
4484
 
4485
	xhttp.open("GET", configProxyUrl, true);
144 - 4486
	xhttp.setRequestHeader("X-Proxy-Url", encodeURI(configShopifyUrl + configShopifyProductsUrl + '?limit=1&handle=b' + handle + '&fields=id,variants'));
2 - 4487
	xhttp.send();
4488
}
4489
 
53 - 4490
function checkBarcode() {
30 - 4491
    var x = document.getElementById("keyword");
4492
    x.focus();
4493
 
53 - 4494
    var validator = new Barcoder();
4495
    var validation = validator.validate(document.getElementById("keyword").value.trim());
4496
 
4497
    if (validation.isValid) {
4498
        document.getElementById("recommendation").innerHTML = 'Valid ' + validation.possibleType + ' Code';
30 - 4499
        document.getElementById("recommendation").className = 'text-success';
53 - 4500
    } else if (validation.possibleType == "GTIN11") {
4501
        var res = calculateGtin12Res(document.getElementById("keyword").value);
4502
        document.getElementById("keyword").value += res;
4503
        document.getElementById("recommendation").innerHTML = 'Finalized GTIN12 Code';
4504
        document.getElementById("recommendation").className = 'text-warning';
6 - 4505
    } else {
53 - 4506
        document.getElementById("recommendation").innerHTML = 'Invalid Barcode';
4507
        document.getElementById("recommendation").className = 'text-danger';
6 - 4508
    }
4509
}
4510
 
2 - 4511
    </script>
4512
 
4513
    <script src="js/chosen.jquery.min.js"></script>
4514
    <script src="js/chosen.init.js"></script>
30 - 4515
    <script>includeHTML();</script>
2 - 4516
</body>
4517
</html>