Subversion Repositories munaweb

Rev

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