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
 
19 - 1159
        <div id="warnings" class="container-fluid invisible"></div>
10 - 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">
17 - 1184
            <div w3-include-html="php/footer.php"></div>
10 - 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");
19 - 1505
    var str;
10 - 1506
 
19 - 1507
    str = '<div class="alert alert-danger alert-dismissible">';
1508
    str += '<button type="button" class="close" data-dismiss="alert">×</button>';
1509
    str += "<h2>eBay API Error</h2>";
1510
    str += "<ul>"
1511
	str += "<li>Id: " + root.errorMessage[0].error[0].errorId + "</li>";
1512
	str += "<li>Domain: " + root.errorMessage[0].error[0].domain + "</li>";
1513
	str += "<li>Severity: " + root.errorMessage[0].error[0].severity + "</li>";
1514
	str += "<li>Category: " + root.errorMessage[0].error[0].category + "</li>";
1515
	str += "<li>Message: " + root.errorMessage[0].error[0].message + "</li>";
1516
	str += "<li>Subdomain: " + root.errorMessage[0].error[0].subdomain + "</li>";
1517
	str += "<li>Parameter: " + root.errorMessage[0].error[0].parameter + "</li>";
1518
    str += "</ul>"
1519
	str += "<p>URL: " + "<a href=\"" + url + "\" target=\"_blank\">" + url + "</a>" + "</p>";
1520
    str += '</div>';
1521
 
1522
	x.innerHTML = str;
10 - 1523
	x.className = x.className.replace(" invisible", " visible");
1524
 
1525
	if (root.ack == 'Failure' || root.ack == 'PartialFailure') {
1526
		x.scrollIntoView(true);
1527
	}
19 - 1528
 
1529
    document.getElementById("searchForm").style.opacity = "1.0";
1530
	document.getElementById("results").innerHTML = "";
10 - 1531
}
1532
 
1533
// item filters for request
1534
var filterarray = [];
1535
 
1536
// Fill the array of item filters from input form
1537
function fillFilterArray() {
1538
	var value = "";
1539
	var listingType = [];
1540
	var conditions = [];
1541
	var obj = [{
1542
		"name": "",
1543
		"value": "",
1544
		"paramName": "",
1545
		"paramValue": ""
1546
	}];
1547
 
1548
	filterarray = [{
1549
		"name": "AvailableTo",
1550
		"value": "US",
1551
		"paramName": "",
1552
		"paramValue": ""
1553
	}];
1554
 
1555
	value = document.getElementById('sellerName').value;
1556
	if (value) {
1557
		obj = {
1558
			"name": "Seller",
1559
			"value": value,
1560
			"paramName": "",
1561
			"paramValue": ""
1562
		};
1563
		filterarray.push(obj);
1564
	}
1565
 
1566
	value = document.getElementById('minPrice').value;
1567
	if (value > 0) {
1568
		obj = {
1569
			"name": "MinPrice",
1570
			"value": Number(value).toFixed(2),
1571
			"paramName": "Currency",
1572
			"paramValue": "USD"
1573
		};
1574
		filterarray.push(obj);
1575
	}
1576
 
1577
	value = document.getElementById('maxPrice').value;
1578
	if (value > 0) {
1579
		obj = {
1580
			"name": "MaxPrice",
1581
			"value": Number(value).toFixed(2),
1582
			"paramName": "Currency",
1583
			"paramValue": "USD"
1584
		};
1585
		filterarray.push(obj);
1586
	}
1587
 
1588
	value = document.getElementById('minBids').value;
1589
	if (value > 0) {
1590
		obj = {
1591
			"name": "MinBids",
1592
			"value": Number(value).toFixed(0),
1593
			"paramName": "",
1594
			"paramValue": ""
1595
		};
1596
		filterarray.push(obj);
1597
	}
1598
 
1599
	value = document.getElementById('maxBids').value;
1600
	if (value && value >= 0) {
1601
		obj = {
1602
			"name": "MaxBids",
1603
			"value": Number(value).toFixed(0),
1604
			"paramName": "",
1605
			"paramValue": ""
1606
		};
1607
		filterarray.push(obj);
1608
	}
1609
 
1610
	value = document.getElementById('minFeedback').value;
1611
	if (value > 0) {
1612
		obj = {
1613
			"name": "FeedbackScoreMin",
1614
			"value": Number(value).toFixed(0),
1615
			"paramName": "",
1616
			"paramValue": ""
1617
		};
1618
		filterarray.push(obj);
1619
	}
1620
 
1621
	value = document.getElementById('maxFeedback').value;
1622
	if (value && value >= 0) {
1623
		obj = {
1624
			"name": "FeedbackScoreMax",
1625
			"value": Number(value).toFixed(0),
1626
			"paramName": "",
1627
			"paramValue": ""
1628
		};
1629
		filterarray.push(obj);
1630
	}
1631
 
1632
	value = document.getElementById('minQuantity').value;
1633
	if (value > 0) {
1634
		obj = {
1635
			"name": "MinQuantity",
1636
			"value": Number(value).toFixed(0),
1637
			"paramName": "",
1638
			"paramValue": ""
1639
		};
1640
		filterarray.push(obj);
1641
	}
1642
 
1643
	value = document.getElementById('maxQuantity').value;
1644
	if (value && value >= 0) {
1645
		obj = {
1646
			"name": "MaxQuantity",
1647
			"value": Number(value).toFixed(0),
1648
			"paramName": "",
1649
			"paramValue": ""
1650
		};
1651
		filterarray.push(obj);
1652
	}
1653
 
1654
	if (document.getElementById('freeShippingOnly').checked) {
1655
		obj = {
1656
			"name": "FreeShippingOnly",
1657
			"value": "true",
1658
			"paramName": "",
1659
			"paramValue": ""
1660
		};
1661
		filterarray.push(obj);
1662
	}
1663
 
1664
	if (document.getElementById('bestOfferOnly').checked) {
1665
		obj = {
1666
			"name": "BestOfferOnly",
1667
			"value": "true",
1668
			"paramName": "",
1669
			"paramValue": ""
1670
		};
1671
		filterarray.push(obj);
1672
	}
1673
 
1674
	if (document.getElementById('lotsOnly').checked) {
1675
		obj = {
1676
			"name": "LotsOnly",
1677
			"value": "true",
1678
			"paramName": "",
1679
			"paramValue": ""
1680
		};
1681
		filterarray.push(obj);
1682
	}
1683
 
1684
	if (document.getElementById('hideDuplicateItems').checked) {
1685
		obj = {
1686
			"name": "HideDuplicateItems",
1687
			"value": "true",
1688
			"paramName": "",
1689
			"paramValue": ""
1690
		};
1691
		filterarray.push(obj);
1692
	}
1693
 
1694
	if (document.getElementById('outletSellerOnly').checked) {
1695
		obj = {
1696
			"name": "OutletSellerOnly",
1697
			"value": "true",
1698
			"paramName": "",
1699
			"paramValue": ""
1700
		};
1701
		filterarray.push(obj);
1702
	}
1703
 
1704
	if (document.getElementById('soldOnly').checked) {
1705
		obj = {
1706
			"name": "SoldOnly",
1707
			"value": "true",
1708
			"paramName": "",
1709
			"paramValue": ""
1710
		};
1711
		filterarray.push(obj);
1712
	}
1713
 
1714
	if (document.getElementById('localPickupOnly').checked) {
1715
		obj = {
1716
			"name": "LocalPickupOnly",
1717
			"value": "true",
1718
			"paramName": "",
1719
			"paramValue": ""
1720
		};
1721
		filterarray.push(obj);
1722
	}
1723
 
1724
	if (document.getElementById('localSearchOnly').checked) {
1725
		obj = {
1726
			"name": "LocalSearchOnly",
1727
			"value": "true",
1728
			"paramName": "",
1729
			"paramValue": ""
1730
		};
1731
		filterarray.push(obj);
1732
 
1733
		value = document.getElementById('maxDistance').value;
1734
		if (value && value >= 0) {
1735
			obj = {
1736
				"name": "MaxDistance",
1737
				"value": Number(value).toFixed(0),
1738
				"paramName": "",
1739
				"paramValue": ""
1740
			};
1741
			filterarray.push(obj);
1742
		}
1743
	}
1744
 
1745
	if (document.getElementById('ltAll').checked) {
1746
		listingType.push("All");
1747
	}
1748
 
1749
	if (document.getElementById('ltAuction').checked) {
1750
		listingType.push("Auction");
1751
	}
1752
 
1753
	if (document.getElementById('ltAuctionWithBIN').checked) {
1754
		listingType.push("AuctionWithBIN");
1755
	}
1756
 
1757
	if (document.getElementById('ltClassified').checked) {
1758
		listingType.push("Classified");
1759
	}
1760
 
1761
	if (document.getElementById('ltFixedPrice').checked) {
1762
		listingType.push("FixedPrice");
1763
	}
1764
 
1765
	if (document.getElementById('ltStoreInventory').checked) {
1766
		listingType.push("StoreInventory");
1767
	}
1768
 
1769
	if (listingType.length) {
1770
		obj = {
1771
			"name": "ListingType",
1772
			"value": listingType,
1773
			"paramName": "",
1774
			"paramValue": ""
1775
		};
1776
		filterarray.push(obj);
1777
	}
1778
 
1779
	if (document.getElementById('condNew').checked) {
1780
		conditions.push("New");
1781
	}
1782
 
1783
	if (document.getElementById('condUsed').checked) {
1784
		conditions.push("Used");
1785
	}
1786
 
1787
	if (document.getElementById('condUnspecified').checked) {
1788
		conditions.push("Unspecified");
1789
	}
1790
 
1791
	if (document.getElementById('cond1000').checked) {
1792
		conditions.push("1000");
1793
	}
1794
 
1795
	if (document.getElementById('cond1500').checked) {
1796
		conditions.push("1500");
1797
	}
1798
 
1799
	if (document.getElementById('cond1750').checked) {
1800
		conditions.push("1750");
1801
	}
1802
 
1803
	if (document.getElementById('cond2000').checked) {
1804
		conditions.push("2000");
1805
	}
1806
 
1807
	if (document.getElementById('cond2500').checked) {
1808
		conditions.push("2500");
1809
	}
1810
 
1811
	if (document.getElementById('cond2750').checked) {
1812
		conditions.push("2750");
1813
	}
1814
 
1815
	if (document.getElementById('cond3000').checked) {
1816
		conditions.push("3000");
1817
	}
1818
 
1819
	if (document.getElementById('cond4000').checked) {
1820
		conditions.push("4000");
1821
	}
1822
 
1823
	if (document.getElementById('cond5000').checked) {
1824
		conditions.push("5000");
1825
	}
1826
 
1827
	if (document.getElementById('cond6000').checked) {
1828
		conditions.push("6000");
1829
	}
1830
 
1831
	if (document.getElementById('cond7000').checked) {
1832
		conditions.push("7000");
1833
	}
1834
 
1835
	if (conditions.length) {
1836
		obj = {
1837
			"name": "Condition",
1838
			"value": conditions,
1839
			"paramName": "",
1840
			"paramValue": ""
1841
		};
1842
		filterarray.push(obj);
1843
	}
1844
 
1845
	if (document.getElementById('locatedIn').options[0].selected) {
1846
		obj = {
1847
			"name": "LocatedIn",
1848
			"value": document.getElementById('locatedIn').options[0].value,
1849
			"paramName": "",
1850
			"paramValue": ""
1851
		};
1852
		filterarray.push(obj);
1853
	} else {
1854
		obj = {
1855
			"name": "LocatedIn",
1856
			"value": document.getElementById('locatedIn').options[1].value,
1857
			"paramName": "",
1858
			"paramValue": ""
1859
		};
1860
		filterarray.push(obj);
1861
	}
1862
 
1863
	if (valueStartMin) {
1864
		obj = {
1865
			"name": "StartTimeFrom",
1866
			"value": valueStartMin,
1867
			"paramName": "",
1868
			"paramValue": ""
1869
		};
1870
		filterarray.push(obj);
1871
	}
1872
 
1873
	if (valueStartMax) {
1874
		obj = {
1875
			"name": "StartTimeTo",
1876
			"value": valueStartMax,
1877
			"paramName": "",
1878
			"paramValue": ""
1879
		};
1880
		filterarray.push(obj);
1881
	}
1882
 
1883
	if (valueEndMin) {
1884
		obj = {
1885
			"name": "EndTimeFrom",
1886
			"value": valueEndMin,
1887
			"paramName": "",
1888
			"paramValue": ""
1889
		};
1890
		filterarray.push(obj);
1891
	}
1892
 
1893
	if (valueEndMax) {
1894
		obj = {
1895
			"name": "EndTimeTo",
1896
			"value": valueEndMax,
1897
			"paramName": "",
1898
			"paramValue": ""
1899
		};
1900
		filterarray.push(obj);
1901
	}
1902
}
1903
 
1904
// Check the item filter parameters from input form
1905
function checkFilterArray() {
1906
	var x = document.getElementById("warnings");
1907
	var warnings = 0;
1908
	var value = "";
1909
	var value2 = "";
1910
	var valueMin = 0;
1911
	var valueMax = 0;
1912
	var html = [];
1913
	var categoryCounter = 0;
1914
 
1915
	x.innerHTML = "";
1916
 
1917
	value = document.getElementById('keyword').value;
1918
	value2 = document.getElementById('sellerName').value;
1919
	for (var categoryIndex = 1; categoryIndex < document.getElementById('category').options.length; categoryIndex++) {
1920
		if (document.getElementById('category').options[categoryIndex].selected) {
1921
			categoryCounter++;
1922
		}
1923
	}
1924
 
1925
	if (!value && !value2 && !categoryCounter) {
1926
		warnings++;
19 - 1927
		html.push(alertStyle("No Keyword, Category or Seller Name specified"));
10 - 1928
	}
1929
 
1930
	if (categoryCounter > 3) {
1931
		warnings++;
19 - 1932
		html.push(alertStyle("Only up to 3 categories allowed"));
10 - 1933
	}
1934
 
1935
	valueMin = document.getElementById('minPrice').value;
1936
	valueMax = document.getElementById('maxPrice').value;
1937
 
1938
	if (valueMin && valueMin < 0) {
1939
		warnings++;
19 - 1940
		html.push(alertStyle("Minimum Price under $0"));
10 - 1941
	}
1942
 
1943
	if (valueMax && valueMax <= 0) {
1944
		warnings++;
19 - 1945
		html.push(alertStyle("Maximum Price at or under $0"));
10 - 1946
	}
1947
 
1948
	if (valueMin && valueMax) {
1949
		if (Number(valueMin) > Number(valueMax)) {
1950
			warnings++;
19 - 1951
			html.push(alertStyle("Minimum Price " + Number(valueMin).toFixed(0) + " greater than Maximum Price " + Number(valueMax).toFixed(0)));
10 - 1952
		}
1953
	}
1954
 
1955
	valueMin = document.getElementById('minBids').value;
1956
	valueMax = document.getElementById('maxBids').value;
1957
 
1958
	if (valueMin && valueMin < 0) {
1959
		warnings++;
19 - 1960
		html.push(alertStyle("Minimum Bids under 0"));
10 - 1961
	}
1962
 
1963
	if (valueMax && valueMax < 0) {
1964
		warnings++;
19 - 1965
		html.push(alertStyle("Maximum Bids under 0"));
10 - 1966
	}
1967
 
1968
	if (valueMin && valueMax) {
1969
		if (Number(valueMin) > Number(valueMax)) {
1970
			warnings++;
19 - 1971
			html.push(alertStyle("Minimum Bids greater than Maximum Bids"));
10 - 1972
		}
1973
	}
1974
 
1975
	valueMin = document.getElementById('minFeedback').value;
1976
	valueMax = document.getElementById('maxFeedback').value;
1977
 
1978
	if (valueMin && valueMin < 0) {
1979
		warnings++;
19 - 1980
		html.push(alertStyle("Minimum Feedback under 0"));
10 - 1981
	}
1982
 
1983
	if (valueMax && valueMax < 0) {
1984
		warnings++;
19 - 1985
		html.push(alertStyle("Maximum Feedback under 0"));
10 - 1986
	}
1987
 
1988
	if (valueMin && valueMax) {
1989
		if (Number(valueMin) > Number(valueMax)) {
1990
			warnings++;
19 - 1991
			html.push(alertStyle("Minimum Feedback greater than Maximum Feedback"));
10 - 1992
		}
1993
	}
1994
 
1995
	valueMin = document.getElementById('minQuantity').value;
1996
	valueMax = document.getElementById('maxQuantity').value;
1997
 
1998
	if (valueMin && valueMin <= 0) {
1999
		warnings++;
19 - 2000
		html.push(alertStyle("Minimum Quantity at or under 0"));
10 - 2001
	}
2002
 
2003
	if (valueMax && valueMax <= 0) {
2004
		warnings++;
19 - 2005
		html.push(alertStyle("Maximum Quantity at or under 0"));
10 - 2006
	}
2007
 
2008
	if (valueMin && valueMax) {
2009
		if (Number(valueMin) > Number(valueMax)) {
2010
			warnings++;
19 - 2011
			html.push(alertStyle("Minimum Quantity greater than Maximum Quantity"));
10 - 2012
		}
2013
	}
2014
 
2015
	if (document.getElementById('ltAll').checked &&
2016
		(document.getElementById('ltAuction').checked ||
2017
			document.getElementById('ltAuctionWithBIN').checked ||
2018
			document.getElementById('ltClassified').checked ||
2019
			document.getElementById('ltFixedPrice').checked ||
2020
			document.getElementById('ltStoreInventory').checked)) {
2021
		warnings++;
19 - 2022
		html.push(alertStyle("Listing Type All Combined with other Type(s)"));
10 - 2023
	}
2024
 
2025
	if (document.getElementById('completedItemsOnly').checked &&
2026
		document.getElementById('searchDescription').checked) {
2027
		warnings++;
19 - 2028
		html.push(alertStyle("Completeted Items does work together with Search Description"));
10 - 2029
	}
2030
 
2031
	valueStartMin = document.getElementById('minStartDate').value;
2032
 
2033
	if (valueStartMin) {
2034
		if (isNaN(valueStartMin)) {
2035
			valueStartMin = moment(valueStartMin).format('YYYY-MM-DD');
2036
			if (!moment(valueStartMin).isValid) {
2037
				warnings++;
19 - 2038
				html.push(alertStyle("Invalid Minimum Start Date"));
10 - 2039
			} else if (moment(valueStartMin).isAfter()) {
2040
				warnings++;
19 - 2041
				html.push(alertStyle("Minimum Start Date in future"));
10 - 2042
			}
2043
		} else {
2044
			var valueStartMinNumber = Number(valueStartMin);
2045
			if (valueStartMinNumber > 0) {
2046
				warnings++;
19 - 2047
				html.push(alertStyle("Minimum Start Date in future"));
10 - 2048
			} else {
2049
				valueStartMin = moment().add(valueStartMinNumber, "days").format('YYYY-MM-DD');
2050
			}
2051
		}
2052
	}
2053
 
2054
	valueStartMax = document.getElementById('maxStartDate').value;
2055
 
2056
	if (valueStartMax) {
2057
		if (isNaN(valueStartMax)) {
2058
			valueStartMax = moment(valueStartMax).format('YYYY-MM-DD');
2059
			if (!moment(valueStartMax).isValid) {
2060
				warnings++;
19 - 2061
				html.push(alertStyle("Invalid Maximum Start Date"));
10 - 2062
			} else if (moment(valueStartMax).isAfter()) {
2063
				warnings++;
19 - 2064
				html.push(alertStyle("Maximum Start Date in future"));
10 - 2065
			}
2066
		} else {
2067
			var valueStartMaxNumber = Number(valueStartMax);
2068
			if (valueStartMaxNumber > 0) {
2069
				warnings++;
19 - 2070
				html.push(alertStyle("Maximum Start Date in future"));
10 - 2071
			} else {
2072
				valueStartMax = moment().add(valueStartMaxNumber, "days").format('YYYY-MM-DD');
2073
			}
2074
		}
2075
	}
2076
 
2077
	valueEndMin = document.getElementById('minEndDate').value;
2078
 
2079
	if (valueEndMin) {
2080
		if (isNaN(valueEndMin)) {
2081
			valueEndMin = moment(valueEndMin).format('YYYY-MM-DD');
2082
			if (!moment(valueEndMin).isValid) {
2083
				warnings++;
19 - 2084
				html.push(alertStyle("Invalid Minimum End Date"));
10 - 2085
			} else if (!document.getElementById('completedItemsOnly').checked && moment(valueEndMin).isBefore()) {
2086
				warnings++;
19 - 2087
				html.push(alertStyle("Minimum End Date in past"));
10 - 2088
			}
2089
		} else {
2090
			var valueEndMinNumber = Number(valueEndMin);
2091
			if (!document.getElementById('completedItemsOnly').checked && valueEndMinNumber < 0) {
2092
				warnings++;
19 - 2093
				html.push(alertStyle("Minimum End Date in past"));
10 - 2094
			} else {
2095
				valueEndMin = moment().add(valueEndMinNumber, "days").format('YYYY-MM-DD');
2096
			}
2097
		}
2098
	}
2099
 
2100
	valueEndMax = document.getElementById('maxEndDate').value;
2101
 
2102
	if (valueEndMax) {
2103
		if (isNaN(valueEndMax)) {
2104
			valueEndMax = moment(valueEndMax).format('YYYY-MM-DD');
2105
			if (!moment(valueEndMax).isValid) {
2106
				warnings++;
19 - 2107
				html.push(alertStyle("Invalid Maximum End Date"));
10 - 2108
			} else if (!document.getElementById('completedItemsOnly').checked && moment(valueEndMax).isBefore()) {
2109
				warnings++;
19 - 2110
				html.push(alertStyle("Maximum End Date in past"));
10 - 2111
			}
2112
		} else {
2113
			var valueEndMaxNumber = Number(valueEndMax);
2114
			if (!document.getElementById('completedItemsOnly').checked && valueEndMaxNumber < 0) {
2115
				warnings++;
19 - 2116
				html.push(alertStyle("Maximum End Date in past"));
10 - 2117
			} else {
2118
				valueEndMax = moment().add(valueEndMaxNumber, "days").format('YYYY-MM-DD');
2119
			}
2120
		}
2121
	}
2122
 
2123
	if (valueStartMin && valueStartMax && valueStartMin > valueStartMax) {
2124
		warnings++;
19 - 2125
		html.push(alertStyle("Maximum Start Date less than Minimum Start Date"));
10 - 2126
	}
2127
 
2128
	if (valueEndMin && valueEndMax && valueEndMin > valueEndMax) {
2129
		warnings++;
19 - 2130
		html.push(alertStyle("Maximum End Date less than Minimum End Date"));
10 - 2131
	}
2132
 
2133
	if (valueStartMin && valueEndMin && valueStartMin > valueEndMin) {
2134
		warnings++;
19 - 2135
		html.push(alertStyle("Minimum End Date less than Minimum Start Date"));
10 - 2136
	}
2137
 
2138
	if (valueStartMin && valueEndMax && valueStartMin > valueEndMax) {
2139
		warnings++;
19 - 2140
		html.push(alertStyle("Maximum End Date less than Minimum Start Date"));
10 - 2141
	}
2142
 
2143
	if (valueStartMax && valueEndMin && valueStartMax > valueEndMin) {
2144
		warnings++;
19 - 2145
		html.push(alertStyle("Minimum End Date less than Maximum Start Date"));
10 - 2146
	}
2147
 
2148
	if (valueStartMax && valueEndMax && valueStartMax > valueEndMax) {
2149
		warnings++;
19 - 2150
		html.push(alertStyle("Maximum End Date less than Maximum Start Date"));
10 - 2151
	}
2152
 
2153
	// Generate ISO dates
2154
	if (valueStartMin) {
2155
		valueStartMin = moment(valueStartMin + " 00:00:00", "YYYY-MM-DD HH:mm:ss").tz("UTC").toISOString();
2156
	}
2157
 
2158
	if (valueStartMax) {
2159
		if (moment().isBefore(valueStartMax + "T23:59:59.999Z")) {
2160
			valueStartMax = moment().tz("UTC").toISOString();
2161
		} else {
2162
			valueStartMax = moment(valueStartMax + " 23:59:59", "YYYY-MM-DD HH:mm:ss").tz("UTC").toISOString();
2163
		}
2164
	}
2165
 
2166
	if (document.getElementById('completedItemsOnly').checked) {
2167
		if (valueEndMin) {
2168
			valueEndMin = moment(valueEndMin + " 00:00:00", "YYYY-MM-DD HH:mm:ss").tz("UTC").toISOString();
2169
		}
2170
 
2171
		if (valueEndMax) {
2172
			if (moment().isBefore(valueEndMax + "T23:59:59.999Z")) {
2173
				valueEndMax = moment().subtract(1, 'minute').tz("UTC").toISOString();
2174
			} else {
2175
				valueEndMax = moment(valueEndMax + " 23:59:59", "YYYY-MM-DD HH:mm:ss").tz("UTC").toISOString();
2176
			}
2177
		}
2178
	} else {
2179
		if (valueEndMin) {
2180
			if (moment().isAfter(valueEndMin + "T00:00:00.000Z")) {
2181
				var valueEndMinMoment = new moment().add(1, 'minute');
2182
				valueEndMin = valueEndMinMoment.tz("UTC").toISOString();
2183
			} else {
2184
				valueEndMin = moment(valueEndMin + " 00:00:00", "YYYY-MM-DD HH:mm:ss").tz("UTC").toISOString();
2185
			}
2186
		}
2187
 
2188
		if (valueEndMax) {
2189
			valueEndMax = moment(valueEndMax + " 23:59:59", "YYYY-MM-DD HH:mm:ss").tz("UTC").toISOString();
2190
		}
2191
	}
2192
 
2193
	if (document.getElementById('localSearchOnly').checked) {
2194
		value = document.getElementById('maxDistance').value;
2195
		if (value === undefined || value <= 0) {
2196
			warnings++;
19 - 2197
			html.push(alertStyle("Local Search Only requires Maximum Distance"));
10 - 2198
		}
2199
	}
2200
 
2201
	// Print warnings
2202
	if (warnings) {
2203
		x.innerHTML = html.join("");
2204
    	x.className = x.className.replace(" invisible", " visible");
2205
		x.scrollIntoView();
2206
	} else {
2207
		x.className = x.className.replace(" visible", " invisible");
2208
	}
2209
 
2210
	return warnings;
2211
}
2212
 
19 - 2213
function alertStyle(message) {
2214
    var str = '<div class="alert alert-danger alert-dismissible">';
2215
    str += '<button type="button" class="close" data-dismiss="alert">×</button>';
2216
    str += '<p><strong>' + message + '</strong></p>';
2217
    str += '</div>';
2218
 
2219
    return str;
2220
}
2221
 
10 - 2222
// Define global variable for the URL filter
2223
var urlfilter = "";
2224
 
2225
// Generates an indexed URL snippet from the array of item filters
2226
function buildURLArray() {
2227
	urlfilter = "";
2228
	// Iterate through each filter in the array
2229
	for (var i = 0; i < filterarray.length; i++) {
2230
		//Index each item filter in filterarray
2231
		var itemfilter = filterarray[i];
2232
		// Iterate through each parameter in each item filter
2233
		for (var index in itemfilter) {
2234
			// Check to see if the paramter has a value (some don't)
2235
			if (itemfilter[index] !== "") {
2236
				if (itemfilter[index] instanceof Array) {
2237
					for (var r = 0; r < itemfilter[index].length; r++) {
2238
						var value = itemfilter[index][r];
2239
						urlfilter += "&itemFilter\(" + i + "\)." + index + "\(" + r + "\)=" + value;
2240
					}
2241
				} else {
2242
					urlfilter += "&itemFilter\(" + i + "\)." + index + "=" + itemfilter[index];
2243
				}
2244
			}
2245
		}
2246
	}
2247
} // End buildURLArray() function
2248
 
2249
var url = "";
2250
var searchUrl = "";
2251
 
2252
function eBaySearch(paramPage) {
2253
	pagenumber = paramPage;
2254
 
2255
	// Clear results outputs and download button
2256
	var x = document.getElementById("results");
12 - 2257
	x.innerHTML = '<div id="loader"></div>';
10 - 2258
	x.className = x.className.replace(" visible", " invisible");
2259
 
12 - 2260
    document.getElementById("searchForm").style.opacity = "0.2";
2261
 
2262
	x = document.getElementById("loader");
2263
	x.className = x.className.replace(" invisible", " visible");
2264
 
10 - 2265
	document.getElementById("download").disabled = true;
2266
	document.getElementById("pricing").disabled = true;
2267
 
2268
	x = document.getElementById("prices");
2269
	x.className = x.className.replace(" visible", " invisible");
2270
 
2271
	x = document.getElementById("duplicates");
2272
	x.className = x.className.replace(" visible", " invisible");
2273
    document.getElementById("duplicatesText").innerHTML = "";
17 - 2274
 
10 - 2275
	endProgressBarModal();
2276
 
2277
	x = document.getElementById("recommendation");
2278
	x.innerHTML = "";
2279
 
2280
	if (document.getElementById("duplicateCheck").checked) {
2281
		findDuplicateListing();
2282
		findPotentialDuplicateListing();
2283
		findShopifyDuplicateListing();
2284
	}
2285
 
2286
	// Print serialized search parameters
2287
	if (pagenumber == 1) {
2288
		x = document.getElementById("parameter");
2289
    	x.className = x.className.replace(" invisible", " visible");
2290
		searchUrl = window.location.protocol + "//" + window.location.hostname + window.location.pathname + '?' + $("form").serialize();
2291
		x.innerHTML = "<a href=\"" + searchUrl + "\" target=\"_blank\" title=\"eBay Search\">" + searchUrl + "</a>";
2292
	}
2293
 
2294
	// Check Parameters
2295
	if (checkFilterArray()) {
12 - 2296
        document.getElementById("searchForm").style.opacity = "1.0";
17 - 2297
        document.getElementById("results").innerHTML = "";
10 - 2298
		return false;
2299
	}
2300
 
2301
	// Fill the filter array from form input
2302
	fillFilterArray();
2303
	// Execute the function to build the URL filter
2304
	buildURLArray(filterarray);
2305
 
2306
	var keyword = document.getElementById('keyword').value;
2307
 
2308
	// Construct the request
2309
	url = configeBayFinding + "?";
2310
	if (document.getElementById('completedItemsOnly').checked) {
2311
		url += "OPERATION-NAME=findCompletedItems";
2312
	} else if (keyword.includes("ReferenceID:")) {
2313
		url += "OPERATION-NAME=findItemsByProduct";
2314
	} else {
2315
		url += "OPERATION-NAME=findItemsAdvanced";
2316
	}
2317
    url += "&SERVICE-VERSION=" + configeBayFindingVersion;
2318
	url += "&SECURITY-APPNAME=" + configAppid;
2319
	url += "&GLOBAL-ID=EBAY-US";
2320
	url += "&RESPONSE-DATA-FORMAT=JSON";
2321
	url += "&REST-PAYLOAD";
2322
	if (keyword.length > 0) {
2323
		if (keyword.includes("ReferenceID:")) {
2324
			url += "&productId.@type=ReferenceID";
2325
			url += "&productId=";
2326
			url += keyword.substr(12);
2327
		} else {
2328
			url += "&keywords=";
2329
			url += encodeURIComponent(keyword.trim().replace(/ /g, "+"));
2330
		}
2331
	}
2332
 
2333
	var catNo = 0;
2334
	for (var index = 1; index < document.getElementById('category').options.length; index++) {
2335
		if (document.getElementById('category').options[index].selected) {
2336
			url += "&categoryId(" + catNo + ")=";
2337
			url += document.getElementById('category').options[index].value;
2338
			++catNo;
2339
		}
2340
	}
2341
 
2342
	url += "&paginationInput.entriesPerPage=100";
2343
	url += "&paginationInput.pageNumber=";
2344
	if (pagenumber === undefined) {
2345
		pagenumber = 1;
2346
	}
2347
	url += pagenumber;
2348
	url += "&sortOrder=";
2349
	url += getSortOrder();
2350
	url += "&buyerPostalCode=";
2351
	url += configZip;
2352
	url += "&outputSelector=SellerInfo";
2353
	if (document.getElementById('searchDescription').checked) {
2354
		url += "&descriptionSearch=true";
2355
	}
2356
	url += urlfilter;
2357
 
2358
	var xhttp = new XMLHttpRequest();
2359
 
2360
	xhttp.onreadystatechange = function() {
2361
    	if (this.readyState == 4) {
2362
			if (document.getElementById('completedItemsOnly').checked) {
2363
				_cb_findCompletedItems(JSON.parse(this.responseText));
2364
			} else {
2365
				_cb_findItemsAdvanced(JSON.parse(this.responseText));
2366
			}
2367
        }
2368
    };
2369
 
2370
	xhttp.open("GET", configProxyUrl, true);
2371
	xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
2372
   	xhttp.send();
19 - 2373
 
2374
    // avoid form reload
2375
   	return false;
10 - 2376
}
2377
 
2378
function getKeywordRecommendations() {
2379
    var x = document.getElementById("keyword");
2380
    x.focus();
2381
	if (x.value.length < 2) {
2382
		return;
2383
	}
2384
 
2385
	// Clear results outputs and download button
2386
	x = document.getElementById("results");
2387
	x.innerHTML = "";
2388
	x.className = x.className.replace(" visible", " invisible");
2389
 
2390
	document.getElementById("download").disabled = true;
2391
	document.getElementById("pricing").disabled = true;
2392
 
2393
	x = document.getElementById("prices");
12 - 2394
	x.innerHTML = "";
10 - 2395
	x.className = x.className.replace(" visible", " invisible");
2396
 
2397
	endProgressBarModal();
2398
 
2399
	// Construct the request
2400
	url = configeBayFinding + "?";
2401
	url += "OPERATION-NAME=getSearchKeywordsRecommendation";
2402
	url += "&SERVICE-VERSION=" + configeBayFindingVersion;
2403
	url += "&SECURITY-APPNAME=" + configAppid;
2404
	url += "&RESPONSE-DATA-FORMAT=JSON";
2405
	url += "&REST-PAYLOAD";
2406
	url += "&keywords=";
2407
	url += encodeURIComponent(document.getElementById('keyword').value.trim().replace(/ /g, "+"));
2408
 
2409
	// Submit the request
2410
	var xhttp = new XMLHttpRequest();
2411
 
2412
	xhttp.onreadystatechange = function() {
2413
    	if (this.readyState == 4) {
2414
    		_cb_getKeywordRecommendations(JSON.parse(this.responseText));
2415
        }
2416
    };
2417
 
2418
	xhttp.open("GET", configProxyUrl, true);
2419
	xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
2420
   	xhttp.send();
2421
 
2422
	return;
2423
}
2424
 
2425
function formatTimeleft(timeleft) {
2426
	var timeleftDays = Math.floor(timeleft / 86400);
2427
	timeleft = timeleft % 86400;
2428
	var timeleftHours = Math.floor(timeleft / 3600);
2429
	timeleft = timeleft % 3600;
2430
	var timeleftMinutes = Math.floor(timeleft / 60);
2431
	return timeleftDays + ' days ' + timeleftHours + ' hours ' + timeleftMinutes + ' minutes';
2432
}
2433
 
2434
function getSortOrder() {
2435
	if (document.getElementById("soBestMatch").checked) {
2436
		return "BestMatch";
2437
	} else if (document.getElementById("soCurrentPriceHighest").checked) {
2438
		return "CurrentPriceHighest";
2439
	} else if (document.getElementById("soEndTimeSoonest").checked) {
2440
		return "EndTimeSoonest";
2441
	} else if (document.getElementById("soPricePlusShippingHighest").checked) {
2442
		return "PricePlusShippingHighest";
2443
	} else if (document.getElementById("soPricePlusShippingLowest").checked) {
2444
		return "PricePlusShippingLowest";
2445
	} else if (document.getElementById("soStartTimeNewest").checked) {
2446
		return "StartTimeNewest";
2447
	} else if (document.getElementById("soWatchCountDecreaseSort").checked) {
2448
		return "WatchCountDecreaseSort";
2449
	} else if (document.getElementById("soDistance").checked) {
2450
		return "DistanceNearest";
2451
	}
2452
	// Auctions Only!
2453
	else if (document.getElementById("soBidCountFewest").checked) {
2454
		return "BidCountFewest";
2455
	}
2456
	// Auctions Only!
2457
	else if (document.getElementById("soBidCountMost").checked) {
2458
		return "BidCountMost";
2459
	}
2460
 
2461
	return "BestMatch";
2462
}
2463
 
2464
function downloadAsCSV() {
2465
	var categoryIndex = 0;
2466
	asyncFlag = false;
2467
 
2468
	initProgressBarModal('Creating CSV Download File');
2469
 
2470
	var x = document.getElementById("csv");
2471
	x.innerHTML = ConvertToCSVHeader();
2472
 
2473
	maxPages = (totalEntries / 100) > 100 ? 100 : Math.trunc(totalEntries / 100.0) + 1;
2474
	currentPage = 0;
2475
 
2476
	var keyword = document.getElementById('keyword').value;
2477
 
2478
	for (var index = 0; index < maxPages; ++index) {
2479
		// Construct the request
2480
		var url = configeBayFinding + "?";
2481
		if (document.getElementById('completedItemsOnly').checked) {
2482
			url += "OPERATION-NAME=findCompletedItems";
2483
		} else if (keyword.includes("ReferenceID:")) {
2484
			url += "OPERATION-NAME=findItemsByProduct";
2485
		} else {
2486
			url += "OPERATION-NAME=findItemsAdvanced";
2487
		}
2488
		url += "&SECURITY-APPNAME=" + configAppid;
2489
		url += "&GLOBAL-ID=EBAY-US";
2490
		url += "&RESPONSE-DATA-FORMAT=JSON";
2491
		url += "&SERVICE-VERSION=" + configeBayFindingVersion;
2492
		url += "&REST-PAYLOAD";
2493
		if (keyword.length > 0) {
2494
			if (keyword.includes("ReferenceID:")) {
2495
				url += "&productId.@type=ReferenceID";
2496
				url += "&productId=";
2497
				url += keyword.substr(12);
2498
			} else {
2499
				url += "&keywords=";
2500
				url += encodeURIComponent(keyword.trim().replace(/ /g, "+"));
2501
			}
2502
		}
2503
 
2504
		var catNo = 0;
2505
		for (categoryIndex = 1; categoryIndex < document.getElementById('category').options.length; categoryIndex++) {
2506
			if (document.getElementById('category').options[categoryIndex].selected) {
2507
				url += "&categoryId(" + catNo + ")=";
2508
				url += document.getElementById('category').options[categoryIndex].value;
2509
				++catNo;
2510
			}
2511
		}
2512
 
2513
		url += "&paginationInput.entriesPerPage=100";
2514
		url += "&paginationInput.pageNumber=";
2515
		url += (index + 1);
2516
		url += "&sortOrder=";
2517
		url += getSortOrder();
2518
		url += "&buyerPostalCode=";
2519
		url += configZip;
2520
		url += "&outputSelector(0)=SellerInfo&outputSelector(1)=StoreInfo";
2521
		if (document.getElementById('searchDescription').checked) {
2522
			url += "&descriptionSearch=true";
2523
		}
2524
 
2525
		url += urlfilter;
2526
 
2527
		var xhttp = new XMLHttpRequest();
2528
 
2529
		xhttp.onreadystatechange = function() {
2530
	    	if (this.readyState == 4) {
2531
				if (document.getElementById('completedItemsOnly').checked) {
2532
					_cb_ConvertToCSVfindCompletedItems(JSON.parse(this.responseText));
2533
				} else {
2534
					_cb_ConvertToCSVfindItemsAdvanced(JSON.parse(this.responseText));
2535
				}
2536
	        }
2537
	    };
2538
 
2539
		xhttp.open("GET", configProxyUrl, true);
2540
		xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
2541
	   	xhttp.send();
2542
   	}
2543
 
2544
	function checkAsyncFlag() {
2545
		if (asyncFlag === false) {
2546
			window.setTimeout(checkAsyncFlag, 100); // wait 100 milliseconds
2547
		} else {
2548
			var textToSaveAsBlob = new Blob([String(document.getElementById("csv").innerHTML)], {
2549
				type: "text/csv"
2550
			});
2551
			var textToSaveAsURL = window.URL.createObjectURL(textToSaveAsBlob);
2552
			var fileNameToSaveAs = "eBaySearch.csv";
2553
 
2554
			var downloadLink = document.createElement("a");
2555
			downloadLink.download = fileNameToSaveAs;
2556
			downloadLink.innerHTML = "Download File";
2557
			downloadLink.href = textToSaveAsURL;
2558
			downloadLink.onclick = destroyClickedElement;
2559
			downloadLink.style.display = "none";
2560
			document.body.appendChild(downloadLink);
2561
 
2562
			endProgressBarModal();
2563
			downloadLink.click();
2564
		}
2565
	}
2566
 
2567
	checkAsyncFlag();
2568
}
2569
 
2570
function destroyClickedElement(event) {
2571
	document.body.removeChild(event.target);
2572
}
2573
 
2574
function _cb_ConvertToCSVfindItemsAdvanced(objArray) {
2575
	var array;
2576
 
2577
	if (objArray.findItemsAdvancedResponse !== undefined) {
2578
		array = typeof objArray.findItemsAdvancedResponse[0] != 'object' ? JSON.parse(objArray.findItemsAdvancedResponse[0]) : objArray.findItemsAdvancedResponse[0].searchResult[0].item;
2579
	} else if (objArray.findItemsByProductResponse !== undefined) {
2580
		array = typeof objArray.findItemsByProductResponse[0] != 'object' ? JSON.parse(objArray.findItemsByProductResponse[0]) : objArray.findItemsByProductResponse[0].searchResult[0].item;
2581
	} else {
2582
		return;
2583
	}
2584
 
2585
	ConvertToCSV(array);
2586
}
2587
 
2588
function _cb_ConvertToCSVfindCompletedItems(objArray) {
2589
	var array = typeof objArray.findCompletedItemsResponse[0] != 'object' ? JSON.parse(objArray.findCompletedItemsResponse[0]) : objArray.findCompletedItemsResponse[0].searchResult[0].item;
2590
	ConvertToCSV(array);
2591
}
2592
 
2593
function findSingleItem(itemId) {
2594
	// Construct the getShippingCosts request
2595
	getShippingCostsDone = false;
2596
 
2597
	url = configeBayShopping + "?";
2598
	url += "callname=GetShippingCosts";
2599
	url += "&responseencoding=JSON";
2600
	url += "&appid=" + configAppid;
2601
	url += "&version=" + configeBayShoppingVersion;
2602
	url += "&DestinationCountryCode=US";
2603
	url += "&DestinationPostalCode=";
2604
	url += configZip;
2605
	url += "&IncludeDetails=true";
2606
	url += "&QuantitySold=1";
2607
	url += "&ItemID=";
2608
	url += itemId;
2609
 
2610
	var xhttp = new XMLHttpRequest();
2611
 
2612
	xhttp.onreadystatechange = function() {
2613
    	if (this.readyState == 4) {
2614
    		_cb_GetShippingCosts(JSON.parse(this.responseText));
2615
        }
2616
    };
2617
 
2618
	xhttp.open("GET", configProxyUrl, true);
2619
	xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
2620
   	xhttp.send();
2621
 
2622
	function checkAsyncFlag() {
2623
		if (getShippingCostsDone !== true) {
2624
			window.setTimeout(function() {
2625
				checkAsyncFlag();
2626
			}, 100); // wait 100 milliseconds
2627
		} else {
2628
			// Construct the getSingleItem request
2629
			url = configeBayShopping + "?";
2630
			url += "callname=GetSingleItem";
2631
			url += "&responseencoding=JSON";
2632
			url += "&appid=" + configAppid;
2633
			url += "&version=" + configeBayShoppingVersion;
2634
			url += "&IncludeSelector=Details,Description,ItemSpecifics";
2635
			url += "&ItemID=";
2636
			url += itemId;
2637
 
2638
			var xhttp = new XMLHttpRequest();
2639
 
2640
			xhttp.onreadystatechange = function() {
2641
		    	if (this.readyState == 4) {
2642
		    		_cb_GetSingleItem(JSON.parse(this.responseText));
2643
		        }
2644
		    };
2645
 
2646
			xhttp.open("GET", configProxyUrl, true);
2647
			xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
2648
		   	xhttp.send();
2649
		}
2650
	}
2651
 
2652
	checkAsyncFlag();
2653
}
2654
 
2655
// Create new page for single item
2656
function _cb_GetSingleItem(root) {
2657
	var ack = root.Ack;
2658
	if (ack != 'Success') {
2659
		var x = document.getElementById("warnings");
2660
 
19 - 2661
        var str = '<div class="alert alert-danger alert-dismissible">';
2662
        str += '<button type="button" class="close" data-dismiss="alert">×</button>';
2663
		str += "<h2>eBay API Error</h2>";
2664
		str += "<ul>"
2665
		str += "<li>Id: " + root.Errors[0].ErrorCode + "</li>";
2666
		str += "<li>Domain: " + root.Errors[0].ErrorClassification + "</li>";
2667
		str += "<li>Severity: " + root.Errors[0].SeverityCode + "</li>";
2668
		str += "<li>Category: " + root.Errors[0].category + "</li>";
2669
		str += "<li>Short Message: " + root.Errors[0].ShortMessage + "</li>";
2670
		str += "<li>Long Message: " + root.Errors[0].LongMessage + "</li>";
2671
		str += "<li>Build/Version: " + root.Build + '/' + root.Version + "</li>";
2672
		str += "</ul>"
2673
		str += "<p>URL: " + "<a href=\"" + url + "\" target=\"_blank\">" + url + "</a>" + "</p>";
2674
		str += "</div>"
2675
 
2676
    	x.innerHTML = str;
10 - 2677
    	x.className = x.className.replace(" invisible", " visible");
2678
 
2679
		if (ack == 'Failure' || ack == 'PartialFailure') {
2680
			x.scrollIntoView(true);
2681
			return;
2682
		}
2683
	}
2684
 
2685
	var str = "";
2686
	var i = 0;
2687
	var JsonObj = typeof root.Item != 'object' ? JSON.parse(root.Item) : root.Item;
2688
 
2689
	var autoPay = JsonObj.autoPay;
2690
	var BestOfferEnabled = JsonObj.BestOfferEnabled;
2691
	var BidCount = JsonObj.BidCount;
2692
	var BusinessSellerDetails = JsonObj.BusinessSellerDetails;
2693
	if (BusinessSellerDetails) { // not yet
2694
	}
2695
	var BuyItNowAvailable = JsonObj.BuyItNowAvailable;
2696
	var BuyItNowPrice = JsonObj.BuyItNowPrice;
2697
	var BuyItNowPriceValue = BuyItNowPrice === undefined ? 0.00 : BuyItNowPrice.Value;
2698
	var BuyItNowPriceCurrencyID = BuyItNowPrice === undefined ? "" : BuyItNowPrice.CurrencyID;
2699
	var Charity = JsonObj.Charity;
2700
	if (Charity) { // not yet
2701
	}
2702
	var ConditionDescription = JsonObj.ConditionDescription;
2703
	var ConditionDisplayName = JsonObj.ConditionDisplayName;
2704
	var ConditionID = JsonObj.ConditionID;
2705
	var ConvertedBuyItNowPrice = JsonObj.ConvertedBuyItNowPrice;
2706
	var ConvertedBuyItNowPriceValue = ConvertedBuyItNowPrice === undefined ? 0.00 : ConvertedBuyItNowPrice.Value;
2707
	var ConvertedBuyItNowPriceCurrencyID = ConvertedBuyItNowPrice === undefined ? "" : ConvertedBuyItNowPrice.CurrencyID;
2708
	var ConvertedCurrentPrice = JsonObj.ConvertedCurrentPrice;
2709
	var ConvertedCurrentPriceValue = ConvertedCurrentPrice === undefined ? 0.00 : ConvertedCurrentPrice.Value;
2710
	var ConvertedCurrentPriceCurrencyID = ConvertedCurrentPrice === undefined ? "" : ConvertedCurrentPrice.CurrencyID;
2711
	var Country = JsonObj.Country;
2712
	var CurrentPrice = JsonObj.CurrentPrice;
2713
	var CurrentPriceValue = CurrentPrice === undefined ? 0.00 : CurrentPrice.Value;
2714
	var CurrentPriceCurrencyID = CurrentPrice === undefined ? "" : CurrentPrice.CurrencyID;
2715
	var Description = JsonObj.Description;
2716
	var DiscountPriceInfo = JsonObj.DiscountPriceInfo;
2717
	if (DiscountPriceInfo) { // not yet
2718
	}
2719
	var EndTime = JsonObj.EndTime;
2720
	var GalleryURL = JsonObj.GalleryURL;
2721
	var HandlingTime = JsonObj.HandlingTime;
2722
	var HighBidder = JsonObj.HighBidder;
2723
	var HighBidderFeedbackPrivate = HighBidder === undefined ? "" : HighBidder.FeedbackPrivate;
2724
	var HighBidderFeedbackScore = HighBidder === undefined ? "" : HighBidder.FeedbackScore;
2725
	var HighBidderUserAnonymized = HighBidder === undefined ? "" : HighBidder.UserAnonymized;
2726
	var HighBidderUserID = HighBidder === undefined ? "" : HighBidder.UserID;
2727
	var HitCount = JsonObj.HitCount;
2728
	var IgnoreQuantity = JsonObj.IgnoreQuantity;
2729
	var IntegratedMerchantCreditCardEnabled = JsonObj.IntegratedMerchantCreditCardEnabled;
2730
	var ItemID = JsonObj.ItemID;
2731
	var ItemSpecifics = JsonObj.ItemSpecifics;
2732
	var ListingStatus = JsonObj.ListingStatus;
2733
	var ListingType = JsonObj.ListingType;
2734
	var Location = JsonObj.Location;
2735
	var LotSize = JsonObj.LotSize;
2736
	var MinimumToBid = JsonObj.MinimumToBid;
2737
	var MinimumToBidCurrencyID = MinimumToBid === undefined ? "" : MinimumToBid.CurrencyID;
2738
	var MinimumToBidValue = MinimumToBid === undefined ? 0.00 : MinimumToBid.Value;
2739
	var PaymentAllowedSite = JsonObj.PaymentAllowedSite;
2740
	if (PaymentAllowedSite) { // not yet
2741
	}
2742
	var PaymentMethods = JsonObj.PaymentMethods;
2743
	var PictureURL = JsonObj.PictureURL;
2744
	var PostalCode = JsonObj.PostalCode;
2745
	var PrimaryCategoryID = JsonObj.PrimaryCategoryID;
2746
	var PrimaryCategoryIDPath = JsonObj.PrimaryCategoryIDPath;
2747
	var PrimaryCategoryName = JsonObj.PrimaryCategoryName;
2748
	var ProductIDValue = JsonObj.ProductID ? JsonObj.ProductID.Value : undefined;
2749
	var ProductIDType = JsonObj.ProductID ? JsonObj.ProductID.Type : undefined;
2750
	var Quantity = JsonObj.Quantity;
2751
	var QuantitySold = JsonObj.QuantitySold;
2752
	var QuantitySoldByPickupInStore = JsonObj.QuantitySoldByPickupInStore;
2753
	var ReserveMet = JsonObj.ReserveMet;
2754
	var ReturnPolicy = JsonObj.ReturnPolicy;
2755
	var ReturnPolicyRefund = ReturnPolicy === undefined ? "" : ReturnPolicy.Refund;
2756
	var ReturnPolicyReturnsWithin = ReturnPolicy === undefined ? "" : ReturnPolicy.ReturnsWithin;
2757
	var ReturnPolicyReturnsAccepted = ReturnPolicy === undefined ? "" : ReturnPolicy.ReturnsAccepted;
2758
	var ReturnPolicyDescription = ReturnPolicy === undefined ? "" : ReturnPolicy.Description;
2759
	var ReturnPolicyShippingCostPaidBy = ReturnPolicy === undefined ? "" : ReturnPolicy.ShippingCostPaidBy;
2760
	var ReturnPolicyRestockingFeeValue = ReturnPolicy === undefined ? "" : ReturnPolicy.RestockingFeeValue;
2761
	var ReturnPolicyRestockingFeeValueOption = ReturnPolicy === undefined ? "" : ReturnPolicy.RestockingFeeValueOption;
2762
	var ReturnPolicyWarrantyDuration = ReturnPolicy === undefined ? "" : ReturnPolicy.WarrantyDuration;
2763
	var ReturnPolicyWarrantyOffered = ReturnPolicy === undefined ? "" : ReturnPolicy.WarrantyOffered;
2764
	var ReturnPolicyWarrantyType = ReturnPolicy === undefined ? "" : ReturnPolicy.WarrantyType;
2765
	var SecondaryCategoryID = JsonObj.SecondaryCategoryID;
2766
	var SecondaryCategoryIDPath = JsonObj.SecondaryCategoryIDPath;
2767
	var SecondaryCategoryName = JsonObj.SecondaryCategoryName;
2768
	var Seller = JsonObj.Seller;
2769
	var SellerFeedbackScore = Seller === undefined ? 0 : Seller.FeedbackScore;
2770
	var SellerPositiveFeedbackPercent = Seller === undefined ? 0.00 : Seller.PositiveFeedbackPercent;
2771
	var SellerTopRatedSeller = Seller === undefined ? "" : Seller.TopRatedSeller;
2772
	var SellerUserID = Seller === undefined ? "" : Seller.UserID;
2773
	var Site = JsonObj.Site;
2774
	var SKU = JsonObj.SKU;
2775
	var StartTime = JsonObj.StartTime;
2776
	var Storefront = JsonObj.Storefront;
2777
	var StorefrontStoreName = Storefront === undefined ? "" : Storefront.StoreName;
2778
	var StorefrontStoreURL = Storefront === undefined ? "" : Storefront.StoreURL;
2779
	var Subtitle = JsonObj.Subtitle;
2780
	var TimeLeft = JsonObj.TimeLeft;
2781
	var Title = JsonObj.Title;
2782
	var TopRatedListing = JsonObj.TopRatedListing;
2783
	var UnitInfo = JsonObj.UnitInfo;
2784
	var UnitInfoUnitQuantity = UnitInfo === undefined ? 0 : UnitInfo.UnitQuantity;
2785
	var UnitInfoUnitType = UnitInfo === undefined ? 0 : UnitInfo.UnitType;
2786
	var ViewItemURLForNaturalSearch = JsonObj.ViewItemURLForNaturalSearch; // contains UPC
2787
	var categoryTitle = '';
2788
 
2789
	str = '<!DOCTYPE html>';
2790
	str += '<html lang="en">';
2791
	str += '<head>';
2792
	str += '<title>' + ItemID + ' - ' + Title + '</title>';
2793
	str += '<meta charset="UTF-8">';
2794
	str += '<meta name="viewport" content="width=device-width, initial-scale=1.0">';
2795
	str += '<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">';
2796
	str += '<link rel="icon" href="favicon.ico" type="image/x-icon">';
2797
	str += '<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">';
2798
	str += '<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"><\/script>';
2799
	str += '<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"><\/script>';
2800
	str += '<link rel="stylesheet" href="css/styleBS.css">';
2801
	str += '<script src="js/muna-tools.js"><\/script>';
2802
	str += '<script src="js/ebayProductBS.js"><\/script>';
17 - 2803
	str += '<script src="js/iframeResizer.min.js"><\/script>';
10 - 2804
	str += '</head>';
2805
	str += '<body>';
2806
	str += '<div class="container-fluid">';
2807
	str += '<div class="container-fluid border bg-secondary">';
2808
	str += '<div class="clearfix">';
2809
	str += '<img class="img-fluid float-right" src="images/MUNA%20-%20Logo%20100x100.png" alt="MUNA Trading Logo" />';
2810
	str += '<h2>' + Title + ' (EBAY-' + Site + '<a href="' + ViewItemURLForNaturalSearch + '" target="_blank">' + ' #' + ItemID + '</a>' + ')</h2>';
2811
 
2812
	if (Subtitle) {
2813
		str += '<h3>' + Subtitle + '</h3>';
2814
	}
2815
	if (PrimaryCategoryID) {
2816
		categoryTitle += PrimaryCategoryName + ' (' + PrimaryCategoryIDPath + ')';
2817
	}
2818
	if (SecondaryCategoryID) {
2819
		str += '<br/>' + SecondaryCategoryName + ' (' + SecondaryCategoryIDPath + ')';
2820
	}
2821
    str += '<h4>' + categoryTitle + '</h4>';
2822
	str += '</div>';
2823
	str += '</div>';
2824
 
2825
	str += '<div class="container-fluid border small">';
2826
	str += '<div class="row bg-light">';
2827
	str += '<div class="container-fluid border col">';
2828
	if (GalleryURL) {
2829
		str += '<img class="img-fluid float-right" src="' + GalleryURL + '" alt="Gallery Image" style="max-height:100px;max-width:100px;">';
2830
	} else if (PictureURL) {
2831
		str += '<img class="img-fluid float-right" src="' + PictureURL[0].replace('http:', 'https:') + '" alt="Gallery Image" style="max-height:100px;max-width:100px;">';
2832
	}
2833
	str += '<h2>Item</h2>';
2834
	str += '<table class="table table-bordered table-sm"><tbody>';
2835
 
2836
	if (ConditionID) {
2837
		str += '<tr><td>Condition</td><td>' + ConditionDisplayName + ' (' + ConditionID + ')</td></tr>';
2838
	}
2839
	str += '<tr><td>Condition Description</td><td>' + (ConditionDescription ? ConditionDescription : 'None entered') + '</td></tr>';
2840
 
2841
	if (ProductIDValue) {
2842
		str += '<tr><td>ProductID</td><td><a href="javascript:void(0)" onclick="findProductInfo(' + ProductIDValue + ')">' + ProductIDValue + ' (' + ProductIDType + ')</a></td></tr>';
2843
	}
2844
 
2845
	if (SKU) {
2846
		str += '<tr><td>SKU</td><td>' + SKU + '</td></tr>';
2847
	}
2848
 
2849
	if (ItemSpecifics) {
2850
		for (i = 0; i < ItemSpecifics.NameValueList.length; i++) {
2851
			str += '<tr><td>' + ItemSpecifics.NameValueList[i].Name + '</td><td>' + ItemSpecifics.NameValueList[i].Value + '</td></tr>';
2852
		}
2853
	}
2854
 
2855
	str += '</tbody></table>';
2856
 
2857
	str += '</div>';
2858
 
2859
	str += '<div class="container-fluid border col ">';
2860
	str += '<h2>Payment</h2>';
2861
	str += '<table class="table table-bordered table-sm"><tbody>';
2862
	if (autoPay && autoPay == 'true' && BidCount && BidCount === 0) {
2863
		str += '<tr><td colspan="2">Requires Immediate Payment</td></tr>';
2864
	}
2865
	if (IntegratedMerchantCreditCardEnabled && IntegratedMerchantCreditCardEnabled == 'true') {
2866
		str += '<tr><td>Merchant Credit Cards</td><td>Enabled</td></tr>';
2867
	}
2868
 
2869
	str += '<tr><td>Payment Methods</td><td>';
2870
	var paymentsArray = String(PaymentMethods).split(',');
2871
	for (i = 0; i < PaymentMethods.length; i++) {
2872
		str += (i > 0 ? ', ' : '') + paymentsArray[i];
2873
	}
2874
	str += '</td></tr>';
2875
 
2876
	str += '</tbody></table>';
2877
 
2878
	if (HandlingTime !== undefined) {
2879
		str += '<h2>Shipping/Handling:</h2>';
2880
    	str += '<table class="table table-bordered table-sm"><tbody>';
2881
		str += '<colgroup><col span="1" style="width:35%;"><col span="1" style="width:65%;"></colgroup>';
17 - 2882
    	str += '<tbody>';
10 - 2883
		str += '<tr><td>Handling Time</td><td>' + HandlingTime + ' ' + (HandlingTime == 1 ? 'day' : 'days') + '</td></tr>';
2884
		str += ship_str;
2885
		str += '</tbody></table>';
2886
	}
2887
 
2888
	if (ReturnPolicy) {
2889
		str += '<h2>Return Policy</h2><p>';
2890
    	str += '<table class="table table-bordered table-sm"><tbody>';
2891
		str += '<tr><td>Returns Accepted</td><td>' + (ReturnPolicyReturnsAccepted ? 'Yes' : 'No') + '</td></tr>';
2892
		str += ReturnPolicyDescription ? '<tr><td>Return Policy Description</td><td>' + ReturnPolicyDescription + '</td></tr>' : '';
2893
		str += ReturnPolicyReturnsWithin ? '<tr><td>Returns Within</td><td>' + ReturnPolicyReturnsWithin + '</td></tr>' : '';
2894
		str += ReturnPolicyRefund ? '<tr><td>Refund</td><td>' + ReturnPolicyRefund + '</td></tr>' : '';
2895
		str += ReturnPolicyShippingCostPaidBy ? '<tr><td>Shipping Cost Paid By</td><td>' + ReturnPolicyShippingCostPaidBy + '</td></tr>' : '';
2896
		str += ReturnPolicyRestockingFeeValueOption ? '<tr><td>Restocking Fee Value Option</td><td>' + ReturnPolicyRestockingFeeValueOption + '</td></tr>' : '';
2897
		str += ReturnPolicyRestockingFeeValue ? '<tr><td>Restocking Fee Value</td><td>' + ReturnPolicyRestockingFeeValue + '</td></tr>' : '';
2898
		str += ReturnPolicyWarrantyOffered ? '<tr><td>Warranty Offered</td><td>' + ReturnPolicyWarrantyOffered + '</td></tr>' : '<tr><td>Warranty</td><td>No</td></tr>';
2899
		str += ReturnPolicyWarrantyType ? '<tr><td>Warranty Type</td><td>' + ReturnPolicyWarrantyType + '</td></tr>' : '';
2900
		str += ReturnPolicyWarrantyDuration ? '<tr><td>Warranty Duration</td><td>' + ReturnPolicyWarrantyType + '</td></tr>' : '';
2901
    	str += '</tbody></table>';
2902
	}
2903
	str += '</div>';
2904
 
2905
	str += '<div class="container-fluid border col ">';
2906
	str += '<h2>Listing</h2>';
2907
	str += '<table class="table table-bordered table-sm"><tbody>';
2908
	str += '<tr><td>Status</td><td>' + ListingStatus + '</td></tr>';
2909
	if (TopRatedListing === true) {
2910
		str += '<tr><td colspan="2">Top Rated Listing</td></tr>';
2911
	}
2912
	str += '<tr><td>Listing Type</td><td>' + ListingType + '</td></tr>';
2913
	str += '<tr><td>Current Price</td><td>' + (CurrentPriceCurrencyID == 'USD' ? '$' : CurrentPriceCurrencyID + ' ') + CurrentPriceValue.toFixed(2) + '</td></tr>';
2914
	if (CurrentPriceCurrencyID != ConvertedCurrentPriceCurrencyID || CurrentPriceValue != ConvertedCurrentPriceValue) {
2915
		str += '<tr><td>Converted Current Price</td><td>' + (ConvertedCurrentPriceCurrencyID = 'USD' ? '$' : ConvertedCurrentPriceCurrencyID + ' ') + ConvertedCurrentPriceValue.toFixed(2) + '</td></tr>';
2916
	}
2917
	str += ship_str_cost;
2918
	str += ship_str_tax;
2919
	if (BuyItNowAvailable === true) {
2920
		str += '<tr><td>Buy It Now Price</td><td>' + (BuyItNowPriceCurrencyID == 'USD' ? '$' : BuyItNowPriceCurrencyID + ' ') + BuyItNowPriceValue.toFixed(2) + '</td></tr>';
2921
		if (BuyItNowPriceCurrencyID != ConvertedBuyItNowPriceCurrencyID || BuyItNowPriceValue != ConvertedBuyItNowPriceValue) {
2922
			str += '<tr><td>Converted Buy It Now Price</td><td>' + (ConvertedBuyItNowPriceCurrencyID = 'USD' ? '$' : ConvertedBuyItNowPriceCurrencyID + ' ') + ConvertedBuyItNowPriceValue.toFixed(2) + '</td></tr>';
2923
		}
2924
	}
2925
	if (LotSize) {
2926
		str += '<tr><td>LotSize</td><td>' + LotSize + '</td></tr>';
2927
	}
2928
 
2929
	if (IgnoreQuantity === undefined) {
2930
		str += '<tr><td>Quantity</td><td>' + Quantity + '</td></tr>';
2931
		str += '<tr><td>Quantity Sold</td><td>' + QuantitySold + '</td></tr>';
2932
		str += '<tr><td>Quantity Sold Store Pickup</td><td>' + QuantitySoldByPickupInStore + '</td></tr>';
2933
	}
2934
 
2935
	if (UnitInfo) {
2936
		str += '<tr><td>Unit Info: ' + UnitInfoUnitQuantity + ' ' + UnitInfoUnitType + '</td></tr>';
2937
	}
2938
 
2939
	str += '<tr><td>Start</td><td>' + moment(StartTime, moment.ISO_8601).format("YYYY-MM-DD hh:MMA") + '</td></tr>';
2940
	str += '<tr><td>End</td><td>' + moment(EndTime, moment.ISO_8601).format("YYYY-MM-DD hh:MMA") + '</td></tr>';
2941
	str += '<tr><td>Time Left</td><td>' + formatTimeleft(moment.duration(TimeLeft).asSeconds()) + '</td></tr>';
2942
	if (BestOfferEnabled === true) {
2943
		str += '<tr><td>Best Offer</td><td>Enabled</td></tr>';
2944
	}
2945
 
2946
	if (ReserveMet === false) {
2947
		str += '<tr><td colspan="2">Reserve not met</td></tr>';
2948
	}
2949
	if (HitCount) {
2950
		str += '<tr><td>Views</td><td>' + HitCount + '</td></tr>';
2951
	}
2952
	if (BidCount) {
2953
		str += '<tr><td>Bids</td><td>' + BidCount + '</td></tr>';
2954
	}
2955
	if (MinimumToBid) {
2956
		str += '<tr><td>Minimum to Bid</td><td>' + (MinimumToBidCurrencyID == 'USD' ? '$' : MinimumToBidCurrencyID + ' ') + MinimumToBidValue.toFixed(2) + '</td></tr>';
2957
	}
2958
	if (HighBidder) {
2959
		str += '<tr><td>High Bidder</td><td>' + HighBidderUserID;
2960
		if (HighBidderFeedbackPrivate === false) {
2961
			str += feebackStarImage(HighBidderFeedbackScore) + ' (' + HighBidderFeedbackScore + ')';
2962
		}
2963
		str += '</td></tr>';
2964
		if (HighBidderUserAnonymized === true) {
2965
			str += '<tr><td colspan="2">High Bidder User Anonymized</td></tr>';
2966
		}
2967
	}
2968
	str += '</tbody></table>';
2969
 
2970
	if (Seller) {
2971
		str += '<h2>Seller</h2>';
2972
		str += '<p>' + SellerUserID + feebackStarImage(SellerFeedbackScore);
2973
		str += ' (' + SellerFeedbackScore + ' / ' + SellerPositiveFeedbackPercent + '%)';
2974
		if (SellerTopRatedSeller) {
2975
			str += '<br/>Top Rated Seller';
2976
		}
2977
		str += '<br/>' + Location + ' ' + (PostalCode ? PostalCode + ' ' : '') + Country;
2978
		if (Storefront) {
2979
			str += '<br/>Store: <a href="' + StorefrontStoreURL + '" target="_blank">' + StorefrontStoreName + '</a>';
2980
		}
2981
		str += '</p>';
2982
 
2983
		str += '<div id="map" style="width:100%;height:300px;"></div>';
2984
		str += '<script>';
2985
		str += '  function initMap() {';
2986
		str += '    var address = \'' + Location + ' ' + (PostalCode ? PostalCode + ' ' : '') + Country + '\';';
2987
		str += '	var geocoder = new google.maps.Geocoder;';
2988
		str += '    geocoder.geocode({"address": address}, function(results, status) {';
2989
		str += '    if (status === "OK") {';
2990
		str += '        if (results[0]) {';
2991
		str += '			var infowindow = new google.maps.InfoWindow;';
2992
		str += '	        var map = new google.maps.Map(document.getElementById("map"), {';
2993
		str += '	          zoom: 10,';
2994
		str += '	          center: {lat: 40.72, lng: -73.96}';
2995
		str += '	        });';
2996
		str += '            map.setCenter(results[0].geometry.location);';
2997
		str += '            var marker = new google.maps.Marker({';
2998
		str += '              map: map,';
2999
		str += '              position: results[0].geometry.location';
3000
		str += '            });';
3001
		str += '            infowindow.setContent(results[0].formatted_address);';
3002
		str += '            infowindow.open(map, marker);';
3003
		str += '        } else {';
3004
		str += '            document.getElementById("map").style.display = "none";';
3005
		str += '        }';
3006
		str += '    } else {';
3007
		str += '        document.getElementById("map").style.display = "none";';
3008
		str += '    }';
3009
		str += '  });';
3010
		str += '  }';
3011
		str += '<\/script>';
3012
	}
3013
 
3014
 
3015
	str += '</div>';
3016
	str += '</div>';
3017
	str += '</div>';
3018
 
3019
	if (PictureURL.length > 1) {
3020
		str += '<div class="container-fluid border">';
3021
		str += '<h2>Pictures</h2>';
3022
		for (i = 0; i < PictureURL.length; i++) {
3023
			str += '<img class="img-fluid" src="' + PictureURL[i].replace('http:', 'https:') + '" alt="Item Image ' + (i + 1) + '">';
3024
		}
3025
		str += '</div>';
3026
	}
3027
 
3028
	if (Description) {
3029
	    if (Description.includes("<link")) {
17 - 3030
            var htmlStr = '<!DOCTYPE html>';
3031
            htmlStr += '<html lang="en">';
3032
            htmlStr += '<head>';
3033
            htmlStr += '<title>' + ItemID + ' Description</title>';
3034
            htmlStr += '<meta charset="UTF-8">';
3035
            htmlStr += '<meta name="viewport" content="width=device-width, initial-scale=1.0">';
3036
            htmlStr += '</head>';
3037
            htmlStr += '<body>';
3038
            htmlStr += Description;
3039
	    htmlStr += '<script src="https://ujsoftware.linkpc.net/ebay/js/iframeResizer.contentWindow.min.js"><\/script>';
3040
            htmlStr += '</body>';
3041
            htmlStr += '</html>';
3042
       	    str += '<div class="container-fluid border"><h2>Description</h2><iframe style="width:100%" scrolling="no" src="data:text/html;base64,' + htmlStr.b64encode() + '">Browser does not support iframes</iframe></div>';
10 - 3043
    	} else {
3044
    		str += '<div class="container-fluid border"><h2>Description</h2>' + Description + '</div>';
3045
	    }
3046
	}
3047
 
3048
	str += '<div id="warnings" class="container-fluid border bg-danger"></div>';
3049
	str += '<footer class="container-fluid text-center border border-bottom-0 border-left-0 border-right-0">';
3050
	str += 'Copyright &#169; ' + new Date().getFullYear() + ' MUNA Trading. All rights reserved.';
3051
	str += '</footer>';
3052
	str += '<script async defer src="https://maps.googleapis.com/maps/api/js?key=' + configGoogleMapsKey + '&callback=initMap"><\/script>';
17 - 3053
	str += '<script>iFrameResize({log:false,checkOrigin:false})<\/script>';
10 - 3054
	str += '</div>';
3055
	str += '</body>';
3056
	str += '</html>';
3057
 
3058
	var newWin = window.open("", ItemID + ' ' + Title);
3059
	if (newWin) {
3060
		newWin.document.open().write(str);
3061
		newWin.document.close();
3062
	}
3063
}
3064
 
3065
function _cb_GetShippingCosts(root) {
3066
	var ack = root.Ack;
3067
	var i;
3068
	var j;
3069
	var taxTableEntries = 0;
3070
	ship_str = "";
3071
 
3072
	if (ack != 'Success') {
3073
		var x = document.getElementById("warnings");
19 - 3074
		var str = '<div class="alert alert-danger alert-dismissible">';
3075
        str += '<button type="button" class="close" data-dismiss="alert">×</button>';
3076
		str += "<h2>eBay API Error</h2>";
3077
		str += "<ul>";
3078
		str += "<li>Id: " + root.Errors[0].ErrorCode + "</li>";
3079
		str += "<li>Domain: " + root.Errors[0].ErrorClassification + "/li>";
3080
		str += "<li>Severity: " + root.Errors[0].SeverityCode + "</li>";
3081
		str += "<li>Short Message: " + root.Errors[0].ShortMessage + "</li>";
3082
		str += "<li>Long Message: " + root.Errors[0].LongMessage + "</li>";
3083
		str += "<li>Build/Version: " + root.Build + '/' + root.Version + "</li>";
3084
		str += "</ul>";
3085
		str += "<p>URL: " + "<a href=\"" + url + "\" target=\"_blank\">" + url + "</a>" + "</p>";
3086
		str += "</div>";
10 - 3087
 
19 - 3088
        x.innerHTML = str;
10 - 3089
    	x.className = x.className.replace(" invisible", " visible");
3090
 
3091
		if (ack == 'Failure' || ack == 'PartialFailure') {
3092
			x.scrollIntoView(true);
3093
			getShippingCostsDone = true;
3094
			return;
3095
		}
3096
	}
3097
 
3098
	ship_str += '<tr><td colspan="2"><strong>Shipping Cost Summary</strong></td></tr>';
3099
	ship_str_cost = "";
3100
	if (root.ShippingCostSummary.ShippingServiceCost) {
3101
		if (root.ShippingCostSummary.ShippingServiceCost.Value === 0) {
3102
			ship_str += '<tr><td>Shipping Service Cost</td><td>Free</td></tr>';
3103
			ship_str_cost = '<tr><td>Shipping</td><td>Free (' + root.ShippingCostSummary.ShippingServiceName + ')</td></tr>';
3104
		} else {
3105
			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>';
3106
			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>';
3107
		}
3108
	}
3109
 
3110
	if (root.ShippingCostSummary.ShippingServiceName) {
3111
		ship_str += '<tr><td>Shipping Service Name</td><td>' + root.ShippingCostSummary.ShippingServiceName + '</td></tr>';
3112
	}
3113
 
3114
	if (root.ShippingCostSummary.ShippingType) {
3115
		ship_str += '<tr><td>Shipping Type</td><td>' + root.ShippingCostSummary.ShippingType + '</td></tr>';
3116
	}
3117
 
3118
	if (root.ShippingCostSummary.ImportCharge) {
3119
		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>';
3120
	}
3121
 
3122
	if (root.ShippingCostSummary.InsuranceCost) {
3123
		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>';
3124
	}
3125
 
3126
	if (root.ShippingCostSummary.InsuranceOption) {
3127
		ship_str += '<tr><td>Insurance Option</td><td>' + root.ShippingCostSummary.InsuranceOption + '</td></tr>';
3128
	}
3129
 
3130
	if (root.ShippingCostSummary.InternationalInsuranceCost) {
3131
		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>';
3132
	}
3133
 
3134
	if (root.ShippingCostSummary.InternationalInsuranceOption) {
3135
		ship_str += '<tr><td>International Insurance Option</td><td>' + root.ShippingCostSummary.InternationalInsuranceOption + '</td></tr>';
3136
	}
3137
 
3138
	if (root.ShippingDetails.ExcludeShipToLocation) {
3139
		var excludeArray = String(root.ShippingDetails.ExcludeShipToLocation).split(',');
3140
		ship_str += '<tr><td>Exclude Ship to Location</td><td>';
3141
		for (i = 0; i < excludeArray.length; i++) {
3142
			ship_str += (i > 0 ? ', ' : '') + mapCountryCode(excludeArray[i]);
3143
		}
3144
		ship_str += '</td></tr>';
3145
	}
3146
 
3147
	if (root.ShippingDetails.SalesTax) {
3148
		if (root.ShippingDetails.SalesTax.SalesTaxAmount) {
3149
			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>';
3150
		}
3151
		if (root.ShippingDetails.SalesTax.SalesTaxPercent) {
3152
			ship_str += '<tr><td>Sales Tax Percentage</td><td>' + root.ShippingDetails.SalesTax.SalesTaxPercent.toFixed(3) + '%</td></tr>';
3153
		}
3154
		if (root.ShippingDetails.SalesTax.SalesTaxState) {
3155
			ship_str += '<tr><td>Sales Tax State</td><td>' + root.ShippingDetails.SalesTax.SalesTaxState + '</td></tr>';
3156
		}
3157
		if (root.ShippingDetails.SalesTax.ShippingIncludedInTax === true) {
3158
			ship_str += '<tr><td colspan="2">Shipping Included In Tax</td></tr>';
3159
		}
3160
	}
3161
 
3162
	ship_str_tax = "";
3163
	if (root.ShippingDetails.TaxTable && root.ShippingDetails.TaxTable.TaxJurisdiction.length > 0) {
3164
		for (i = 0; i < root.ShippingDetails.TaxTable.TaxJurisdiction.length; i++) {
3165
			if (root.ShippingDetails.TaxTable.TaxJurisdiction[i].JurisdictionID !== undefined) {
3166
				taxTableEntries++;
3167
			}
3168
		}
3169
	}
3170
 
3171
	if (taxTableEntries) {
3172
		ship_str += '<tr><td colspan="2"><strong>Tax Table</strong></td></tr>';
3173
		for (i = 0; i < root.ShippingDetails.TaxTable.TaxJurisdiction.length; i++) {
3174
			if (root.ShippingDetails.TaxTable.TaxJurisdiction[i].JurisdictionID !== undefined) {
3175
				if (root.ShippingDetails.TaxTable.TaxJurisdiction[i].JurisdictionID == configTaxStateId) {
3176
					ship_str_tax += '<tr><td>Tax</td><td>' + root.ShippingDetails.TaxTable.TaxJurisdiction[i].JurisdictionID + ' ' + root.ShippingDetails.TaxTable.TaxJurisdiction[i].SalesTaxPercent.toFixed(3) + '%';
3177
					if (root.ShippingDetails.TaxTable.TaxJurisdiction[i].ShippingIncludedInTax && root.ShippingDetails.TaxTable.TaxJurisdiction[i].ShippingIncludedInTax === true) {
3178
						ship_str_tax += '<br/>Shipping included in Tax';
3179
					}
3180
					ship_str_tax += '</td></tr>';
3181
				}
3182
				ship_str += '<tr><td>' + root.ShippingDetails.TaxTable.TaxJurisdiction[i].JurisdictionID + '</td><td>' + root.ShippingDetails.TaxTable.TaxJurisdiction[i].SalesTaxPercent.toFixed(3) + '%';
3183
				if (root.ShippingDetails.TaxTable.TaxJurisdiction[i].ShippingIncludedInTax && root.ShippingDetails.TaxTable.TaxJurisdiction[i].ShippingIncludedInTax === true) {
3184
					ship_str += '<br/>Shipping included in Tax';
3185
				}
3186
				ship_str += '</td></tr>';
3187
			}
3188
		}
3189
	}
3190
 
3191
	for (i = 0; root.ShippingDetails.ShippingServiceOption && i < root.ShippingDetails.ShippingServiceOption.length; i++) {
3192
		ship_str += '<tr><td colspan="2"><strong>Shipping Option ' + root.ShippingDetails.ShippingServiceOption[i].ShippingServicePriority + '</strong></td></tr>';
3193
 
3194
		if (root.ShippingDetails.ShippingServiceOption[i].ShippingServiceCost) {
3195
			if (root.ShippingDetails.ShippingServiceOption[i].ShippingServiceCost.Value === 0) {
3196
				ship_str += '<tr><td>Shipping Service Cost</td><td>Free</td></tr>';
3197
			} else {
3198
				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>';
3199
			}
3200
		}
3201
 
3202
		if (root.ShippingDetails.ShippingServiceOption[i].ShippingInsuranceCost) {
3203
			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>';
3204
		}
3205
 
3206
		if (root.ShippingDetails.ShippingServiceOption[i].ShippingServiceAdditionalCost) {
3207
			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>';
3208
		}
3209
 
3210
		if (root.ShippingDetails.ShippingServiceOption[i].ShippingSurcharge) {
3211
			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>';
3212
		}
3213
 
3214
		if (root.ShippingDetails.ShippingServiceOption[i].ShippingServiceName) {
3215
			ship_str += '<tr><td>Shipping Service Name</td><td>' + root.ShippingDetails.ShippingServiceOption[i].ShippingServiceName + '</td></tr>';
3216
		}
3217
 
3218
		if (root.ShippingDetails.ShippingServiceOption[i].ShippingServiceOptionType) {
3219
			ship_str += '<tr><td>Shipping Type</td><td>' + root.ShippingDetails.ShippingServiceOption[i].ShippingServiceOptionType + '</td></tr>';
3220
		}
3221
 
3222
		if (root.ShippingDetails.ShippingServiceOption[i].ShippingTimeMin && root.ShippingDetails.ShippingServiceOption[i].ShippingTimeMax) {
3223
			ship_str += '<tr><td>Delivery Time</td><td>';
3224
			if (root.ShippingDetails.ShippingServiceOption[i].ShippingTimeMin != root.ShippingDetails.ShippingServiceOption[i].ShippingTimeMax) {
3225
				ship_str += 'Between ' + root.ShippingDetails.ShippingServiceOption[i].ShippingTimeMin + ' and ';
3226
			}
3227
			ship_str += root.ShippingDetails.ShippingServiceOption[i].ShippingTimeMax + ' days</td></tr>';
3228
		}
3229
 
3230
		if (root.ShippingDetails.ShippingServiceOption[i].ShippingServiceCutOffTime) {
3231
			ship_str += '<tr><td>Shipping Type</td><td>' + root.ShippingDetails.ShippingServiceOption[i].ShippingServiceCutOffTime + '</td></tr>';
3232
		}
3233
 
3234
		if (root.ShippingDetails.ShippingServiceOption[i].ExpeditedService && root.ShippingDetails.ShippingServiceOption[i].ExpeditedService === true) {
3235
			ship_str += '<tr><td colspan="2">Expedited Service</td></tr>';
3236
		}
3237
 
3238
		if (root.ShippingDetails.ShippingServiceOption[i].FastAndFree && root.ShippingDetails.ShippingServiceOption[i].FastAndFree === true) {
3239
			ship_str += '<tr><td colspan="2">Fast and Free</td></tr>';
3240
		}
3241
 
3242
		if (root.ShippingDetails.ShippingServiceOption[i].ShipsTo) {
3243
			var includeArray = String(root.ShippingDetails.ShippingServiceOption[i].ShipsTo).split(',');
3244
			ship_str += '<tr><td>Ship to Location</td><td>';
3245
			for (j = 0; j < includeArray.length; j++) {
3246
				ship_str += (j > 0 ? ', ' : '') + includeArray[j];
3247
			}
3248
			ship_str += '</td></tr>';
3249
		}
3250
	}
3251
 
3252
	for (i = 0; root.ShippingDetails.InternationalShippingServiceOption && i < root.ShippingDetails.InternationalShippingServiceOption.length; i++) {
3253
		ship_str += '<tr><td colspan="2"><strong>International Shipping Option ' + root.ShippingDetails.InternationalShippingServiceOption[i].ShippingServicePriority + '</strong></td></tr>';
3254
 
3255
		if (root.ShippingDetails.InternationalShippingServiceOption[i].ShippingServiceCost) {
3256
			if (root.ShippingDetails.InternationalShippingServiceOption[i].ShippingServiceCost.Value === 0) {
3257
				ship_str += '<tr><td>Shipping Service Cost</td><td>Free</td></tr>';
3258
			} else {
3259
				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>';
3260
			}
3261
		}
3262
 
3263
		if (root.ShippingDetails.InternationalShippingServiceOption[i].ShippingInsuranceCost) {
3264
			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>';
3265
		}
3266
 
3267
		if (root.ShippingDetails.InternationalShippingServiceOption[i].ShippingServiceAdditionalCost) {
3268
			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>';
3269
		}
3270
 
3271
		if (root.ShippingDetails.InternationalShippingServiceOption[i].ImportCharge) {
3272
			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>';
3273
		}
3274
 
3275
		if (root.ShippingDetails.InternationalShippingServiceOption[i].ShippingServiceName) {
3276
			ship_str += '<tr><td>Shipping Service Name</td><td>' + root.ShippingDetails.InternationalShippingServiceOption[i].ShippingServiceName + '</td></tr>';
3277
		}
3278
 
3279
		if (root.ShippingDetails.InternationalShippingServiceOption[i].InternationalShippingServiceOptionType) {
3280
			ship_str += '<tr><td>Shipping Type</td><td>' + root.ShippingDetails.InternationalShippingServiceOption[i].InternationalShippingServiceOptionType + '</td></tr>';
3281
		}
3282
 
3283
		if (root.ShippingDetails.InternationalShippingServiceOption[i].EstimatedDeliveryMinTime && root.ShippingDetails.InternationalShippingServiceOption[i].EstimatedDeliveryMaxTime) {
3284
			ship_str += '<tr><td>Delivery Time</td><td>';
3285
			if (root.ShippingDetails.InternationalShippingServiceOption[i].EstimatedDeliveryMinTime != root.ShippingDetails.InternationalShippingServiceOption[i].EstimatedDeliveryMaxTime) {
3286
				ship_str += 'Between ' + moment(root.ShippingDetails.InternationalShippingServiceOption[i].EstimatedDeliveryMinTime, moment.ISO_8601).format("YYYY-MM-DD") + ' and ';
3287
			}
3288
			ship_str += moment(root.ShippingDetails.InternationalShippingServiceOption[i].EstimatedDeliveryMinTime, moment.ISO_8601).format("YYYY-MM-DD");
3289
			ship_str += (moment(root.ShippingDetails.InternationalShippingServiceOption[i].EstimatedDeliveryMaxTime).isValid() ? '' : ' days') + '</td></tr>';
3290
		}
3291
 
3292
		if (root.ShippingDetails.InternationalShippingServiceOption[i].ShippingServiceCutOffTime) {
3293
			ship_str += '<tr><td>Shipping Type</td><td>' + root.ShippingDetails.InternationalShippingServiceOption[i].ShippingServiceCutOffTime + '</td></tr>';
3294
		}
3295
 
3296
		if (root.ShippingDetails.InternationalShippingServiceOption[i].ShipsTo) {
3297
			var includeInternationalArray = String(root.ShippingDetails.InternationalShippingServiceOption[i].ShipsTo).split(',');
3298
			ship_str += '<tr><td>Ship to Location</td><td>';
3299
			for (j = 0; j < includeInternationalArray.length; j++) {
3300
				ship_str += (j > 0 ? ', ' : '') + includeInternationalArray[j];
3301
			}
3302
			ship_str += '</td></tr>';
3303
		}
3304
	}
3305
 
3306
	getShippingCostsDone = true;
3307
}
3308
 
3309
function ConvertToCSVHeader() {
3310
	var header = "";
3311
 
3312
	header += "itemId,";
3313
	header += "title,";
3314
	header += "subtitle,";
3315
	header += "globalId,";
3316
	header += "primaryCategory.categoryId,";
3317
	header += "primaryCategory.categoryName,";
3318
	header += "galleryURL,";
3319
	header += "viewItemURL,";
3320
	header += "paymentMethod,";
3321
	header += "autoPay,";
3322
	header += "location,";
3323
	header += "country,";
3324
	header += "sellerUserName,";
3325
	header += "feedbackScore,";
3326
	header += "positiveFeedbackPercent,";
3327
	header += "feedbackRatingStar,";
3328
	header += "topRatedSeller,";
3329
	header += "storeName,";
3330
	header += "storeURL,";
3331
	header += "shippingInfo.shippingServiceCost.currencyId,";
3332
	header += "shippingInfo.shippingServiceCost.value,";
3333
	header += "shippingInfo.shippingType,";
3334
	header += "shippingInfo.shipToLocations,";
3335
	header += "shippingInfo.expeditedShipping,";
3336
	header += "shippingInfo.oneDayShippingAvailable,";
3337
	header += "shippingInfo.handlingTime,";
3338
	header += "sellingStatus.currentPrice.currencyId,";
3339
	header += "sellingStatus.currentPrice.value,";
3340
	header += "sellingStatus.convertedCurrentPrice.currencyId,";
3341
	header += "sellingStatus.convertedCurrentPrice.value,";
3342
	header += "sellingStatus.bidCount,";
3343
	header += "sellingStatus.sellingState,";
3344
	header += "sellingStatus.timeLeft,";
3345
	header += "listingInfo.bestOfferEnabled,";
3346
	header += "listingInfo.buyItNowAvailable,";
3347
	header += "listingInfo.convertedBuyItNowPrice.currencyId,";
3348
	header += "listingInfo.convertedBuyItNowPrice.value,";
3349
	header += "listingInfo.startTime,";
3350
	header += "listingInfo.endTime,";
3351
	header += "listingInfo.listingType,";
3352
	header += "listingInfo.gift,";
3353
	header += "listingInfo.watchCount,";
3354
	header += "returnsAccepted,";
3355
	header += "galleryPlusPictureURL,";
3356
	header += "condition.conditionId,";
3357
	header += "condition.conditionDisplayName,";
3358
	header += "isMultiVariationListing,";
3359
	header += "topRatedListing,";
3360
	header += "distance,";
3361
	header += "distance unit";
3362
	header += "\r\n";
3363
 
3364
	return header;
3365
}
3366
 
3367
function readParameters() {
3368
	if (window.location.search[0] == '?') {
12 - 3369
        var str = window.location.search.split('?')[1];
10 - 3370
   		$('form').deserialize(str);
12 - 3371
    	$('#category').trigger("chosen:updated");
10 - 3372
	    eBaySearch(1);
3373
   	}
3374
}
3375
 
3376
jQuery.fn.deserialize = function(data) {
3377
	var f = this,
3378
		map = {},
3379
		find = function(selector) {
3380
			return f.is("form") ? f.find(selector) : f.filter(selector);
3381
		};
3382
	// Get map of values
3383
	data = data.replace(/\+/g, " ");
3384
	jQuery.each(data.split("&"), function() {
3385
		var nv = this.split("="),
3386
			n = decodeURIComponent(nv[0]),
3387
			v = nv.length > 1 ? decodeURIComponent(nv[1]) : null;
3388
		if (!(n in map)) {
3389
			map[n] = [];
3390
		}
3391
		map[n].push(v);
3392
	});
3393
	// Set values for all form elements in the data
3394
	jQuery.each(map, function(n, v) {
3395
		find("[name='" + n + "']").val(v);
3396
	});
3397
	// Clear all form elements not in form data
3398
	find("input:text,select,textarea").each(function() {
3399
		if (!(jQuery(this).attr("name") in map)) {
3400
			jQuery(this).val("");
3401
		}
3402
	});
3403
	find("input:checkbox:checked,input:radio:checked").each(function() {
3404
		if (!(jQuery(this).attr("name") in map)) {
3405
			this.checked = false;
3406
		}
3407
	});
3408
	return this;
3409
};
3410
 
3411
// Function to convert eBay JSON item to CSV format.
3412
function ConvertToCSV(array) {
3413
	var str = "";
3414
 
3415
	++currentPage;
3416
	updateProgressBar(maxPages, currentPage);
3417
 
3418
	for (var i = 0; i < array.length; i++) {
3419
		var line = "";
3420
 
3421
		var JsonObj = array[i];
3422
		line += "'" + JsonObj.itemId + ",";
3423
 
3424
		var title = String(JsonObj.title).replace(/\"/g, "");
3425
		line += "\"" + title + "\",";
3426
 
3427
		if (JsonObj.subtitle) {
3428
			var subtitle = String(JsonObj.subtitle).replace(/\"/g, "");
3429
			line += "\"" + subtitle + "\",";
3430
		} else {
3431
			line += ",";
3432
		}
3433
 
3434
		line += JsonObj.globalId + ",";
3435
 
3436
		var primaryCategory = JsonObj.primaryCategory;
3437
		line += primaryCategory[0].categoryId + ",";
3438
		var categoryName = String(primaryCategory[0].categoryName).replace(/\"/g, "");
3439
		line += "\"" + categoryName + "\",";
3440
 
3441
		line += JsonObj.galleryURL + ",";
3442
		line += "\"" + JsonObj.viewItemURL + "\",";
3443
		line += "\"" + JsonObj.paymentMethod + "\",";
3444
		line += JsonObj.autoPay + ",";
3445
		line += "\"" + JsonObj.location + "\",";
3446
		line += JsonObj.country + ",";
3447
 
3448
		var sellerInfo = JsonObj.sellerInfo;
3449
		line += sellerInfo[0].sellerUserName + ",";
3450
		line += sellerInfo[0].feedbackScore + ",";
3451
		line += sellerInfo[0].positiveFeedbackPercent + ",";
3452
		line += sellerInfo[0].feedbackRatingStar + ",";
3453
		line += sellerInfo[0].topRatedSeller + ",";
3454
 
3455
		var storeInfo = JsonObj.storeInfo;
3456
		if (storeInfo) {
3457
			var storeName = String(storeInfo[0].storeName).replace(/\"/g, "");
3458
			line += "\"" + storeName + "\",";
3459
			line += storeInfo[0].storeURL + ",";
3460
		} else {
3461
			line += ",";
3462
			line += ",";
3463
		}
3464
		var shippingInfo = JsonObj.shippingInfo;
3465
		var shippingServiceCost = shippingInfo[0].shippingServiceCost;
3466
		if (shippingServiceCost) {
3467
			line += shippingServiceCost[0]["@currencyId"] + ",";
3468
			line += shippingServiceCost[0].__value__ + ",";
3469
		} else {
3470
			line += ",";
3471
			line += ",";
3472
		}
3473
		line += shippingInfo[0].shippingType + ",";
3474
		line += shippingInfo[0].shipToLocations + ",";
3475
		line += shippingInfo[0].expeditedShipping + ",";
3476
		line += shippingInfo[0].oneDayShippingAvailable + ",";
3477
		line += shippingInfo[0].handlingTime + ",";
3478
 
3479
		var sellingStatus = JsonObj.sellingStatus;
3480
		var currentPrice = sellingStatus[0].currentPrice;
3481
		var convertedCurrentPrice = sellingStatus[0].convertedCurrentPrice;
3482
		line += currentPrice[0]["@currencyId"] + ",";
3483
		line += currentPrice[0].__value__ + ",";
3484
		line += convertedCurrentPrice[0]["@currencyId"] + ",";
3485
		line += convertedCurrentPrice[0].__value__ + ",";
3486
		if (sellingStatus[0].bidCount) {
3487
			line += sellingStatus[0].bidCount + ",";
3488
		} else {
3489
			line += ",";
3490
		}
3491
		line += sellingStatus[0].sellingState + ",";
3492
		line += formatTimeleft(moment.duration(sellingStatus[0].timeLeft).asSeconds()) + ",";
3493
 
3494
		var listingInfo = JsonObj.listingInfo;
3495
		line += listingInfo[0].bestOfferEnabled + ",";
3496
		line += listingInfo[0].buyItNowAvailable + ",";
3497
 
3498
		var convertedBuyItNowPrice = listingInfo[0].convertedBuyItNowPrice;
3499
		if (convertedBuyItNowPrice) {
3500
			line += convertedBuyItNowPrice[0]["@currencyId"] + ",";
3501
			line += convertedBuyItNowPrice[0].__value__ + ",";
3502
		} else {
3503
			line += ",";
3504
			line += ",";
3505
		}
3506
		line += listingInfo[0].startTime + ",";
3507
		line += listingInfo[0].endTime + ",";
3508
		line += listingInfo[0].listingType + ",";
3509
		line += listingInfo[0].gift + ",";
3510
		if (listingInfo[0].watchCount) {
3511
			line += listingInfo[0].watchCount + ",";
3512
		} else {
3513
			line += ",";
3514
		}
3515
 
3516
		line += JsonObj.returnsAccepted + ",";
3517
		if (JsonObj.galleryPlusPictureURL) {
3518
			line += JsonObj.galleryPlusPictureURL + ",";
3519
		} else {
3520
			line += ",";
3521
		}
3522
 
3523
		var condition = JsonObj.condition;
3524
		if (condition) {
3525
			line += condition[0].conditionId + ",";
3526
			line += condition[0].conditionDisplayName + ",";
3527
			line += JsonObj.isMultiVariationListing + ",";
3528
			line += JsonObj.topRatedListing + ",";
3529
		} else {
3530
			line += ",";
3531
			line += ",";
3532
			line += ",";
3533
			line += ",";
3534
		}
3535
 
3536
		if (JsonObj.distance !== undefined) {
3537
			line += JsonObj.distance[0].__value__ + ",";
3538
			line += JsonObj.distance[0]["@unit"] + ",";
3539
		} else {
3540
			line += ",";
3541
			line += ",";
3542
		}
3543
 
3544
		line += '\r\n';
3545
 
3546
		str += line;
3547
	}
3548
 
3549
	var x = document.getElementById("csv");
3550
	x.innerHTML += str;
3551
 
3552
	if (currentPage >= maxPages) {
3553
		asyncFlag = true;
3554
	}
3555
}
3556
 
3557
function resetForm() {
3558
	document.getElementById("searchForm").reset();
3559
	$(document.getElementById("category")).trigger("chosen:updated");
3560
}
3561
 
3562
function mapCountryCode(code) {
3563
	var mappedCode = code;
3564
	var countryCodes = {};
3565
 
3566
	countryCodes.AA = "APO/FPO";
3567
	countryCodes.AD = "Andorra";
3568
	countryCodes.AE = "United Arab Emirates";
3569
	countryCodes.AF = "Afghanistan";
3570
	countryCodes.AG = "Antigua and Barbuda";
3571
	countryCodes.AI = "Anguilla";
3572
	countryCodes.AL = "Albania";
3573
	countryCodes.AM = "Armenia";
3574
	countryCodes.AN = "Netherlands Antilles";
3575
	countryCodes.AO = "Angola";
3576
	countryCodes.AQ = "Antarctica";
3577
	countryCodes.AR = "Argentina";
3578
	countryCodes.AS = "American Samoa";
3579
	countryCodes.AT = "Austria";
3580
	countryCodes.AU = "Australia";
3581
	countryCodes.AW = "Aruba";
3582
	countryCodes.AZ = "Azerbaijan";
3583
	countryCodes.BA = "Bosnia and Herzegovina";
3584
	countryCodes.BB = "Barbados";
3585
	countryCodes.BD = "Bangladesh";
3586
	countryCodes.BE = "Belgium";
3587
	countryCodes.BF = "Burkina Faso";
3588
	countryCodes.BG = "Bulgaria";
3589
	countryCodes.BH = "Bahrain";
3590
	countryCodes.BI = "Burundi";
3591
	countryCodes.BJ = "Benin";
3592
	countryCodes.BM = "Bermuda";
3593
	countryCodes.BN = "Brunei Darussalam";
3594
	countryCodes.BO = "Bolivia";
3595
	countryCodes.BR = "Brazil";
3596
	countryCodes.BS = "Bahamas";
3597
	countryCodes.BT = "Bhutan";
3598
	countryCodes.BV = "Bouvet Island";
3599
	countryCodes.BW = "Botswana";
3600
	countryCodes.BY = "Belarus";
3601
	countryCodes.BZ = "Belize";
3602
	countryCodes.CA = "Canada";
3603
	countryCodes.CC = "Cocos (Keeling) Islands";
3604
	countryCodes.CD = "The Democratic Republic of the Congo";
3605
	countryCodes.CF = "Central African Republic";
3606
	countryCodes.CG = "Congo";
3607
	countryCodes.CH = "Switzerland";
3608
	countryCodes.CI = "Cote d'Ivoire";
3609
	countryCodes.CK = "Cook Islands";
3610
	countryCodes.CL = "Chile";
3611
	countryCodes.CM = "Cameroon";
3612
	countryCodes.CN = "China";
3613
	countryCodes.CO = "Colombia";
3614
	countryCodes.CR = "Costa Rica";
3615
	countryCodes.CU = "Cuba";
3616
	countryCodes.CV = "Cape Verde";
3617
	countryCodes.CX = "Christmas Island";
3618
	countryCodes.CY = "Cyprus";
3619
	countryCodes.CZ = "Czech Republic";
3620
	countryCodes.DE = "Germany";
3621
	countryCodes.DJ = "Djibouti";
3622
	countryCodes.DK = "Denmark";
3623
	countryCodes.DM = "Dominica";
3624
	countryCodes.DO = "Dominican Republic";
3625
	countryCodes.DZ = "Algeria";
3626
	countryCodes.EC = "Ecuador";
3627
	countryCodes.EE = "Estonia";
3628
	countryCodes.EG = "Egypt";
3629
	countryCodes.EH = "Western Sahara";
3630
	countryCodes.ER = "Eritrea";
3631
	countryCodes.ES = "Spain";
3632
	countryCodes.ET = "Ethiopia";
3633
	countryCodes.FI = "Finland";
3634
	countryCodes.FJ = "Fiji";
3635
	countryCodes.FK = "Falkland Islands (Malvinas)";
3636
	countryCodes.FM = "Federated States of Micronesia";
3637
	countryCodes.FO = "Faroe Islands";
3638
	countryCodes.FR = "France";
3639
	countryCodes.GA = "Gabon";
3640
	countryCodes.GB = "United Kingdom";
3641
	countryCodes.GD = "Grenada";
3642
	countryCodes.GE = "Georgia";
3643
	countryCodes.GF = "French Guiana";
3644
	countryCodes.GG = "Guernsey";
3645
	countryCodes.GH = "Ghana";
3646
	countryCodes.GI = "Gibraltar";
3647
	countryCodes.GL = "Greenland";
3648
	countryCodes.GM = "Gambia";
3649
	countryCodes.GN = "Guinea";
3650
	countryCodes.GP = "Guadeloupe";
3651
	countryCodes.GQ = "Equatorial Guinea";
3652
	countryCodes.GR = "Greece";
3653
	countryCodes.GS = "South Georgia and the South Sandwich Islands";
3654
	countryCodes.GT = "Guatemala";
3655
	countryCodes.GU = "Guam";
3656
	countryCodes.GW = "Guinea-Bissau";
3657
	countryCodes.GY = "Guyana";
3658
	countryCodes.HK = "Hong Kong";
3659
	countryCodes.HM = "Heard Island and McDonald Islands";
3660
	countryCodes.HN = "Honduras";
3661
	countryCodes.HR = "Croatia";
3662
	countryCodes.HT = "Haiti";
3663
	countryCodes.HU = "Hungary";
3664
	countryCodes.ID = "Indonesia";
3665
	countryCodes.IE = "Ireland";
3666
	countryCodes.IL = "Israel";
3667
	countryCodes.IN = "India";
3668
	countryCodes.IO = "British Indian Ocean Territory";
3669
	countryCodes.IQ = "Iraq";
3670
	countryCodes.IR = "Islamic Republic of Iran";
3671
	countryCodes.IS = "Iceland";
3672
	countryCodes.IT = "Italy";
3673
	countryCodes.JE = "Jersey";
3674
	countryCodes.JM = "Jamaica";
3675
	countryCodes.JO = "Jordan";
3676
	countryCodes.JP = "Japan";
3677
	countryCodes.KE = "Kenya";
3678
	countryCodes.KG = "Kyrgyzstan";
3679
	countryCodes.KH = "Cambodia";
3680
	countryCodes.KI = "Kiribati";
3681
	countryCodes.KM = "Comoros";
3682
	countryCodes.KN = "Saint Kitts and Nevis";
3683
	countryCodes.KP = "Democratic People's Republic of Korea";
3684
	countryCodes.KR = "Republic of Korea";
3685
	countryCodes.KW = "Kuwait";
3686
	countryCodes.KY = "Cayman Islands";
3687
	countryCodes.KZ = "Kazakhstan";
3688
	countryCodes.LA = "Lao People's Democratic Republic";
3689
	countryCodes.LB = "Lebanon";
3690
	countryCodes.LC = "Saint Lucia";
3691
	countryCodes.LI = "Liechtenstein";
3692
	countryCodes.LK = "Sri Lanka";
3693
	countryCodes.LR = "Liberia";
3694
	countryCodes.LS = "Lesotho";
3695
	countryCodes.LT = "Lithuania";
3696
	countryCodes.LU = "Luxembourg";
3697
	countryCodes.LV = "Latvia";
3698
	countryCodes.LY = "Libyan Arab Jamahiriya";
3699
	countryCodes.MA = "Morocco";
3700
	countryCodes.MC = "Monaco";
3701
	countryCodes.MD = "Republic of Moldova";
3702
	countryCodes.ME = "Montenegro";
3703
	countryCodes.MG = "Madagascar";
3704
	countryCodes.MH = "Marshall Islands";
3705
	countryCodes.MK = "The Former Yugoslav Republic of Macedonia";
3706
	countryCodes.ML = "Mali";
3707
	countryCodes.MM = "Myanmar";
3708
	countryCodes.MN = "Mongolia";
3709
	countryCodes.MO = "Macao";
3710
	countryCodes.MP = "Northern Mariana Islands";
3711
	countryCodes.MQ = "Martinique";
3712
	countryCodes.MR = "Mauritania";
3713
	countryCodes.MS = "Montserrat";
3714
	countryCodes.MT = "Malta";
3715
	countryCodes.MU = "Mauritius";
3716
	countryCodes.MV = "Maldives";
3717
	countryCodes.MW = "Malawi";
3718
	countryCodes.MX = "Mexico";
3719
	countryCodes.MY = "Malaysia";
3720
	countryCodes.MZ = "Mozambique";
3721
	countryCodes.NA = "Namibia";
3722
	countryCodes.NC = "New Caledonia";
3723
	countryCodes.NE = "Niger";
3724
	countryCodes.NF = "Norfolk Island";
3725
	countryCodes.NG = "Nigeria";
3726
	countryCodes.NI = "Nicaragua";
3727
	countryCodes.NL = "Netherlands";
3728
	countryCodes.NO = "Norway";
3729
	countryCodes.NP = "Nepal";
3730
	countryCodes.NR = "Nauru";
3731
	countryCodes.NU = "Niue";
3732
	countryCodes.NZ = "New Zealand";
3733
	countryCodes.OM = "Oman";
3734
	countryCodes.PA = "Panama";
3735
	countryCodes.PE = "Peru";
3736
	countryCodes.PF = "French Polynesia Includes Tahiti";
3737
	countryCodes.PG = "Papua New Guinea";
3738
	countryCodes.PH = "Philippines";
3739
	countryCodes.PK = "Pakistan";
3740
	countryCodes.PL = "Poland";
3741
	countryCodes.PM = "Saint Pierre and Miquelon";
3742
	countryCodes.PN = "Pitcairn";
3743
	countryCodes.PR = "Puerto Rico";
3744
	countryCodes.PS = "Palestinian territory, Occupied";
3745
	countryCodes.PT = "Portugal";
3746
	countryCodes.PW = "Palau";
3747
	countryCodes.PY = "Paraguay";
3748
	countryCodes.QA = "Qatar";
3749
	countryCodes.QM = "Guernsey";
3750
	countryCodes.QN = "Jan Mayen";
3751
	countryCodes.QO = "Jersey";
3752
	countryCodes.RE = "Reunion";
3753
	countryCodes.RO = "Romania";
3754
	countryCodes.RS = "Serbia";
3755
	countryCodes.RU = "Russian Federation";
3756
	countryCodes.RW = "Rwanda";
3757
	countryCodes.SA = "Saudi Arabia";
3758
	countryCodes.SB = "Solomon Islands";
3759
	countryCodes.SC = "Seychelles";
3760
	countryCodes.SD = "Sudan";
3761
	countryCodes.SE = "Sweden";
3762
	countryCodes.SG = "Singapore";
3763
	countryCodes.SH = "Saint Helena";
3764
	countryCodes.SI = "Slovenia";
3765
	countryCodes.SJ = "Svalbard and Jan Mayen";
3766
	countryCodes.SK = "Slovakia";
3767
	countryCodes.SL = "Sierra Leone";
3768
	countryCodes.SM = "San Marino";
3769
	countryCodes.SN = "Senegal";
3770
	countryCodes.SO = "Somalia";
3771
	countryCodes.SR = "Suriname";
3772
	countryCodes.ST = "Sao Tome and Principe";
3773
	countryCodes.SV = "El Salvador";
3774
	countryCodes.SY = "Syrian Arab Republic";
3775
	countryCodes.SZ = "Swaziland";
3776
	countryCodes.TA = "Tristan da Cunha";
3777
	countryCodes.TC = "Turks and Caicos Islands";
3778
	countryCodes.TD = "Chad";
3779
	countryCodes.TF = "French Southern Territories";
3780
	countryCodes.TG = "Togo";
3781
	countryCodes.TH = "Thailand";
3782
	countryCodes.TJ = "Tajikistan";
3783
	countryCodes.TK = "Tokelau";
3784
	countryCodes.TM = "Turkmenistan";
3785
	countryCodes.TN = "Tunisia";
3786
	countryCodes.TO = "Tonga";
3787
	countryCodes.TR = "Turkey";
3788
	countryCodes.TT = "Trinidad and Tobago";
3789
	countryCodes.TV = "Tuvalu";
3790
	countryCodes.TW = "Taiwan, Province of China";
3791
	countryCodes.TZ = "Tanzania, United Republic of";
3792
	countryCodes.UA = "Ukraine";
3793
	countryCodes.UG = "Uganda";
3794
	countryCodes.UM = "United States Minor Outlying Islands";
3795
	countryCodes.US = "United States";
3796
	countryCodes.UY = "Uruguay";
3797
	countryCodes.UZ = "Uzbekistan";
3798
	countryCodes.VA = "Holy See (Vatican City state)";
3799
	countryCodes.VC = "Saint Vincent and the Grenadines";
3800
	countryCodes.VE = "Venezuela";
3801
	countryCodes.VG = "Virgin Islands, British";
3802
	countryCodes.VI = "Virgin Islands, US";
3803
	countryCodes.VN = "Vietnam";
3804
	countryCodes.VU = "Vanuatu";
3805
	countryCodes.WF = "Wallis and Futuna";
3806
	countryCodes.WS = "Samoa";
3807
	countryCodes.YE = "Yemen";
3808
	countryCodes.YT = "Mayotte";
3809
	countryCodes.ZA = "South Africa";
3810
	countryCodes.ZM = "Zambia";
3811
	countryCodes.ZW = "Zimbabwe";
3812
 
3813
	if (countryCodes[code] !== undefined) {
3814
		mappedCode = countryCodes[code];
3815
	}
3816
 
3817
	return mappedCode;
3818
}
3819
 
3820
var minActive = [0.0, 0.0, 0.0];
3821
var maxActive = [0.0, 0.0, 0.0];
3822
var avgActive = [0.0, 0.0, 0.0];
3823
var noActive = [0, 0, 0];
3824
var minSold = [0.0, 0.0, 0.0];
3825
var maxSold = [0.0, 0.0, 0.0];
3826
var avgSold = [0.0, 0.0, 0.0];
3827
var noSold = [0, 0, 0];
3828
var minUnsold = [0.0, 0.0, 0.0];
3829
var maxUnsold = [0.0, 0.0, 0.0];
3830
var avgUnsold = [0.0, 0.0, 0.0];
3831
var noUnsold = [0, 0, 0];
3832
var newActiveBreakdown = [];
3833
var usedActiveBreakdown = [];
3834
var newSoldBreakdown = [];
3835
var usedSoldBreakdown = [];
3836
 
3837
function getPricing() {
3838
	minActive = [0.0, 0.0, 0.0];
3839
	maxActive = [0.0, 0.0, 0.0];
3840
	avgActive = [0.0, 0.0, 0.0];
3841
	noActive = [0, 0, 0];
3842
	minSold = [0.0, 0.0, 0.0];
3843
	maxSold = [0.0, 0.0, 0.0];
3844
	avgSold = [0.0, 0.0, 0.0];
3845
	noSold = [0, 0, 0];
3846
	minUnsold = [0.0, 0.0, 0.0];
3847
	maxUnsold = [0.0, 0.0, 0.0];
3848
	avgUnsold = [0.0, 0.0, 0.0];
3849
	noUnsold = [0, 0, 0];
3850
	maxPricingPages = [-1, -1];
3851
	totalPricingEntries = [0, 0];
3852
	newActiveBreakdown = [];
3853
	usedActiveBreakdown = [];
3854
	newSoldBreakdown = [];
3855
	usedSoldBreakdown = [];
3856
 
3857
	getPricingData(0);
3858
	getPricingData(1);
3859
}
3860
 
3861
function getPricingData(searchIndex) {
3862
	var index = 0;
3863
	var keyword = document.getElementById('keyword').value;
3864
 
3865
	// Construct the request
3866
	var url = configeBayFinding + "?";
3867
	if (searchIndex === 0) {
3868
		if (keyword.includes("ReferenceID:")) {
3869
			url += "OPERATION-NAME=findItemsByProduct";
3870
		} else {
3871
			url += "OPERATION-NAME=findItemsAdvanced";
3872
		}
3873
	} else {
3874
		url += "OPERATION-NAME=findCompletedItems";
3875
	}
3876
	url += "&SECURITY-APPNAME=" + configAppid;
3877
	url += "&GLOBAL-ID=EBAY-US";
3878
	url += "&RESPONSE-DATA-FORMAT=JSON";
3879
	url += "&SERVICE-VERSION=" + configeBayFindingVersion;
3880
	url += "&REST-PAYLOAD";
3881
	if (keyword.length > 0) {
3882
		if (keyword.includes("ReferenceID:")) {
3883
			url += "&productId.@type=ReferenceID";
3884
			url += "&productId=";
3885
			url += keyword.substr(12);
3886
		} else {
3887
			url += "&keywords=";
3888
			url += encodeURIComponent(keyword.trim().replace(/ /g, "+"));
3889
		}
3890
	}
3891
 
3892
	var catNo = 0;
3893
	for (var categoryIndex = 1; categoryIndex < document.getElementById('category').options.length; categoryIndex++) {
3894
		if (document.getElementById('category').options[categoryIndex].selected) {
3895
			url += "&categoryId(" + catNo + ")=";
3896
			url += document.getElementById('category').options[categoryIndex].value;
3897
			++catNo;
3898
		}
3899
	}
3900
 
3901
	url += "&paginationInput.entriesPerPage=100";
3902
	url += "&paginationInput.pageNumber=";
3903
	url += (index + 1);
3904
	url += "&sortOrder=";
3905
	url += getSortOrder();
3906
	url += "&buyerPostalCode=";
3907
	url += configZip;
3908
	url += "&outputSelector(0)=SellerInfo&outputSelector(1)=StoreInfo";
3909
	if (document.getElementById('searchDescription').checked) {
3910
		url += "&descriptionSearch=true";
3911
	}
3912
 
3913
	url += urlfilter;
3914
 
3915
	var xhttp = new XMLHttpRequest();
3916
 
3917
	xhttp.onreadystatechange = function() {
3918
    	if (this.readyState == 4) {
3919
			if (searchIndex === 0) {
3920
				_cb_PriceActiveItems(JSON.parse(this.responseText));
3921
			} else {
3922
				_cb_PriceCompletedItems(JSON.parse(this.responseText));
3923
			}
3924
        }
3925
    };
3926
 
3927
	xhttp.open("GET", configProxyUrl, true);
3928
	xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
3929
   	xhttp.send();
3930
 
3931
	function waitForMaxPricingPages(i) {
3932
		if (maxPricingPages[i] < 0) {
3933
			window.setTimeout(waitForMaxPricingPages, 500, i); // wait 500 milliseconds
3934
		} else {
3935
			for (index = 1; index < maxPricingPages[searchIndex]; index++) {
3936
				// Construct the request
3937
				var url = configeBayFinding + "?";
3938
				if (searchIndex === 0) {
3939
					if (keyword.includes("ReferenceID:")) {
3940
						url += "OPERATION-NAME=findItemsByProduct";
3941
					} else {
3942
						url += "OPERATION-NAME=findItemsAdvanced";
3943
					}
3944
				} else {
3945
					url += "OPERATION-NAME=findCompletedItems";
3946
				}
3947
				url += "&SECURITY-APPNAME=" + configAppid;
3948
				url += "&GLOBAL-ID=EBAY-US";
3949
				url += "&RESPONSE-DATA-FORMAT=JSON";
3950
				url += "&SERVICE-VERSION=" + configeBayFindingVersion;
3951
				url += "&REST-PAYLOAD";
3952
				keyword = document.getElementById('keyword').value;
3953
				if (keyword.length > 0) {
3954
					if (keyword.includes("ReferenceID:")) {
3955
						url += "&productId.@type=ReferenceID";
3956
						url += "&productId=";
3957
						url += keyword.substr(12);
3958
					} else {
3959
						url += "&keywords=";
3960
						url += encodeURIComponent(keyword.trim().replace(/ /g, "+"));
3961
					}
3962
				}
3963
 
3964
				var catNo = 0;
3965
				for (var categoryIndex = 1; categoryIndex < document.getElementById('category').options.length; categoryIndex++) {
3966
					if (document.getElementById('category').options[categoryIndex].selected) {
3967
						url += "&categoryId(" + catNo + ")=";
3968
						url += document.getElementById('category').options[categoryIndex].value;
3969
						++catNo;
3970
					}
3971
				}
3972
 
3973
				url += "&paginationInput.entriesPerPage=100";
3974
				url += "&paginationInput.pageNumber=";
3975
				url += (index + 1);
3976
				url += "&sortOrder=";
3977
				url += getSortOrder();
3978
				url += "&buyerPostalCode=";
3979
				url += configZip;
3980
				url += "&outputSelector(0)=SellerInfo&outputSelector(1)=StoreInfo";
3981
				if (document.getElementById('searchDescription').checked) {
3982
					url += "&descriptionSearch=true";
3983
				}
3984
 
3985
				url += urlfilter;
3986
 
3987
				var xhttp = new XMLHttpRequest();
3988
 
3989
				xhttp.onreadystatechange = function() {
3990
			    	if (this.readyState == 4) {
3991
						if (searchIndex === 0) {
3992
							_cb_PriceActiveItems(JSON.parse(this.responseText));
3993
						} else {
3994
							_cb_PriceCompletedItems(JSON.parse(this.responseText));
3995
						}
3996
			        }
3997
			    };
3998
 
3999
				xhttp.open("GET", configProxyUrl, true);
4000
				xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
4001
			   	xhttp.send();			}
4002
		}
4003
	}
4004
 
4005
	waitForMaxPricingPages(searchIndex);
4006
}
4007
 
4008
function _cb_PriceActiveItems(objArray) {
4009
	var array;
4010
 
4011
	if (objArray.findItemsAdvancedResponse !== undefined) {
4012
		array = typeof objArray.findItemsAdvancedResponse[0] != 'object' ? JSON.parse(objArray.findItemsAdvancedResponse[0]) : objArray.findItemsAdvancedResponse[0].searchResult[0].item;
4013
		totalPricingEntries[0] = Number(objArray.findItemsAdvancedResponse[0].paginationOutput[0].totalEntries);
4014
	} else if (objArray.findItemsByProductResponse !== undefined) {
4015
		array = typeof objArray.findItemsByProductResponse[0] != 'object' ? JSON.parse(objArray.findItemsByProductResponse[0]) : objArray.findItemsByProductResponse[0].searchResult[0].item;
4016
		totalPricingEntries[0] = Number(objArray.findItemsByProductResponse[0].paginationOutput[0].totalEntries);
4017
	} else {
4018
		return;
4019
	}
4020
	//	var array = typeof objArray.findItemsAdvancedResponse[0] != 'object' ? JSON.parse(objArray.findItemsAdvancedResponse[0]) : objArray.findItemsAdvancedResponse[0].searchResult[0].item;
4021
	if (totalPricingEntries[0] > 0) {
4022
		priceItem(array, 0);
4023
	}
4024
}
4025
 
4026
function _cb_PriceCompletedItems(objArray) {
12 - 4027
//	var array = typeof objArray.findCompletedItemsResponse[0] != 'object' ? JSON.parse(objArray.findCompletedItemsResponse[0]) : objArray.findCompletedItemsResponse[0].searchResult[0].item;
4028
    var array;
4029
    if (objArray.findCompletedItemsResponse[0].searchResult !== undefined) {
4030
    	array = objArray.findCompletedItemsResponse[0].searchResult[0].item;
4031
 
4032
    	totalPricingEntries[1] = Number(objArray.findCompletedItemsResponse[0].paginationOutput[0].totalEntries);
4033
	    if (totalPricingEntries[1] > 0) {
4034
    		priceItem(array, 1);
4035
	    }
10 - 4036
	}
4037
}
4038
 
4039
function priceItem(array, index) {
4040
	var shippingCost = 0.0;
4041
	var itemCost = 0.0;
4042
	var totalCost = 0.0;
4043
	var totalCostInt = 0;
4044
	var sellingStatus;
4045
	var sellingState;
4046
	var bidCount;
4047
	var condInd;
4048
	var conditionId;
4049
 
4050
	if (totalPricingEntries[index] < 1) {
4051
		maxPricingPages[index] = 0;
4052
	} else {
4053
		maxPricingPages[index] = (totalPricingEntries[index] / 100) > 100 ? 100 : Math.trunc(totalPricingEntries[index] / 100.0) + 1;
4054
	}
4055
 
4056
	for (var i = 0; i < array.length; i++) {
4057
		var JsonObj = array[i];
4058
 
4059
		var shippingInfo = JsonObj.shippingInfo;
4060
		var shippingServiceCost = shippingInfo[0].shippingServiceCost;
4061
		if (shippingServiceCost) {
4062
			shippingCost = Number(shippingServiceCost[0].__value__);
4063
		} else {
4064
			shippingCost = 0.0;
4065
		}
4066
 
4067
		sellingStatus = JsonObj.sellingStatus;
4068
		sellingState = sellingStatus[0].sellingState;
4069
		bidCount = sellingStatus[0].bidCount;
4070
		var convertedCurrentPrice = sellingStatus[0].convertedCurrentPrice;
4071
		itemCost = Number(convertedCurrentPrice[0].__value__);
4072
 
4073
		var listingInfo = JsonObj.listingInfo;
4074
		var convertedBuyItNowPrice = listingInfo[0].convertedBuyItNowPrice;
4075
		if (bidCount === 0 && convertedBuyItNowPrice) {
4076
			itemCost = Number(convertedBuyItNowPrice[0].__value__);
4077
		}
4078
 
4079
		var condition = JsonObj.condition;
4080
		if (condition) {
4081
			conditionId = condition[0].conditionId;
4082
			if (conditionId == 1000 || conditionId == 1500 || conditionId == 2750) {
4083
				condInd = 1;
4084
			} else {
4085
				condInd = 2;
4086
			}
4087
		} else {
4088
			condInd = 2;
4089
		}
4090
 
4091
		totalCost = itemCost + shippingCost;
4092
		totalCostInt = Math.ceil(totalCost);
4093
 
4094
		if (sellingState == "Active") {
4095
			if (totalCost < minActive[0] || !minActive[0]) {
4096
				minActive[0] = totalCost;
4097
			}
4098
			if (totalCost > maxActive[0]) {
4099
				maxActive[0] = totalCost;
4100
			}
4101
			avgActive[0] += totalCost;
4102
			++noActive[0];
4103
 
4104
			if (totalCost < minActive[condInd] || !minActive[condInd]) {
4105
				minActive[condInd] = totalCost;
4106
			}
4107
			if (totalCost > maxActive[condInd]) {
4108
				maxActive[condInd] = totalCost;
4109
			}
4110
			avgActive[condInd] += totalCost;
4111
			++noActive[condInd];
4112
 
4113
			if (condInd == 1) {
4114
				if (newActiveBreakdown[totalCostInt] === undefined) {
4115
					newActiveBreakdown[totalCostInt] = 0;
4116
				}
4117
				++newActiveBreakdown[totalCostInt];
4118
			} else {
4119
				if (usedActiveBreakdown[totalCostInt] === undefined) {
4120
					usedActiveBreakdown[totalCostInt] = 0;
4121
				}
4122
				++usedActiveBreakdown[totalCostInt];
4123
			}
4124
		} else if (sellingState == "EndedWithSales") {
4125
			if (totalCost < minSold[0] || !minSold[0]) {
4126
				minSold[0] = totalCost;
4127
			}
4128
			if (totalCost > maxSold[0]) {
4129
				maxSold[0] = totalCost;
4130
			}
4131
			avgSold[0] += totalCost;
4132
			++noSold[0];
4133
 
4134
			if (totalCost < minSold[condInd] || !minSold[condInd]) {
4135
				minSold[condInd] = totalCost;
4136
			}
4137
			if (totalCost > maxSold[condInd]) {
4138
				maxSold[condInd] = totalCost;
4139
			}
4140
			avgSold[condInd] += totalCost;
4141
			++noSold[condInd];
4142
 
4143
			if (condInd == 1) {
4144
				if (newSoldBreakdown[totalCostInt] === undefined) {
4145
					newSoldBreakdown[totalCostInt] = 0;
4146
				}
4147
				++newSoldBreakdown[totalCostInt];
4148
			} else {
4149
				if (usedSoldBreakdown[totalCostInt] === undefined) {
4150
					usedSoldBreakdown[totalCostInt] = 0;
4151
				}
4152
				++usedSoldBreakdown[totalCostInt];
4153
			}
4154
		} else {
4155
			if (totalCost < minUnsold[0] || !minUnsold[0]) {
4156
				minUnsold[0] = totalCost;
4157
			}
4158
			if (totalCost > maxUnsold[0]) {
4159
				maxUnsold[0] = totalCost;
4160
			}
4161
			avgUnsold[0] += totalCost;
4162
			++noUnsold[0];
4163
 
4164
			if (totalCost < minUnsold[condInd] || !minUnsold[condInd]) {
4165
				minUnsold[condInd] = totalCost;
4166
			}
4167
			if (totalCost > maxUnsold[condInd]) {
4168
				maxUnsold[condInd] = totalCost;
4169
			}
4170
			avgUnsold[condInd] += totalCost;
4171
			++noUnsold[condInd];
4172
		}
4173
	}
4174
 
4175
	var x = document.getElementById("prices");
4176
	x.className = x.className.replace(" invisible", " visible");
4177
 
4178
	var str = '<h2>Pricing Information (Shipping included)</h2>';
4179
	str += '<table class="table table-striped table-bordered">';
4180
	str += '  <thead class="thead-dark">';
4181
	str += '	<tr>';
4182
	str += '		<th></th>';
4183
	str += '		<th>Number</th>';
4184
	str += '        <th>Minimum</th>';
4185
	str += '        <th>Maximum</th>';
4186
	str += '        <th>Average</th>';
4187
	str += '	</tr>';
17 - 4188
	str += '  </thead>';
4189
	str += '  <tbody>';
10 - 4190
	str += '	<tr>';
4191
	str += '		<td>Active</td>';
4192
	str += '		<td>' + noActive[0] + '<br/>' + noActive[1] + ' / ' + noActive[2] + '</td>';
4193
	str += '		<td>$' + Number(minActive[0]).toFixed(2) + '<br/>$' + Number(minActive[1]).toFixed(2) + ' / $' + Number(minActive[2]).toFixed(2) + '</td>';
4194
	str += '		<td>$' + Number(maxActive[0]).toFixed(2) + '<br/>$' + Number(maxActive[1]).toFixed(2) + ' / $' + Number(maxActive[2]).toFixed(2) + '</td>';
4195
	str += '		<td>';
4196
	if (noActive[0]) {
4197
		str += '$' + Number(avgActive[0] / noActive[0]).toFixed(2);
4198
		str += '<br/>$' + (noActive[1] > 0 ? Number(avgActive[1] / noActive[1]).toFixed(2) : 0.00);
4199
		str += ' / $' + (noActive[2] > 0 ? Number(avgActive[2] / noActive[2]).toFixed(2) : 0.00);
4200
	}
4201
	str += '        </td>';
4202
	str += '	</tr>';
4203
 
4204
	str += '<tr><td colspan="5">';
4205
	str += '<canvas id="activeChart"></canvas>';
4206
	str += '</td></tr>';
4207
 
4208
	str += '	<tr>';
4209
	str += '		<td>Sold</td>';
4210
	str += '		<td>' + noSold[0] + '<br/>' + noSold[1] + ' / ' + noSold[2] + '</td>';
4211
	str += '		<td>$' + Number(minSold[0]).toFixed(2) + '<br/>$' + Number(minSold[1]).toFixed(2) + ' / $' + Number(minSold[2]).toFixed(2) + '</td>';
4212
	str += '		<td>$' + Number(maxSold[0]).toFixed(2) + '<br/>$' + Number(maxSold[1]).toFixed(2) + ' / $' + Number(maxSold[2]).toFixed(2) + '</td>';
4213
	str += '		<td>';
4214
	if (noSold[0]) {
4215
		str += '$' + Number(avgSold[0] / noSold[0]).toFixed(2);
4216
		str += '<br/>$' + (noSold[1] > 0 ? Number(avgSold[1] / noSold[1]).toFixed(2) : 0.00);
4217
		str += ' / $' + (noSold[2] > 0 ? Number(avgSold[2] / noSold[2]).toFixed(2) : 0.00);
4218
	}
4219
	str += '        </td>';
4220
	str += '	</tr>';
4221
 
4222
	str += '<tr><td colspan="5">';
4223
	str += '<canvas id="soldChart"></canvas>';
4224
	str += '</td></tr>';
4225
 
4226
	str += '	<tr>';
4227
	str += '		<td>Unsold</td>';
4228
	str += '		<td>' + noUnsold[0] + '<br/>' + noUnsold[1] + ' / ' + noUnsold[2] + '</td>';
4229
	str += '		<td>$' + Number(minUnsold[0]).toFixed(2) + '<br/>$' + Number(minUnsold[1]).toFixed(2) + ' / $' + Number(minUnsold[2]).toFixed(2) + '</td>';
4230
	str += '		<td>$' + Number(maxUnsold[0]).toFixed(2) + '<br/>$' + Number(maxUnsold[1]).toFixed(2) + ' / $' + Number(maxUnsold[2]).toFixed(2) + '</td>';
4231
	str += '		<td>';
4232
	if (noUnsold[0]) {
4233
		str += '$' + Number(avgUnsold[0] / noUnsold[0]).toFixed(2);
4234
		str += '<br/>$' + (noUnsold[1] > 0 ? Number(avgUnsold[1] / noUnsold[1]).toFixed(2) : 0.00);
4235
		str += ' / $' + (noUnsold[2] > 0 ? Number(avgUnsold[2] / noUnsold[2]).toFixed(2) : 0.00);
4236
	}
4237
	str += '        </td>';
4238
	str += '	</tr>';
17 - 4239
	str += '  </tbody>';
10 - 4240
	str += '</table>';
4241
 
4242
	x.innerHTML = str;
4243
 
4244
	pricingGraphs(0, usedActiveBreakdown, newActiveBreakdown);
4245
	pricingGraphs(1, usedSoldBreakdown, newSoldBreakdown);
4246
}
4247
 
4248
function pricingGraphs(index, usedBreakdown, newBreakdown) {
4249
	var i;
4250
	var newData = [];
4251
	var usedData = [];
4252
	var labelData = [];
4253
	var ctx = document.getElementById(index === 0 ? 'activeChart' : 'soldChart').getContext('2d');
4254
	var min = findMin(usedBreakdown, newBreakdown);
4255
	var max = findMax(usedBreakdown, newBreakdown);
4256
 
4257
	for (i = min; i < max; i++) {
4258
		labelData.push('<$' + i);
4259
 
4260
		if (usedBreakdown[i] === undefined) {
4261
			usedData.push(0);
4262
		} else {
4263
			usedData.push(usedBreakdown[i]);
4264
		}
4265
 
4266
		if (newBreakdown[i] === undefined) {
4267
			newData.push(0);
4268
		} else {
4269
			newData.push(newBreakdown[i]);
4270
		}
4271
	}
4272
 
4273
	var myChart = new Chart(ctx, {
4274
	  type: 'bar',
4275
	  options: {
4276
	    scales: {
4277
	        yAxes: [{
4278
	            ticks: {
4279
	                fixedStepSize: 1
4280
	            }
4281
	        }],
4282
	    },
4283
	  },
4284
	  data: {
4285
    	labels: labelData,
4286
	    datasets: [{
4287
    	  label: 'Used',
4288
		  data: usedData,
4289
    	  backgroundColor: "rgba(0,102,0,1)"
4290
	    }, {
4291
    	  label: 'New',
4292
	      data: newData,
4293
    	  backgroundColor: "rgba(204,0,0,1)"
4294
	    }]
4295
	  }
4296
	});
4297
}
4298
 
4299
function findMin(Used, New) {
4300
	var i;
4301
	var minUsed = 0, minNew = 0;
4302
	var min = 0;
4303
 
4304
	for (i = 0; i < Used.length; i++) {
4305
		if (Used[i] !== undefined) {
4306
			minUsed = i;
4307
			break;
4308
		}
4309
	}
4310
 
4311
	for (i = 0; i < New.length; i++) {
4312
		if (New[i] !== undefined) {
4313
			minNew = i;
4314
			break;
4315
		}
4316
	}
4317
 
4318
	if (minUsed > 0 && minUsed <= minNew) {
4319
		min = minUsed;
4320
	} else if (minNew > 0 && minNew <= minUsed) {
4321
		min = minNew;
4322
	}
4323
 
4324
	return min;
4325
}
4326
 
4327
function findMax(Used, New) {
4328
	var max = 0;
4329
 
4330
	if (Used.length >= New.length) {
4331
		max = Used.length;
4332
	} else if (New.length >= Used.length) {
4333
		max = New.length;
4334
	}
4335
 
4336
	return max;
4337
}
4338
 
4339
function _cb_findDuplicateListing(root) {
4340
	var x;
4341
	var txt;
4342
	var response = root.findItemsAdvancedResponse[0];
4343
	var ack = response.ack;
4344
	if (ack != 'Success') {
4345
		if (ack == 'Failure' || ack == 'PartialFailure') {
4346
			return;
4347
		}
4348
	}
4349
 
4350
	var items = response.searchResult[0].item || [];
4351
 
4352
	if (Number(response.paginationOutput[0].totalEntries) > 0) {
4353
		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>';
4354
		document.getElementById("duplicatesText").innerHTML += txt;
4355
		x = document.getElementById("duplicates");
4356
    	x.className = x.className.replace(" invisible", " visible");
4357
	}
4358
}
4359
 
4360
function findDuplicateListing() {
4361
	var keywordURL;
4362
	var keyword = document.getElementById('keyword').value;
4363
 
4364
	// Construct the request
4365
	url = configeBayFinding + "?";
4366
	url += "OPERATION-NAME=findItemsAdvanced";
4367
	url += "&SERVICE-VERSION=" + configeBayFindingVersion;
4368
	url += "&SECURITY-APPNAME=" + configAppid;
4369
	url += "&GLOBAL-ID=EBAY-US";
4370
	url += "&RESPONSE-DATA-FORMAT=JSON";
4371
	url += "&REST-PAYLOAD";
4372
 
4373
	if (keyword.length > 0) {
4374
		if (keyword.includes("ReferenceID:")) {
4375
			url += "&productId.@type=ReferenceID";
4376
			url += "&productId=";
4377
			url += keyword.substr(12);
4378
		} else {
4379
			url += "&keywords=";
4380
			url += encodeURIComponent(keyword.trim().replace(/ /g, "+"));
4381
		}
4382
	}
4383
 
4384
	url += "&paginationInput.entriesPerPage=1";
4385
	url += "&paginationInput.pageNumber=1";
4386
	url += "&itemFilter(0).name=Seller";
4387
	url += "&itemFilter(0).value=";
4388
	url += configeBaySellerName;
4389
	url += "&outputSelector=SellerInfo";
4390
 
4391
	// Submit the request
4392
	var xhttp = new XMLHttpRequest();
4393
 
4394
	xhttp.onreadystatechange = function() {
4395
    	if (this.readyState == 4) {
4396
    		_cb_findDuplicateListing(JSON.parse(this.responseText));
4397
        }
4398
    };
4399
 
4400
	xhttp.open("GET", configProxyUrl, true);
4401
	xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
4402
   	xhttp.send();
4403
}
4404
 
4405
function _cb_findPotentialDuplicateListing(root) {
4406
	var x;
4407
	var response = root.findCompletedItemsResponse[0];
4408
	var ack = response.ack;
4409
	if (ack != 'Success') {
4410
		if (ack == 'Failure' || ack == 'PartialFailure') {
4411
			return;
4412
		}
4413
	}
4414
 
4415
	var items = response.searchResult[0].item || [];
4416
 
4417
	if (Number(response.paginationOutput[0].totalEntries) > 0) {
4418
		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>';
4419
		document.getElementById("duplicatesText").innerHTML += txt;
4420
		x = document.getElementById("duplicates");
4421
    	x.className = x.className.replace(" invisible", " visible");
4422
	}
4423
}
4424
 
4425
function findPotentialDuplicateListing() {
4426
	var keywordURL;
4427
	var keyword = document.getElementById('keyword').value;
4428
 
4429
	// Construct the request
4430
	url = configeBayFinding + "?";
4431
	url += "OPERATION-NAME=findCompletedItems";
4432
	url += "&SERVICE-VERSION=" + configeBayFindingVersion;
4433
	url += "&SECURITY-APPNAME=" + configAppid;
4434
	url += "&GLOBAL-ID=EBAY-US";
4435
	url += "&RESPONSE-DATA-FORMAT=JSON";
4436
	url += "&REST-PAYLOAD";
4437
	url += "&keywords=";
4438
	url += encodeURIComponent(keyword.trim().replace(/ /g, "+"));
4439
	url += "&paginationInput.entriesPerPage=1";
4440
	url += "&paginationInput.pageNumber=1";
4441
	url += "&itemFilter(0).name=Seller";
4442
	url += "&itemFilter(0).value=";
4443
	url += configeBaySellerName;
4444
	url += "&outputSelector=SellerInfo";
4445
 
4446
	var xhttp = new XMLHttpRequest();
4447
 
4448
	xhttp.onreadystatechange = function() {
4449
    	if (this.readyState == 4) {
4450
    		_cb_findPotentialDuplicateListing(JSON.parse(this.responseText));
4451
        }
4452
    };
4453
 
4454
	xhttp.open("GET", configProxyUrl, true);
4455
	xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
4456
   	xhttp.send();
4457
}
4458
 
4459
function findShopifyDuplicateListing() { // Barcode Search Only
4460
	var handle;
4461
	var xhttp = new XMLHttpRequest();
4462
	xhttp.onreadystatechange = function() {
4463
		if (this.readyState == 4 && this.status == 200) {
4464
			//window.alert(this.responseText);
4465
			var json = JSON.parse(this.responseText);
4466
			if (json.products[0] !== undefined) {
4467
			    var sku = getJsonValue(json.products[0].variants[0].sku);
4468
				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>';
4469
				document.getElementById("duplicatesText").innerHTML += txt;
4470
        		x = document.getElementById("duplicates");
4471
            	x.className = x.className.replace(" invisible", " visible");
4472
			}
4473
		}
4474
	};
4475
 
4476
	handle = parseInt(document.getElementById('keyword').value, 10);
4477
 
4478
	xhttp.open("GET", configProxyUrl, true);
4479
	xhttp.setRequestHeader("X-Proxy-Url", encodeURI(configShopifyUrl + configShopifyProductsUrl + '?handle=b' + handle + '&fields=id,variants'));
4480
	xhttp.send();
4481
}
4482
 
4483
function checkUPC() {
4484
    var x = document.getElementById("keyword");
4485
    x.focus();
4486
 
4487
    if (isValidUpcCode(document.getElementById("keyword").value)) {
4488
        document.getElementById("recommendation").innerHTML = 'Valid UPC Code';
4489
        document.getElementById("recommendation").className = 'text-success';
4490
    } else {
4491
        var res = calculateUpcRes(document.getElementById("keyword").value);
4492
        if (res > -1) {
4493
            document.getElementById("keyword").value += res;
4494
            document.getElementById("recommendation").innerHTML = 'Finalized UPC Code';
4495
            document.getElementById("recommendation").className = 'text-warning';
4496
        } else {
4497
            document.getElementById("recommendation").innerHTML = 'Invalid UPC Code';
4498
            document.getElementById("recommendation").className = 'text-danger';
4499
        }
4500
    }
4501
}
4502
 
4503
    </script>
4504
 
4505
    <script src="js/chosen.jquery.min.js"></script>
4506
    <script src="js/chosen.init.js"></script>
17 - 4507
    <script>includeHTML();</script>
10 - 4508
</body>
4509
</html>