Subversion Repositories munaweb

Rev

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

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