Subversion Repositories munaweb

Rev

Details | Last modification | View Log | RSS feed

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