Subversion Repositories munaweb

Rev

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

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