Subversion Repositories munaweb

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
10 - 1
<!DOCTYPE html>
2
<html lang="en">
3
 
4
<head>
5
    <title>eBay Quick Listing</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
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
12
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
13
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
14
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
15
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.2/css/bootstrap-select.min.css">
16
    <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
17
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.2/js/bootstrap-select.js"></script>
18
    <script src="js/XMLWriter.js"></script>
19
    <script src="https://cdn.jsdelivr.net/npm/lodash@4.17.11/lodash.min.js"></script>
20
    <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.min.js"></script>
21
    <link rel="stylesheet" href="css/styleBS.css">
22
    <script src="js/muna-tools.js"></script>
12 - 23
    <style>
24
        .btn-group-sm > .btn, .btn-sm {font-size:small!important}
25
    </style>
10 - 26
</head>
27
 
28
<body style="font-size:80%!important;" onload="return initConfig();" onbeforeunload="return confirmUnload();">
29
    <div class="container-fluid">
30
        <div class="container-fluid">
31
            <div class="container-fluid bg-secondary">
32
                <div class="clearfix">
33
                    <img class="img-fluid float-right" src="images/MUNA%20-%20Logo%20100x100.png" alt="MUNA Trading Logo" />
34
                    <h1 id="connected">eBay Quick Listing
35
                    <input id="login" type="button" class="btn bg-success mb-2 w3-hide" onclick="eBayLogin();" value="Login" /></h1>
36
                </div>
37
            </div>
38
 
39
            <div class="container-fluid bg-light">
12 - 40
                <div class="row">
41
                    <div class="container-fluid border col-6">
42
                        <div class="container-fluid border bg-primary">
43
                            <div class="form-group">
44
                                <form id="searchForm" onsubmit="findOneBay();return false;">
45
                                    <select id="keyword" title="Select Item ..." class="selectpicker mx-2 mt-2 btn-sm" data-style="btn-sm" data-width="fit" data-live-search="true" autofocus="autofocus" onchange="findOneBay();">
46
                                    </select>
47
                                </form>
10 - 48
                            </div>
12 - 49
                        </div>
10 - 50
 
12 - 51
                        <div class="container-fluid border">
52
                            <form id="listForm">
53
                                <div class="mt-2">
54
                                    <label for="category" class="mr-sm-2">Category:</label>
55
                                    <select id="category" name="category" data-placeholder="Select Category..." class="selectpicker mb-2 mr-sm-2" data-style="btn-outline-dark btn-sm" onchange="return categoryValues();" onload="return categoryValues();">
56
                                        <option class="small" value="29792">Audiobooks</option>
57
                                        <option class="small" value="29223">Books Antiquarian &amp; Collectible</option>
58
                                        <option class="small" value="182882">Books Children Young Adults</option>
59
                                        <option class="small" value="171228">Books Fiction Literature</option>
60
                                        <option class="small" value="171243">Books Nonfiction</option>
61
                                        <option class="small" value="268">Books Other</option>
62
                                        <option class="small" value="2228">Books Textbooks, Education</option>
63
                                        <option class="small" selected="selected" value="176984">CDs</option>
64
                                        <option class="small" value="617">DVDs Blu-ray Discs</option>
65
                                        <!--option value="666">Trading Cards Auto Racing</option-->
66
                                        <option class="small" value="213">Trading Cards Baseball</option>
67
                                        <option class="small" value="214">Trading Cards Basketball</option>
68
                                        <!--option value="133072">Trading Cards College</option-->
69
                                        <option class="small" value="215">Trading Cards Football</option>
70
                                        <!--option value="4240">Trading Cards Golf</option-->
71
                                        <option class="small" value="216">Trading Cards Ice Hockey</option>
72
                                        <!--option value="183444">Trading Cards Soccer</option-->
10 - 73
                                    </select>
12 - 74
                                    <label for="format" class="mr-sm-2">Format:</label>
75
                                    <select id="format" name="format" data-placeholder="Select Format..." class="selectpicker mb-2 mr-sm-2" data-style="btn-outline-dark btn-sm" onchange="return categoryValues();" onload="return categoryValues();">
76
                                        <option class="small" value="Chinese">Auction</option>
15 - 77
                                        <option class="small" value="FixedPriceItem" selected>Fixed Price</option>
10 - 78
                                    </select>
79
                                </div>
80
 
12 - 81
                                <div class="mt-2">
82
                                    <div class="clearfix">
83
                                        <a id="image1anchor" href="#" target="_blank"><img id="image1" src="images/default-image.png" alt="(Front Image Missing)" style="max-height:80px;" onload="return pictureLoad(true);" onerror="return pictureLoad(false);" crossorigin="anonymous" /></a>
84
                                        <a id="image2anchor" href="#" target="_blank"><img id="image2" src="images/default-image.png" alt="(Back Image Missing)" style="max-height:80px;" onload="return pictureLoad(true);" onerror="return pictureLoad(false);" crossorigin="anonymous" /></a>
85
                                        <img id="descriptionImage" src="images/default-image.png" alt="(Front/Back Image Missing)" style="max-height:50px;display:inline-block;" onload="return pictureLoad(true);" onerror="return pictureLoad(false); " crossorigin="anonymous" />
86
                                        <a id="image3anchor" class=" invisible" href="#" target="_blank"><img id="image3" src="images/default-image.png" alt="(Optional Image 3)" style="max-height:80px;" crossorigin="anonymous" /></a>
87
                                        <a id="image4anchor" class=" invisible" href="#" target="_blank"><img id="image4" src="images/default-image.png" alt="(Optional Image 4)" style="max-height:80px;" crossorigin="anonymous" /></a>
88
                                        <a id="image5anchor" class=" invisible" href="#" target="_blank"><img id="image5" src="images/default-image.png" alt="(Optional Image 5)" style="max-height:80px;" crossorigin="anonymous" /></a>
89
                                        <a id="image6anchor" class=" invisible" href="#" target="_blank"><img id="image6" src="images/default-image.png" alt="(Optional Image 6)" style="max-height:80px;" crossorigin="anonymous" /></a>
90
                                        <a id="image7anchor" class=" invisible" href="#" target="_blank"><img id="image7" src="images/default-image.png" alt="(Optional Image 7)" style="max-height:80px;" crossorigin="anonymous" /></a>
91
                                        <a id="image8anchor" class=" invisible" href="#" target="_blank"><img id="image8" src="images/default-image.png" alt="(Optional Image 8)" style="max-height:80px;" crossorigin="anonymous" /></a>
92
                                        <a id="image9anchor" class=" invisible" href="#" target="_blank"><img id="image9" src="images/default-image.png" alt="(Optional Image 9)" style="max-height:80px;" crossorigin="anonymous" /></a>
93
                                        <a id="image10anchor" class=" invisible" href="#" target="_blank"><img id="image10" src="images/default-image.png" alt="(Optional Image 10)" style="max-height:80px;" crossorigin="anonymous" /></a>
94
                                    </div>
10 - 95
                                </div>
12 - 96
 
97
                                <div class="mt-2">
98
                                    <label for="title" class="keepTogether mr-sm-2">Title:</label>
99
                                    <input id="title" name="title" type="text" maxlength="80" style="width:90%" onblur="return extractFromTitle();" onKeyPress="printTitleLength()" onKeyUp="printTitleLength()" required>
100
                                    <span id="titleLength" class="small">(0)</span>
10 - 101
                                </div>
12 - 102
 
103
                                <div class="mt-2">
104
                                    <label for="price" class="keepTogether mr-sm-2">Price:</label>
105
                                    <input id="price" name="price" style="width:8%" type="text" required>
106
                                    <label for="bestoffer" class="mr-sm-2">Best Offer:</label>
107
                                    <input id="bestoffer" name="bestoffer" class="checkbox" type="checkbox">
108
                                    <label for="quantity" class="keepTogether mr-sm-2">Quantity:</label>
109
                                    <input id="quantity" name="quantity" style="width:8%" type="text" value="1" maxlength="4" required>
110
                                    <label for="sku" class="keepTogether mr-sm-2">SKU:</label>
111
                                    <input id="sku" name="sku" style="width:12%" type="text" value="Batch X" maxlength="20" required>
112
                                    <label for="conditionId" class="keepTogether mr-sm-2">Condition:</label>
113
                                    <select id="conditionId" name="conditionId" data-placeholder="Select Condition..." class="selectpicker" data-style="btn-outline-dark btn-sm">
114
                                        <option class="small" value="1000">New</option>
115
                                        <option class="small" value="1500">New other (see details)</option>
116
                                        <option class="small" value="1750">New with defects</option>
117
                                        <option class="small" value="2000">Manufacturer refurbished</option>
118
                                        <option class="small" value="2500">Seller refurbished</option>
119
                                        <option class="small" value="2750">Like New</option>
120
                                        <option class="small" value="3000">Used / Pre-owned</option>
121
                                        <option class="small" value="4000">Very Good</option>
122
                                        <option class="small" value="5000">Good</option>
123
                                        <option class="small" value="6000">Acceptable</option>
124
                                        <option class="small" value="7000">For parts or not working</option>
125
                                    </select>
10 - 126
                                </div>
12 - 127
                                <div class="form-group">
128
                                    <label for="condition">Condition Description:</label>
129
                                    <input id="CdConditionDescriptionSingular" type="button" class="btn btn-dark btn-xs border rounded-circle w3-hide" onclick="return setCdConditionDescription('S');" value="S" />
130
                                    <input id="CdConditionDescriptionPlural" type="button" class="btn btn-dark btn-xs border rounded-circle w3-hide" onclick="return setCdConditionDescription('P');" value="P" />
131
                                    <input id="CdConditionDescriptionDigipak" type="button" class="btn btn-dark btn-xs border rounded-circle w3-hide" onclick="return setCdConditionDescription('D');" value="D" />
132
                                    <input id="CdConditionDescriptionNewCase" type="button" class="btn btn-dark btn-xs border rounded-circle w3-hide" onclick="return setCdConditionDescription('N');" value="N" />
133
                                    <textarea id="condition" name="condition" class="form-control" style="font-size:95%!important" rows="2" maxlength="1000" required></textarea>
10 - 134
                                </div>
135
                            </form>
12 - 136
                            <div id="bookDetails" class="container-fluid  ">
137
                                <form id="bookForm" class="form-fluid">
138
                                    <div>
139
                                        <label for="bookISBN" class="keepTogether mr-sm-2">ISBN:</label>
140
                                        <input id="bookISBN" name="bookISBN" style="width:13%" type="text" disabled>
141
                                        <label for="bookFormat" class="keepTogether mr-sm-2">Format:</label>
142
                                        <select id="bookFormat" name="bookFormat" data-placeholder="Select Format..." class="selectpicker" data-style="btn-outline-dark btn-sm">
143
                                            <option class="small" value="Hardcover">Hardcover</option>
144
                                            <option class="small" value="Paperback">Paperback</option>
145
                                            <option class="small" value="CD-ROM (Non-Audio)">CD-ROM (Non-Audio)</option>
146
                                            <option class="small" value="Mixed Lot">Mixed Lot</option>
147
                                            <option class="small" value="Board Book">Board Book</option>
148
                                            <option class="small" value="Loose-Leaf">Loose-Leaf</option>
149
                                            <option class="small" value="Postcard Book">Postcard Book</option>
150
                                            <option class="small" value="Shrink-Wrapped Pack">Shrink-Wrapped Pack</option>
151
                                        </select>
152
                                        <label for="bookAuthor" class="keepTogether mr-sm-2">Author:</label>
153
                                        <input id="bookAuthor" name="bookAuthor" style="width:29%" type="text" maxlength="40">
154
                                        <label for="bookPublicationYear" class="keepTogether mr-sm-2">Year:</label>
155
                                        <input id="bookPublicationYear" name="bookPublicationYear" style="width:8%" type="text" maxlength="4">
156
                                    </div>
157
                                    <div>
158
                                        <label for="bookSubject" class="keepTogether mr-sm-2">Subject:</label>
159
                                        <select id="bookSubject" name="bookSubject" data-placeholder="Select Subject..." class="selectpicker" data-style="btn-outline-dark btn-sm">
160
                                            <option class="small" value="Activity &amp; Coloring Books">Activity & Coloring Books</option>
161
                                            <option class="small" value="Architecture &amp; Design">Architecture & Design</option>
162
                                            <option class="small" value="Art &amp; Photography">Art & Photography</option>
163
                                            <option class="small" value="Biography &amp; Autobiography">Biography & Autobiography</option>
164
                                            <option class="small" value="Books on Collecting">Books on Collecting</option>
165
                                            <option class="small" value="Business &amp; Economics">Business & Economics</option>
166
                                            <option class="small" value="Computers &amp; Internet">Computers & Internet</option>
167
                                            <option class="small" value="Cooking, Food &amp; Wine">Cooking, Food & Wine</option>
168
                                            <option class="small" value="Erotica">Erotica</option>
169
                                            <option class="small" value="Family &amp; Relationships">Family & Relationships</option>
170
                                            <option class="small" value="Games &amp; Puzzles">Games & Puzzles</option>
171
                                            <option class="small" value="Health &amp; Fitness">Health & Fitness</option>
172
                                            <option class="small" value="History">History</option>
173
                                            <option class="small" value="Hobbies &amp; Crafts">Hobbies & Crafts</option>
174
                                            <option class="small" value="Home &amp; Garden">Home & Garden</option>
175
                                            <option class="small" value="Humor">Humor</option>
176
                                            <option class="small" value="Law &amp; Government">Law & Government</option>
177
                                            <option class="small" value="Library &amp; Information Science">Library & Information Science</option>
178
                                            <option class="small" value="Literary Criticism">Literary Criticism</option>
179
                                            <option class="small" value="Literature">Literature</option>
180
                                            <option class="small" value="Medical">Medical</option>
181
                                            <option class="small" value="Military &amp; War">Military & War</option>
182
                                            <option class="small" value="Novel">Novel</option>
183
                                            <option class="small" value="Outdoor &amp; Nature">Outdoor & Nature</option>
184
                                            <option class="small" value="Paranormal &amp; Metaphysical">Paranormal & Metaphysical</option>
185
                                            <option class="small" value="Performing Arts">Performing Arts</option>
186
                                            <option class="small" value="Pets &amp; Animal Care">Pets & Animal Care</option>
187
                                            <option class="small" value="Philosophy">Philosophy</option>
188
                                            <option class="small" value="Psychology">Psychology</option>
189
                                            <option class="small" value="Reference">Reference</option>
190
                                            <option class="small" value="Religion &amp; Spirituality">Religion & Spirituality</option>
191
                                            <option class="small" value="Science &amp; Technology">Science & Technology</option>
192
                                            <option class="small" value="Self-Help">Self-Help</option>
193
                                            <option class="small" value="Sexuality">Sexuality</option>
194
                                            <option class="small" value="Social Sciences">Social Sciences</option>
195
                                            <option class="small" value="Sports &amp; Recreation">Sports & Recreation</option>
196
                                            <option class="small" value="Teaching &amp; Education">Teaching & Education</option>
197
                                            <option class="small" value="Transportation">Transportation</option>
198
                                            <option class="small" value="Travel, Geography &amp; Exploration">Travel, Geography & Exploration</option>
199
                                            <option class="small" value="True Crime">True Crime</option>
200
                                            <option class="small" value="Vintage Paperbacks">Vintage Paperbacks</option>
201
                                        </select>
202
                                        <label for="bookLanguage" class="keepTogether mr-sm-2">Language:</label>
203
                                        <input id="bookLanguage" name="bookLanguage" style="width:20%" type="text">
204
                                        <label for="bookCountry" class="keepTogether mr-sm-2">Country:</label>
205
                                        <input id="bookCountry" name="bookCountry" style="width:25%" type="text" maxlength="65">
206
                                    </div>
10 - 207
 
17 - 208
                                    <div class="border">
12 - 209
                                        <div class="form-check-inline">
210
                                            <label class="form-check-label">Special Attributes:</label>
211
                                        </div>
212
                                        <div class="form-check-inline">
213
                                            <label class="form-check-label" for="bookDustJacket">
214
                                                <input id="bookDustJacket" name="bookDustJacket" class="form-check-input" type="checkbox">Dust Jacket
215
                                            </label>
216
                                        </div>
217
                                        <div class="form-check-inline">
218
                                            <label class="form-check-label" for="bookIllustrated">
219
                                                <input id="bookIllustrated" name="bookIllustrated" class="form-check-input" type="checkbox">Illustrated
220
                                            </label>
221
                                        </div>
222
                                        <div class="form-check-inline">
223
                                            <label class="form-check-label" for="bookLargePrint">
224
                                                <input id="bookLargePrint" name="bookLargePrint" class="form-check-input" type="checkbox">Large Print
225
                                            </label>
226
                                        </div>
227
                                        <div class="form-check-inline">
228
                                            <label class="form-check-label" for="bookSigned">
229
                                                <input id="bookSigned" name="bookSigned" class="form-check-input" type="checkbox">Signed
230
                                            </label>
231
                                        </div>
232
                                    </div>
233
                                </form>
10 - 234
                            </div>
12 - 235
                            <div id="cdDetails" class="container-fluid  ">
236
                                <form id="cdForm" class="form-fluid">
237
                                    <div>
238
                                        <label for="cdUPC" class="keepTogether w3-hide">UPC:</label>
239
                                        <input id="cdUPC" name="cdUPC" class="w3-hide" type="text" disabled>
240
                                        <label for="cdArtist" class="keepTogether mr-sm-2">Artist:</label>
241
                                        <input id="cdArtist" name="cdArtist" style="width:30%" type="text" maxlength="40">
242
                                        <label for="cdTitle" class="keepTogether mr-sm-2">Title:</label>
243
                                        <input id="cdTitle" name="cdTitle" style="width:30%" type="text" maxlength="65">
244
                                        <label for="cdRecordLabel" class="keepTogether mr-sm-2">Label:</label>
245
                                        <input id="cdRecordLabel" name="cdRecordLabel" style="width:20%" type="text" maxlength="40">
246
                                    </div>
247
                                    <div>
248
                                        <label for="cdReleaseYear" class="keepTogether mr-sm-2">Year:</label>
249
                                        <input id="cdReleaseYear" name="cdReleaseYear" type="text" style="width:6%" maxlength="4">
250
                                        <label for="cdDuration" class="keepTogether mr-sm-2">Duration:</label>
251
                                        <select id="cdDuration" name="cdDuration" data-placeholder="Select Duration..." class="selectpicker" data-width="auto" data-style="btn-outline-dark btn-sm">
252
                                            <option class="small" value="Album" selected>Album</option>
253
                                            <option class="small" value="Mini Album">Mini Album</option>
254
                                            <option class="small" value="Box Set">Box Set</option>
255
                                            <option class="small" value="EP">EP</option>
256
                                            <option class="small" value="Single">Single</option>
257
                                            <option class="small" value="Maxi-Single">Maxi-Single</option>
258
                                        </select>
259
                                        <label for="cdGenre" class="keepTogether mr-sm-2">Genre:</label>
260
                                        <select id="cdGenre" name="cdGenre" data-placeholder="Select Genre..." class="selectpicker" data-width="auto" data-style="btn-outline-dark btn-sm">
261
                                            <option class="small" value="Blues">Blues</option>
262
                                            <option class="small" value="Children&apos;s">Children's</option>
263
                                            <option class="small" value="Classical">Classical</option>
264
                                            <option class="small" value="Comedy &amp; Spoken Word">Comedy & Spoken Word</option>
265
                                            <option class="small" value="Country">Country</option>
266
                                            <option class="small" value="Dance &amp; Electronica">Dance & Electronica</option>
267
                                            <option class="small" value="Folk">Folk</option>
268
                                            <option class="small" value="Holiday">Holiday</option>
269
                                            <option class="small" value="Jazz">Jazz</option>
270
                                            <option class="small" value="Latin">Latin</option>
271
                                            <option class="small" value="Metal">Metal</option>
272
                                            <option class="small" value="Military">Military</option>
273
                                            <option class="small" value="New Age &amp; Easy Listening">New Age & Easy Listening</option>
274
                                            <option class="small" value="Pop">Pop</option>
275
                                            <option class="small" value="R&amp;B &amp; Soul">R&B & Soul</option>
276
                                            <option class="small" value="Rap &amp; Hip-Hop">Rap & Hip-Hop</option>
277
                                            <option class="small" value="Reggae, Ska &amp; Dub">Reggae, Ska & Dub</option>
278
                                            <option class="small" value="Religious &amp; Devotional">Religious & Devotional</option>
279
                                            <option class="small" value="Rock">Rock</option>
280
                                            <option class="small" value="Soundtracks &amp; Musicals">Soundtracks & Musicals</option>
281
                                            <option class="small" value="Sound Effects &amp; Nature">Sound Effects & Nature</option>
282
                                            <option class="small" value="World Music">World Music</option>
283
                                        </select>
284
                                        <label for="cdCountry" class="keepTogether mr-sm-2">Country:</label>
285
                                        <input id="cdCountry" name="cdCountry" type="text" style="width:16%" maxlength="65">
286
                                    </div>
10 - 287
 
17 - 288
                                    <div class="border">
12 - 289
                                        <span>Special Attributes:<br/></span>
290
                                        <div class="form-check-inline">
291
                                            <label class="form-check-label" for="cdCompilation">
292
                                                <input id="cdCompilation" name="cdCompilation" class="form-check-input" type="checkbox">Compilation
293
                                            </label>
10 - 294
                                        </div>
12 - 295
                                        <div class="form-check-inline">
296
                                            <label class="form-check-label" for="cdDigipak">
297
                                                <input id="cdDigipak" name="cdDigipak" class="form-check-input" type="checkbox">Digipak
298
                                            </label>
299
                                        </div>
300
                                        <div class="form-check-inline">
301
                                            <label class="form-check-label" for="cdDualDisc">
302
                                                <input id="cdDualDisc" name="cdDualDisc" class="form-check-input" type="checkbox">DualDisc
303
                                            </label>
304
                                        </div>
305
                                        <div class="form-check-inline">
306
                                            <label class="form-check-label" for="cdEnhanced">
307
                                                <input id="cdEnhanced" name="cdEnhanced" class="form-check-input" type="checkbox">Enhanced
308
                                            </label>
309
                                        </div>
310
                                        <div class="form-check-inline">
311
                                            <label class="form-check-label" for="cdLiveRecording">
312
                                                <input id="cdLiveRecording" name="cdLiveRecording" class="form-check-input" type="checkbox">Live
313
                                            </label>
314
                                        </div>
315
                                        <div class="form-check-inline">
316
                                            <label class="form-check-label" for="cdPromo">
317
                                                <input id="cdPromo" name="cdPromo" class="form-check-input" type="checkbox">Promo
318
                                            </label>
319
                                        </div>
320
                                        <div class="form-check-inline">
321
                                            <label class="form-check-label" for="cdReissue">
322
                                                <input id="cdReissue" name="cdReissue" class="form-check-input" type="checkbox">Reissue
323
                                            </label>
324
                                        </div>
325
                                        <div class="form-check-inline">
326
                                            <label class="form-check-label" for="cdRemastered">
327
                                                <input id="cdRemastered" name="cdRemastered" class="form-check-input" type="checkbox">Remastered
328
                                            </label>
329
                                        </div>
330
                                        <div class="form-check-inline">
331
                                            <label class="form-check-label" for="cdHDCD">
332
                                                <input id="cdHDCD" name="cdHDCD" class="form-check-input" type="checkbox">HDCD
333
                                            </label>
334
                                        </div>
335
                                        <div class="form-check-inline">
336
                                            <label class="form-check-label" for="cdGreatestHits">
337
                                                <input id="cdGreatestHits" name="cdGreatestHits" class="form-check-input" type="checkbox">Greatest Hits
338
                                            </label>
339
                                        </div>
340
                                    </div>
341
 
342
                                    <div>
343
                                        <div class="container-fluid row">
344
                                            <div class="container-fluid col-6">
345
                                                <label for="cdTracksFormat" class="mb-2 mr-sm-2">Track List (optional):</label>
346
                                                <input id="cdTracksFormat" type="button" class="btn btn-dark btn-xs border rounded-circle mb-2 mr-sm-2" onclick="return formatTrackList();" value="Format" />
347
                                                <input id="cdUnorderedTrackList" name="cdUnorderedTrackList" class="mb-2" type="checkbox" onchange="return updateTracklistPreview();">
348
                                                <label for="cdUnorderedTrackList" class="mb-2 mr-sm-2">Unordered</label>
349
                                                <textarea id="cdTracks" name="cdTracks" class="form-control" style="font-size:95%!important" rows="12"></textarea>
10 - 350
                                            </div>
12 - 351
                                            <div class="container-fluid col-6">
352
                                                <p>Preview:</p>
353
                                                <div class="border">
354
                                                    <p id="tracklistPreview"></p>
355
                                                </div>
356
                                            </div>
10 - 357
                                        </div>
358
                                    </div>
12 - 359
                                </form>
360
                            </div>
361
                            <div id="dvdDetails" class="container-fluid  ">
362
                                <form id="dvdForm" class="form-fluid">
363
                                    <div>
364
                                        <label for="dvdUPC" class="keepTogether mr-sm-2">UPC:</label>
365
                                        <input id="dvdUPC" name="dvdUPC" style="width:13%" type="text" disabled>
366
                                        <label for="dvdFormat" class="keepTogether mr-sm-2">Format:</label>
367
                                        <select id="dvdFormat" name="dvdFormat" data-placeholder="Select Format..." class="selectpicker" data-style="btn-outline-dark btn-sm">
368
                                            <option class="small" value="Blu-ray Disc">Blu-ray Disc</option>
369
                                            <option class="small" value="DVD" selected>DVD</option>
370
                                            <option class="small" value="HD DVD">HD DVD</option>
371
                                            <option class="small" value="UltraViolet Code">UltraViolet Code</option>
372
                                        </select>
373
                                        <label for="dvdTitle" class="keepTogether mr-sm-2">Title:</label>
374
                                        <input id="dvdTitle" name="dvdTitle" style="width:44%" type="text" maxlength="65">
375
                                    </div>
376
                                    <div>
377
                                        <label for="dvdActor" class="keepTogether mr-sm-2">Actor:</label>
378
                                        <input id="dvdActor" name="dvdActor" style="width:30%" type="text" maxlength="65">
379
                                        <label for="dvdLeadingRole" class="keepTogether mr-sm-2">Lead:</label>
380
                                        <input id="dvdLeadingRole" name="dvdLeadingRole" style="width:30%" type="text" maxlength="65">
381
                                        <label for="dvdDirector" class="keepTogether mr-sm-2">Director:</label>
382
                                        <input id="dvdDirector" name="dvdDirector" style="width:20%" type="text" maxlength="65">
383
                                    </div>
384
                                    <div>
385
                                        <label for="dvdReleaseYear" class="keepTogether mr-sm-2">Movie Year:</label>
386
                                        <input id="dvdReleaseYear" name="dvdReleaseYear" style="width:8%" type="text" maxlength="4">
387
                                        <label for="dvdDVDEditionYear" class="keepTogether mr-sm-2">DVD Year:</label>
388
                                        <input id="dvdDVDEditionYear" name="dvdDVDEditionYear" style="width:8%" type="text" maxlength="4">
389
                                        <label for="dvdGenre" class="keepTogether mr-sm-2">Genre:</label>
390
                                        <select id="dvdGenre" name="dvdGenre" data-placeholder="Select Genre..." class="selectpicker" data-style="btn-outline-dark btn-sm">
391
                                            <option class="small" value="Action &amp; Adventure">Action & Adventure</option>
392
                                            <option class="small" value="Animation &amp; Anime">Animation & Anime</option>
393
                                            <option class="small" value="Children&apos;s &amp; Family">Children's & Family</option>
394
                                            <option class="small" value="Comedy">Comedy</option>
395
                                            <option class="small" value="Documentary">Documentary</option>
396
                                            <option class="small" value="Drama">Drama</option>
397
                                            <option class="small" value="Educational">Educational</option>
398
                                            <option class="small" value="Exercise &amp; Fitness">Exercise & Fitness</option>
399
                                            <option class="small" value="Foreign Language">Foreign Language</option>
400
                                            <option class="small" value="Horror">Horror</option>
401
                                            <option class="small" value="Music &amp; Concerts">Music & Concerts</option>
402
                                            <option class="small" value="Musicals &amp; Broadway">Musicals & Broadway</option>
403
                                            <option class="small" value="Romance">Romance</option>
404
                                            <option class="small" value="Sci-Fi &amp; Fantasy">Sci-Fi & Fantasy</option>
405
                                            <option class="small" value="Sports">Sports</option>
406
                                            <option class="small" value="Thriller &amp; Mystery">Thriller & Mystery</option>
407
                                            <option class="small" value="TV Shows">TV Shows</option>
408
                                            <option class="small" value="Westerns">Westerns</option>
409
                                        </select>
410
                                        <label for="dvdRating" class="keepTogether mr-sm-2">Rating:</label>
411
                                        <select id="dvdRating" name="dvdRating" data-placeholder="Select Rating..." class="selectpicker" data-style="btn-outline-dark btn-sm">
412
                                            <option class="small" value="G">G</option>
413
                                            <option class="small" value="PG">PG</option>
414
                                            <option class="small" value="PG-13">PG-13</option>
415
                                            <option class="small" value="R">R</option>
416
                                            <option class="small" value="NR">NR</option>
417
                                            <option class="small" value="NC-17">NC-17</option>
418
                                            <option class="small" value="TV-Y">TV-Y</option>
419
                                            <option class="small" value="TV-Y7">TV-Y7</option>
420
                                            <option class="small" value="TV-G">TV-G</option>
421
                                            <option class="small" value="TV-PG">TV-PG</option>
422
                                            <option class="small" value="TV-14">TV-14</option>
423
                                            <option class="small" value="TV-MA">TV-MA</option>
424
                                        </select>
425
                                    </div>
426
                                    <div>
427
                                        <label for="dvdRegionCode" class="keepTogether mr-sm-2">Region:</label>
428
                                        <select id="dvdRegionCode" name="dvdRegionCode" data-placeholder="Select Region..." class="selectpicker" data-width="auto" data-style="btn-outline-dark btn-sm">
429
                                            <option class="small" value="Blu-ray: Region Free">Blu-ray: Region Free</option>
430
                                            <option class="small" value="Blu-ray: A (Americas, Southeast Asia...)">Blu-ray: A</option>
431
                                            <option class="small" value="Blu-ray: B (Europe, AU, NZ, Africa...)">Blu-ray: B</option>
432
                                            <option class="small" value="Blu-ray: C (China, Russia, India...)">Blu-ray: C</option>
433
                                            <option class="small" value="DVD: 0/All (Region Free/Worldwide)">DVD: 0/All</option>
434
                                            <option class="small" value="DVD: 1 (US, Canada...)" selected>DVD: 1</option>
435
                                            <option class="small" value="DVD: 2 (Europe, Japan, Middle East...)">DVD: 2</option>
436
                                            <option class="small" value="DVD: 3 (Southeast Asia, Taiwan, HK...)">DVD: 3</option>
437
                                            <option class="small" value="DVD: 4 (AU, NZ, Latin America...)">DVD: 4</option>
438
                                            <option class="small" value="DVD: 5 (Russia, India, Africa...)">DVD: 5</option>
439
                                            <option class="small" value="DVD: 6 (China)">DVD: 6 (China)</option>
440
                                        </select>
441
                                        <label for="dvdRental" class="keepTogether mr-sm-2">Rental:</label>
442
                                        <select id="dvdRental" name="dvdRental" class="selectpicker" data-width="fit" data-style="btn-outline-dark btn-sm">
443
                                            <option class="small" value="No" selected>No</option>
444
                                            <option class="small" value="Yes">Yes</option>
445
                                        </select>
446
                                        <label for="dvdSeason" class="keepTogether mr-sm-2">Season:</label>
447
                                        <select id="dvdSeason" name="dvdSeason" data-placeholder="Select Season..." class="selectpicker" data-width="auto" data-style="btn-outline-dark btn-sm">
448
                                            <option class="small" value="Complete Series Box Set">Complete Series Box Set</option>
449
                                            <option class="small" value="1">1</option>
450
                                            <option class="small" value="2">2</option>
451
                                            <option class="small" value="3">3</option>
452
                                            <option class="small" value="4">4</option>
453
                                            <option class="small" value="5">5</option>
454
                                            <option class="small" value="6">6</option>
455
                                            <option class="small" value="7">7</option>
456
                                            <option class="small" value="8">8</option>
457
                                            <option class="small" value="9">9</option>
458
                                            <option class="small" value="10">10</option>
459
                                            <option class="small" value="11">11</option>
460
                                            <option class="small" value="12">12</option>
461
                                            <option class="small" value="13">13</option>
462
                                            <option class="small" value="14">14</option>
463
                                            <option class="small" value="15">15</option>
464
                                            <option class="small" value="16">16</option>
465
                                            <option class="small" value="17">17</option>
466
                                            <option class="small" value="18">18</option>
467
                                            <option class="small" value="19">19</option>
468
                                            <option class="small" value="20">20</option>
469
                                            <option class="small" value="21">21</option>
470
                                            <option class="small" value="22">22</option>
471
                                            <option class="small" value="23">23</option>
472
                                            <option class="small" value="24">24</option>
473
                                        </select>
474
                                        <label for="dvdCountry" class="keepTogether mr-sm-2">Country:</label>
475
                                        <input id="dvdCountry" name="dvdCountry" style="width:14%" type="text" maxlength="65">
476
                                    </div>
477
 
17 - 478
                                    <div class="border">
12 - 479
                                        <div class="form-check-inline">
480
                                            <label class="form-check-label">Special Attributes:</label>
481
                                        </div>
482
                                        <div class="form-check-inline">
483
                                            <label class="form-check-label" for="dvd3D">
484
                                                <input id="dvd3D" name="dvd3D" class="form-check-input" type="checkbox">3D
485
                                            </label>
486
                                        </div>
487
                                        <div class="form-check-inline">
488
                                            <label class="form-check-label" for="dvdAnniversaryEdition">
489
                                                <input id="dvdAnniversaryEdition" name="dvdAnniversaryEdition" class="form-check-input" type="checkbox">Anniversary Edition
490
                                            </label>
491
                                        </div>
492
                                        <div class="form-check-inline">
493
                                            <label class="form-check-label" for="dvdBoxSet">
494
                                                <input id="dvdBoxSet" name="dvdBoxSet" class="form-check-input" type="checkbox">Box Set
495
                                            </label>
496
                                        </div>
497
                                        <div class="form-check-inline">
498
                                            <label class="form-check-label" for="dvdCollectorsEdition">
499
                                                <input id="dvdCollectorsEdition" name="dvdCollectorsEdition" class="form-check-input" type="checkbox">Collector's Edition
500
                                            </label>
501
                                        </div>
502
                                        <div class="form-check-inline">
503
                                            <label class="form-check-label" for="dvdDeluxeEdition">
504
                                                <input id="dvdDeluxeEdition" name="dvdDeluxeEdition" class="form-check-input" type="checkbox">Deluxe Edition
505
                                            </label>
506
                                        </div>
507
                                        <div class="form-check-inline">
508
                                            <label class="form-check-label" for="dvdDirectorsCut">
509
                                                <input id="dvdDirectorsCut" name="dvdDirectorsCut" class="form-check-input" type="checkbox">Director's Cut
510
                                            </label>
511
                                        </div>
512
                                        <div class="form-check-inline">
513
                                            <label class="form-check-label" for="dvdExtendedEdition">
514
                                                <input id="dvdExtendedEdition" name="dvdExtendedEdition" class="form-check-input" type="checkbox">Extended Edition
515
                                            </label>
516
                                        </div>
517
                                        <div class="form-check-inline">
518
                                            <label class="form-check-label" for="dvdFullScreen">
519
                                                <input id="dvdFullScreen" name="dvdFullScreen" class="form-check-input" type="checkbox">Full Screen
520
                                            </label>
521
                                        </div>
522
                                        <div class="form-check-inline">
523
                                            <label class="form-check-label" for="dvdLimitedEdition">
524
                                                <input id="dvdLimitedEdition" name="dvdLimitedEdition" class="form-check-input" type="checkbox">Limited Edition
525
                                            </label>
526
                                        </div>
527
                                        <div class="form-check-inline">
528
                                            <label class="form-check-label" for="dvdPromo">
529
                                                <input id="dvdPromo" name="dvdPromo" class="form-check-input" type="checkbox">Promo
530
                                            </label>
531
                                        </div>
532
                                        <div class="form-check-inline">
533
                                            <label class="form-check-label" for="dvdSignatureCollection">
534
                                                <input id="dvdSignatureCollection" name="dvdSignatureCollection" class="form-check-input" type="checkbox">Signature Collection
535
                                            </label>
536
                                        </div>
537
                                        <div class="form-check-inline">
538
                                            <label class="form-check-label" for="dvdSpecialEdition">
539
                                                <input id="dvdSpecialEdition" name="dvdSpecialEdition" class="form-check-input" type="checkbox">Special Edition
540
                                            </label>
541
                                        </div>
542
                                        <div class="form-check-inline">
543
                                            <label class="form-check-label" for="dvdSteelbook">Steelbook
544
                                                <input id="dvdSteelbook" name="dvdSteelbook" class="form-check-input" type="checkbox">
545
                                            </label>
546
                                        </div>
547
                                        <div class="form-check-inline">
548
                                            <label class="form-check-label" for="dvdUnratedEdition">
549
                                                <input id="dvdUnratedEdition" name="dvdUnratedEdition" class="form-check-input" type="checkbox">Unrated Edition
550
                                            </label>
551
                                        </div>
552
                                        <div class="form-check-inline">
553
                                            <label class="form-check-label" for="dvdWidescreen">
554
                                                <input id="dvdWidescreen" name="dvdWidescreen" class="form-check-input" type="checkbox">Widescreen
555
                                            </label>
556
                                        </div>
557
                                    </div>
558
                                </form>
559
                            </div>
560
                            <div id="tradingCardDetails" class="container-fluid   w3-hide">
561
                                <form id="tradingCardForm" class="form-fluid">
562
                                    <div>
563
                                        <label for="tcPlayer" class="keepTogether mr-sm-2">Player:</label>
564
                                        <input id="tcPlayer" name="tcPlayer" style="width:29%" type="text">
565
                                        <label for="tcPosition" class="keepTogether mr-sm-2">Position:</label>
566
                                        <input id="tcPosition" name="tcPosition" style="width:8%" type="text">
567
                                        <label for="tcTeam" class="keepTogether mr-sm-2">Team:</label>
568
                                        <input id="tcTeam" name="tcTeam" style="width:29%" type="text">
569
                                        <label for="tcSeason" class="keepTogether mr-sm-2">Season:</label>
570
                                        <input id="tcSeason" name="tcSeason" style="width:8%" type="text">
571
                                    </div>
572
                                    <div>
573
                                        <label for="tcManufacturer" class="keepTogether mr-sm-2">Manufacturer:</label>
574
                                        <input id="tcManufacturer" name="tcManufacturer" style="width:30%" type="text">
575
                                        <label for="tcNumber" class="keepTogether mr-sm-2">Number:</label>
576
                                        <input id="tcNumber" name="tcNumber" style="width:8%" type="text">
577
                                        <label for="tcSeries" class="keepTogether mr-sm-2">Series:</label>
578
                                        <input id="tcSeries" name="tcSeries" style="width:30%" type="text">
579
                                    </div>
580
                                    <div>
581
                                        <div class="form-check-inline">
582
                                            <label class="form-check-label" for="tcPoA">
583
                                                <input id="tcPoA" name="tcPoA" class="form-check-input" type="checkbox">Piece of Authentic
584
                                            </label>
585
                                        </div>
586
                                        <div class="form-check-inline">
587
                                            <label class="form-check-label" for="tcRookie">
588
                                                <input id="tcRookie" name="tcRookie" class="form-check-input" type="checkbox">Rookie
589
                                            </label>
590
                                        </div>
591
                                        <div class="form-check-inline">
592
                                            <label class="form-check-label" for="tcSerial">
593
                                                <input id="tcSerial" name="tcSerial" class="form-check-input" type="checkbox">Serialized
594
                                            </label>
595
                                        </div>
596
                                    </div>
597
                                </form>
598
                            </div>
19 - 599
                            <div id="results" class="container-fluid w3-hide"></div>
10 - 600
                        </div>
601
 
12 - 602
                        <div class="clearfix">
603
                            <input id="verify" type="submit" class="btn btn-danger" onclick="verifyListingImage();" value="Verify" />
604
                            <input id="list" type="button" class="btn btn-danger" onclick="submitListing(0);" value="List" />
605
                            <input id="savexml" type="button" class="btn btn-danger" onclick="submitListing(1);" value="XML" />
606
                            <input type="button" class="btn btn-dark float-right" onclick="resetForm()" value="Reset form" />
10 - 607
                        </div>
12 - 608
 
10 - 609
                    </div>
610
 
12 - 611
                    <div class="container-fluid col-6">
17 - 612
                        <div class="container border bg-light">
613
                            <div id="productinfo"></div>
614
                            <div id="productinfoSearch"></div>
615
                            <div id="productinfoDuplicate"></div>
616
                        </div>
12 - 617
                        <div id="discogsReleases" class="container border w3-hide"></div>
618
                        <div id="prices" class="container border w3-hide"></div>
10 - 619
                    </div>
620
                </div>
621
            </div>
622
 
623
        </div>
624
 
625
        <footer class="container-fluid text-center border border-bottom-0 border-left-0 border-right-0">
17 - 626
            <div w3-include-html="php/footer.php"></div>
10 - 627
        </footer>
628
 
629
    </div>
12 - 630
 
10 - 631
    <script>
632
 
633
// Globals
634
var picturesAreLoaded = false;
635
var xml = '';
636
var category = '';
637
var catalogTitle = '';
638
var catalogActorNames = '';
639
var listItems = [];
640
var additionalPictures = [];
641
var isManualMode = false;
642
var isDuplicate = false;
643
var eBayProductId = '';
644
 
645
var CC = -1; /* 0=Book, 1=CD, 2=DVD, 3=Trading Card */
646
var ShippingProfileIdList = ['146987753023', '146987646023', '146987753023', '125181485023'];
647
var ShippingProfileNameList = ['Free Economy Shipping', 'Free Standard Shipping', 'Free Economy Shipping', 'Trading Card without Tracking Number'];
648
var MinPriceList = ['5.98', '5.48', '5.48', '0.99'];
649
var ProductListingDetailsNameList = ['ISBN', 'UPC', 'UPC', 'UPC'];
650
var StoreCategoryList = ['30460217018', '30432075018', '30606323018', '1'];
651
var movieFormats = ["DVD", "Blu-ray Disc", "HD DVD"];
652
var auctionFormat = ['FixedPriceItem', 'FixedPriceItem', 'FixedPriceItem', 'Chinese'];
653
var discogsQty = 0;
654
 
655
var ConditionIdList = ['2750', '4000', '4000', '4000'];
656
var ConditionDescriptionList = ['The book is in mint condition and shows only slight cover wear due to shelf storage. The cover and binding are undamaged and the pages have no markings or writing. Please view all images of the actual book.',
657
    'The disc is in near mint/mint condition and has been tested by us. The jewel case is in good shape, the inside tray is intact. Please view all actual images.',
658
    'The case is in good shape, the disc in near mint/mint condition. Please view all actual images.',
659
    'The card is in near mint/mint condition and will be mailed out in a sleeve within 1 business day after payment cleared. Expedited service with tracking number and top loader is available at an extra charge.'
660
];
661
 
662
var ConditionDescriptionCdPlural = 'The discs are in near mint/mint condition and have been tested by us. The jewel case is in good shape, the inside trays are intact. Please view all actual images.';
663
var ConditionDescriptionCdNewCase = 'The disc is in near mint/mint condition and comes in a new jewel case. Please view all actual images.';
664
var ConditionDescriptionCdDigipak = 'The disc is in near mint/mint condition and has been tested by us. The digipak is in good shape, the inside tray intact. Please view all actual images.';
665
 
12 - 666
var Description1 = '<meta name="viewport" content="width=device-width, initial-scale=1.0"><style>.w3-ol{list-style-type:1}.w3-ol li{padding:8px 16px;border-bottom:1px solid #ddd}.w3-ol li:last-child{border-bottom:none} img {max-width:100%}.tabs {max-width:90%;float:none;list-style: none;margin: 0 auto;}.tabs:after {content:"";display:table;clear: both;}.tabs input[type=radio] {display:none;}.tabs label {opacity:0.5;display:block;font-size:30px;font-weight:normal;text-decoration:none;text-align:center;line-height:2;cursor:pointer;-webkit-transition:all 0.5s;transition:all 0.5s;}.tabs label span {display:inline-block;float:left;}.tabs label:hover {opacity:1;}.tab-content {display:none;width:100%;float:left;padding:8px 16px;box-shadow:0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12);border-radius:8px;background-color:#ffffff;}.tab-content * {-webkit-animation:scale 0.7s ease-in-out;-moz-animation:scale 0.7s ease-in-out;animation:scale 0.7s ease-in-out;}@keyframes scale {0% {transform:scale(0.9);opacity:0;}50% {transform:scale(1.01);opacity:0.5;}100% {transform:scale(1);opacity:1;}}.tabs [id^="tab"]:checked + label { opacity:1; }#tab1:checked ~ #tab-content1, #tab2:checked ~ #tab-content2, #tab3:checked ~ #tab-content3 {display:block;}.header-logo { max-height:100px!important; }.header-company-name { font-size:64px!important; }.header-button-1, .header-button-2, .header-button-3, .header-button-4, .header-button-5 {	}.header-icon-text { font-size:30px!important; }.header-icon { width:50px!important; height:50px!important;}.paypal-logo { max-height:100px!important; }.tab-alternate-header {	display:none!important; }@media only screen and (max-width:780px) {.header-logo { max-height:80px!important; }.header-company-name { font-size:48px!important; }.header-button-2, .header-button-3, .header-button-5 { display:none!important; }.header-icon-text { font-size:24px!important; }.header-icon { width:45px!important; height:45px!important;}.paypal-logo { max-height:80px!important; }.tabs {max-width:100%!important;}.tab-button { display:none!important; }.tab-alternate-header { display:block!important; }#tab-content1, #tab-content2, #tab-content3 { display:block!important; }}@media only screen and (max-width:500px) {.header-logo { max-height:60px!important; }.header-company-name { font-size:32px!important; }.header-button-2, .header-button-3, .header-button-4, .header-button-5 { display:none!important; }.header-icon-text { font-size:20px!important; }.header-icon { width:40px!important; height:40px!important;}.paypal-logo { max-height:60px!important; }.tabs {max-width:100%!important;}.tab-button { display:none!important; }.tab-alternate-header {	display:block!important; }#tab-content1, #tab-content2, #tab-content3 { display:block!important; }}</style><link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"><div class="w3-main"><div class="w3-container  w3-light-grey w3-text-black  w3-round-large" style="background-color:hsla(200, 100%, 25%, .8);"><div class="w3-center w3-text-white w3-round-large w3-border-white w3-topbar w3-bottombar w3-rightbar w3-leftbar " style="background-color:hsla(200, 100%, 25%, .8);"><h2 class="header-icon-text"><img class="header-icon" alt="Clipboard" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/if_clipboard_1055091.png"> Product Description</h2></div><div class="row "><!-- *************** Place description here ****************** --><div class="w3-container  w3-twothird">';
667
var Description2 = '</div><div class="w3-container  w3-third"><img class="w3-image w3-border w3-right" alt="';
10 - 668
var Description2a = '" src="';
669
var DescImage;
12 - 670
var Description3 = '"></div><!-- *************** Place description here ****************** --></div></div><div class="w3-container  w3-light-grey w3-text-black  w3-round-large" style="background-color:hsla(200, 100%, 25%, .8);"><div class="tabs "><!-- Radio button and label for #tab-content1 --><input name="tabs" id="tab1" checked="" type="radio"><label for="tab1"><span class="tab-button header-icon-text  w3-center w3-text-white w3-round-large w3-border-white w3-topbar w3-bottombar w3-rightbar w3-leftbar " style="background-color:hsla(200, 100%, 25%, .8);"><img class="header-icon" alt="Credit Card" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/if_creditcard_1055079.png"> Payments</span></label><!-- Radio button and label for #tab-content2 --><input class="tab-button" name="tabs" id="tab2" type="radio"><label for="tab2"><span class="tab-button header-icon-text  w3-center w3-text-white w3-round-large w3-border-white w3-topbar w3-bottombar w3-rightbar w3-leftbar " style="background-color:hsla(200, 100%, 25%, .8);"><img class="header-icon" alt="Dolly" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/if_dolly_1055070.png"> Shipping</span></label><!-- Radio button and label for #tab-content3 --><input class="tab-button" name="tabs" id="tab3" type="radio"><label for="tab3"><span class="tab-button header-icon-text  w3-center w3-text-white w3-round-large w3-border-white w3-topbar w3-bottombar w3-rightbar w3-leftbar " style="background-color:hsla(200, 100%, 25%, .8);"><img class="header-icon" alt="Delivery Truck" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/if_truck_1054949.png"> Return</span> </label><div id="tab-content1" class="tab-content"><div class="tab-alternate-header w3-center w3-text-white w3-round-large w3-border-white w3-topbar w3-bottombar w3-rightbar w3-leftbar " style="background-color:hsla(200, 100%, 25%, .8);"><h2 class="header-icon-text"><img class="header-icon" alt="Credit Card" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/if_creditcard_1055079.png"> Payments</h2></div><img class="paypal-logo w3-image w3-right " alt="PayPal Seal" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/paypal-verified.png"><p>We accept PayPal and all major credit cards through secure payment processor PayPal.</p><ul><li>We charge 6% sales tax for items shipped to the state of Virginia.</li><li>Payment must be received in full within 3 days from the date of purchase.</li><li>We leave positive eBay feedback as soon as the payment clears.</li></ul></div><!-- #tab-content1 --><div id="tab-content2" class="tab-content"><div class="tab-alternate-header w3-center w3-text-white w3-round-large w3-border-white w3-topbar w3-bottombar w3-rightbar w3-leftbar " style="background-color:hsla(200, 100%, 25%, .8);"><h2 class="header-icon-text"><img class="header-icon" alt="Dolly" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/if_dolly_1055070.png"> Shipping</h2></div>';
10 - 671
var DescriptionFreeShipping = '<p>We offer free USPS Economy or Media Mail, expedited service is available at an additional cost.</p>';
672
var DescriptionTradingCardShipping = '<p>Standard USPS shipping without Tracking Number. Expedited service with tracking number and top loader available at an extra cost.</p>';
12 - 673
var Description4 = '<ul><li>All items will be shipped from the United States.</li><li>We will only ship to the confirmed PayPal address. Please make sure it matches your shipping address.</li><li>Shipping Monday through Saturday, excluding federal holidays, within 24 hours after payment is received.</li><li>If a tracking number is provided by the shipping carrier, we will update your order with the tracking information.</li><li>Shipping Outside of the United States incurs additional shipping charges.</li></ul></div><!-- #tab-content2 --><div id="tab-content3" class="tab-content"><div class="tab-alternate-header w3-center w3-text-white w3-round-large w3-border-white w3-topbar w3-bottombar w3-rightbar w3-leftbar " style="background-color:hsla(200, 100%, 25%, .8);"><h2 class="header-icon-text"><img class="header-icon" alt="Delivery Truck" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/if_truck_1054949.png"> Return</h2></div><p>Please <a href="https://contact.ebay.com/ws/eBayISAPI.dll?ContactUserNextGen&amp;recipient=muna_trading" target="_blank">contact us</a> before returning an item or leaving negative feedback. We will get back to you immediately and work with you to make your purchase right. </p></div><!-- #tab-content3 --></div></div><footer class="w3-container w3-center"><div class="w3-container w3-center "><a class="header-button-1 w3-button w3-round-xlarge w3-border w3-border-black w3-white" href="https://stores.ebay.com/munatrading" target="_blank"><img alt="Sales Tag" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/if_shop_1054978.png" width="35px" height="35px"> Other Items</a><a class="header-button-2 w3-button w3-round-xlarge w3-border w3-border-black w3-white" href="https://feedback.ebay.com/ws/eBayISAPI.dll?ViewFeedback2&amp;userid=muna_trading&amp;ftab=AllFeedback" target="_blank"><img alt="Paper and pencil" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/if_compose_1055085.png" width="35px" height="35px"> Feedbacks</a><a class="header-button-3 w3-button w3-round-xlarge w3-border w3-border-black w3-white" href="https://www.ebay.com/usr/muna_trading" target="_blank"><img alt="Contacts" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/if_contacts_1055082.png" width="35px" height="35px"> About Us</a><a class="header-button-4 w3-button w3-round-xlarge w3-border w3-border-black w3-white" href="https://contact.ebay.com/ws/eBayISAPI.dll?ContactUserNextGen&amp;recipient=muna_trading" target="_blank"><img alt="Envelope" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/if_mail_1055030.png" width="35px" height="35px"> Contact Us</a><a class="header-button-5 w3-button w3-round-xlarge w3-border w3-border-black w3-white" href="https://my.ebay.com/ws/eBayISAPI.dll?AcceptSavedSeller&amp;mode=0&amp;preference=0&amp;ssPageName=STRK:MEFS:ADDMP&amp;sellerid=muna_trading" target="_blank"><img alt="Heart" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/if_heart_1055045.png" width="35px" height="35px"> Add To Favorites</a></div><div class="w3-container w3-center "><img class="header-logo w3-image" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/MUNA_-_Logo_100x100.png" alt="MUNA Logo"></div><p>Thanks so much for looking at our auction and please do not hesitate to <a href="https://contact.ebay.com/ws/eBayISAPI.dll?ContactUserNextGen&amp;recipient=muna_trading" target="_blank">contact us</a> should you have any questions!</p></footer></div>';
10 - 674
var DescCore = '';
675
var ImageURLs = [];
12 - 676
var maxAdditionalImages = 8;
10 - 677
var imagesToUpload = 0;
678
var imageUploadError = false;
679
var titlesToRead = 0;
680
var upc = '';
681
 
682
 
683
// Initialize Configuration Variables
684
function initConfig() {
685
    var i;
686
    var j;
687
 
688
    eBayAuthToken = readCookie();
689
    if (eBayAuthToken.length > 0) {
690
        connected();
691
    }
692
 
693
    if (eBayAuthTokenFlag === false) {
694
        var x = document.getElementById("login");
695
        if (x.className.indexOf("w3-show") == -1) {
696
            x.className += " w3-show";
697
        }
698
    }
699
 
700
    categoryValues();
701
    requireNewVerify();
702
 
703
    $('#listForm').on('change input cut paste',requireNewVerify);
704
    $('#bookForm').on('change input cut paste',requireNewVerify);
705
    $('#cdForm').on('change input cut paste',requireNewVerify);
706
    $('#dvdForm').on('change input cut paste',requireNewVerify);
707
    $('#tradingCardForm').on('change input cut paste',requireNewVerify);
15 - 708
 
10 - 709
    var xhttp = new XMLHttpRequest();
710
    xhttp.onreadystatechange = function() {
711
        if (this.readyState == 4 && this.status == 200) {
712
            //window.alert(this.responseText);
713
 
714
            var parser = new DOMParser();
715
            var htmlDoc = parser.parseFromString(this.responseText, "text/html");
716
            var x = htmlDoc.getElementsByTagName("a");
717
 
718
            listItems = [];
719
            additionalPictures = [];
720
            titlesToRead = 0;
721
 
722
            for (i = 0, j = 0; i < x.length; i++) {
723
                if (htmlDoc.getElementsByTagName("a")[i].innerHTML.endsWith(configImage1Extension)) {
724
                    var n = htmlDoc.getElementsByTagName("a")[i].innerHTML.lastIndexOf(configImage1Extension);
725
                    listItems[j] = htmlDoc.getElementsByTagName("a")[i].innerHTML.substr(0, n);
726
                    ++titlesToRead;
727
                    getTitleFromeBay(listItems[j], j);
728
                    j++;
729
                }
730
            }
731
 
732
            for (i = 0; i < x.length; i++) {
733
                if (htmlDoc.getElementsByTagName("a")[i].innerHTML.endsWith(configImage1Extension) ||
734
                    htmlDoc.getElementsByTagName("a")[i].innerHTML.endsWith(configImage2Extension) ||
735
                    htmlDoc.getElementsByTagName("a")[i].innerHTML.endsWith(configdescriptionImageExtension)) {
736
                    continue;
737
                }
738
 
739
                if (htmlDoc.getElementsByTagName("a")[i].innerHTML.endsWith(".jpg")) {
740
                    for (j = 0; j < listItems.length; j++) {
741
                        if (htmlDoc.getElementsByTagName("a")[i].innerHTML.startsWith(listItems[j]) && !htmlDoc.getElementsByTagName("a")[i].innerHTML.endsWith(" - small.jpg")) {
742
                            if (additionalPictures[j] === undefined) {
743
                                additionalPictures[j] = [];
744
                            }
745
                            additionalPictures[j].push(htmlDoc.getElementsByTagName("a")[i].innerHTML);
746
                        }
747
                    }
748
                }
749
            }
750
 
751
            function checkTitlesToRead() {
752
                if (titlesToRead > 0) {
753
                    window.setTimeout(checkTitlesToRead, 100); // wait 100 milliseconds
754
                } else {
755
                    sortList(document.getElementById("keyword"));
756
                    $("#keyword").selectpicker('refresh');
757
                    document.getElementById("bookDetails").className += " w3-hide";
758
                    document.getElementById("cdDetails").className += " w3-hide";
759
                    document.getElementById("dvdDetails").className += " w3-hide";
760
                }
761
            }
762
 
763
            checkTitlesToRead();
764
 
765
        }
766
    };
767
    xhttp.open("GET", configListingUrl + '?t=' + Math.random(), true);
768
    xhttp.send();
769
 
770
}
771
 
772
function sortList(lb) {
773
    var arrTexts = [];
774
    var res;
775
    var i;
776
    var lbCopy = $.extend(true, {}, lb);
777
 
778
    for (i = 0; i < lb.length; i++) {
779
        arrTexts[i] = lb.options[i].style.color + '|' + lb.options[i].id + '|' + lb.options[i].text + '|' + i;
780
    }
781
 
782
    arrTexts.sort();
783
 
784
    for (i = 0; i < arrTexts.length; i++) {
785
        res = arrTexts[i].split('|');
786
        lb[i] =  lbCopy[res[3]];
787
    }
788
}
789
 
790
function getTitleFromeBay(identifier, index) {
791
    // Construct the request
792
    url = configeBayShopping + "?";
793
    url += "callname=FindProducts";
794
    url += "&version=" + configeBayShoppingVersion;
795
    url += "&appid=" + configAppid;
796
    url += "&responseencoding=JSON";
797
    url += "&siteid=0";
798
    url += "&AvailableItemsOnly=true";
799
    url += "&MaxEntries=1";
800
    url += "&MessageID=";
801
    url += index;
802
    url += "&QueryKeywords=";
803
    url += encodeURIComponent(identifier.trim().replace(/ /g, "+"));
804
 
805
    var xhttp = new XMLHttpRequest();
806
 
807
    xhttp.onreadystatechange = function() {
808
        if (this.readyState == 4) {
809
            _cb_getTitleFromeBay(JSON.parse(this.responseText));
810
        }
811
    };
812
 
813
    xhttp.open("GET", configProxyUrl, true);
814
    xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
815
    xhttp.send();
816
 
817
    return false;
818
}
819
 
820
// Create new page for single item
821
function _cb_getTitleFromeBay(root) {
822
    var optionsAsString;
823
    var JsonObj;
824
    var color;
825
 
826
    if (root.Ack != 'Success') {
827
        color = 'purple';
828
        if (isNumeric((listItems[root.CorrelationID]))) {
829
            if (listItems[root.CorrelationID].substr(0, 3) == '978' || listItems[root.CorrelationID].substr(0, 3) == '979') {
830
                if (!isValidISBNCode(listItems[root.CorrelationID])) {
831
                    color = 'red';
832
                }
833
            } else {
834
                if (!isValidUpcOrEanCode(listItems[root.CorrelationID])) {
835
                    color = 'red';
836
                }
837
            }
838
        }
839
 
12 - 840
        optionsAsString = "<option class='small' id='" + escapeHtml(listItems[root.CorrelationID]) + "' " + "value='" + escapeHtml(listItems[root.CorrelationID]) + "'>" + listItems[root.CorrelationID] + "</option>";
10 - 841
        document.getElementById("keyword").innerHTML += optionsAsString;
842
        document.getElementById(listItems[root.CorrelationID]).style.color = color;
843
    } else {
844
        JsonObj = typeof root.Product[0] != 'object' ? JSON.parse(root.Product[0]) : root.Product[0];
12 - 845
        optionsAsString = "<option class='small'' id='" + escapeHtml(listItems[root.CorrelationID]) + "' " + "value='" + escapeHtml(listItems[root.CorrelationID]) + "'>" + listItems[root.CorrelationID] + " - " + JsonObj.Title + "</option>";
10 - 846
        document.getElementById("keyword").innerHTML += optionsAsString;
847
    }
848
 
849
    --titlesToRead;
850
}
851
 
852
// Create new page for single item
853
function _cb_FindProducts(root) {
854
    var j;
855
    var x;
856
    var ack = root.Ack;
857
    var MoreResults = root.MoreResults;
858
 
859
    if (ack != 'Success' || MoreResults) { // xxxxx allow to look at all results
860
        x = document.getElementById("productinfo");
17 - 861
        y = document.getElementById("productinfoSearch");
10 - 862
        if (root.Errors !== undefined && root.Errors[0].ShortMessage != 'No match found.') {
863
            x.innerHTML = "<h2>eBay API Error<h2>";
864
            x.innerHTML += "<p>Id: " + root.Errors[0].ErrorCode + "<br/>";
865
            x.innerHTML += "Domain: " + root.Errors[0].ErrorClassification + "<br/>";
866
            x.innerHTML += "Severity: " + root.Errors[0].SeverityCode + "<br/>";
867
            x.innerHTML += "Category: " + root.Errors[0].category + "<br/>";
868
            x.innerHTML += "Short Message: " + root.Errors[0].ShortMessage + "<br/>";
869
            x.innerHTML += "Long Message: " + root.Errors[0].LongMessage + "<br/>";
870
            x.innerHTML += "Build/Version: " + root.Build + '/' + root.Version + "</p>";
871
            x.innerHTML += "<p>URL: " + "<a href=\"" + url + "\" target=\"_blank\">" + url + "</a>" + "</p>";
872
        } else {
873
            x.innerHTML = '<h2 class="bg-danger">Manual Mode</h3>';
874
            x.innerHTML += "<h3>" + document.getElementById("keyword").value + "</h3>";
875
            catalogTitle = document.getElementById("keyword").value.trim();
876
            if (isNumeric(catalogTitle)) {
877
                if (catalogTitle.startsWith('978') || catalogTitle.startsWith('979')) {
17 - 878
                    y.innerHTML += '<a href="https://isbnsearch.org/isbn/' + catalogTitle + '" target="blank"><button class="btn"><i class="fa fa-search"></i> ISBN Search</button></a>';
879
                    y.innerHTML += '<a href="https://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Dpopular&field-keywords=' + catalogTitle + '" target="blank"><button class="btn"><i class="fa fa-search"></i> Amazon</button></a>';
880
                    y.innerHTML += '<a href="https://ujsoftware.linkpc.net/ebay/search.html?keyword=' + encodeURIComponent(catalogTitle.trim()) + '&listingType=All&hideDuplicateItems=on&locatedIn=WorldWide&sortOrder=PricePlusShippingLowest&results=100" target="blank"><button class="btn"><i class="fa fa-search"></i> eBay</button></a>';
10 - 881
                } else {
17 - 882
                    y.innerHTML += '<a href="https://dvdlist.kazart.com/queryDVDList.php3?search=' + catalogTitle + '&select=UPC&Submit=Search&since=All&genre=All&date=All&status=All&sort1=title&sort1by=ASC&sort2=year&sort2by=ASC&sort3=genre&sort3by=ASC" target="blank"><button class="btn"><i class="fa fa-search"></i> Kazart</button></a>';
883
                    y.innerHTML += '<a href="https://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Dpopular&field-keywords=' + catalogTitle + '" target="blank"><button class="btn"><i class="fa fa-search"></i> Amazon</button></a>';
884
                    y.innerHTML += '<a href="https://ujsoftware.linkpc.net/ebay/search.html?keyword=' + encodeURIComponent(catalogTitle.trim()) + '&listingType=All&hideDuplicateItems=on&locatedIn=WorldWide&sortOrder=PricePlusShippingLowest&results=100" target="blank"><button class="btn"><i class="fa fa-search"></i> eBay</button></a>';
10 - 885
                }
886
            } else {
887
                catalogTitle = document.getElementById("keyword").value.trim();
888
                splitTradingCardElements();
889
                fillForm();
890
 
17 - 891
                y.innerHTML += '<a href="https://ujsoftware.linkpc.net/ebay/search.html?keyword=' + encodeURIComponent(catalogTitle.trim()) + '&listingType=All&hideDuplicateItems=on&locatedIn=WorldWide&sortOrder=PricePlusShippingLowest&results=100" target="blank"><button class="btn"><i class="fa fa-search"></i> eBay</button></a>';
10 - 892
            }
893
 
894
            printManualButtons();
895
        }
896
 
897
        unsetAdditionalImages();
898
 
899
        for (i = 0; i < additionalPictures.length; i++) {
900
            if (additionalPictures[i] !== undefined && additionalPictures[i][0].startsWith(document.getElementById("keyword").value.trim())) {
901
                if (additionalPictures[i].length > maxAdditionalImages) {
902
                    document.getElementById("productinfo").innerHTML += '<p class="bg-danger"><strong>Too many additional images.</a></strong></p>';
903
                } else {
904
                    for (j = 0; j < additionalPictures[i].length; j++) {
905
                        setAdditionalImage(j + 3, additionalPictures[i][j]);
906
                    }
907
                }
908
            }
909
        }
910
 
911
        document.getElementById("image1").src = configListingUrl + document.getElementById("keyword").value.trim() + configImage1Extension;
912
        document.getElementById("image2").src = configListingUrl + document.getElementById("keyword").value.trim() + configImage2Extension;
913
        document.getElementById("descriptionImage").src = configListingUrl + document.getElementById("keyword").value.trim() + configdescriptionImageExtension;
914
        document.getElementById("image1anchor").href = document.getElementById("image1").src;
915
        document.getElementById("image2anchor").href = document.getElementById("image2").src;
916
 
917
        isManualMode = true;
918
        catalogActorNames = '';
919
 
920
        isDuplicate = false;
921
        findDuplicateListing();
922
        findPotentialDuplicateListing();
923
        findShopifyDuplicateListing();
924
 
925
        upc = catalogTitle;
926
 
927
        return;
928
    }
929
 
930
    isManualMode = false;
931
 
932
    var str = "";
17 - 933
    var str2 = "";
10 - 934
    var i = 0;
935
    var JsonObj = typeof root.Product[0] != 'object' ? JSON.parse(root.Product[0]) : root.Product[0];
936
 
937
    var DetailsURL = JsonObj.DetailsURL;
938
    var ItemSpecifics = JsonObj.ItemSpecifics;
939
    var StockPhotoURL = JsonObj.StockPhotoURL;
940
    var ProductID = JsonObj.ProductID;
941
    var TotalProducts = Number(root.TotalProducts);
942
    var searchStr = '';
943
    var munaSearchStr = '';
944
 
945
    catalogTitle = JsonObj.Title;
946
    catalogActorNames = '';
947
 
948
    str = '';
949
    DescCore = '';
950
 
951
    if (StockPhotoURL && StockPhotoURL.length > 1) {
952
        if (DetailsURL && DetailsURL.length > 1) {
953
            str += '<a href="' + DetailsURL + '" target="_blank">';
954
        }
955
        str += '<img class="img-fluid float-right " src="' + StockPhotoURL + '" alt="Gallery Image" style="max-height:100px;max-width:100px;">';
956
        if (DetailsURL && DetailsURL.length > 1) {
957
            str += '</a>';
958
        }
959
    }
960
 
961
    str += '<h3>' + catalogTitle + '</h3>';
962
 
17 - 963
    str += '<table class="table-bordered"><tbody>';
10 - 964
 
965
    eBayProductId = '';
966
    upc = catalogTitle;
967
    if (ProductID) {
968
        for (i = 0; i < ProductID.length; i++) {
969
            if (ProductID[i].Type == 'Reference') {
17 - 970
                str += '<tr><td>' + ProductID[i].Type + '</td><td>' + ProductID[i].Value + '</td></tr>';
10 - 971
                munaSearchStr = 'ReferenceID%3A' + ProductID[i].Value;
972
                eBayProductId = ProductID[i].Value;
973
            } else {
17 - 974
                str += '<tr><td>' + ProductID[i].Type + '</td><td>' + ProductID[i].Value + '</td></tr>';
10 - 975
                searchStr = ProductID[i].Value;
976
                if (ProductID[i].Type == 'UPC') {
977
                    upc = ProductID[i].Value;
978
                }
979
            }
980
        }
981
    }
982
 
983
    if (ItemSpecifics) {
984
        for (i = 0; i < ItemSpecifics.NameValueList.length; i++) {
17 - 985
            str += '<tr><td>' + ItemSpecifics.NameValueList[i].Name + '</td><td>' + ItemSpecifics.NameValueList[i].Value + '</td></tr>';
10 - 986
 
987
            if (ItemSpecifics.NameValueList[i].Name == 'Leading Role') {
988
                catalogActorNames = ItemSpecifics.NameValueList[i].Value;
989
            }
990
        }
991
    }
992
 
17 - 993
    str += '</tbody></table>';
10 - 994
 
995
    if (MoreResults) {
996
        str += '<p class="float-right bg-danger">' + TotalProducts + ' Products found</p>';
997
    }
998
 
999
    if (catalogTitle.includes(movieFormats[0]) || catalogTitle.includes(movieFormats[1]) || catalogTitle.includes(movieFormats[2])) {
17 - 1000
        str2 += '<a href="https://dvdlist.kazart.com/queryDVDList.php3?search=' + searchStr + '&select=UPC&Submit=Search&since=All&genre=All&date=All&status=All&sort1=title&sort1by=ASC&sort2=year&sort2by=ASC&sort3=genre&sort3by=ASC" target="blank"><button class="btn"><i class="fa fa-search"></i> Kazart</button></a>';
10 - 1001
    } else if (catalogTitle.includes('Paperback') || catalogTitle.includes('Hardcover')) {
17 - 1002
        str2 += '<a href="https://isbnsearch.org/isbn/' + searchStr + '" target="blank"><button class="btn"><i class="fa fa-search"></i> ISBN Search</button></a>';
10 - 1003
    }
1004
 
17 - 1005
    str2 += '<a href="https://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=' + searchStr + '" target="blank"><button class="btn"><i class="fa fa-search"></i> Amazon</button></a>';
1006
    str2 += '<a href="https://ujsoftware.linkpc.net/ebay/search.html?keyword=' + (munaSearchStr.length > 0 ? munaSearchStr : encodeURIComponent(searchStr.trim())) + '&listingType=All&hideDuplicateItems=on&locatedIn=WorldWide&sortOrder=PricePlusShippingLowest&results=100" target="blank"><button class="btn"><i class="fa fa-search"></i> eBay</button></a>';
10 - 1007
 
1008
    x = document.getElementById("productinfo");
1009
    x.innerHTML = str;
17 - 1010
    x = document.getElementById("productinfoSearch");
1011
    x.innerHTML = str2;
10 - 1012
 
1013
 
1014
    isDuplicate = false;
1015
    findDuplicateListing();
1016
    findPotentialDuplicateListing();
1017
    findShopifyDuplicateListing();
1018
 
1019
    fillForm(ItemSpecifics);
1020
}
1021
 
1022
function printManualButtons() {
1023
    var x = document.getElementById("productinfo");
1024
    if (!x.innerHTML.includes('fillManualForm0')) {
1025
        x.innerHTML += '<p><br/></p>';
17 - 1026
        x.innerHTML += '<a href="javascript:void(0)" id="fillManualForm0" class="btn btn-dark btn-xs border" onclick="fillManualForm(0)">Book Form</a>';
1027
        x.innerHTML += '<a href="javascript:void(0)" id="fillManualForm1" class="btn btn-dark btn-xs border" onclick="fillManualForm(1)">CD Form</a>';
1028
        x.innerHTML += '<a href="javascript:void(0)" id="fillManualForm2" class="btn btn-dark btn-xs border" onclick="fillManualForm(2)">DVD Form</a>';
1029
        x.innerHTML += '<a href="javascript:void(0)" id="fillManualForm3" class="btn btn-dark btn-xs border" onclick="fillManualForm(3)">Trading Card Form</a>';
1030
        x.innerHTML += '<p><br/></p>';
10 - 1031
    }
1032
}
1033
 
1034
function setAdditionalImage(imageNumber, imageName) {
1035
    if (imageName !== undefined) {
1036
        document.getElementById("image" + imageNumber).src = configListingUrl + imageName.trim();
12 - 1037
        document.getElementById("image" + imageNumber + "anchor").className = document.getElementById("image" + imageNumber + "anchor").className.replace(" invisible", " visible");
10 - 1038
        document.getElementById("image" + imageNumber + "anchor").href = document.getElementById("image" + imageNumber).src;
1039
    }
1040
}
1041
 
1042
function unsetAdditionalImages() {
12 - 1043
    for (var i = 0; i < maxAdditionalImages; i++) {
1044
        document.getElementById("image" + (i+3)).src = 'images/default-image.png';
1045
        document.getElementById("image" + (i+3) + "anchor").className = document.getElementById("image" + (i+3) + "anchor").className.replace(" visible", " invisible");
1046
        document.getElementById("image" + (i+3) + "anchor").href = '#';
10 - 1047
    }
1048
}
1049
 
1050
function requireNewVerify() {
1051
    listButtonHot(false);
1052
}
1053
 
1054
function requireNewLogin() {
1055
    // dummy
1056
}
1057
 
1058
function hideDetailWindows() {
1059
    var x, y;
1060
 
1061
    x = document.getElementById("bookDetails");
1062
    x.className = x.className.replace(" w3-show", "");
1063
    document.getElementById("bookForm").reset();
1064
    x = document.getElementById("cdDetails");
1065
    x.className = x.className.replace(" w3-show", "");
1066
    document.getElementById("cdForm").reset();
1067
    x = document.getElementById("dvdDetails");
1068
    x.className = x.className.replace(" w3-show", "");
1069
    document.getElementById("dvdForm").reset();
1070
    x = document.getElementById("tradingCardDetails");
1071
    x.className = x.className.replace(" w3-show", "");
1072
    document.getElementById("tradingCardForm").reset();
1073
    document.getElementById("cdTracks").innerHTML = "";
1074
    document.getElementById("cdUnorderedTrackList").checked = false;
1075
    updateTracklistPreview();
1076
 
1077
    for (var imageNumber = 0; imageNumber < maxAdditionalImages; imageNumber++) {
1078
        x = document.getElementById("image" + (imageNumber + 3) + "anchor");
1079
        y = document.getElementById("image" + (imageNumber + 3));
1080
 
12 - 1081
        x.className = x.className.replace(" visible", " invisible");
1082
        x.href = '#';
1083
        y.src = 'images/default-image.png';
10 - 1084
    }
1085
}
1086
 
1087
var url = "";
1088
 
1089
function findOneBay() {
1090
    var n;
1091
    var keyword;
1092
 
1093
    if (document.getElementById("list").className.includes("btn-success")) {
1094
        alert("Listing verified but not yet submitted");
1095
        return;
1096
    }
1097
 
1098
    requireNewVerify();
1099
 
1100
    hideDetailWindows();
1101
 
1102
    ImageURLs = [];
1103
 
1104
    if (!document.getElementById("keyword").value) {
1105
        return false;
1106
    }
1107
 
1108
    if (document.getElementById("keyword").value.endsWith(" Front")) {
1109
        n = document.getElementById("keyword").value.lastIndexOf(" Front");
1110
        document.getElementById("keyword").value = document.getElementById("keyword").value.substr(0, n);
1111
    } else if (document.getElementById("keyword").value.endsWith(" Rear")) {
1112
        n = document.getElementById("keyword").value.lastIndexOf(" Rear");
1113
        document.getElementById("keyword").value = document.getElementById("keyword").value.substr(0, n);
1114
    }
1115
 
1116
    keyword = document.getElementById('keyword').value;
1117
 
1118
    // Clear results outputs button
1119
    clearStatusWindows();
17 - 1120
    document.getElementById("productinfoSearch").innerHTML = "";
1121
    document.getElementById("productinfoDuplicate").innerHTML = "";
10 - 1122
 
1123
    discogsQty = 1;
1124
 
1125
    // Construct the request
1126
    url = configeBayShopping + "?";
1127
    url += "callname=FindProducts";
1128
    url += "&version=" + configeBayShoppingVersion;
1129
    url += "&appid=" + configAppid;
1130
    url += "&responseencoding=JSON";
1131
    url += "&siteid=0";
1132
    url += "&AvailableItemsOnly=true";
1133
    url += "&MaxEntries=1";
1134
    url += "&QueryKeywords=";
1135
    url += encodeURIComponent(keyword.trim().replace(/ /g, "+"));
1136
 
1137
    var xhttp = new XMLHttpRequest();
1138
 
1139
    xhttp.onreadystatechange = function() {
1140
        if (this.readyState == 4) {
1141
            _cb_FindProducts(JSON.parse(this.responseText));
1142
        }
1143
    };
1144
 
1145
    xhttp.open("GET", configProxyUrl, true);
1146
    xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
1147
    xhttp.send();
1148
 
1149
    getPricing();
1150
 
1151
    return false;
1152
}
1153
 
1154
function fillForm(ItemSpecifics) {
1155
    var eBayTitle;
1156
    var fieldName;
1157
    var field;
1158
    var n;
1159
    var i;
1160
    var j;
1161
    var x;
1162
    var movieIndex = 0;
1163
    var titleField = document.getElementById("title");
1164
 
1165
    eBayTitle = catalogTitle;
1166
    if (catalogActorNames.length > 0) {
1167
        eBayTitle += ' ' + catalogActorNames.join(', ');
1168
    }
1169
 
1170
    document.getElementById("title").value = eBayTitle;
1171
    printTitleLength();
1172
 
1173
    if (catalogTitle.includes("(CD")) {
1174
        findDiscogsReleases(document.getElementById("keyword").value);
1175
 
1176
        x = document.getElementById("cdDetails");
1177
        if (x.className.indexOf("w3-show") == -1) {
1178
            x.className += " w3-show";
1179
        }
1180
 
1181
        if (!isManualMode) {
1182
            titleField.value = reformatCdTitle(catalogTitle);
1183
            printTitleLength();
1184
        }
1185
 
1186
        if (titleField.value.endsWith(' (Label))')) {
1187
            titleField.value = titleField.value.substr(0, titleField.value.indexOf(' (Label))')) + ')';
1188
            printTitleLength();
1189
        }
1190
 
1191
        if (titleField.value.endsWith(' (USA))')) {
1192
            titleField.value = titleField.value.substr(0, titleField.value.indexOf(' (USA))')) + ')';
1193
            printTitleLength();
1194
        }
1195
 
1196
        document.getElementById("cdCountry").value = configDefaultCountry;
1197
 
1198
        if (ItemSpecifics) {
1199
            for (i = 0; i < ItemSpecifics.NameValueList.length; i++) {
1200
                fieldName = 'cd' + ItemSpecifics.NameValueList[i].Name.replace(/ /g, '');
1201
                field = document.getElementById(fieldName);
1202
                if (field) {
1203
                    field.value = ItemSpecifics.NameValueList[i].Value;
1204
                }
1205
            }
1206
        }
1207
        $('#cdGenre').prop('disabled', false).selectpicker('refresh');
1208
 
1209
        if (titleField.value.indexOf('[EP]') > 0) {
1210
            document.getElementById("cdDuration").value = 'EP';
1211
        } else if (titleField.value.indexOf('[Maxi-Single]') > 0 || titleField.value.indexOf('[Maxi Single]') > 0) {
1212
            document.getElementById("cdDuration").value = 'Maxi-Single';
1213
        } else if (titleField.value.indexOf('[Single]') > 0) {
1214
            document.getElementById("cdDuration").value = 'Single';
1215
        }
1216
        $('#cdDuration').prop('disabled', false).selectpicker('refresh');
1217
 
1218
        if (titleField.value.indexOf('[Digipak]') > 0) {
1219
            document.getElementById("cdDigipak").checked = true;
1220
        }
1221
 
1222
        if (document.getElementById("cdArtist").value.length < 1) {
1223
            if (titleField.value.substr(0, titleField.value.includes('Various Artists'))) {
1224
                document.getElementById("cdArtist").value = 'Various';
1225
            } else {
1226
                document.getElementById("cdArtist").value = titleField.value.substr(0, titleField.value.indexOf(' - '));
1227
            }
1228
        }
1229
 
1230
        if (document.getElementById("cdRecordLabel").value.length < 1) {
1231
            n = titleField.value.indexOf('(CD');
1232
            document.getElementById("cdRecordLabel").value = titleField.value.substr(n).substr(titleField.value.substr(n).lastIndexOf(',') + 2);
1233
            document.getElementById("cdRecordLabel").value = document.getElementById("cdRecordLabel").value.substr(0, document.getElementById("cdRecordLabel").value.lastIndexOf(')'));
1234
        }
1235
 
1236
        if (document.getElementById("cdReleaseYear").value.length < 1) {
1237
            n = titleField.value.indexOf('(CD');
1238
            document.getElementById("cdReleaseYear").value = getYear(titleField.value.substr(n));
1239
        }
1240
 
12 - 1241
        $('#category').selectpicker('val', "176984");
1242
        $('#category').selectpicker('refresh');
10 - 1243
        categoryValues();
1244
 
1245
        $('#cdTracks').on('change input cut paste',updateTracklistPreview);
1246
    } else if (catalogTitle.includes(movieFormats[0]) || catalogTitle.includes(movieFormats[1]) || catalogTitle.includes(movieFormats[2])) {
1247
        x = document.getElementById("dvdDetails");
1248
        if (x.className.indexOf("w3-show") == -1) {
1249
            x.className += " w3-show";
1250
        }
1251
 
1252
        document.getElementById("dvdCountry").value = configDefaultCountry;
1253
 
1254
        if (ItemSpecifics) {
1255
            for (i = 0; i < ItemSpecifics.NameValueList.length; i++) {
1256
                fieldName = 'dvd' + ItemSpecifics.NameValueList[i].Name.replace(/ /g, '');
1257
                field = document.getElementById(fieldName);
1258
                if (field) {
1259
                    field.value = ItemSpecifics.NameValueList[i].Value;
1260
                }
1261
            }
1262
        }
1263
        $('#dvdGenre').prop('disabled', false).selectpicker('refresh');
1264
        $('#dvdRating').prop('disabled', false).selectpicker('refresh');
1265
        $('#dvdRegionCode').prop('disabled', false).selectpicker('refresh');
1266
        $('#dvdRental').prop('disabled', false).selectpicker('refresh');
1267
        $('#dvdSeason').prop('disabled', false).selectpicker('refresh');
1268
 
1269
        for (i = 0; i < movieFormats.length; i++) {
1270
            if (catalogTitle.includes('(' + movieFormats[i])) {
12 - 1271
                $('#dvdFormat').selectpicker('val', movieFormats[i]);
10 - 1272
                movieIndex = i;
1273
            } else if (catalogTitle.includes('(HD-DVD')) {
12 - 1274
                $('#dvdFormat').selectpicker('val', 'HD DVD');
10 - 1275
                movieIndex = i;
1276
            }
1277
        }
1278
        $('#dvdFormat').prop('disabled', false).selectpicker('refresh');
1279
 
1280
        if (document.getElementById("dvdReleaseYear").value.length < 1) {
1281
            n = titleField.value.indexOf('(' + movieFormats[movieIndex]);
1282
            document.getElementById("dvdReleaseYear").value = getYear(titleField.value.substr(n));
1283
        }
1284
 
1285
        if (document.getElementById("dvdDVDEditionYear").value.length < 1) {
1286
            n = titleField.value.indexOf('(' + movieFormats[movieIndex]);
1287
            document.getElementById("dvdDVDEditionYear").value = getYear(titleField.value.substr(n));
1288
        }
1289
 
1290
        if (document.getElementById("dvdTitle").value.length < 1) {
1291
            n = titleField.value.lastIndexOf('(' + movieFormats[movieIndex]);
1292
            document.getElementById("dvdTitle").value = titleField.value.substr(0, n);
1293
        }
1294
 
1295
        if (titleField.value.indexOf("3D") > 0) {
1296
            document.getElementById("dvd3D").checked = true;
1297
        }
1298
 
1299
        if (titleField.value.indexOf("Anniversary") > 0) {
1300
            document.getElementById("dvdAnniversaryEdition").checked = true;
1301
        }
1302
 
1303
        if (titleField.value.indexOf("Collector") > 0) {
1304
            document.getElementById("dvdCollectorsEdition").checked = true;
1305
        }
1306
 
1307
        if (titleField.value.indexOf("Deluxe") > 0) {
1308
            document.getElementById("dvdDeluxeEdition").checked = true;
1309
        }
1310
 
1311
        if (titleField.value.indexOf("Director") > 0) {
1312
            document.getElementById("dvdDirectorsCut").checked = true;
1313
        }
1314
 
1315
        if (titleField.value.indexOf("Extended") > 0) {
1316
            document.getElementById("dvdExtendedEdition").checked = true;
1317
        }
1318
 
1319
        if (titleField.value.indexOf("Full Screen") > 0 || titleField.value.indexOf("Fullscreen") > 0 ||
1320
            titleField.value.indexOf("Full Frame") > 0 || titleField.value.indexOf("Fullframe") > 0) {
1321
            document.getElementById("dvdFullScreen").checked = true;
1322
        }
1323
 
1324
        if (titleField.value.indexOf("Limited") > 0) {
1325
            document.getElementById("dvdLimitedEdition").checked = true;
1326
        }
1327
 
1328
        if (titleField.value.indexOf("Promo") > 0) {
1329
            document.getElementById("dvdPromo").checked = true;
1330
        }
1331
 
1332
        if (titleField.value.indexOf("Signature") > 0) {
1333
            document.getElementById("dvdSignatureCollection").checked = true;
1334
        }
1335
 
1336
        if (titleField.value.indexOf("Special") > 0) {
1337
            document.getElementById("dvdSpecialEdition").checked = true;
1338
        }
1339
 
1340
        if (titleField.value.indexOf("Steelbook") > 0) {
1341
            document.getElementById("dvdSteelbook").checked = true;
1342
        }
1343
 
1344
        if (titleField.value.indexOf("Unrated") > 0) {
1345
            document.getElementById("dvdUnratedEdition").checked = true;
1346
        }
1347
 
1348
        if (titleField.value.indexOf("Wide Screen") > 0 || titleField.value.indexOf("Widescreen") > 0) {
1349
            document.getElementById("dvdWidescreen").checked = true;
1350
        }
1351
 
12 - 1352
        $('#category').selectpicker('val', "617");
1353
        $('#category').selectpicker('refresh');
10 - 1354
        categoryValues();
1355
    } else if (catalogTitle.includes("Paperback") || catalogTitle.includes("Hardcover")) {
1356
        x = document.getElementById("bookDetails");
1357
        if (x.className.indexOf("w3-show") == -1) {
1358
            x.className += " w3-show";
1359
        }
1360
 
1361
        document.getElementById("bookLanguage").value = configDefaultLanguage;
1362
        document.getElementById("bookCountry").value = configDefaultCountry;
1363
        document.getElementById("bookSubject").value = "";
1364
 
1365
        if (ItemSpecifics) {
1366
            for (i = 0; i < ItemSpecifics.NameValueList.length; i++) {
1367
                fieldName = 'book' + ItemSpecifics.NameValueList[i].Name.replace(/ /g, '');
1368
                field = document.getElementById(fieldName);
1369
                if (field) {
1370
                    field.value = ItemSpecifics.NameValueList[i].Value;
1371
                }
1372
            }
1373
        }
1374
 
1375
        $('#bookFormat').prop('disabled', false).selectpicker('refresh');
1376
        $('#bookSubject').prop('disabled', false).selectpicker('refresh');
1377
 
12 - 1378
        $('#category').selectpicker('val', "171243");
1379
        $('#category').selectpicker('refresh');
10 - 1380
        categoryValues();
1381
    } else {
1382
        printManualButtons();
1383
    }
1384
 
1385
    function toDataURL(url) {
1386
        var xhr = new XMLHttpRequest();
1387
        xhr.onload = function() {
1388
            var reader = new FileReader();
1389
            reader.onloadend = function() {
1390
                DescImage = reader.result;
1391
            };
1392
            reader.readAsDataURL(xhr.response);
1393
        };
1394
        xhr.open('GET', url);
1395
        xhr.responseType = 'blob';
1396
        xhr.send();
1397
    }
1398
 
1399
    toDataURL(configListingUrl + document.getElementById("keyword").value.trim() + configdescriptionImageExtension);
1400
    document.getElementById("image1").src = configListingUrl + document.getElementById("keyword").value.trim() + configImage1Extension;
1401
    document.getElementById("image2").src = configListingUrl + document.getElementById("keyword").value.trim() + configImage2Extension;
1402
    document.getElementById("descriptionImage").src = configListingUrl + document.getElementById("keyword").value.trim() + configdescriptionImageExtension;
1403
    document.getElementById("image1anchor").href = document.getElementById("image1").src;
1404
    document.getElementById("image2anchor").href = document.getElementById("image2").src;
1405
    unsetAdditionalImages();
1406
 
1407
    for (i = 0; i < additionalPictures.length; i++) {
1408
        if (additionalPictures[i] !== undefined && additionalPictures[i][0].startsWith(document.getElementById("keyword").value.trim())) {
1409
            if (additionalPictures[i].length > maxAdditionalImages) {
1410
                document.getElementById("productinfo").innerHTML += '<p class="bg-danger"><strong>Too many additional images.</a></strong></p>';
1411
            } else {
1412
                for (j = 0; j < additionalPictures[i].length + 4; j++) {
1413
                    setAdditionalImage(j + 3, additionalPictures[i][j]);
1414
                }
1415
            }
1416
        }
1417
    }
1418
}
1419
 
1420
function getYear(str) {
1421
    return str.match(/[12][0-9][0-9][0-9]/);
1422
}
1423
 
1424
function fillManualForm(type) {
1425
    var n;
1426
    var x;
1427
 
1428
    hideDetailWindows();
1429
 
1430
    if (document.getElementById("format").value.length <= 1) {
12 - 1431
        $('#format').selectpicker('val', auctionFormat[type]);
1432
        $('#format').selectpicker('refresh');
10 - 1433
    }
1434
 
1435
    if (type === 0) {
12 - 1436
        $('#category').selectpicker('val', "171243");
1437
        $('#category').selectpicker('refresh');
10 - 1438
        if (isNumeric(catalogTitle)) {
1439
            document.getElementById("bookISBN").value = catalogTitle;
1440
        } else {
1441
            document.getElementById("bookISBN").value = configDoesNotApply;
1442
        }
1443
        document.getElementById("bookLanguage").value = configDefaultLanguage;
1444
        document.getElementById("bookCountry").value = configDefaultCountry;
1445
        categoryValues();
1446
        x = document.getElementById("bookDetails");
1447
        if (x.className.indexOf("w3-show") == -1) {
1448
            x.className += " w3-show";
1449
        }
1450
 
12 - 1451
        $('#bookFormat').selectpicker('val', "");
10 - 1452
        $('#bookFormat').prop('disabled', false).selectpicker('refresh');
12 - 1453
        $('#bookSubject').selectpicker('val', "");
10 - 1454
        $('#bookSubject').prop('disabled', false).selectpicker('refresh');
1455
    } else if (type == 1) {
1456
        document.getElementById("category").value = "176984";
12 - 1457
        $('#category').selectpicker('val', "176984");
1458
        $('#category').selectpicker('refresh');
10 - 1459
        if (isNumeric(catalogTitle)) {
1460
            document.getElementById("cdUPC").value = catalogTitle;
1461
        } else {
1462
            document.getElementById("cdUPC").value = configDoesNotApply;
1463
            if ((n = catalogTitle.indexOf(" - ")) > 0) {
1464
                document.getElementById("cdArtist").value = catalogTitle.substr(0, n);
1465
            }
1466
        }
1467
        document.getElementById("cdCountry").value = configDefaultCountry;
1468
        categoryValues();
1469
 
12 - 1470
        document.getElementById("cdDuration").selectedIndex = 0;
10 - 1471
        $('#cdDuration').prop('disabled', false).selectpicker('refresh');
12 - 1472
        $('#cdGenre').selectpicker('val', "");
10 - 1473
        $('#cdGenre').prop('disabled', false).selectpicker('refresh');
1474
 
1475
        x = document.getElementById("cdDetails");
1476
        if (x.className.indexOf("w3-show") == -1) {
1477
            x.className += " w3-show";
1478
        }
1479
 
1480
        findDiscogsReleases(document.getElementById("keyword").value);
1481
        $('#cdTracks').on('change input cut paste',updateTracklistPreview);
1482
    } else if (type == 2) {
12 - 1483
        $('#category').selectpicker('val', "617");
1484
        $('#category').selectpicker('refresh');
10 - 1485
        if (isNumeric(catalogTitle)) {
1486
            document.getElementById("dvdUPC").value = catalogTitle;
1487
        } else {
1488
            document.getElementById("dvdUPC").value = configDoesNotApply;
1489
        }
1490
        document.getElementById("dvdCountry").value = configDefaultCountry;
1491
        categoryValues();
1492
        x = document.getElementById("dvdDetails");
1493
        if (x.className.indexOf("w3-show") == -1) {
1494
            x.className += " w3-show";
1495
        }
1496
 
12 - 1497
        $('#dvdFormat').selectpicker('val', 'DVD');
1498
        $('#dvdGenre').selectpicker('val', "");
1499
        $('#dvdRating').selectpicker('val', "");
1500
        $('#dvdRegionCode').selectpicker('val', 'DVD: 1 (US, Canada...)');
1501
        $('#dvdRental').selectpicker('val', 'No');
1502
        $('#dvdSeason').selectpicker('val', "");
10 - 1503
        $('#dvdFormat').prop('disabled', false).selectpicker('refresh');
1504
        $('#dvdGenre').prop('disabled', false).selectpicker('refresh');
1505
        $('#dvdRating').prop('disabled', false).selectpicker('refresh');
1506
        $('#dvdRegionCode').prop('disabled', false).selectpicker('refresh');
1507
        $('#dvdRental').prop('disabled', false).selectpicker('refresh');
1508
        $('#dvdSeason').prop('disabled', false).selectpicker('refresh');
1509
    } else if (type == 3) {
1510
        catalogTitle = document.getElementById("keyword").value.trim();
1511
        splitTradingCardElements();
1512
    }
1513
 
1514
    fillForm();
1515
}
1516
 
1517
function resetForm() {
1518
    var i;
1519
 
1520
    document.getElementById("searchForm").reset();
1521
    document.getElementById("listForm").reset();
1522
    document.getElementById("productinfo").innerHTML = "<p>Product Info</p>";
1523
    initConfig();
1524
    clearStatusWindows();
1525
    for (i = 1; i <= 7; i++) {
1526
        document.getElementById("image" + i).src = "";
1527
    }
1528
    document.getElementById("descriptionImage").src = "";
1529
    hideDetailWindows();
1530
}
1531
 
1532
function verifyListingImage() {
1533
    if (eBayAuthTokenFlag === false) {
1534
        return;
1535
    }
1536
    if (isDuplicate) {
1537
        window.alert("This is a duplicate.");
1538
        return;
1539
    }
1540
 
1541
    var x = document.getElementById("results");
1542
    x.innerHTML = '';
1543
    if (x.className.indexOf("w3-show") == -1) {
1544
        x.className += " w3-show";
1545
    }
1546
 
1547
    if (ImageURLs.length === 0) {
1548
        uploadSiteHostedPictures();
1549
    } else {
1550
        verifyListing();
1551
    }
1552
}
1553
 
1554
function verifyListing() {
1555
    var i;
1556
    var authErrorFlag = false;
1557
 
1558
    var xw = new XMLWriter('UTF-8', '1.0');
1559
    var xhr = new XMLHttpRequest();
1560
 
1561
    if (!createAddXML(xw, xhr, 'VerifyAddItemRequest', 'VerifyAddItem', false)) {
1562
        return;
1563
    }
1564
 
1565
    xml = xw.flush();
1566
    xw.close();
1567
 
1568
    xhr.onload = function() {
1569
        var jsonObj = XMLparse(xhr.responseXML, false);
1570
        var obj = jsonObj.VerifyAddItemResponse;
1571
        var returnCode = obj.Ack;
1572
        var x = document.getElementById("results");
1573
        var str = "";
1574
 
1575
        if (returnCode == 'Success' ||
1576
            (returnCode == 'Warning' && (obj.Errors.ErrorCode == '21917108' || obj.Errors.ErrorCode == '21920205' || obj.Errors.ErrorCode == '21917164'))) {
1577
            listButtonHot(true);
1578
 
1579
            str += '<div class="alert ' + (returnCode == 'Success' ? "alert-success" : "alert-warning" ) + ' alert-dismissible">';
1580
            str += '<button type="button" class="close" data-dismiss="alert">×</button>';
1581
            str += '<p><strong>' + returnCode + ':</strong></p>';
1582
 
1583
            if (returnCode == 'Warning') {
1584
                str += "<p>" + obj.Errors.SeverityCode + " (" + obj.Errors.ErrorCode + "): " + escapeHtml(obj.Errors.LongMessage) + "</p>";
1585
            }
1586
            var fees = getJsonArray(obj.Fees.Fee);
1587
            str += "<ul>";
1588
            for (i = 0; i < fees.length; i++) {
1589
                if (fees[i].Fee.text !== "0.0") {
1590
                    str += '<li>' + fees[i].Name + ": $" + Number(fees[i].Fee.text).toFixed(2) + "</li>";
1591
                }
1592
            }
1593
 
1594
            if (obj.DiscountReason) {
1595
                str += "<li>Discount Reason: " + obj.DiscountReason + "</li>";
1596
            }
1597
 
1598
            str += "</ul>";
1599
            str += '</div>';
1600
 
1601
            var recommendations = getJsonArray(obj.ListingRecommendations.Recommendation);
1602
            for (i = 0; i < recommendations.length; i++) {
1603
                str += '<div class="alert alert-info alert-dismissible">';
1604
                str += '<button type="button" class="close" data-dismiss="alert">×</button>';
1605
                str += decode(recommendations[i]);
1606
                str += '</div>';
1607
            }
1608
 
1609
            x.innerHTML += str;
1610
        } else {
1611
            requireNewVerify();
1612
 
1613
            str += '<div class="alert alert-danger alert-dismissible">';
1614
            str += '<button type="button" class="close" data-dismiss="alert">×</button>';
1615
            str += '<p><strong>' + returnCode + ':</strong></p>';
1616
 
1617
            var errors = getJsonArray(obj.Errors);
1618
            str += "<ul>";
1619
            for (i = 0; i < errors.length; i++) {
1620
                str += '<li>' + errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "</li>";
1621
                if (errors[i].LongMessage.includes('Auth')) {
1622
                    authErrorFlag = true;
1623
                }
1624
            }
1625
            str += "</ul>";
1626
 
1627
            if (obj.DuplicateInvocationDetails) {
1628
                str += '<p>Duplicate Invocation Id ' + obj.DuplicateInvocationDetails.DuplicateInvocationID + ' Tracking Id' + obj.DuplicateInvocationDetails.InvocationTrackingID + ' Status ' + obj.DuplicateInvocationDetails.Status + '</p>';
1629
            }
1630
 
1631
            str += "</div>";
1632
            x.innerHTML += str;
1633
 
1634
            if (authErrorFlag === true) {
1635
                eBayAuthTokenFlag = false;
1636
                x = document.getElementById("login");
1637
                if (x.className.indexOf("w3-show") == -1) {
1638
                    x.className += " w3-show";
1639
                }
1640
            }
1641
        }
1642
 
1643
        if (obj.Message) {
1644
            str += '<div class="alert alert-info alert-dismissible">';
1645
            str += '<button type="button" class="close" data-dismiss="alert">×</button>';
1646
            str += '<p>' + obj.Message + '</p>';
1647
            str += '</div>';
1648
            x.innerHTML += str;
1649
        }
1650
    };
1651
 
1652
    xhr.send(xml);
1653
}
1654
 
1655
function decode(recommendation) {
1656
    var str = "<p>";
1657
    var i;
1658
 
1659
    str += recommendation.Code + " (" + recommendation.Type + "/" + recommendation.Group + ") for '" + recommendation.FieldName;
1660
    if (recommendation.Value) {
1661
        str += "': " + recommendation.Value;
1662
    }
1663
 
1664
    if (recommendation.Message) {
1665
        str += "<br/>" + recommendation.Message;
1666
    }
1667
 
1668
    var metadata = recommendation.Metadata;
1669
    if (metadata) {
1670
        if (metadata.length > 0) {
1671
            for (i = 0; i < metadata.length; i++) {
1672
                if (metadata[i].Name != "correlationId" &&
1673
                    metadata[i].Name != "currency" &&
1674
                    metadata[i].Name != "similarItems") {
1675
                    str += "<br/>" + metadata[i].Name + " = " + metadata[i].Value;
1676
                }
1677
            }
1678
        } else {
1679
            if (metadata.Name != "correlationId" &&
1680
                metadata.Name != "currency" &&
1681
                metadata.Name != "similarItems") {
1682
                str += "<br/>" + metadata.Name + " = " + metadata.Value;
1683
            }
1684
        }
1685
    }
1686
 
1687
    str += "</p>";
1688
 
1689
    return str;
1690
}
1691
 
1692
function submitListing(saveFlag) {
1693
    var i;
1694
    var authErrorFlag = false;
1695
 
1696
    if (document.getElementById("list").className.indexOf("btn-success") == -1) {
1697
        return;
1698
    }
1699
 
1700
    var xw = new XMLWriter('UTF-8', '1.0');
1701
    var xhr = new XMLHttpRequest();
1702
 
1703
    createAddXML(xw, xhr, 'AddItemRequest', 'AddItem', saveFlag);
1704
 
1705
    xml = xw.flush();
1706
    xw.close();
1707
 
1708
    xhr.onload = function() {
1709
        var jsonObj = XMLparse(xhr.responseXML, false);
1710
        var obj = jsonObj.AddItemResponse;
1711
        var str = '';
1712
        var returnCode = obj.Ack;
1713
 
1714
        var x = document.getElementById("results");
1715
        if (x.className.indexOf("w3-show") == -1) {
1716
            x.className += " w3-show";
1717
        }
1718
 
1719
        if (returnCode == 'Success' ||
1720
            (returnCode == 'Warning' && (obj.Errors.ErrorCode == '21917108' || obj.Errors.ErrorCode == '21920205' || obj.Errors.ErrorCode == '21917164'))) {
1721
            listButtonHot(false);
1722
            moveImages();
1723
            ImageURLs = [];
1724
            document.getElementById("title").value = "";
1725
            printTitleLength();
1726
            deleteSubmittedEntry();
1727
 
1728
 
1729
            str += '<div class="alert ' + (returnCode == 'Success' ? "alert-success" : "alert-warning" ) + ' alert-dismissible">';
1730
            str += '<button type="button" class="close" data-dismiss="alert">×</button>';
1731
            str += '<p><strong>' + returnCode + '</strong>, Item Id <a href="https://www.ebay.com/itm/' + obj.ItemID + '" target="_blank">' + obj.ItemID + '</a></p>';
1732
 
1733
            if (returnCode == 'Warning') {
1734
                str += "<p>" + obj.Errors.SeverityCode + " (" + obj.Errors.ErrorCode + "): " + escapeHtml(obj.Errors.LongMessage) + "</p>";
1735
            }
1736
            var fees = getJsonArray(obj.Fees.Fee);
1737
            str += "<ul>";
1738
            for (i = 0; i < fees.length; i++) {
1739
                if (fees[i].Fee.text !== "0.0") {
1740
                    str += '<li>' + fees[i].Name + ": $" + Number(fees[i].Fee.text).toFixed(2) + "</li>";
1741
                }
1742
            }
1743
 
1744
            if (obj.DiscountReason) {
1745
                str += "<li>Discount Reason: " + obj.DiscountReason + "</li>";
1746
            }
1747
 
1748
            str += '</ul>';
1749
            str += '</div>';
1750
 
12 - 1751
            x.innerHTML = str;
10 - 1752
        } else {
1753
            requireNewVerify();
1754
            str += '<div class="alert alert-danger alert-dismissible">';
1755
            str += '<button type="button" class="close" data-dismiss="alert">×</button>';
1756
            str += '<p><strong>' + returnCode + ':</strong></p>';
1757
 
1758
            var errors = getJsonArray(obj.Errors);
1759
            str += "<ul>";
1760
            for (i = 0; i < errors.length; i++) {
1761
                str += '<li>' + errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "</li>";
1762
                if (errors[i].LongMessage.includes('Auth')) {
1763
                    authErrorFlag = true;
1764
                }
1765
            }
1766
            str += "</ul>";
1767
 
1768
            if (obj.DuplicateInvocationDetails) {
1769
                str += '<p>Duplicate Invocation Id ' + obj.DuplicateInvocationDetails.DuplicateInvocationID + ' Tracking Id' + obj.DuplicateInvocationDetails.InvocationTrackingID + ' Status ' + obj.DuplicateInvocationDetails.Status + '</p>';
1770
            }
1771
 
1772
            str += "</div>";
12 - 1773
            x.innerHTML = str;
10 - 1774
 
1775
            if (authErrorFlag === true) {
1776
                eBayAuthTokenFlag = false;
1777
                x = document.getElementById("login");
1778
                if (x.className.indexOf("w3-show") == -1) {
1779
                    x.className += " w3-show";
1780
                }
1781
            }
1782
        }
1783
 
1784
        unsetAdditionalImages();
1785
    };
1786
 
1787
    if (saveFlag) {
1788
        var sPos = xml.indexOf('<Item>');
1789
        var ePos = xml.indexOf('</Item>');
1790
        var textToSave = xml.substr(sPos, ePos - sPos + 7);
1791
        var textToSaveAsBlob = new Blob([String(textToSave)], {
1792
            type: "text/xml"
1793
        });
1794
        var textToSaveAsURL = window.URL.createObjectURL(textToSaveAsBlob);
1795
        var fileNameToSaveAs = document.getElementById('keyword').value + ".xml";
1796
        var str = '';
1797
 
1798
        var downloadLink = document.createElement("a");
1799
        downloadLink.download = fileNameToSaveAs;
1800
        downloadLink.innerHTML = "Download File";
1801
        downloadLink.href = textToSaveAsURL;
1802
        downloadLink.onclick = destroyClickedElement;
1803
        downloadLink.style.display = "none";
1804
        document.body.appendChild(downloadLink);
1805
 
1806
        str += '<div class="alert alert-success alert-dismissible">';
1807
        str += '<button type="button" class="close" data-dismiss="alert">×</button>';
1808
        str += '<p><strong>XML Saved</strong>, Filename ' + fileNameToSaveAs;
1809
        str += '</div>';
1810
        document.getElementById("results").innerHTML = str;
1811
 
1812
        downloadLink.click();
1813
        listButtonHot(false);
1814
        moveImages();
1815
        ImageURLs = [];
1816
        unsetAdditionalImages();
1817
        deleteSubmittedEntry();
1818
    } else {
1819
        xhr.send(xml);
1820
    }
1821
}
1822
 
1823
function moveImages() {
1824
    var i, j;
1825
    var item = document.getElementById("keyword").value.trim();
1826
    var images = [];
1827
 
1828
    images.push(item + configImage1Extension);
1829
    images.push(item + configImage2Extension);
1830
    images.push(item + configdescriptionImageExtension);
1831
 
1832
    for (i = 0; i < additionalPictures.length; i++) {
1833
        if (additionalPictures[i] !== undefined && additionalPictures[i][0].startsWith(item)) {
1834
            for (j = 0; j < additionalPictures[i].length; j++) {
1835
                images.push(additionalPictures[i][j]);
1836
            }
1837
        }
1838
    }
1839
 
1840
    for (i=0; i < images.length; i++) {
1841
        var xhttp = new XMLHttpRequest();
1842
        xhttp.onreadystatechange = function() {
1843
            if (this.readyState == 4 && this.status == 200) {
1844
            } else if (this.readyState == 4 && this.status == 400) {
1845
            }
1846
        };
1847
 
1848
        xhttp.open("GET", "moveImage.php?filename=" + images[i], true);
1849
        xhttp.send();
1850
    }
1851
}
1852
 
1853
function destroyClickedElement(event) {
1854
    document.body.removeChild(event.target);
1855
}
1856
 
1857
function deleteSubmittedEntry() {
1858
    var x = document.getElementById("keyword");
1859
    x.remove(x.selectedIndex);
1860
    x.selectedIndex = -1;
1861
    $("#keyword").selectpicker('refresh');
1862
}
1863
 
1864
function createAddXML(xw, xhr, xmlrequest, callname, saveFlag) {
1865
    var errorText = "";
1866
    var ShippingProfileName;
1867
    var ShippingProfileId;
1868
    var si, opt;
1869
    var weightInOz;
1870
 
1871
    if (picturesAreLoaded === false) {
1872
        errorText += "<li>Images not yet uploaded!</li>";
1873
    }
1874
 
1875
    if (document.getElementById("format").value <= 1) {
1876
        errorText += "<li>Select Auction Format!</li>";
1877
    }
1878
 
1879
    if (document.getElementById("sku").value == 'Batch X') {
1880
        errorText += "<li>Wrong Batch Number!</li>";
1881
    }
1882
 
1883
    if (document.getElementById("category").value == '0') {
1884
        errorText += "<li>Wrong Category!</li>";
1885
    }
1886
 
1887
    if (document.getElementById("sku").value.length < 1) {
1888
        errorText += "<li>Batch Number Empty!</li>";
1889
    }
1890
 
1891
    if (document.getElementById("condition").value === "") {
1892
        errorText += "<li>Condition Description Empty!</li>";
1893
    }
1894
 
1895
    if (document.getElementById("quantity").value === "") {
1896
        errorText += "<li>Quantity Empty!</li>";
1897
    }
1898
 
1899
    if (document.getElementById("price").value === "") {
1900
        errorText += "<li>Price Empty!</li>";
1901
    }
1902
 
1903
    if (document.getElementById("title").value === "") {
1904
        errorText += "<li>Title Empty!</li>";
1905
    }
1906
 
1907
    if (errorText.length > 0) {
1908
        var str = '';
1909
        var x = document.getElementById("results");
1910
        str += '<div class="alert alert-danger alert-dismissible">';
1911
        str += '<button type="button" class="close" data-dismiss="alert">×</button>';
1912
        str += '<h2>Form Errors</h2><ul>' + errorText + '</ul>';
1913
        str += '</div>';
1914
        x.innerHTML += str;
1915
        if (x.className.indexOf("w3-show") == -1) {
1916
            x.className += " w3-show";
1917
        }
1918
 
1919
        return;
1920
    }
1921
 
1922
    xw.writeStartDocument();
1923
    xw.writeStartElement(xmlrequest);
1924
    xw.writeAttributeString('xmlns', 'urn:ebay:apis:eBLBaseComponents');
1925
 
1926
    xw.writeStartElement('RequesterCredentials');
1927
    xw.writeElementString('eBayAuthToken', eBayAuthToken);
1928
    xw.writeEndElement(); /* RequesterCredentials */
1929
 
1930
    xw.writeStartElement('Item');
1931
 
1932
    if (CC == 3 || saveFlag) {
1933
        xw.writeElementString('UUID', document.getElementById('keyword').value.hashCode().pad(32));
1934
    }
1935
 
1936
    xw.writeElementString('Site', 'US');
1937
    xw.writeElementString('Country', 'US');
1938
    xw.writeElementString('PostalCode', configZip);
1939
    xw.writeElementString('Currency', 'USD');
1940
    xw.writeElementString('HitCounter', 'HiddenStyle');
1941
 
1942
    var format = document.getElementById('format').value;
1943
    xw.writeElementString('ListingType', format);
1944
    if (format == 'Chinese') {
1945
        xw.writeElementString('ListingDuration', 'Days_7');
1946
    } else if (format == 'FixedPriceItem') {
1947
        xw.writeElementString('ListingDuration', 'Days_30');
1948
    }
1949
 
1950
    xw.writeStartElement('PrimaryCategory');
1951
    xw.writeElementString('CategoryID', category);
1952
    xw.writeEndElement(); /* PrimaryCategory */
1953
 
1954
    if (document.getElementById("category").value != '29223') {
1955
        xw.writeElementString('ConditionID', document.getElementById('conditionId').value);
1956
    }
1957
    if (document.getElementById('conditionId').value != '1000') {
1958
        xw.writeElementString('ConditionDescription', escapeXml(document.getElementById('condition').value));
1959
    }
1960
 
1961
    xw.writeStartElement('StartPrice');
1962
    xw.writeAttributeString('currencyID', 'USD');
1963
    xw.writeString(document.getElementById('price').value);
1964
    xw.writeEndElement(); /* StartPrice */
1965
 
1966
    xw.writeElementString('PayPalEmailAddress', configLinkedPayPal);
1967
    xw.writeElementString('PaymentMethods', 'PayPal');
1968
    xw.writeElementString('Quantity', document.getElementById('quantity').value);
1969
    xw.writeElementString('Title', escapeXml(document.getElementById('title').value));
1970
    if (!isManualMode) {
1971
        xw.writeElementString('SKU', escapeXml(document.getElementById('sku').value));
1972
    } else {
1973
        if (isNumeric(document.getElementById('keyword').value.trim())) {
1974
            xw.writeElementString('SKU', escapeXml(document.getElementById('sku').value + ' - ' + ProductListingDetailsNameList[CC] + ' ' + document.getElementById('keyword').value.trim()));
1975
        } else {
1976
            xw.writeElementString('SKU', escapeXml(document.getElementById('sku').value));
1977
        }
1978
    }
1979
 
1980
    xw.writeStartElement('SellerProfiles');
1981
    xw.writeStartElement('SellerPaymentProfile');
1982
    xw.writeElementString('PaymentProfileID', '116958658023');
1983
    xw.writeElementString('PaymentProfileName', 'PayPal');
1984
    xw.writeEndElement(); /* SellerPaymentProfile */
1985
    xw.writeStartElement('SellerReturnProfile');
1986
    xw.writeElementString('ReturnProfileID', '123043332023');
1987
    xw.writeElementString('ReturnProfileName', 'Returns Accepted,Buyer,30 Days,Money Back');
1988
    xw.writeEndElement(); /* SellerReturnProfile */
1989
 
1990
    xw.writeStartElement('SellerShippingProfile');
1991
    ShippingProfileId = ShippingProfileIdList[CC];
1992
    ShippingProfileName = ShippingProfileNameList[CC];
1993
    if (CC == 1) {
1994
        if (document.getElementById('title').value.includes('Discs') || discogsQty > 1) {
1995
            ShippingProfileId = ShippingProfileIdList[2];
1996
            ShippingProfileName = ShippingProfileNameList[2];
1997
        }
1998
    }
1999
    xw.writeElementString('ShippingProfileID', ShippingProfileId);
2000
    xw.writeElementString('ShippingProfileName', ShippingProfileName);
2001
    xw.writeEndElement(); /* SellerShippingProfile */
2002
 
2003
    xw.writeEndElement(); /* SellerProfiles */
2004
 
2005
    if (CC == 1) {
2006
        weightInOz = 4;
2007
 
2008
        if (discogsQty > 0) {
2009
            weightInOz = discogsQty * 4;
2010
        }
2011
 
2012
        if (document.getElementById('title').value.includes('Discs')) {
2013
            var pos = document.getElementById('title').value.indexOf('Discs');
2014
            var discNo = Number(document.getElementById('title').value.substr(pos - 2, 1));
2015
            if (discNo > 1) {
2016
                weightInOz = discNo * 4;
2017
            }
2018
        }
2019
 
2020
        xw.writeStartElement('ShippingPackageDetails');
2021
        xw.writeElementString('ShippingPackage', 'PackageThickEnvelope');
2022
        xw.writeElementString('ShippingIrregular', 'false');
2023
        xw.writeElementString('MeasurementUnit', 'English');
2024
        xw.writeElementString('WeightMajor', '0');
2025
        xw.writeElementString('WeightMinor', weightInOz.toString());
2026
        xw.writeEndElement(); /* ShippingPackageDetails> */
2027
    } else if (CC == 2) {
2028
        xw.writeStartElement('ShippingPackageDetails');
2029
        xw.writeElementString('ShippingPackage', 'PackageThickEnvelope');
2030
        xw.writeElementString('ShippingIrregular', 'false');
2031
        xw.writeElementString('MeasurementUnit', 'English');
2032
        xw.writeElementString('WeightMajor', '0');
2033
        xw.writeElementString('WeightMinor', '6');
2034
        xw.writeEndElement(); /* ShippingPackageDetails> */
2035
    } else if (CC == 3) {
2036
        xw.writeStartElement('ShippingPackageDetails');
2037
        xw.writeElementString('ShippingPackage', 'Letter');
2038
        xw.writeElementString('ShippingIrregular', 'false');
2039
        xw.writeElementString('MeasurementUnit', 'English');
2040
        xw.writeElementString('WeightMajor', '0');
2041
        xw.writeElementString('WeightMinor', '1');
2042
        xw.writeEndElement(); /* ShippingPackageDetails> */
2043
    }
2044
 
2045
    xw.writeStartElement('ProductListingDetails');
2046
    if (CC == 3) {
2047
        xw.writeElementString(ProductListingDetailsNameList[CC], configDoesNotApply);
2048
    } else {
2049
        si = document.getElementById("keyword").selectedIndex;
2050
        opt = document.getElementById("keyword").options;
2051
        if (!isManualMode) {
2052
            if (eBayProductId.length > 0) {
2053
                xw.writeElementString('ProductReferenceID', eBayProductId);
2054
            } else {
2055
                if (isNumeric(document.getElementById('keyword').value.trim())) {
2056
                    if (opt[si].style.color != 'red') {
2057
                        xw.writeElementString(ProductListingDetailsNameList[CC], document.getElementById('keyword').value.trim());
2058
                    } else {
2059
                        xw.writeElementString(ProductListingDetailsNameList[CC], configDoesNotApply);
2060
                    }
2061
                } else {
2062
                    xw.writeElementString(ProductListingDetailsNameList[CC], configDoesNotApply);
2063
                }
2064
            }
2065
        } else {
2066
            if (opt[si].style.color == 'red') {
2067
                xw.writeElementString(ProductListingDetailsNameList[CC], configDoesNotApply);
2068
            } else if (CC === 0) {
2069
                xw.writeElementString(ProductListingDetailsNameList[CC], document.getElementById('bookISBN').value.trim());
2070
            } else if (CC == 1) {
2071
                xw.writeElementString(ProductListingDetailsNameList[CC], document.getElementById('cdUPC').value.trim());
2072
            } else if (CC == 2) {
2073
                xw.writeElementString(ProductListingDetailsNameList[CC], document.getElementById('dvdUPC').value.trim());
2074
            }
2075
        }
2076
    }
2077
    xw.writeEndElement(); /* ProductListingDetails */
2078
 
2079
    xw.writeStartElement('Storefront');
2080
    if (CC != 3) {
2081
        xw.writeElementString('StoreCategoryID', StoreCategoryList[CC]);
2082
    } else {
2083
        if (category == "666") {
2084
            xw.writeElementString('StoreCategoryID', "30431905018");
2085
        } else if (category == "213") {
2086
            xw.writeElementString('StoreCategoryID', "30431901018");
2087
        } else if (category == "214") {
2088
            xw.writeElementString('StoreCategoryID', "30431902018");
2089
        } else if (category == "215") {
2090
            xw.writeElementString('StoreCategoryID', "30431903018");
2091
        } else if (category == "216") {
2092
            xw.writeElementString('StoreCategoryID', "30431904018");
2093
        } else {
2094
            xw.writeElementString('StoreCategoryID', "");
2095
        }
2096
    }
2097
    xw.writeEndElement(); /* Storefront */
2098
 
2099
    xw.writeStartElement('PictureDetails');
2100
    for (var imageNumber = 0; imageNumber < ImageURLs.length; imageNumber++) {
2101
        xw.writeElementString('PictureURL', ImageURLs[imageNumber]);
2102
    }
2103
    xw.writeEndElement(); /* PictureDetails */
2104
 
2105
    // Use Tax Table
2106
    //	xw.writeStartElement('ShippingDetails');
2107
    //	xw.writeStartElement('SalesTax');
2108
    //	xw.writeElementString('SalesTaxPercent', configTaxRate);
2109
    //	xw.writeElementString('SalesTaxState', configTaxStateId);
2110
    //	xw.writeElementString('ShippingIncludedInTax', 'false');
2111
    //	xw.writeEndElement(); /* SalesTax */
2112
    //	xw.writeEndElement(); /* ShippingDetails */
2113
    xw.writeElementString('UseTaxTable', 'true');
2114
 
2115
    if (document.getElementById('bestoffer').checked) {
2116
        var autoAcceptPrice = Number(document.getElementById('price').value) * configAutoAcceptPrice;
2117
        var minBestOfferPrice = Number(document.getElementById('price').value) * configMinBestOfferPrice;
2118
 
2119
        xw.writeStartElement('BestOfferDetails');
2120
        xw.writeElementString('BestOfferEnabled', 'true');
2121
        xw.writeEndElement(); /* BestOfferDetails */
2122
        xw.writeStartElement('ListingDetails');
2123
        xw.writeStartElement('BestOfferAutoAcceptPrice');
2124
        xw.writeAttributeString('currencyID', 'USD');
2125
        xw.writeString(autoAcceptPrice.toFixed(2));
2126
        xw.writeEndElement(); /* BestOfferAutoAcceptPrice */
2127
        xw.writeStartElement('MinimumBestOfferPrice');
2128
        xw.writeAttributeString('currencyID', 'USD');
2129
        xw.writeString(minBestOfferPrice.toFixed(2));
2130
        xw.writeEndElement(); /* MinimumBestOfferPrice */
2131
        xw.writeEndElement(); /* ListingDetails */
2132
    }
2133
 
2134
    var Desc = Description1;
2135
    Desc += '<h3>' + document.getElementById('title').value + '</h3>';
2136
    generateDescCore();
2137
    Desc += DescCore;
2138
    if (document.getElementById('conditionId').value != '1000') {
2139
        Desc += '<p>' + document.getElementById('condition').value + '</p>';
2140
    }
2141
    Desc += Description2;
2142
    Desc += document.getElementById('title').value.replace(/['"]+/g, '');
2143
    Desc += Description2a;
2144
    Desc += DescImage;
2145
    Desc += Description3;
2146
    if (CC !== 3) {
2147
        Desc += DescriptionFreeShipping;
2148
    } else {
2149
        Desc += DescriptionTradingCardShipping;
2150
    }
2151
    Desc += Description4;
2152
    xw.writeElementString('Description', escapeXml(Desc));
2153
 
2154
    if (callname.includes('Verify') && configGetRecommendations === true) {
2155
        xw.writeElementString('IncludeRecommendations', 'true');
2156
    }
2157
 
2158
    generateItemSpecifics(xw);
2159
 
2160
    xw.writeEndElement(); /* Item */
2161
 
2162
    xw.writeElementString('ErrorLanguage', 'en_US');
2163
    xw.writeElementString('Version', configeBayTradingVersion);
2164
    xw.writeElementString('WarningLevel', configWarningLevel);
2165
 
2166
    xw.writeEndElement(); /* xmlrequest */
2167
    xw.writeEndDocument();
2168
 
2169
    xhr.open('POST', configProxyUrl, true);
2170
    xhr.setRequestHeader('Content-Type', 'text/xml');
2171
    xhr.setRequestHeader('X-EBAY-API-APP-NAME', configAppid);
2172
    xhr.setRequestHeader('X-EBAY-API-COMPATIBILITY-LEVEL', configeBayTradingVersion);
2173
    xhr.setRequestHeader('X-EBAY-API-CALL-NAME', callname);
2174
    xhr.setRequestHeader('X-EBAY-API-SITEID', '0');
2175
    xhr.setRequestHeader('X-EBAY-API-DEV-NAME', '');
2176
    xhr.setRequestHeader('X-EBAY-API-CERT-NAME', '');
2177
    xhr.setRequestHeader('X-Proxy-URL', configServiceEndpoint);
2178
 
2179
    return true;
2180
}
2181
 
2182
function categoryValues() {
2183
    category = document.getElementById("category").value;
2184
 
2185
    if (category == 182882 || category == 171228 || category == 171243 || category == 2228 || category == 268) {
2186
        /* Books */
2187
        CC = 0;
2188
        conditionDescriptionButtons(0);
2189
    } else if (category == 176984 || category == 29792) {
2190
        /* CDs */
2191
        CC = 1;
2192
        conditionDescriptionButtons(1);
2193
    } else if (category == 617) {
2194
        /* DVDs */
2195
        CC = 2;
2196
        conditionDescriptionButtons(0);
2197
    } else if (category == 666 || category == 213 || category == 214 || category == 133072 || category == 215 || category == 4240 || category == 216 || category == 183444) {
2198
        /* Trading Cards */
2199
        CC = 3;
2200
        conditionDescriptionButtons(0);
2201
    } else {
2202
        conditionDescriptionButtons(0);
2203
        return;
2204
    }
2205
 
12 - 2206
    if (document.getElementById("format").value.length < 1) {
2207
        $('#format').selectpicker('val', auctionFormat[CC]);
2208
        $('#format').selectpicker('refresh');
10 - 2209
    }
2210
 
2211
    if (document.getElementById("price").value.length < 4) {
2212
        document.getElementById("price").value = MinPriceList[CC];
2213
    }
2214
 
2215
    document.getElementById("condition").value = ConditionDescriptionList[CC];
12 - 2216
    $('#conditionId').selectpicker('val', ConditionIdList[CC]);
2217
    $('#conditionId').selectpicker('refresh');
10 - 2218
    document.getElementById("quantity").value = 1;
2219
    document.getElementById("bestoffer").checked = false;
2220
}
2221
 
2222
function conditionDescriptionButtons(flag) {
2223
    var x = [];
2224
    x[0] = document.getElementById("CdConditionDescriptionSingular");
12 - 2225
    x[0].className = x[0].className.replace("btn-dark", "btn-info");
10 - 2226
    x[1] = document.getElementById("CdConditionDescriptionPlural");
12 - 2227
    x[1].className = x[1].className.replace("btn-info", "btn-dark");
10 - 2228
    x[2] = document.getElementById("CdConditionDescriptionDigipak");
12 - 2229
    x[2].className = x[2].className.replace("btn-info", "btn-dark");
10 - 2230
    x[3] = document.getElementById("CdConditionDescriptionNewCase");
12 - 2231
    x[3].className = x[3].className.replace("btn-info", "btn-dark");
10 - 2232
 
2233
    for (var i = 0; i < x.length; i++) {
2234
        if (flag) {
2235
            if (x[i].className.indexOf("w3-show-inline-block") == -1) {
2236
                x[i].className += " w3-show-inline-block";
2237
            }
2238
        } else {
2239
            x[i].className = x[i].className.replace(" w3-show-inline-block", "");
2240
        }
2241
    }
2242
}
2243
 
2244
function setCdConditionDescription(flag) {
12 - 2245
    var x = [];
2246
    x[0] = document.getElementById("CdConditionDescriptionSingular");
2247
    x[1] = document.getElementById("CdConditionDescriptionPlural");
2248
    x[2] = document.getElementById("CdConditionDescriptionDigipak");
2249
    x[3] = document.getElementById("CdConditionDescriptionNewCase");
2250
 
2251
    x[0].className = x[0].className.replace("btn-info", "btn-dark");
2252
    x[1].className = x[1].className.replace("btn-info", "btn-dark");
2253
    x[2].className = x[2].className.replace("btn-info", "btn-dark");
2254
    x[3].className = x[3].className.replace("btn-info", "btn-dark");
2255
 
10 - 2256
    if (flag == 'S') {
2257
        document.getElementById("condition").value = ConditionDescriptionList[1];
12 - 2258
        x[0].className = x[0].className.replace("btn-dark", "btn-info");
10 - 2259
    } else if (flag == 'P') {
2260
        document.getElementById("condition").value = ConditionDescriptionCdPlural;
12 - 2261
        x[1].className = x[1].className.replace("btn-dark", "btn-info");
10 - 2262
        discogsQty = 2;
2263
    } else if (flag == 'D') {
2264
        document.getElementById("condition").value = ConditionDescriptionCdDigipak;
2265
        document.getElementById("cdDigipak").checked = true;
12 - 2266
        x[2].className = x[2].className.replace("btn-dark", "btn-info");
10 - 2267
    } else if (flag == 'N') {
2268
        document.getElementById("condition").value = ConditionDescriptionCdNewCase;
12 - 2269
        x[3].className = x[3].className.replace("btn-dark", "btn-info");
10 - 2270
    }
2271
}
2272
 
2273
var minActive = [0.0, 0.0, 0.0];
2274
var maxActive = [0.0, 0.0, 0.0];
2275
var avgActive = [0.0, 0.0, 0.0];
2276
var noActive = [0, 0, 0];
2277
var minSold = [0.0, 0.0, 0.0];
2278
var maxSold = [0.0, 0.0, 0.0];
2279
var avgSold = [0.0, 0.0, 0.0];
2280
var noSold = [0, 0, 0];
2281
var minUnsold = [0.0, 0.0, 0.0];
2282
var maxUnsold = [0.0, 0.0, 0.0];
2283
var avgUnsold = [0.0, 0.0, 0.0];
2284
var noUnsold = [0, 0, 0];
2285
var maxPricingPages = [-1, -1];
2286
var totalPricingEntries = [0, 0];
2287
var newActiveBreakdown = [];
2288
var usedActiveBreakdown = [];
2289
var newSoldBreakdown = [];
2290
var usedSoldBreakdown = [];
2291
var maxPriceByNumber = [0.0, 0.0];
2292
var listingNumberPercentage = 0.25;
2293
 
2294
 
2295
function getPricing() {
2296
    minActive = [0.0, 0.0, 0.0];
2297
    maxActive = [0.0, 0.0, 0.0];
2298
    avgActive = [0.0, 0.0, 0.0];
2299
    noActive = [0, 0, 0];
2300
    minSold = [0.0, 0.0, 0.0];
2301
    maxSold = [0.0, 0.0, 0.0];
2302
    avgSold = [0.0, 0.0, 0.0];
2303
    noSold = [0, 0, 0];
2304
    minUnsold = [0.0, 0.0, 0.0];
2305
    maxUnsold = [0.0, 0.0, 0.0];
2306
    avgUnsold = [0.0, 0.0, 0.0];
2307
    noUnsold = [0, 0, 0];
2308
    maxPricingPages = [-1, -1];
2309
    totalPricingEntries = [0, 0];
2310
    newActiveBreakdown = [];
2311
    usedActiveBreakdown = [];
2312
    newSoldBreakdown = [];
2313
    usedSoldBreakdown = [];
2314
 
2315
    getPricingData(0);
2316
    getPricingData(1);
2317
}
2318
 
2319
function getPricingData(searchIndex) {
2320
    var index = 0;
2321
    var keyword;
2322
 
2323
    keyword = document.getElementById('keyword').value;
2324
 
2325
    // Construct the request
2326
    var url = configeBayFinding + "?";
2327
    if (searchIndex === 0) {
2328
        url += "OPERATION-NAME=findItemsAdvanced";
2329
    } else {
2330
        url += "OPERATION-NAME=findCompletedItems";
2331
    }
2332
    url += "&SECURITY-APPNAME=" + configAppid;
2333
    url += "&GLOBAL-ID=EBAY-US";
2334
    url += "&RESPONSE-DATA-FORMAT=JSON";
2335
    url += "&SERVICE-VERSION=" + configeBayFindingVersion;
2336
    url += "&REST-PAYLOAD";
2337
    url += "&keywords=";
2338
    url += encodeURIComponent(keyword.trim().replace(/ /g, "+"));
2339
 
2340
    url += "&paginationInput.entriesPerPage=100";
2341
    url += "&paginationInput.pageNumber=";
2342
    url += (index + 1);
2343
    url += "&buyerPostalCode=";
2344
    url += configZip;
2345
 
2346
    var xhttp = new XMLHttpRequest();
2347
 
2348
    xhttp.onreadystatechange = function() {
2349
        if (this.readyState == 4) {
2350
            if (searchIndex === 0) {
2351
                _cb_PriceActiveItems(JSON.parse(this.responseText));
2352
            } else {
2353
                _cb_PriceCompletedItems(JSON.parse(this.responseText));
2354
            }
2355
        }
2356
    };
2357
 
2358
    xhttp.open("GET", configProxyUrl, true);
2359
    xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
2360
    xhttp.send();
2361
 
2362
    function waitForMaxPricingPages(i) {
2363
        if (maxPricingPages[i] < 0) {
2364
            window.setTimeout(waitForMaxPricingPages, 500, i); // wait 500 milliseconds
2365
        } else {
2366
            for (index = 1; index < maxPricingPages[searchIndex]; index++) {
2367
                // Construct the request
2368
                var url = configeBayFinding + "?";
2369
                if (searchIndex === 0) {
2370
                    url += "OPERATION-NAME=findItemsAdvanced";
2371
                } else {
2372
                    url += "OPERATION-NAME=findCompletedItems";
2373
                }
2374
                url += "&SECURITY-APPNAME=" + configAppid;
2375
                url += "&GLOBAL-ID=EBAY-US";
2376
                url += "&RESPONSE-DATA-FORMAT=JSON";
2377
                url += "&SERVICE-VERSION=" + configeBayFindingVersion;
2378
                url += "&REST-PAYLOAD";
2379
                url += "&keywords=";
2380
                url += encodeURIComponent(keyword.trim().replace(/ /g, "+"));
2381
 
2382
                url += "&paginationInput.entriesPerPage=100";
2383
                url += "&paginationInput.pageNumber=";
2384
                url += (index + 1);
2385
 
2386
                var xhttp = new XMLHttpRequest();
2387
 
2388
                xhttp.onreadystatechange = function() {
2389
                    if (this.readyState == 4) {
2390
                        if (searchIndex === 0) {
2391
                            _cb_PriceActiveItems(JSON.parse(this.responseText));
2392
                        } else {
2393
                            _cb_PriceCompletedItems(JSON.parse(this.responseText));
2394
                        }
2395
                    }
2396
                };
2397
 
2398
                xhttp.open("GET", configProxyUrl, true);
2399
                xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
2400
                xhttp.send();
2401
            }
2402
        }
2403
    }
2404
 
2405
    waitForMaxPricingPages(searchIndex);
2406
}
2407
 
2408
function _cb_PriceActiveItems(objArray) {
2409
    var array = typeof objArray.findItemsAdvancedResponse[0] != 'object' ? JSON.parse(objArray.findItemsAdvancedResponse[0]) : objArray.findItemsAdvancedResponse[0].searchResult[0].item;
2410
    totalPricingEntries[0] = Number(objArray.findItemsAdvancedResponse[0].paginationOutput[0].totalEntries);
2411
    if (totalPricingEntries[0] > 0) {
2412
        priceItem(array, 0);
2413
    }
2414
}
2415
 
2416
function _cb_PriceCompletedItems(objArray) {
2417
    var array = typeof objArray.findCompletedItemsResponse[0] != 'object' ? JSON.parse(objArray.findCompletedItemsResponse[0]) : objArray.findCompletedItemsResponse[0].searchResult[0].item;
2418
    totalPricingEntries[1] = Number(objArray.findCompletedItemsResponse[0].paginationOutput[0].totalEntries);
2419
    if (totalPricingEntries[1] > 0) {
2420
        priceItem(array, 1);
2421
    }
2422
}
2423
 
2424
function priceItem(array, index) {
2425
    var i;
2426
    var Title;
2427
    var shippingCost = 0.0;
2428
    var itemCost = 0.0;
2429
    var totalCost = 0.0;
2430
    var totalCostInt = 0;
2431
    var sellingStatus;
2432
    var sellingState;
2433
    var bidCount;
2434
    var condInd;
2435
    var condition;
2436
    var conditionId;
2437
    var shippingInfo;
2438
    var shippingServiceCost;
2439
    var convertedCurrentPrice;
2440
    var listingInfo;
2441
    var convertedBuyItNowPrice;
2442
    var JsonObj;
2443
 
2444
    if (array === undefined) {
2445
        return;
2446
    }
2447
 
2448
    if (totalPricingEntries[index] < 1) {
2449
        maxPricingPages[index] = 0;
2450
    } else {
2451
        maxPricingPages[index] = (totalPricingEntries[index] / 100) > 100 ? 100 : Math.trunc(totalPricingEntries[index] / 100.0) + 1;
2452
    }
2453
 
2454
    for (i = 0; i < array.length; i++) {
2455
        JsonObj = array[i];
2456
 
2457
        Title = JsonObj.title[0].toLowerCase();
2458
        if (Title.includes("disc only") > 0 ||
2459
            Title.includes("disk only") > 0 ||
2460
            Title.includes("only disc") > 0 ||
2461
            Title.includes("only disk") > 0 ||
2462
            Title.search(/dis[ck].*only/) > 0) {
2463
            continue; // exclude "disc only listing
2464
        }
2465
 
2466
        condition = JsonObj.condition;
2467
        if (condition) {
2468
            conditionId = condition[0].conditionId;
2469
            if (conditionId == 1000 || conditionId == 1500 || conditionId == 2750) {
2470
                condInd = 1;
2471
            } else if (conditionId <= 4000) {
2472
                condInd = 2;
2473
            } else {
2474
                continue; // Only 'Very Good' and better
2475
            }
2476
        } else {
2477
            condInd = 2;
2478
        }
2479
 
2480
        shippingInfo = JsonObj.shippingInfo;
2481
        shippingServiceCost = shippingInfo[0].shippingServiceCost;
2482
        if (shippingServiceCost) {
2483
            shippingCost = Number(shippingServiceCost[0].__value__);
2484
        } else {
2485
            shippingCost = 0.0;
2486
        }
2487
 
2488
        sellingStatus = JsonObj.sellingStatus;
2489
        sellingState = sellingStatus[0].sellingState;
2490
        bidCount = sellingStatus[0].bidCount;
2491
        convertedCurrentPrice = sellingStatus[0].convertedCurrentPrice;
2492
        itemCost = Number(convertedCurrentPrice[0].__value__);
2493
 
2494
        listingInfo = JsonObj.listingInfo;
2495
        convertedBuyItNowPrice = listingInfo[0].convertedBuyItNowPrice;
2496
        if (bidCount === 0 && convertedBuyItNowPrice) {
2497
            itemCost = Number(convertedBuyItNowPrice[0].__value__);
2498
        }
2499
 
2500
        if (condition) {
2501
            conditionId = condition[0].conditionId;
2502
            if (conditionId == 1000 || conditionId == 1500 || conditionId == 2750) {
2503
                condInd = 1;
2504
            } else {
2505
                condInd = 2;
2506
            }
2507
        } else {
2508
            condInd = 2;
2509
        }
2510
 
2511
        totalCost = itemCost + shippingCost;
2512
        totalCostInt = Math.ceil(totalCost);
2513
 
2514
        if (sellingState == "Active") {
2515
            if (totalCost < minActive[0] || !minActive[0]) {
2516
                minActive[0] = totalCost;
2517
            }
2518
            if (totalCost > maxActive[0]) {
2519
                maxActive[0] = totalCost;
2520
            }
2521
            avgActive[0] += totalCost;
2522
            ++noActive[0];
2523
 
2524
            if (totalCost < minActive[condInd] || !minActive[condInd]) {
2525
                minActive[condInd] = totalCost;
2526
            }
2527
            if (totalCost > maxActive[condInd]) {
2528
                maxActive[condInd] = totalCost;
2529
            }
2530
            avgActive[condInd] += totalCost;
2531
            ++noActive[condInd];
2532
 
2533
            if (condInd == 1) {
2534
                if (newActiveBreakdown[totalCostInt] === undefined) {
2535
                    newActiveBreakdown[totalCostInt] = 0;
2536
                }
2537
                ++newActiveBreakdown[totalCostInt];
2538
            } else {
2539
                if (usedActiveBreakdown[totalCostInt] === undefined) {
2540
                    usedActiveBreakdown[totalCostInt] = 0;
2541
                }
2542
                ++usedActiveBreakdown[totalCostInt];
2543
            }
2544
        } else if (sellingState == "EndedWithSales") {
2545
            if (totalCost < minSold[0] || !minSold[0]) {
2546
                minSold[0] = totalCost;
2547
            }
2548
            if (totalCost > maxSold[0]) {
2549
                maxSold[0] = totalCost;
2550
            }
2551
            avgSold[0] += totalCost;
2552
            ++noSold[0];
2553
 
2554
            if (totalCost < minSold[condInd] || !minSold[condInd]) {
2555
                minSold[condInd] = totalCost;
2556
            }
2557
            if (totalCost > maxSold[condInd]) {
2558
                maxSold[condInd] = totalCost;
2559
            }
2560
            avgSold[condInd] += totalCost;
2561
            ++noSold[condInd];
2562
 
2563
            if (condInd == 1) {
2564
                if (newSoldBreakdown[totalCostInt] === undefined) {
2565
                    newSoldBreakdown[totalCostInt] = 0;
2566
                }
2567
                ++newSoldBreakdown[totalCostInt];
2568
            } else {
2569
                if (usedSoldBreakdown[totalCostInt] === undefined) {
2570
                    usedSoldBreakdown[totalCostInt] = 0;
2571
                }
2572
                ++usedSoldBreakdown[totalCostInt];
2573
            }
2574
        } else /* Unsold */ {
2575
            if (totalCost < minUnsold[0] || !minUnsold[0]) {
2576
                minUnsold[0] = totalCost;
2577
            }
2578
            if (totalCost > maxUnsold[0]) {
2579
                maxUnsold[0] = totalCost;
2580
            }
2581
            avgUnsold[0] += totalCost;
2582
            ++noUnsold[0];
2583
 
2584
            if (totalCost < minUnsold[condInd] || !minUnsold[condInd]) {
2585
                minUnsold[condInd] = totalCost;
2586
            }
2587
            if (totalCost > maxUnsold[condInd]) {
2588
                maxUnsold[condInd] = totalCost;
2589
            }
2590
            avgUnsold[condInd] += totalCost;
2591
            ++noUnsold[condInd];
2592
        }
2593
    }
2594
 
2595
    var x = document.getElementById("prices");
2596
    if (x.className.indexOf("w3-show") == -1) {
2597
        x.className += " w3-show";
2598
    }
2599
 
2600
    var str = '<h3>Pricing Information (Shipping included)</h3>';
2601
    str += '<table class="table table-striped table-bordered table-hover">';
2602
    str += '	<thead class="thead-dark">';
2603
    str += '	<tr>';
2604
    str += '		<th></th>';
2605
    str += '		<th>Number</th>';
2606
    str += '        <th>Minimum</th>';
2607
    str += '        <th>Maximum</th>';
2608
    str += '        <th>Average</th>';
2609
    str += '	</tr>';
2610
    str += '	</thead>';
2611
    str += '	<tbody>';
2612
    str += '	<tr>';
2613
    str += '		<td>Active</td>';
2614
    str += '		<td>' + noActive[0] + '<br/>' + noActive[1] + ' / ' + noActive[2] + '</td>';
2615
    str += '		<td>$' + Number(minActive[0]).toFixed(2) + '<br/>$' + Number(minActive[1]).toFixed(2) + ' / $' + Number(minActive[2]).toFixed(2) + '</td>';
2616
    str += '		<td>$' + Number(maxActive[0]).toFixed(2) + '<br/>$' + Number(maxActive[1]).toFixed(2) + ' / $' + Number(maxActive[2]).toFixed(2) + '</td>';
2617
    str += '		<td>';
2618
    if (noActive[0]) {
2619
        str += '$' + Number(avgActive[0] / noActive[0]).toFixed(2);
2620
        str += '<br/>$' + (noActive[1] > 0 ? Number(avgActive[1] / noActive[1]).toFixed(2) : 0.00);
2621
        str += ' / $' + (noActive[2] > 0 ? Number(avgActive[2] / noActive[2]).toFixed(2) : 0.00);
2622
    }
2623
    str += '</td>';
2624
    str += '	</tr>';
2625
 
2626
    str += '<tr><td colspan="5">';
2627
    str += '<canvas id="activeChart" width="640" height="320" style="border:1px solid #000000;"></canvas>';
2628
    str += '</td></tr>';
2629
 
2630
    str += '	<tr>';
2631
    str += '		<td>Sold</td>';
2632
    str += '		<td>' + noSold[0] + '<br/>' + noSold[1] + ' / ' + noSold[2] + '</td>';
2633
    str += '		<td>$' + Number(minSold[0]).toFixed(2) + '<br/>$' + Number(minSold[1]).toFixed(2) + ' / $' + Number(minSold[2]).toFixed(2) + '</td>';
2634
    str += '		<td>$' + Number(maxSold[0]).toFixed(2) + '<br/>$' + Number(maxSold[1]).toFixed(2) + ' / $' + Number(maxSold[2]).toFixed(2) + '</td>';
2635
    str += '		<td>';
2636
    if (noSold[0]) {
2637
        str += '$' + Number(avgSold[0] / noSold[0]).toFixed(2);
2638
        str += '<br/>$' + (noSold[1] > 0 ? Number(avgSold[1] / noSold[1]).toFixed(2) : 0.00);
2639
        str += ' / $' + (noSold[2] > 0 ? Number(avgSold[2] / noSold[2]).toFixed(2) : 0.00);
2640
    }
2641
    str += '</td>';
2642
    str += '	</tr>';
2643
 
2644
    str += '<tr><td colspan="5">';
2645
    str += '<canvas id="soldChart" width="640" height="320" style="border:1px solid #000000;"></canvas>';
2646
    str += '</td></tr>';
2647
 
2648
    str += '	<tr>';
2649
    str += '		<td>Unsold</td>';
2650
    str += '		<td>' + noUnsold[0] + '<br/>' + noUnsold[1] + ' / ' + noUnsold[2] + '</td>';
2651
    str += '		<td>$' + Number(minUnsold[0]).toFixed(2) + '<br/>$' + Number(minUnsold[1]).toFixed(2) + ' / $' + Number(minUnsold[2]).toFixed(2) + '</td>';
2652
    str += '		<td>$' + Number(maxUnsold[0]).toFixed(2) + '<br/>$' + Number(maxUnsold[1]).toFixed(2) + ' / $' + Number(maxUnsold[2]).toFixed(2) + '</td>';
2653
    str += '		<td>';
2654
    if (noUnsold[0]) {
2655
        str += '$' + Number(avgUnsold[0] / noUnsold[0]).toFixed(2);
2656
        str += '<br/>$' + (noUnsold[1] > 0 ? Number(avgUnsold[1] / noUnsold[1]).toFixed(2) : 0.00);
2657
        str += ' / $' + (noUnsold[2] > 0 ? Number(avgUnsold[2] / noUnsold[2]).toFixed(2) : 0.00);
2658
    }
2659
    str += '</td>';
2660
    str += '	</tr>';
2661
    str += '	</tbody>';
2662
    str += '</table>';
2663
 
2664
    x.innerHTML = str;
2665
 
2666
    pricingGraphs(0, usedActiveBreakdown, newActiveBreakdown);
2667
    pricingGraphs(1, usedSoldBreakdown, newSoldBreakdown);
2668
}
2669
 
2670
function pricingGraphs(index, usedBreakdown, newBreakdown) {
2671
    var i;
2672
    var myChart;
2673
    var newData = [];
2674
    var usedData = [];
2675
    var labelData = [];
2676
    var ctx = document.getElementById(index === 0 ? 'activeChart' : 'soldChart').getContext('2d');
2677
    var min = findMin(usedBreakdown, newBreakdown);
2678
    var max = findMax(usedBreakdown, newBreakdown);
2679
 
2680
    for (i = min; i < max; i++) {
2681
        labelData.push('<$' + i);
2682
 
2683
        if (usedBreakdown[i] === undefined) {
2684
            usedData.push(0);
2685
        } else {
2686
            usedData.push(usedBreakdown[i]);
2687
        }
2688
 
2689
        if (newBreakdown[i] === undefined) {
2690
            newData.push(0);
2691
        } else {
2692
            newData.push(newBreakdown[i]);
2693
        }
2694
    }
2695
 
2696
    myChart = new Chart(ctx, {
2697
        type: 'bar',
2698
        options: {
2699
            responsive: false,
2700
            maintainAspectRatio: false,
2701
            scales: {
2702
                yAxes: [{
2703
                    ticks: {
2704
                        fixedStepSize: 1
2705
                    }
2706
                }],
2707
            },
2708
        },
2709
        data: {
2710
            labels: labelData,
2711
            datasets: [{
2712
                label: 'Used',
2713
                data: usedData,
2714
                backgroundColor: "rgba(0,102,0,1)"
2715
            }, {
2716
                label: 'New',
2717
                data: newData,
2718
                backgroundColor: "rgba(204,0,0,1)"
2719
            }]
2720
        }
2721
    });
2722
}
2723
 
2724
function findMin(Used, New) {
2725
    var i;
2726
    var minUsed = 0,
2727
        minNew = 0;
2728
    var min = 0;
2729
 
2730
    for (i = 0; i < Used.length; i++) {
2731
        if (Used[i] !== undefined) {
2732
            minUsed = i;
2733
            break;
2734
        }
2735
    }
2736
 
2737
    for (i = 0; i < New.length; i++) {
2738
        if (New[i] !== undefined) {
2739
            minNew = i;
2740
            break;
2741
        }
2742
    }
2743
 
2744
    if (minUsed > 0 && minNew > 0) {
2745
        min = Math.min(minUsed, minNew);
2746
    } else if (minUsed > 0) {
2747
        min = minUsed;
2748
    } else if (minNew > 0) {
2749
        min = minNew;
2750
    }
2751
 
2752
    return min;
2753
}
2754
 
2755
function findMax(Used, New) {
2756
    var max = 0;
2757
 
2758
    if (Used.length >= New.length) {
2759
        max = Used.length;
2760
    } else if (New.length >= Used.length) {
2761
        max = New.length;
2762
    }
2763
 
2764
    return max;
2765
}
2766
 
2767
function listButtonHot(flag) {
2768
    var i;
2769
    var x = [];
2770
 
2771
    x[0] = document.getElementById("list");
2772
    x[1] = document.getElementById("savexml");
2773
 
2774
    for (i = 0; i < 2; i++) {
2775
        if (flag === true) {
2776
            x[i].className = x[i].className.replace(" btn-danger", " btn-success");
2777
        } else {
2778
            x[i].className = x[i].className.replace(" btn-success", " btn-danger");
2779
        }
2780
    }
2781
}
2782
 
2783
function clearStatusWindows() {
2784
    var x = document.getElementById("results");
2785
    x.innerHTML = "";
2786
    x.className = x.className.replace(" w3-show", "");
2787
    x = document.getElementById("prices");
2788
    x.innerHTML = "";
2789
    x.className = x.className.replace(" w3-show", "");
2790
    x = document.getElementById("discogsReleases");
2791
    x.innerHTML = "";
2792
    x.className = x.className.replace(" w3-show", "");
2793
}
2794
 
2795
function pictureLoad(flag) {
2796
    picturesAreLoaded = flag;
2797
}
2798
 
2799
function reformatCdTitle(str) {
2800
    if (str.includes("Various Artists")) {
2801
        return str;
2802
    }
2803
 
2804
    var n = str.lastIndexOf(" by ");
2805
 
2806
    if (n > 0) {
2807
        var title = str.substr(0, n);
2808
        var rest = str.substr(n + 4);
2809
        n = rest.indexOf("(");
2810
        var artist = rest.substr(0, n).trim();
2811
        var info = rest.substr(n);
2812
        return (artist + " - " + title + " " + info);
2813
    }
2814
 
2815
    return str;
2816
}
2817
 
2818
function extractFromTitle() {
2819
    var titleField = document.getElementById("title");
2820
    var n;
2821
 
2822
    titleField.value = titleField.value.trim().replace(/[\u2012\u2013\u2014\u2015]/, '-').replace(/\u200E/, '').replace(/  +/g, ' ');
2823
    printTitleLength();
2824
 
2825
    if (CC == 1) {
2826
        if (titleField.value.indexOf(', EP,') > 0) {
12 - 2827
            $('#cdDuration').selectpicker('val', 'EP');
10 - 2828
        } else if (titleField.value.indexOf('[Maxi-Single]') > 0 || titleField.value.indexOf('[Maxi Single]') > 0) {
12 - 2829
            $('#cdDuration').selectpicker('val', 'Maxi-Single');
10 - 2830
        } else if (titleField.value.indexOf(', Single,') > 0) {
12 - 2831
            $('#cdDuration').selectpicker('val', 'Single');
10 - 2832
        }
2833
        $('#cdDuration').prop('disabled', false).selectpicker('refresh');
2834
 
2835
        if (titleField.value.indexOf(', Digipak,') > 0) {
2836
            document.getElementById("cdDigipak").checked = true;
2837
        } else {
2838
            document.getElementById("cdDigipak").checked = false;
2839
        }
2840
 
2841
        if (titleField.value.includes('Various Artists')) {
2842
            document.getElementById("cdArtist").value = 'Various';
2843
        } else {
2844
            document.getElementById("cdArtist").value = titleField.value.substr(0, titleField.value.indexOf(" - "));
2845
        }
2846
 
2847
        n = titleField.value.indexOf('(CD');
2848
        document.getElementById("cdRecordLabel").value = titleField.value.substr(n).substr(titleField.value.substr(n).lastIndexOf(',') + 2);
2849
        document.getElementById("cdRecordLabel").value = document.getElementById("cdRecordLabel").value.substr(0, document.getElementById("cdRecordLabel").value.lastIndexOf(')'));
2850
 
2851
        n = titleField.value.indexOf('(CD');
2852
        document.getElementById("cdReleaseYear").value = getYear(titleField.value.substr(n));
2853
    }
2854
}
2855
 
2856
function reformatPastedTitle(e) {
2857
    var clipboardData, pastedData;
2858
    var x = document.getElementById("title");
2859
 
2860
    // Stop data actually being pasted
2861
    e.stopPropagation();
2862
    e.preventDefault();
2863
 
2864
    // Get pasted data via clipboard API
2865
    clipboardData = e.clipboardData || window.clipboardData;
2866
    pastedData = clipboardData.getData('Text');
2867
 
2868
    x.value = pastedData.trim().replace(/[\u2012\u2013\u2014\u2015]/, '-').replace(/\u200E/, '');
2869
    printTitleLength();
2870
}
2871
 
2872
function formatTrackList() {
2873
    var i;
2874
    var lines = [];
2875
    var x = document.getElementById("cdTracks");
2876
 
2877
    if (x.value.length < 1) {
2878
        return;
2879
    }
2880
 
2881
    lines = x.value.split('\n');
2882
 
2883
    for (i = 0; i < lines.length; i++) {
2884
        lines[i] = lines[i].trim();
2885
        lines[i] = lines[i].replace(/^\d+ /, '');
2886
        lines[i] = lines[i].replace(/^\d+. /, '');
2887
        lines[i] = lines[i].replace(/^\t/g, '');
2888
        lines[i] = lines[i].replace(/\t(\d+[:.]\d{2})$/, "\[$1\]");
2889
        lines[i] = lines[i].replace(/^\u0096/, '');
2890
        lines[i] = lines[i].replace(/ \t/, ' - ');
2891
        lines[i] = lines[i].replace(/[\u2012\u2013\u2014\u2015]/, '');
2892
        lines[i] = lines[i].replace(/@/g, '*');
2893
        lines[i] = lines[i].replace(/\*/g, '');
2894
    }
2895
 
2896
    x.value = lines.join('\n');
2897
    updateTracklistPreview();
2898
}
2899
 
2900
function splitTradingCardElements() {
2901
    // [Year] [First Last], [Position] at [Club] - [Card Manufacturer] [Series] -P-[Card Number] [Rookie] [S####] [other]
2902
    var elem;
2903
    var stop1 = 0,
2904
        stop2 = 0,
2905
        stop3 = 0;
2906
    var str;
2907
    var title;
2908
    var cardYear = '';
2909
    var cardPlayer = '';
2910
    var cardPosition = '';
2911
    var cardTeam = '';
2912
    var cardManufacturer = '';
2913
    var cardSeries = '';
2914
    var cardNumber = '';
2915
    var isRookie = false;
2916
    var isSerialized = false;
2917
    var isPoA = false;
2918
 
2919
    title = document.getElementById('keyword').value.replace('-P-', '#');
2920
    catalogTitle = title;
2921
    var res = title.split(' ');
2922
    for (elem = 0; elem < res.length; elem++) {
2923
        if (res[elem].endsWith(',')) {
2924
            stop1 = elem;
2925
        }
2926
 
2927
        if (res[elem] == '-') {
2928
            stop2 = elem - 1;
2929
        }
2930
 
2931
        if (res[elem].startsWith('#')) {
2932
            stop3 = elem;
2933
        }
2934
    }
2935
 
2936
    if (!stop1 || !stop2 || !stop3) {
2937
        return;
2938
    }
2939
 
2940
    cardYear = res[0];
2941
    for (elem = 1; elem <= stop1; elem++) {
2942
        cardPlayer += res[elem] + ' ';
2943
    }
2944
    cardPlayer = cardPlayer.substr(0, cardPlayer.length - 2);
2945
 
2946
    cardPosition = res[elem];
2947
    elem += 2;
2948
 
2949
    for (; elem <= stop2; elem++) {
2950
        cardTeam += res[elem] + ' ';
2951
    }
2952
    cardTeam = cardTeam.trim();
2953
    elem++;
2954
 
2955
    cardManufacturer = res[elem];
2956
 
2957
    if (cardManufacturer == "UpperDeck") {
2958
        catalogTitle = catalogTitle.replace("UpperDeck", "Upper Deck");
2959
        cardManufacturer = "Upper Deck";
2960
    } else if (cardManufacturer == "AceAuthentic") {
2961
        catalogTitle = catalogTitle.replace("AceAuthentic", "Ace Authentic");
2962
        cardManufacturer = "Ace Authentic";
2963
    } else if (cardManufacturer == "BeAPlayer") {
2964
        catalogTitle = catalogTitle.replace("BeAPlayer", "Be A Player");
2965
        cardManufacturer = "Be A Player";
2966
    } else if (cardManufacturer == "CollectorsEdge") {
2967
        catalogTitle = catalogTitle.replace("CollectorsEdge", "Collector's Edge");
2968
        cardManufacturer = "Collector's Edge";
2969
    } else if (cardManufacturer == "GoalLine") {
2970
        catalogTitle = catalogTitle.replace("GoalLine", "Goal Line");
2971
        cardManufacturer = "Goal Line";
2972
    } else if (cardManufacturer == "InTheGame") {
2973
        catalogTitle = catalogTitle.replace("InTheGame", "In the Game");
2974
        cardManufacturer = "In the Game";
2975
    } else if (cardManufacturer == "OnyxAuthenticated") {
2976
        catalogTitle = catalogTitle.replace("OnyxAuthenticated", "Onyx Authenticated");
2977
        cardManufacturer = "Onyx Authenticated";
2978
    } else if (cardManufacturer == "PressPass") {
2979
        catalogTitle = catalogTitle.replace("PressPass", "Press Pass");
2980
        cardManufacturer = "Press Pass";
2981
    } else if (cardManufacturer == "ProSet") {
2982
        catalogTitle = catalogTitle.replace("ProSet", "Pro Set");
2983
        cardManufacturer = "Pro Set";
2984
    }
2985
    elem++;
2986
 
2987
    for (; elem < stop3; elem++) {
2988
        cardSeries += res[elem] + ' ';
2989
    }
2990
    cardSeries = cardSeries.trim();
2991
    cardNumber = res[elem];
2992
    elem++;
2993
 
2994
    for (; elem < res.length; elem++) {
2995
        if (res[elem] == "Gameworn") {
2996
            isPoA = true;
2997
        }
2998
 
2999
        if (res[elem] == "Rookie") {
3000
            isRookie = true;
3001
        }
3002
 
3003
        if (res[elem].startsWith("S") && isNumeric(res[elem].substr(1))) {
3004
            catalogTitle = catalogTitle.replace(res[elem], "/" + res[elem].substr(1));
3005
            isSerialized = true;
3006
        }
3007
    }
3008
 
3009
    str = '<h3>' + title + '</h3>';
3010
    str += '<p>';
3011
    str += 'Season: ' + cardYear + '<br/>';
3012
    str += 'Player: ' + cardPlayer + '<br/>';
3013
    str += 'Position: ' + cardPosition + '<br/>';
3014
    str += 'Team: ' + cardTeam + '<br/>';
3015
    str += 'Card Manufacturer: ' + cardManufacturer + '<br/>';
3016
    if (cardSeries.length > 0) {
3017
        str += 'Card Series: ' + cardSeries + '<br/>';
3018
    }
3019
    str += 'Card Number: ' + cardNumber + '<br/>';
3020
    if (isRookie) {
3021
        str += 'Rookie<br/>';
3022
    }
3023
    if (isSerialized) {
3024
        str += 'Serialized<br/>';
3025
    }
3026
    if (isPoA) {
3027
        str += 'Piece of Authentic<br/>';
3028
    }
3029
    str += '</p>';
3030
 
3031
    var x = document.getElementById("productinfo");
3032
    x.innerHTML = str;
3033
 
3034
    document.getElementById("tcPlayer").value = cardPlayer;
3035
    document.getElementById("tcPosition").value = cardPosition;
3036
    document.getElementById("tcTeam").value = cardTeam;
3037
    document.getElementById("tcSeason").value = cardYear;
3038
    document.getElementById("tcManufacturer").value = cardManufacturer;
3039
    document.getElementById("tcNumber").value = cardNumber;
3040
    document.getElementById("tcSeries").value = cardSeries;
3041
    document.getElementById("tcRookie").checked = false;
3042
    document.getElementById("tcPoA").checked = false;
3043
    document.getElementById("tcSerial").checked = false;
3044
 
3045
    if (isRookie) {
3046
        document.getElementById("tcRookie").checked = true;
3047
    }
3048
 
3049
    if (isPoA) {
3050
        document.getElementById("tcPoA").checked = true;
3051
    }
3052
 
3053
    if (isSerialized) {
3054
        document.getElementById("tcSerial").checked = true;
3055
    }
3056
 
3057
    var currentCategory = document.getElementById("category").value;
3058
    if (currentCategory != "213" && currentCategory != "214" && currentCategory != "215" && currentCategory != "216") {
12 - 3059
        $('#category').selectpicker('val', "");
3060
        $('#category').selectpicker('refresh');
10 - 3061
    }
3062
 
3063
    x = document.getElementById("tradingCardDetails");
3064
    if (x.className.indexOf("w3-show") == -1) {
3065
        x.className += " w3-show";
3066
    }
3067
}
3068
 
3069
function generateDescCore() {
3070
    DescCore = '';
3071
 
3072
    if (CC === 0) {
3073
        DescCore = '<p>';
3074
        DescCore += 'Format: ' + document.getElementById("bookFormat").value + '<br/>';
3075
        if (document.getElementById("bookAuthor").value.length > 0) {
3076
            DescCore += 'Author: ' + document.getElementById("bookAuthor").value.toString().replace(/,/g, ', ') + '<br/>';
3077
        }
3078
        if (document.getElementById("bookPublicationYear").value.length > 0) {
3079
            DescCore += 'Publication Year: ' + document.getElementById("bookPublicationYear").value + '<br/>';
3080
        }
3081
        if (document.getElementById("bookSubject").value.length > 0) {
3082
            DescCore += 'Subject: ' + document.getElementById("bookSubject").value + '<br/>';
3083
        }
3084
        if (document.getElementById("bookLanguage").value.length > 0) {
3085
            DescCore += 'Language: ' + document.getElementById("bookLanguage").value + '<br/>';
3086
        }
3087
        if (document.getElementById("bookCountry").value.length > 0) {
3088
            DescCore += 'Country: ' + document.getElementById("bookCountry").value + '<br/>';
3089
        }
3090
        if (document.getElementById("bookDustJacket").checked) {
3091
            DescCore += 'Dust Jacket<br/>';
3092
        }
3093
        if (document.getElementById("bookIllustrated").checked) {
3094
            DescCore += 'Illustrated<br/>';
3095
        }
3096
        if (document.getElementById("bookLargePrint").checked) {
3097
            DescCore += 'Large Print<br/>';
3098
        }
3099
        if (document.getElementById("bookSigned").checked) {
3100
            DescCore += 'Signed<br/>';
3101
        }
3102
        DescCore += '</p>';
3103
    } else if (CC == 1) {
3104
        DescCore = generateTracklist();
3105
    } else if (CC == 2) {
3106
        DescCore = '<p>';
3107
        DescCore += 'Format: ' + document.getElementById("dvdFormat").value + '<br/>';
3108
        if (document.getElementById("dvdActor").value.length > 0) {
3109
            DescCore += 'Actors: ' + document.getElementById("dvdActor").value.toString().replace(/,/g, ', ') + '<br/>';
3110
        }
3111
        if (document.getElementById("dvdLeadingRole").value.length > 0) {
3112
            DescCore += 'Leading Role: ' + document.getElementById("dvdLeadingRole").value.toString().replace(/,/g, ', ') + '<br/>';
3113
        }
3114
        if (document.getElementById("dvdDirector").value.length > 0) {
3115
            DescCore += 'Director: ' + document.getElementById("dvdDirector").value.toString().replace(/,/g, ', ') + '<br/>';
3116
        }
3117
        if (document.getElementById("dvdDVDEditionYear").value.length > 0) {
3118
            DescCore += 'DVD Edition Year: ' + document.getElementById("dvdDVDEditionYear").value + '<br/>';
3119
        }
3120
        if (document.getElementById("dvdReleaseYear").value.length > 0) {
3121
            DescCore += 'Movie Release Year: ' + document.getElementById("dvdReleaseYear").value + '<br/>';
3122
        }
3123
        if (document.getElementById("dvdGenre").value.length > 1) {
3124
            DescCore += 'Genre: ' + document.getElementById("dvdGenre").value + '<br/>';
3125
        }
3126
        if (document.getElementById("dvdRating").value.length > 1) {
3127
            DescCore += 'Rating: ' + document.getElementById("dvdRating").value + '<br/>';
3128
        }
3129
        if (document.getElementById("dvdRegionCode").value.length > 1) {
3130
            DescCore += 'Region Code: ' + document.getElementById("dvdRegionCode").value + '<br/>';
3131
        }
3132
        if (document.getElementById("dvdSeason").value.length > 0 && document.getElementById("dvdSeason").value != ' ') {
3133
            DescCore += 'Season: ' + document.getElementById("dvdSeason").value + '<br/>';
3134
        }
3135
        if (document.getElementById("dvdCountry").value.length > 0) {
3136
            DescCore += 'Country/Region of Manufacture: ' + document.getElementById("dvdCountry").value + '<br/>';
3137
        }
3138
        if (document.getElementById("dvd3D").checked) {
3139
            DescCore += '3D<br/>';
3140
        }
3141
        if (document.getElementById("dvdAnniversaryEdition").checked) {
3142
            DescCore += 'Anniversary Edition<br/>';
3143
        }
3144
        if (document.getElementById("dvdBoxSet").checked) {
3145
            DescCore += 'Box Set<br/>';
3146
        }
3147
        if (document.getElementById("dvdCollectorsEdition").checked) {
3148
            DescCore += 'Collector\'s Edition<br/>';
3149
        }
3150
        if (document.getElementById("dvdDeluxeEdition").checked) {
3151
            DescCore += 'Deluxe Edition<br/>';
3152
        }
3153
        if (document.getElementById("dvdDirectorsCut").checked) {
3154
            DescCore += 'Director\'s Cut<br/>';
3155
        }
3156
        if (document.getElementById("dvdExtendedEdition").checked) {
3157
            DescCore += 'Extended Edition<br/>';
3158
        }
3159
        if (document.getElementById("dvdFullScreen").checked) {
3160
            DescCore += 'Full Screen<br/>';
3161
        }
3162
        if (document.getElementById("dvdLimitedEdition").checked) {
3163
            DescCore += 'Limited Edition<br/>';
3164
        }
3165
        if (document.getElementById("dvdPromo").checked) {
3166
            DescCore += 'Promo<br/>';
3167
        }
3168
        if (document.getElementById("dvdSignatureCollection").checked) {
3169
            DescCore += 'Signature Collection<br/>';
3170
        }
3171
        if (document.getElementById("dvdSpecialEdition").checked) {
3172
            DescCore += 'Special Edition<br/>';
3173
        }
3174
        if (document.getElementById("dvdSteelbook").checked) {
3175
            DescCore += 'Steelbook<br/>';
3176
        }
3177
        if (document.getElementById("dvdUnratedEdition").checked) {
3178
            DescCore += 'Unrated Edition<br/>';
3179
        }
3180
        if (document.getElementById("dvdWidescreen").checked) {
3181
            DescCore += 'Widescreen<br/>';
3182
        }
3183
        DescCore += '</p>';
3184
    } else if (CC == 3) {
3185
        DescCore = '<p>';
3186
        DescCore += 'Season: ' + document.getElementById("tcSeason").value + '<br/>';
3187
        DescCore += 'Player: ' + document.getElementById("tcPlayer").value + '<br/>';
3188
        DescCore += 'Position: ' + document.getElementById("tcPosition").value + '<br/>';
3189
        DescCore += 'Team: ' + document.getElementById("tcTeam").value + '<br/>';
3190
        DescCore += 'Card Manufacturer: ' + document.getElementById("tcManufacturer").value + '<br/>';
3191
        if (document.getElementById("tcSeries").value.length > 0) {
3192
            DescCore += 'Card Series: ' + document.getElementById("tcSeries").value + '<br/>';
3193
        }
3194
        DescCore += 'Card Number: ' + document.getElementById("tcNumber").value + '<br/>';
3195
        if (document.getElementById("tcRookie").checked) {
3196
            DescCore += 'Rookie<br/>';
3197
        }
3198
        if (document.getElementById("tcSerial").checked) {
3199
            DescCore += 'Serialized<br/>';
3200
        }
3201
        if (document.getElementById("tcPoA").checked) {
3202
            DescCore += 'Piece of Authentic<br/>';
3203
        }
3204
        DescCore += '</p>';
3205
    }
3206
}
3207
 
3208
function generateTracklist() {
3209
    var str = '';
3210
    var listType = 'ol';
3211
 
3212
    if (document.getElementById("cdTracks").value.length > 0) {
3213
        if (document.getElementById("cdUnorderedTrackList").checked) {
3214
            listType = 'ul';
3215
        }
3216
 
3217
        str += '<p>Tracklist:</p><' + listType + ' class="w3-' + listType + '">';
3218
        var lines = document.getElementById("cdTracks").value.split('\n');
3219
        for (var i = 0; i < lines.length; i++) {
3220
            str += '<li>' + lines[i] + '</li>';
3221
        }
3222
        str += '</' + listType + '>';
3223
    }
3224
 
3225
    return (str);
3226
}
3227
 
3228
function updateTracklistPreview() {
3229
    document.getElementById("tracklistPreview").innerHTML = generateTracklist();
3230
}
3231
 
3232
function generateItemSpecifics(xw) {
3233
    xw.writeStartElement('ItemSpecifics');
3234
 
3235
    if (CC === 0) {
3236
        xw.writeStartElement('NameValueList');
3237
        xw.writeElementString('Name', 'Author');
3238
        xw.writeElementString('Value', escapeXml(document.getElementById("bookAuthor").value));
3239
        xw.writeEndElement(); /* NameValueList */
3240
        xw.writeStartElement('NameValueList');
3241
        xw.writeElementString('Name', 'Format');
3242
        xw.writeElementString('Value', escapeXml(document.getElementById("bookFormat").value));
3243
        xw.writeEndElement(); /* NameValueList */
3244
        xw.writeStartElement('NameValueList');
3245
        xw.writeElementString('Name', 'Publication Year');
3246
        xw.writeElementString('Value', escapeXml(document.getElementById("bookPublicationYear").value));
3247
        xw.writeEndElement(); /* NameValueList */
3248
        xw.writeStartElement('NameValueList');
3249
        xw.writeElementString('Name', 'Subject');
3250
        xw.writeElementString('Value', escapeXml(document.getElementById("bookSubject").value));
3251
        xw.writeEndElement(); /* NameValueList */
3252
        xw.writeStartElement('NameValueList');
3253
        xw.writeElementString('Name', 'Language');
3254
        xw.writeElementString('Value', escapeXml(document.getElementById("bookLanguage").value));
3255
        xw.writeEndElement(); /* NameValueList */
3256
        xw.writeStartElement('NameValueList');
3257
        xw.writeElementString('Name', 'Country/Region of Manufacture');
3258
        xw.writeElementString('Value', escapeXml(document.getElementById("bookCountry").value));
3259
        xw.writeEndElement(); /* NameValueList */
3260
 
3261
        if (document.getElementById("bookDustJacket").checked ||
3262
            document.getElementById("bookIllustrated").checked ||
3263
            document.getElementById("bookLargePrint").checked ||
3264
            document.getElementById("bookSigned").checked) {
3265
            xw.writeStartElement('NameValueList');
3266
            xw.writeElementString('Name', 'Special Attributes');
3267
            itemSpecificCheckbox(xw, "bookDustJacket", 'Dust Jacket');
3268
            itemSpecificCheckbox(xw, "bookIllustrated", 'Illustrated');
3269
            itemSpecificCheckbox(xw, "bookLargePrint", 'Large Print');
3270
            itemSpecificCheckbox(xw, "bookSigned", 'Signed');
3271
            xw.writeEndElement(); /* NameValueList */
3272
        }
3273
    } else if (CC == 1) {
3274
        xw.writeStartElement('NameValueList');
3275
        xw.writeElementString('Name', 'Genre');
3276
        xw.writeElementString('Value', escapeXml(document.getElementById("cdGenre").value));
3277
        xw.writeEndElement(); /* NameValueList */
3278
        xw.writeStartElement('NameValueList');
3279
        xw.writeElementString('Name', 'Duration');
3280
        xw.writeElementString('Value', escapeXml(document.getElementById("cdDuration").value));
3281
        xw.writeEndElement(); /* NameValueList */
3282
        xw.writeStartElement('NameValueList');
3283
        xw.writeElementString('Name', 'Record Label');
3284
        xw.writeElementString('Value', escapeXml(document.getElementById("cdRecordLabel").value));
3285
        xw.writeEndElement(); /* NameValueList */
3286
        xw.writeStartElement('NameValueList');
3287
        xw.writeElementString('Name', 'Release Year');
3288
        xw.writeElementString('Value', escapeXml(document.getElementById("cdReleaseYear").value));
3289
        xw.writeEndElement(); /* NameValueList */
3290
        xw.writeStartElement('NameValueList');
3291
        xw.writeElementString('Name', 'Artist');
3292
        xw.writeElementString('Value', escapeXml(document.getElementById("cdArtist").value));
3293
        xw.writeEndElement(); /* NameValueList */
3294
        xw.writeStartElement('NameValueList');
3295
        xw.writeElementString('Name', 'Title');
3296
        xw.writeElementString('Value', escapeXml(document.getElementById("cdTitle").value));
3297
        xw.writeEndElement(); /* NameValueList */
3298
        xw.writeStartElement('NameValueList');
3299
        xw.writeElementString('Name', 'Country/Region of Manufacture');
3300
        xw.writeElementString('Value', escapeXml(document.getElementById("cdCountry").value));
3301
        xw.writeEndElement(); /* NameValueList */
3302
 
3303
        if (document.getElementById("cdCompilation").checked ||
3304
            document.getElementById("cdDigipak").checked ||
3305
            document.getElementById("cdDualDisc").checked ||
3306
            document.getElementById("cdEnhanced").checked ||
3307
            document.getElementById("cdHDCD").checked) {
3308
            xw.writeStartElement('NameValueList');
3309
            xw.writeElementString('Name', 'Special Attributes');
3310
            itemSpecificCheckbox(xw, "cdCompilation", 'Compilation');
3311
            itemSpecificCheckbox(xw, "cdDigipak", 'Digipak');
3312
            itemSpecificCheckbox(xw, "cdDualDisc", 'DualDisc');
3313
            itemSpecificCheckbox(xw, "cdEnhanced", 'Enhanced');
3314
            itemSpecificCheckbox(xw, "cdHDCD", 'HDCD');
3315
            xw.writeEndElement(); /* NameValueList */
3316
        }
3317
 
3318
        if (document.getElementById("cdLiveRecording").checked ||
3319
            document.getElementById("cdPromo").checked ||
3320
            document.getElementById("cdReissue").checked ||
3321
            document.getElementById("cdRemastered").checked ||
3322
            document.getElementById("cdGreatestHits").checked) {
3323
            xw.writeStartElement('NameValueList');
3324
            xw.writeElementString('Name', 'Edition');
3325
            itemSpecificCheckbox(xw, "cdCompilation", 'Compilation');
3326
            itemSpecificCheckbox(xw, "cdDigipak", 'Digipak');
3327
            itemSpecificCheckbox(xw, "cdDualDisc", 'DualDisc');
3328
            itemSpecificCheckbox(xw, "cdEnhanced", 'Enhanced');
3329
            itemSpecificCheckbox(xw, "cdLiveRecording", 'Live Recording');
3330
            itemSpecificCheckbox(xw, "cdPromo", 'Promo');
3331
            itemSpecificCheckbox(xw, "cdReissue", 'Reissue');
3332
            itemSpecificCheckbox(xw, "cdRemastered", 'Remastered');
3333
            itemSpecificCheckbox(xw, "cdHDCD", 'HDCD');
3334
            itemSpecificCheckbox(xw, "cdGreatestHits", 'Greatest Hits');
3335
            xw.writeEndElement(); /* NameValueList */
3336
        }
3337
    } else if (CC == 2) {
3338
        xw.writeStartElement('NameValueList');
3339
        xw.writeElementString('Name', 'Format');
3340
        xw.writeElementString('Value', escapeXml(document.getElementById("dvdFormat").value));
3341
        xw.writeEndElement(); /* NameValueList */
3342
        xw.writeStartElement('NameValueList');
3343
        xw.writeElementString('Name', 'Movie/TV Title');
3344
        xw.writeElementString('Value', escapeXml(document.getElementById("dvdTitle").value));
3345
        xw.writeEndElement(); /* NameValueList */
3346
        xw.writeStartElement('NameValueList');
3347
        xw.writeElementString('Name', 'Actor');
3348
        xw.writeElementString('Value', escapeXml(document.getElementById("dvdActor").value));
3349
        xw.writeEndElement(); /* NameValueList */
3350
        xw.writeStartElement('NameValueList');
3351
        xw.writeElementString('Name', 'Leading Role');
3352
        xw.writeElementString('Value', escapeXml(document.getElementById("dvdLeadingRole").value));
3353
        xw.writeEndElement(); /* NameValueList */
3354
        xw.writeStartElement('NameValueList');
3355
        xw.writeElementString('Name', 'Release Year');
3356
        xw.writeElementString('Value', escapeXml(document.getElementById("dvdReleaseYear").value));
3357
        xw.writeEndElement(); /* NameValueList */
3358
        xw.writeStartElement('NameValueList');
3359
        xw.writeElementString('Name', 'DVD Edition Year');
3360
        xw.writeElementString('Value', escapeXml(document.getElementById("dvdDVDEditionYear").value));
3361
        xw.writeEndElement(); /* NameValueList */
3362
        xw.writeStartElement('NameValueList');
3363
        xw.writeElementString('Name', 'Director');
3364
        xw.writeElementString('Value', escapeXml(document.getElementById("dvdDirector").value));
3365
        xw.writeEndElement(); /* NameValueList */
3366
        xw.writeStartElement('NameValueList');
3367
        xw.writeElementString('Name', 'Genre');
3368
        xw.writeElementString('Value', escapeXml(document.getElementById("dvdGenre").value));
3369
        xw.writeEndElement(); /* NameValueList */
3370
        xw.writeStartElement('NameValueList');
3371
        xw.writeElementString('Name', 'Rating');
3372
        xw.writeElementString('Value', escapeXml(document.getElementById("dvdRating").value));
3373
        xw.writeEndElement(); /* NameValueList */
3374
        xw.writeStartElement('NameValueList');
3375
        xw.writeElementString('Name', 'Region Code');
3376
        xw.writeElementString('Value', escapeXml(document.getElementById("dvdRegionCode").value));
3377
        xw.writeEndElement(); /* NameValueList */
3378
 
3379
        if (document.getElementById("dvd3D").checked ||
3380
            document.getElementById("dvdAnniversaryEdition").checked ||
3381
            document.getElementById("dvdBoxSet").checked ||
3382
            document.getElementById("dvdCollectorsEdition").checked ||
3383
            document.getElementById("dvdDeluxeEdition").checked ||
3384
            document.getElementById("dvdDirectorsCut").checked ||
3385
            document.getElementById("dvdExtendedEdition").checked ||
3386
            document.getElementById("dvdFullScreen").checked ||
3387
            document.getElementById("dvdLimitedEdition").checked ||
3388
            document.getElementById("dvdPromo").checked ||
3389
            document.getElementById("dvdSignatureCollection").checked ||
3390
            document.getElementById("dvdSpecialEdition").checked ||
3391
            document.getElementById("dvdSteelbook").checked ||
3392
            document.getElementById("dvdUnratedEdition").checked ||
3393
            document.getElementById("dvdWidescreen").checked) {
3394
            xw.writeStartElement('NameValueList');
3395
            xw.writeElementString('Name', 'Edition');
3396
            itemSpecificCheckbox(xw, "dvd3D", '3D');
3397
            itemSpecificCheckbox(xw, "dvdAnniversaryEdition", 'Anniversary Edition');
3398
            itemSpecificCheckbox(xw, "dvdBoxSet", 'Box Set');
3399
            itemSpecificCheckbox(xw, "dvdCollectorsEdition", 'Collector&apos;s Edition');
3400
            itemSpecificCheckbox(xw, "dvdDeluxeEdition", 'Deluxe Edition');
3401
            itemSpecificCheckbox(xw, "dvdDirectorsCut", 'Director&apos;s Cut');
3402
            itemSpecificCheckbox(xw, "dvdExtendedEdition", 'Extended Edition');
3403
            itemSpecificCheckbox(xw, "dvdFullScreen", 'Full Screen');
3404
            itemSpecificCheckbox(xw, "dvdLimitedEdition", 'Limited Edition');
3405
            itemSpecificCheckbox(xw, "dvdPromo", 'Promo');
3406
            itemSpecificCheckbox(xw, "dvdSignatureCollection", 'Signature Collection');
3407
            itemSpecificCheckbox(xw, "dvdSpecialEdition", 'Special Edition');
3408
            itemSpecificCheckbox(xw, "dvdSteelbook", 'Steelbook');
3409
            itemSpecificCheckbox(xw, "dvdUnratedEdition", 'UnratedEdition');
3410
            itemSpecificCheckbox(xw, "dvdWidescreen", 'Widescreen');
3411
            xw.writeEndElement(); /* NameValueList */
3412
        }
3413
 
3414
        xw.writeStartElement('NameValueList');
3415
        xw.writeElementString('Name', 'Former Rental');
3416
        xw.writeElementString('Value', escapeXml(document.getElementById("dvdRental").value));
3417
        xw.writeEndElement(); /* NameValueList */
3418
        xw.writeStartElement('NameValueList');
3419
        xw.writeElementString('Name', 'Season');
3420
        xw.writeElementString('Value', escapeXml(document.getElementById("dvdSeason").value));
3421
        xw.writeEndElement(); /* NameValueList */
3422
        xw.writeStartElement('NameValueList');
3423
        xw.writeElementString('Name', 'Country/Region of Manufacture');
3424
        xw.writeElementString('Value', escapeXml(document.getElementById("dvdCountry").value));
3425
        xw.writeEndElement(); /* NameValueList */
3426
    } else if (CC == 3) {
3427
        xw.writeStartElement('NameValueList');
3428
        xw.writeElementString('Name', 'Card Manufacturer');
3429
        xw.writeElementString('Value', escapeXml(document.getElementById("tcManufacturer").value));
3430
        xw.writeEndElement(); /* NameValueList */
3431
 
3432
        if (document.getElementById("tcRookie").checked ||
3433
            document.getElementById("tcSerial").checked ||
3434
            document.getElementById("tcPoA").checked) {
3435
            xw.writeStartElement('NameValueList');
3436
            xw.writeElementString('Name', 'Card Attributes');
3437
            if (document.getElementById("tcRookie").checked) {
3438
                itemSpecificCheckbox(xw, "tcRookie", 'Rookie');
3439
            }
3440
            if (document.getElementById("tcSerial").checked) {
3441
                itemSpecificCheckbox(xw, "tcSerial", 'Serial Numbered');
3442
            }
3443
            if (document.getElementById("tcPoA").checked) {
3444
                itemSpecificCheckbox(xw, "tcPoA", 'Piece of Authentic');
3445
            }
3446
            xw.writeEndElement(); /* NameValueList */
3447
        }
3448
 
3449
        xw.writeStartElement('NameValueList');
3450
        xw.writeElementString('Name', 'Product');
3451
        xw.writeElementString('Value', 'Single');
3452
        xw.writeEndElement(); /* NameValueList */
3453
        xw.writeStartElement('NameValueList');
3454
        xw.writeElementString('Name', 'Professional Grader');
3455
        xw.writeElementString('Value', 'Not Professionally Graded');
3456
        xw.writeEndElement(); /* NameValueList */
3457
        xw.writeStartElement('NameValueList');
3458
        xw.writeElementString('Name', 'Grade');
3459
        xw.writeElementString('Value', 'Ungraded');
3460
        xw.writeEndElement(); /* NameValueList */
3461
        xw.writeStartElement('NameValueList');
3462
        xw.writeElementString('Name', 'Original/Reprint');
3463
        xw.writeElementString('Value', 'Original');
3464
        xw.writeEndElement(); /* NameValueList */
3465
        //		xw.writeStartElement('NameValueList');
3466
        //		xw.writeElementString('Name', 'Autograph Authentication');
3467
        //		xw.writeElementString('Value', 'Not Authenticated');
3468
        //		xw.writeEndElement(); /* NameValueList */
3469
        //		xw.writeStartElement('NameValueList');
3470
        //		xw.writeElementString('Name', 'Autograph Format');
3471
        //		xw.writeElementString('Value', 'Not Autographed');
3472
        //		xw.writeEndElement(); /* NameValueList */
3473
        xw.writeStartElement('NameValueList');
3474
        xw.writeElementString('Name', 'Modified Item');
3475
        xw.writeElementString('Value', 'No');
3476
        xw.writeEndElement(); /* NameValueList */
3477
        xw.writeStartElement('NameValueList');
3478
        xw.writeElementString('Name', 'Player');
3479
        xw.writeElementString('Value', escapeXml(document.getElementById("tcPlayer").value));
3480
        xw.writeEndElement(); /* NameValueList */
3481
        xw.writeStartElement('NameValueList');
3482
        xw.writeElementString('Name', 'Team');
3483
        xw.writeElementString('Value', escapeXml(document.getElementById("tcTeam").value));
3484
        xw.writeEndElement(); /* NameValueList */
3485
        xw.writeStartElement('NameValueList');
3486
        xw.writeElementString('Name', 'Season');
3487
        xw.writeElementString('Value', escapeXml(document.getElementById("tcSeason").value));
3488
        xw.writeEndElement(); /* NameValueList */
3489
        xw.writeStartElement('NameValueList');
3490
        xw.writeElementString('Name', 'Year');
3491
        xw.writeElementString('Value', escapeXml(document.getElementById("tcSeason").value));
3492
        xw.writeEndElement(); /* NameValueList */
3493
        xw.writeStartElement('NameValueList');
3494
        xw.writeElementString('Name', 'Era');
3495
        if (category == '213') {
3496
            xw.writeElementString('Value', 'Modern (1981-Now)');
3497
        } else {
3498
            xw.writeElementString('Value', 'Modern (1970-Now)');
3499
        }
3500
        xw.writeEndElement(); /* NameValueList */
3501
        xw.writeStartElement('NameValueList');
3502
        xw.writeElementString('Name', 'League');
3503
        if (category == "215") {
3504
            xw.writeElementString('Value', 'NFL');
3505
        } else if (category == "213") {
3506
            xw.writeElementString('Value', 'Major League');
3507
        } else if (category == "214") {
3508
            xw.writeElementString('Value', 'NBA');
3509
        } else if (category == "216") {
3510
            xw.writeElementString('Value', 'NHL');
3511
        } else {
3512
            xw.writeElementString('Value', '');
3513
        }
3514
        xw.writeEndElement(); /* NameValueList */
3515
        xw.writeStartElement('NameValueList');
3516
        xw.writeElementString('Name', 'Card Number');
3517
        xw.writeElementString('Value', escapeXml(document.getElementById("tcNumber").value));
3518
        xw.writeEndElement(); /* NameValueList */
3519
        xw.writeStartElement('NameValueList');
3520
        xw.writeElementString('Name', 'Series');
3521
        xw.writeElementString('Value', escapeXml(document.getElementById("tcSeries").value));
3522
        xw.writeEndElement(); /* NameValueList */
3523
        xw.writeStartElement('NameValueList');
3524
        xw.writeElementString('Name', 'Country/Region of Manufacture');
3525
        xw.writeElementString('Value', 'United States');
3526
        xw.writeEndElement(); /* NameValueList */
3527
    }
3528
 
3529
    xw.writeEndElement(); /* ItemSpecifics */
3530
}
3531
 
3532
function itemSpecificCheckbox(xw, id, val) {
3533
    if (document.getElementById(id).checked) {
3534
        xw.writeElementString('Value', val);
3535
    }
3536
}
3537
 
3538
function _cb_findDuplicateListing(root) {
3539
    var x;
3540
    var response = root.findItemsAdvancedResponse[0];
3541
    var ack = response.ack;
3542
    if (ack != 'Success') {
3543
        x = document.getElementById("productinfo").innerHTML += 'Duplicate Check Failed';
3544
 
3545
        if (ack == 'Failure' || ack == 'PartialFailure') {
3546
            return;
3547
        }
3548
    }
3549
 
3550
    var items = response.searchResult[0].item || [];
3551
 
3552
    if (Number(response.paginationOutput[0].totalEntries) > 0) {
17 - 3553
        document.getElementById("productinfoDuplicate").innerHTML += '<span class="bg-danger"><strong>Duplicate, see Item Id <a href="https://www.ebay.com/itm/' + items[0].itemId + '" target="_blank">' + items[0].itemId + '</a></strong></span>';
10 - 3554
        isDuplicate = true;
3555
    }
3556
}
3557
 
3558
function findDuplicateListing() {
3559
    var keyword = document.getElementById('keyword').value;
3560
 
3561
    // Construct the request
3562
    url = configeBayFinding + "?";
3563
    url += "OPERATION-NAME=findItemsAdvanced";
3564
    url += "&SERVICE-VERSION=" + configeBayFindingVersion;
3565
    url += "&SECURITY-APPNAME=" + configAppid;
3566
    url += "&GLOBAL-ID=EBAY-US";
3567
    url += "&RESPONSE-DATA-FORMAT=JSON";
3568
    url += "&REST-PAYLOAD";
3569
    url += "&keywords=";
3570
    url += encodeURIComponent(keyword.trim().replace(/ /g, "+"));
3571
    url += "&paginationInput.entriesPerPage=1";
3572
    url += "&paginationInput.pageNumber=1";
3573
    url += "&itemFilter(0).name=Seller";
3574
    url += "&itemFilter(0).value=";
3575
    url += configeBaySellerName;
3576
    url += "&outputSelector=SellerInfo";
3577
 
3578
    // Submit the request
3579
    var xhttp = new XMLHttpRequest();
3580
 
3581
    xhttp.onreadystatechange = function() {
3582
        if (this.readyState == 4) {
3583
            _cb_findDuplicateListing(JSON.parse(this.responseText));
3584
        }
3585
    };
3586
 
3587
    xhttp.open("GET", configProxyUrl, true);
3588
    xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
3589
    xhttp.send();
3590
 
3591
    return false;
3592
}
3593
 
3594
function _cb_findPotentialDuplicateListing(root) {
3595
    var x;
3596
    var response = root.findCompletedItemsResponse[0];
3597
    var ack = response.ack;
3598
    if (ack != 'Success') {
17 - 3599
        x = document.getElementById("productinfoDuplicate").innerHTML += '<span class="bg-danger"><strong>Duplicate Check Failed</strong></span>';
10 - 3600
 
3601
        if (ack == 'Failure' || ack == 'PartialFailure') {
3602
            return;
3603
        }
3604
    }
3605
 
3606
    var items = response.searchResult[0].item || [];
3607
 
3608
    if (Number(response.paginationOutput[0].totalEntries) > 0) {
17 - 3609
        document.getElementById("productinfoDuplicate").innerHTML += '<span class="bg-warning"><strong>Potential Duplicate, see Item Id <a href="https://www.ebay.com/itm/' + items[0].itemId + '" target="_blank">' + items[0].itemId + '</a></strong></span>';
10 - 3610
    }
3611
}
3612
 
3613
function findPotentialDuplicateListing() {
3614
    var keyword = document.getElementById('keyword').value;
3615
 
3616
    // Construct the request
3617
    url = configeBayFinding + "?";
3618
    url += "OPERATION-NAME=findCompletedItems";
3619
    url += "&SERVICE-VERSION=" + configeBayFindingVersion;
3620
    url += "&SECURITY-APPNAME=" + configAppid;
3621
    url += "&GLOBAL-ID=EBAY-US";
3622
    url += "&RESPONSE-DATA-FORMAT=JSON";
3623
    url += "&REST-PAYLOAD";
3624
    url += "&keywords=";
3625
    url += encodeURIComponent(keyword.trim().replace(/ /g, "+"));
3626
    url += "&paginationInput.entriesPerPage=1";
3627
    url += "&paginationInput.pageNumber=1";
3628
    url += "&itemFilter(0).name=Seller";
3629
    url += "&itemFilter(0).value=";
3630
    url += configeBaySellerName;
3631
    url += "&outputSelector=SellerInfo";
3632
 
3633
    var xhttp = new XMLHttpRequest();
3634
 
3635
    xhttp.onreadystatechange = function() {
3636
        if (this.readyState == 4) {
3637
            _cb_findPotentialDuplicateListing(JSON.parse(this.responseText));
3638
        }
3639
    };
3640
 
3641
    xhttp.open("GET", configProxyUrl, true);
3642
    xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
3643
    xhttp.send();
3644
 
3645
    return false;
3646
}
3647
 
3648
function findShopifyDuplicateListing() { // Barcode Search
3649
    var handle;
3650
    var xhttp = new XMLHttpRequest();
3651
    xhttp.onreadystatechange = function() {
3652
        if (this.readyState == 4 && this.status == 200) {
3653
            //window.alert(this.responseText);
3654
            var json = JSON.parse(this.responseText);
3655
            if (json.products[0] !== undefined) {
3656
			    var sku = getJsonValue(json.products[0].variants[0].sku);
17 - 3657
                document.getElementById("productinfoDuplicate").innerHTML += '<span class="bg-warning"><strong>Potential Duplicate, see Shopify Item Id <a href="https://munatrading.com/products/b' + handle + '" target="_blank">' + handle + '</a> (SKU=' + sku + ')</strong></span>';
10 - 3658
            }
3659
        }
3660
    };
3661
 
3662
    handle = parseInt(document.getElementById('keyword').value, 10);
3663
 
3664
    xhttp.open("GET", configProxyUrl, true);
3665
	xhttp.setRequestHeader("X-Proxy-Url", encodeURI(configShopifyUrl + configShopifyProductsUrl + '?handle=b' + handle + '&fields=id,variants'));
3666
    xhttp.send();
3667
}
3668
 
3669
function connected() {
3670
    var x;
3671
 
3672
    eBayAuthTokenFlag = true;
3673
    if (!document.getElementById("connected").innerHTML.endsWith("(Connected)")) {
3674
        document.getElementById("connected").innerHTML += " (Connected)";
3675
    }
3676
 
3677
    x = document.getElementById("verify");
3678
    x.className = x.className.replace(" btn-danger", " btn-success");
3679
 
3680
    x = document.getElementById("login");
3681
    x.className = x.className.replace(" w3-show", "");
3682
 
3683
    x = document.getElementById("results");
3684
    x.innerHTML = "";
3685
    x.className = x.className.replace(" w3-show", "");
3686
}
3687
 
3688
function confirmUnload() {
3689
    return "Do you really want to leave the quick listing tool?";
3690
}
3691
 
3692
function uploadSiteHostedPictures() {
3693
    imagesToUpload = 0;
3694
    imageUploadError = false;
3695
 
3696
    ++imagesToUpload;
3697
    uploadSiteHostedPicture('image1', 0);
3698
    ++imagesToUpload;
3699
    uploadSiteHostedPicture('image2', 1);
3700
    for (var imageNumber = 0; imageNumber < maxAdditionalImages; imageNumber++) {
12 - 3701
        if (document.getElementById("image" + (imageNumber + 3) + "anchor").className.includes(" visible")) {
10 - 3702
            ++imagesToUpload;
3703
            uploadSiteHostedPicture('image' + (imageNumber + 3), (imageNumber + 2));
3704
        }
3705
    }
3706
 
3707
    function checkImagesToUpload() {
3708
        if (imagesToUpload > 0) {
3709
            window.setTimeout(checkImagesToUpload, 100); // wait 100 milliseconds
3710
        } else {
3711
            if (!imageUploadError) {
3712
                verifyListing();
3713
            } else {
3714
                ImageURLs = [];
3715
                imagesToUpload = 0;
3716
            }
3717
        }
3718
    }
3719
 
3720
    checkImagesToUpload();
3721
}
3722
 
3723
function uploadSiteHostedPicture(imageId, index) {
3724
    var i;
3725
    var str = '';
3726
    var imageBasename = document.getElementById(imageId).src.substr(document.getElementById(imageId).src.lastIndexOf('/') + 1);
3727
 
3728
    str += '<?xml version="1.0" encoding="utf-8"?>';
3729
    str += '<UploadSiteHostedPicturesRequest xmlns="urn:ebay:apis:eBLBaseComponents">';
3730
    str += '    <RequesterCredentials>';
3731
    str += '        <eBayAuthToken>' + eBayAuthToken + '</eBayAuthToken>';
3732
    str += '    </RequesterCredentials>';
3733
    str += '	<ExtensionInDays>' + 30 + '</ExtensionInDays>';
3734
    str += '    <PictureSet>Supersize</PictureSet>';
3735
    str += '	<PictureName>' + imageBasename + '</PictureName>';
3736
    str += '    <ExternalPictureURL>' + document.getElementById(imageId).src + '</ExternalPictureURL>';
3737
    str += '</UploadSiteHostedPicturesRequest>';
3738
 
3739
    var xhr = new XMLHttpRequest();
3740
    xhr.open("POST", configProxyUrl, true);
3741
    xhr.setRequestHeader('X-EBAY-API-APP-NAME', configAppid);
3742
    xhr.setRequestHeader('X-EBAY-API-DEV-NAME', configDevid);
3743
    xhr.setRequestHeader('X-EBAY-API-CERT-NAME', configCertid);
3744
    xhr.setRequestHeader('X-EBAY-API-COMPATIBILITY-LEVEL', configeBayTradingVersion);
3745
    xhr.setRequestHeader('X-EBAY-API-CALL-NAME', 'UploadSiteHostedPictures');
3746
    xhr.setRequestHeader('X-EBAY-API-SITEID', '0');
3747
    xhr.setRequestHeader('X-Proxy-URL', configServiceEndpoint);
3748
 
3749
    xhr.onload = function() {
3750
        var jsonObj = XMLparse(xhr.responseXML, false);
3751
        var obj = jsonObj.UploadSiteHostedPicturesResponse;
3752
        var str = '';
3753
        var returnCode = obj.Ack;
3754
        var x = document.getElementById("results");
3755
 
3756
        if (returnCode == 'Success') {
3757
            str += '<div class="alert alert-success alert-dismissible">';
3758
            str += '<button type="button" class="close" data-dismiss="alert">×</button>';
3759
            str += '<p>Image ' + (index + 1) + ' Upload: <strong>' + returnCode + '</strong></p>';
11 - 3760
            str += '</div>';
10 - 3761
            x.innerHTML += str;
3762
            ImageURLs[index] = obj.SiteHostedPictureDetails.FullURL;
3763
        } else {
3764
            ImageURLs = [];
3765
            imageUploadError = true;
3766
 
3767
            str += '<div class="alert alert-danger alert-dismissible">';
3768
            str += '<button type="button" class="close" data-dismiss="alert">×</button>';
3769
            str += '<p>Image ' + (index + 1) + ' Upload: <strong>' + returnCode + '</strong></p>';
3770
 
3771
            var errors = getJsonArray(obj.Errors);
3772
            str += "<ul>";
3773
            for (i = 0; i < errors.length; i++) {
3774
                str += '<li>' + errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "</li>";
3775
            }
3776
            str += "</ul>";
11 - 3777
            str += '</div>';
10 - 3778
            x.innerHTML += str;
3779
        }
3780
 
3781
        --imagesToUpload;
3782
    };
3783
 
3784
    xhr.send(str);
3785
}
3786
 
3787
function findDiscogsReleases(str) {
3788
    if (str.length < 1) {
3789
        return;
3790
    }
3791
 
3792
    // Construct the request
3793
    url = configDiscogsApiUrl + "?";
3794
    url += "token=";
3795
    url += configDiscogsToken;
3796
    url += "&type=release";
3797
    url += "&format=CD";
3798
    if (isNumeric(str)) {
3799
        url += "&barcode=";
3800
    } else {
3801
        url += "&q=";
3802
    }
3803
    url += str;
3804
 
3805
    var xhttp = new XMLHttpRequest();
3806
 
3807
    xhttp.onreadystatechange = function() {
3808
        if (this.readyState == 4) {
3809
            var response = this.responseText;
3810
            if (this.status != 200) { // discogs returns HTML instead JSON
3811
                response = '{"pagination": {"per_page": 50, "items": 0, "page": 1, "urls": {}, "pages": 1}, "results": []}';
3812
            }
3813
            _cb_findDiscogsReleases(JSON.parse(response));
3814
        }
3815
    };
3816
 
3817
    xhttp.open("GET", configProxyUrl, true);
3818
    xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
3819
    xhttp.send();
3820
}
3821
 
3822
function _cb_findDiscogsReleases(root) {
3823
    var tableStr = '';
3824
    var i, j;
3825
    var x;
3826
 
3827
    tableStr = '<h3>Discogs Releases</h3>';
3828
    tableStr += '<table id="discogsTable" class="table small table-hover">';
3829
    tableStr += '<thead class="thead-dark">';
3830
    tableStr += '<tr>';
3831
    tableStr += tableHeader('Title');
3832
    tableStr += tableHeader('Label');
3833
    tableStr += tableHeader('Catalog #');
3834
    tableStr += tableHeader('Format');
3835
    tableStr += tableHeader('Year');
3836
    tableStr += tableHeader('Country');
3837
    tableStr += tableHeader('Genre');
3838
    tableStr += tableHeader('');
3839
    tableStr += '</tr>';
3840
    tableStr += '</thead>';
3841
    tableStr += '<tbody>';
3842
 
3843
    for (i = 0; i < root.results.length; i++) {
3844
        tableStr += '<tr>';
3845
 
3846
        tableStr += tableCellLink(root.results[i].title, configDiscogsBaseUrl + root.results[i].uri);
3847
 
3848
        str = [];
3849
        for (j = 0; j < root.results[i].label.length && j < 2; j++) {
3850
            str.push(root.results[i].label[j]);
3851
        }
3852
        tableStr += tableCell(str.join(', '));
3853
 
3854
        tableStr += tableCell(root.results[i].catno);
3855
 
3856
        str = [];
3857
        for (j = 0; j < root.results[i].format.length; j++) {
3858
            str.push(root.results[i].format[j]);
3859
        }
3860
        tableStr += tableCell(str.join(', '));
3861
 
3862
        tableStr += tableCell(root.results[i].year);
3863
        tableStr += tableCell(root.results[i].country);
3864
 
3865
        tableStr += tableCell(root.results[i].genre.join(', '));
3866
 
3867
        tableStr += tableCellButton(root.results[i].resource_url);
3868
 
3869
        tableStr += '</tr>';
3870
    }
3871
 
3872
    tableStr += '</tbody>';
3873
    tableStr += '</table>';
3874
 
17 - 3875
    tableStr += '<div class="container-fluid">';
3876
    tableStr += '<form id="searchFormDiscogs" class="form-inline" onsubmit="specialDiscogsSearch();return false;">';
3877
    tableStr += '<div class="input-group">';
3878
    tableStr += '<label for="discogsRelease" class="keepTogether mr-sm-2">Release #:</label>';
3879
    tableStr += '<input id="discogsRelease" name="discogsRelease" class="form-control" style="width:30%;font-size:95%!important" type="text" maxlength="10">';
3880
    tableStr += '<div class="input-group-append">';
3881
    tableStr += '<button class="btn" onclick="specialDiscogsSearch();return false;"><i class="fa fa-search"></i></button>';
3882
    tableStr += '</div>';
3883
    tableStr += '</div>';
3884
    tableStr += '</form>';
3885
    tableStr += '</div>';
3886
 
3887
    if (!document.getElementById("productinfoSearch").innerHTML.includes("Discogs")) {
3888
        document.getElementById("productinfoSearch").innerHTML += '<a href="https://www.discogs.com/search/?q=&format_exact=CD&type=all" target="_blank"><button class="btn"><i class="fa fa-search"></i> Discogs</button></a>';
10 - 3889
    }
3890
 
3891
    x = document.getElementById("discogsReleases");
3892
    x.innerHTML = tableStr;
3893
    if (x.className.indexOf("w3-show") == -1) {
3894
        x.className += " w3-show";
3895
    }
3896
 
17 - 3897
    x = document.getElementById("productinfoSearch");
15 - 3898
    if (!x.innerHTML.includes("CD Price")) {
17 - 3899
        x.innerHTML += '<a href="https://www.getcdprices.com/upc/' + upc + '" target="blank"><button class="btn"><i class="fa fa-search"></i> CD Price</button></a>';
15 - 3900
    }
10 - 3901
}
3902
 
3903
function specialDiscogsSearch() {
3904
    if (document.getElementById("discogsRelease").value.length > 0) {
3905
        findDiscogsReleases("r" + document.getElementById("discogsRelease").value);
3906
    }
3907
}
3908
 
3909
function tableHeader(str) {
3910
    return ('<th>' + (str === undefined ? '' : str) + '</th>');
3911
}
3912
 
3913
function tableCell(str) {
3914
    return ('<td>' + (str === undefined ? '' : str) + '</td>');
3915
}
3916
 
3917
function tableCellLink(text, link) {
3918
    var str = "<a href=\"" + link + "\" target=\"_blank\">" + text + "</a>";
3919
    return ('<td>' + str + '</td>');
3920
}
3921
 
3922
function tableCellButton(link) {
12 - 3923
    var str = '<button type="button" class="btn btn-primary fa fa-arrow-left" onclick="getDiscogsRelease(&quot;' + link + '&quot;);"></button>';
10 - 3924
    return ('<td>' + str + '</td>');
3925
}
3926
 
3927
function getDiscogsRelease(url) {
3928
    var xhttp = new XMLHttpRequest();
3929
 
3930
    xhttp.onreadystatechange = function() {
3931
        if (this.readyState == 4) {
3932
            _cb_getDiscogsRelease(JSON.parse(this.responseText));
3933
        }
3934
    };
3935
 
3936
    xhttp.open("GET", configProxyUrl, true);
3937
    xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
3938
    xhttp.send();
3939
}
3940
 
3941
function _cb_getDiscogsRelease(root) {
3942
    var str;
3943
    var titleStr = '';
3944
    var trackStr;
3945
    var artist;
3946
    var label;
3947
    var year;
3948
    var position;
3949
    var promo = '';
3950
    var digipak = '';
3951
    var duration = '';
3952
    var quantity = '';
3953
    var i, j;
3954
    var temp;
3955
 
3956
    // Tracklist
3957
    trackStr = [];
3958
    allNumbers = true;
3959
 
3960
    for (i = 0; i < root.tracklist.length; i++) {
3961
        str = '';
3962
        if (root.tracklist[i].position.length > 0) {
3963
            str += root.tracklist[i].position + '. ';
3964
 
3965
            position = Number(root.tracklist[i].position);
3966
            if (isNaN(position) || position != (i + 1)) {
3967
                allNumbers = false;
3968
            }
3969
        }
3970
 
3971
        if (root.tracklist[i].artists !== undefined) {
3972
            for (j = 0; j < root.tracklist[i].artists.length; j++) {
3973
                temp = root.tracklist[i].artists[j].name.replace(/\([0-9]+\)$/, "");
3974
                str += temp + " " + root.tracklist[i].artists[j].join + " ";
3975
            }
3976
            str += " - ";
3977
        }
3978
 
3979
        str += root.tracklist[i].title;
3980
 
3981
        if (root.tracklist[i].duration.length > 0) {
3982
            str += " [" + root.tracklist[i].duration + "]";
3983
        }
3984
 
3985
        trackStr.push(str);
3986
    }
3987
 
3988
    str = str.replace(/  +/g, ' ');
3989
    if (allNumbers) {
3990
        for (i = 0; i < trackStr.length; i++) {
3991
            trackStr[i] = trackStr[i].replace(/^\d+. /g, '');
3992
        }
3993
    } else {
3994
        document.getElementById("cdUnorderedTrackList").checked = true;
3995
    }
3996
 
3997
    $("#cdTracks").val(trackStr.join('\n'));
3998
    updateTracklistPreview();
3999
 
4000
    // Title
4001
    titleStr = '';
4002
    artist = '';
4003
    label = '';
4004
    year = '';
4005
    catno = '';
4006
    if (root.artists !== undefined) {
4007
        for (i = 0; i < root.artists.length; i++) {
4008
            temp = root.artists[i].name.replace(/\([0-9]+\)$/, "");
4009
            artist += temp + " " + root.artists[i].join + " ";
4010
        }
4011
    }
4012
 
4013
    artist = artist.trim();
4014
    if (artist != 'Various') {
4015
        titleStr += artist + " - " + root.title;
4016
    } else {
4017
        titleStr += root.title + " by Various Artists";
4018
    }
4019
    titleStr += " (CD";
4020
 
4021
    document.getElementById("cdTitle").value = root.title;
4022
 
4023
    // formats
4024
    promo = '';
4025
    duration = '';
4026
    quantity = '';
4027
    digipak = '';
4028
    for (i = 0; i < root.formats.length; i++) {
4029
        if (root.formats[i].name.startsWith("CD")) {
12 - 4030
            if (root.formats[i].descriptions !== undefined) {
4031
                for (j = 0; j < root.formats[i].descriptions.length; j++) {
4032
                    if (root.formats[i].descriptions[j] == "Enhanced") {
4033
                        document.getElementById("cdEnhanced").checked = true;
4034
                    } else if (root.formats[i].descriptions[j] == "Compilation") {
4035
                        document.getElementById("cdCompilation").checked = true;
4036
                    } else if (root.formats[i].descriptions[j] == "Digipak") {
4037
                        document.getElementById("cdDigipak").checked = true;
4038
                        digipak = root.formats[i].descriptions[j];
4039
                        setCdConditionDescription('D');
4040
                    } else if (root.formats[i].descriptions[j] == "Promo") {
4041
                        document.getElementById("cdPromo").checked = true;
4042
                        promo = 'PROMO';
4043
                    } else if (root.formats[i].descriptions[j] == "Reissue") {
4044
                        document.getElementById("cdReissue").checked = true;
4045
                    } else if (root.formats[i].descriptions[j] == "Remastered") {
4046
                        document.getElementById("cdRemastered").checked = true;
4047
                    } else if (root.formats[i].descriptions[j] == "HDCD") {
4048
                        document.getElementById("cdHDCD").checked = true;
4049
                    } else if (root.formats[i].descriptions[j] == "Album" ||
4050
                        root.formats[i].descriptions[j] == "Mini-Album" ||
4051
                        root.formats[i].descriptions[j] == "EP" ||
4052
                        root.formats[i].descriptions[j] == "Maxi-Single" ||
4053
                        root.formats[i].descriptions[j] == "Single") {
4054
                        $('#cdDuration').selectpicker('val', root.formats[i].descriptions[j]);
4055
                        $('#cdDuration').prop('disabled', false).selectpicker('refresh');
4056
                        if (!root.formats[i].descriptions[j].includes("Album")) {
4057
                            duration = root.formats[i].descriptions[j];
4058
                        }
10 - 4059
                    }
4060
                }
12 - 4061
            }
10 - 4062
 
12 - 4063
            discogsQty = Number(root.formats[i].qty);
4064
            if (discogsQty > 1) {
4065
                setCdConditionDescription('P');
4066
                quantity = Number(root.formats[i].qty) + ' Discs';
10 - 4067
            }
4068
        }
4069
    }
4070
 
4071
    // genres
4072
    if (document.getElementById("cdGenre").value.length <= 1) {
4073
        for (i = 0; i < root.genres.length; i++) {
4074
            if (isInSelectList("cdGenre", root.genres[i])) {
4075
                $('#cdGenre').prop('disabled', false).selectpicker('refresh');
4076
                break;
4077
            }
4078
        }
4079
    }
4080
 
4081
    // country
12 - 4082
    var country = getJsonValue(root.country);
4083
    if (country != 'undefined' && country != 'US' && !country.includes('Europe')) {
4084
        if (country == 'UK') {
10 - 4085
            document.getElementById("cdCountry").value = 'United Kingdom';
4086
        } else {
4087
            document.getElementById("cdCountry").value = root.country;
4088
        }
4089
    } else {
4090
        document.getElementById("cdCountry").value = "United States";
4091
    }
4092
 
4093
    // title remainder
4094
    if (duration.length > 0) {
4095
        titleStr += ", " + duration;
4096
    }
4097
 
4098
    if (digipak.length > 0) {
4099
        titleStr += ", " + digipak;
4100
    }
4101
 
4102
    if (quantity.length > 0) {
4103
        titleStr += ", " + quantity;
4104
    }
4105
 
4106
    if (root.released !== undefined) {
4107
        year = root.released.substr(0, 4);
4108
        titleStr += ", " + year;
4109
    }
4110
 
4111
    if (root.labels !== undefined) {
4112
        label = root.labels[0].name;
4113
        titleStr += ", " + label;
4114
    }
4115
 
4116
    titleStr += ")";
4117
 
4118
    if (promo.length > 0) {
4119
        titleStr += " " + promo + ' ' + root.labels[0].catno;
4120
    }
4121
 
4122
    titleStr = titleStr.trim();
4123
    titleStr = titleStr.replace(/  +/g, ' ');
4124
    titleStr = titleStr.replace('<br>', '');
4125
 
4126
    if (titleStr.includes('Greatest Hits')) {
4127
        document.getElementById("cdGreatestHits").checked = true;
4128
    }
4129
 
4130
    if (isNumeric(document.getElementById("title").value) || document.getElementById("title").value.length === 0) {
4131
        document.getElementById("title").value = titleStr;
4132
        printTitleLength();
4133
        document.getElementById("cdArtist").value = artist;
4134
        document.getElementById("cdRecordLabel").value = label;
4135
        document.getElementById("cdReleaseYear").value = year;
4136
    }
4137
}
4138
 
4139
function isInSelectList(list, value) {
4140
    var i;
4141
    var opts = document.getElementById(list).options;
4142
 
4143
    for (i = 0; i < opts.length; ++i)
4144
        if (opts[i].value.includes(value)) {
12 - 4145
            $('#' + list).selectpicker('val', opts[i].value);
10 - 4146
            return true;
4147
        }
4148
 
4149
    return false;
4150
}
4151
 
4152
function printTitleLength() {
4153
    var len = document.getElementById("title").value.length;
4154
 
4155
    color = (len > 80 ? 'red' : 'black');
4156
 
4157
    document.getElementById("titleLength").innerHTML = '(' + len + ')';
4158
    document.getElementById("titleLength").style.color = color;
4159
}
4160
 
4161
/**
4162
 * Creates a read/writable property which returns a function set for write/set (assignment)
4163
 * and read/get access on a variable
4164
 *
4165
 * @param {Any} value initial value of the property
4166
 */
4167
function createProperty(value) {
4168
    var _value = value;
4169
 
4170
    /**
4171
     * Overwrite getter.
4172
     *
4173
     * @returns {Any} The Value.
4174
     * @private
4175
     */
4176
    function _get() {
4177
        return _value;
4178
    }
4179
 
4180
    /**
4181
     * Overwrite setter.
4182
     *
4183
     * @param {Any} v   Sets the value.
4184
     * @private
4185
     */
4186
    function _set(v) {
4187
        _value = v;
4188
    }
4189
 
4190
    return {
4191
        "get": _get,
4192
        "set": _set
4193
    };
4194
}
4195
 
4196
    </script>
17 - 4197
    <script>includeHTML();</script>
10 - 4198
 
4199
</body>
4200
</html>