Subversion Repositories munaweb

Rev

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

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