Subversion Repositories munaweb

Rev

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

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