Subversion Repositories munaweb

Rev

Details | Last modification | View Log | RSS feed

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