Subversion Repositories munaweb

Rev

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

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