Subversion Repositories munaweb

Rev

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