Subversion Repositories munaweb

Rev

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