Subversion Repositories munaweb

Rev

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

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