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