//--------------------------
// 29 Oct 2007
// modified for eBid site
//--------------------------
// 2/27/2007
// revamped the scripts and included PHP code to pull in the
// auctions and automatically create a gallery of selected auctions.
//--------------------------
// 11/19/2006
// this updates the xsell13f.js with some changes to the way 
// script comments are displayed in the code output.
// The eBay Description editor collapsed page code into one long string, 
// and that causes the script to quit working.
// The solution is to make the script tolerate a single sentence.
//--------------------------
// 5/04/2010
// ebid changed display page and logo
// modified code to pick up elements from new page layout
//--------------------------


//--------------------------
//  copyright © 2005-2010 isdntek.com
//  do not copy without permission
//--------------------------

	var quot="'";
	var quote='"';
	var key=0;
	var ebay=false;
	var siteflag=0;

	var sameRatio=true;
	var maxThRatio=0;
	var sliderWidthRatio=0;
	var startaction=0;
	var galleryCode="";
	var selectedItem="BorderColor";
	var slideFontBolded;
	var slideFontFace;
	var slideFontSize;
	var compressscript=false;
	var storeReferral="";
	var xsell='<span style="font-family:sans-serif;color:#808080;font-size:10px;text-align:center" >Free Cross-sell script from <a href="http://www.isdntek.com/tagbot/xsell_ebid.htm" style="color:#808080">ISDN*tek</a> </span>'

//--------------------------
//  slider code variables
//--------------------------

	var scrollspeed ="30"   // 10fast to 50slow
 	var textcolor   ="#222222"
 	var slideborder ="#555555"
 	var slidebgcolor="#EEE9D9"
	var popupborder ="#BF8088"
	var slideshadow ="#704440"
	var slideaccent ="#B87880"   // "#AF7078"

	var j=0; 
	var thCnt=0
 	var CrossSellimages=new Array()	
	var AuctionDescrp=new Array()
	var AuctionThumb=new Array()
	var AuctionLink=new Array()
	var thRat   = new Array();

	var borderWidth=2
 	var gallerywidth ="450"
	var selectedShape=80
	var thRatio=0.80

	var lgHt=80
	var thHt=lgHt*thRatio // 64
	var vSpc=4 // img padding
	var hSpc=2

	var thBorderWid=0 //-borders on slider pics
	var thBorderColor='none'

 	var sliderheight=""+lgHt+(vSpc*2)
 	var sliderwidth=0	
 	var scrollamount=-1
 	var slider1, slider2
 	var CrossSellStrip='<nobr>'+CrossSellimages.join("")+'</nobr>'


function $(v){return document.getElementById(v) }
//--------------------------
//  color routines
//--------------------------

function whichItemColors(){ //-show which color option is selected
	if ($('selcol1').checked==true){selectedItem='BorderColor'}
	if ($('selcol2').checked==true){selectedItem='GalleryColor'}
	if ($('selcol3').checked==true){selectedItem='TextColor'}
}

function setColor(palettecolor) { //-this a user-defined function called from the palette module
	// it is used to tell the palette what to paint.
	// palettecolor will come from a style, so can be hex or RGB or none
	whichItemColors()
	$(selectedItem).value=colorcode(palettecolor)
	$(selectedItem).style.backgroundColor=colorcode(palettecolor)
}

function doDrab(){
	whichItemColors()
	drabColor($(selectedItem).value)
	setColor($('previewColor').style.backgroundColor)
}

function doNoColor(palettecolor){
	whichItemColors()
	$(selectedItem).value="";
	$(selectedItem).style.backgroundColor=""
}

function removeSpaces(word) { 
	word.replace(/ /g,"")
	return word
	//newword=""
	//for (i=0; i<word.length; i++){if (word.substr(i,1)!=" "){newword=newword+word.substr(i,1)} }
	//return newword
}

function checkHexColor(word) {var notHex=false
	hexstring="0123456789abcdef#"
	word=word.replace(/ /g,"")
	for (i=0; i<word.length; i++){if (hexstring.indexOf(word.substr(i,1).toLowerCase())<0){notHex=true}}
	if (notHex==false){if (word.length>0 && word.substr(0,1)!="#"){word="#"+word}}
	return word
}

//====================


//====================

var fieldnames=new Array("Thumb ","Link ","Auction ","Caption ","Clear ","for ") // for languages
function makeInputFields(fldname) {
	if (fldname) {fieldnames=fldname}
	InFields="<table><tr><td align=right><small>"
	for (var i=1; i<=20; i++){
	  InFields=InFields+'<span id=th'+i+'><nobr>'+fieldnames[0]+i+' <input id=thumb'+i+'   type=text size=40 value="http://" onmousedown="clearHttp(this.id)" onfocus="this.select()"></nobr><br></span>'
	  InFields=InFields+'<span id=li'+i+'><nobr>'+fieldnames[1]+i+' <input id=link'+i+'    type=text size=40 value="http://" onmousedown="clearHttp(this.id)" onfocus="this.select()"></nobr><br></span>'
	  InFields=InFields+'<span id=ca'+i+'><nobr>'+fieldnames[3]+i+' <input id=cap'+i+'     type=text size=40 value="" onfocus="this.select()"></nobr><br></span>'
	  InFields=InFields+'<br>'
	  if (i==10){InFields=InFields+'<center><input type=button value="'+fieldnames[4]+' &uarr;" onclick="ClearGallery(1,10);"></center></small></td><td>&nbsp;</td><td align=right><small>'}
	}
	InFields=InFields+'<center><input type=button value="'+fieldnames[4]+' &uarr;" onclick="ClearGallery(11,20);"></center></small></td></tr></table>'
	$('inputFields').innerHTML=InFields
        LoadTestFields()
//$('thumb1').setFocus
//alert("")
}


function LoadTestFields(){
	for (var i=1; i<=8; i++){
	  $('thumb'+i  ).value="http://www.isdntek.com/tagbot/misc/bambi_100.jpg"
	  $('link'+i   ).value="http://www.isdntek.com/clicpic.htm"
	  $('cap'+i    ).value=""+fieldnames[3]+fieldnames[5]+fieldnames[2]+i
	}

}


function clearHttp(item) {
	if ($(item).value=="http://"){$(item).value=""}
}

function ClearGallery(a,b) {
	for (var i=a; i<=b; i++){
		$('thumb'+i).value=""
		$('link'+i).value=""
		$('cap'+i).value=""
	}
}


function importImages() {  //kill this
	//--move all of the image/auction fields into array variables.
	//--clear the arrays first
	for (var i=1; i<=20; i++){AuctionDescrp[i]=""; AuctionThumb[i]=""; AuctionLink[i]=""; CrossSellimages[i]="";}	
	for (var i=1; i<=20; i++){  
 	//  if ($('auction'+i).value!=""){auction[i]=$('auction'+i).value.replace(/ /g,""); } 
	    if ($('cap'+i).value!=""){ AuctionDescrp[i]=replaceQuoteLong($('cap'+i).value); }
	}   

}

function importInputs(){ 
	//--pick up all of the gallery appearance variables
	slideFontFace=$('fontFace').value
	slideFontSize=$('FontSize').value+"px"
	if ($('Bold').checked){slideFontBolded="bold"}else{slideFontBolded="normal"}

	newheight = parseInt($('CustomHeight').value)
	if (newheight>=10) {lgHt=newheight} 

	newratio = parseInt($('CustomRatio').value)
	if (newratio<50 || newratio>100) 
	{if (newratio<50){newratio=50}; if (newratio>100){newratio=100}; $('CustomRatio').value=newratio}
	thRatio=newratio/100

	newwidth = parseInt($('CustomGalWid').value)
	if (newwidth>=50) {gallerywidth=""+newwidth} else {gallerywidth="50"}

	thHt =Math.round(lgHt*thRatio)
	sliderheight=""+lgHt+(vSpc*2)

 	slidebgcolor=checkHexColor($('GalleryColor').value)
 	slideborder =checkHexColor($('BorderColor' ).value)
 	textcolor   =checkHexColor($('TextColor'   ).value)
	  //--echo corrections back to form
	  $('GalleryColor').value=slidebgcolor
	  $('BorderColor' ).value=slideborder
	  $('TextColor'   ).value=textcolor 
	borderWidth =parseInt($('BorderSize'   ).value)
	scrollspeed =parseInt($('ScrollerSpeed').value)
	if($('groupborders').checked==true){thBorderWid=1; thBorderColor=slideborder}else{thBorderWid=0;thBorderColor='none'}
	if($('compress1').checked==true){compressscript=true} else{compressscript=false}

	siteflag=0
	if ($('store').checked==true){storeReferral="&refid=store"}else{storeReferral=""}
}


function showAuctionList(show) {
	//if (show==true && $('searchurl').value!=""){
	if (show==false ){
		$('showAuctions').style.display="none"}
	else {
		$('showAuctions').style.display="block"
	}
    	if (startaction){preloader();} //--call only after page load
}


function replaceQuote(testWord){var pos=-1; var newWord="";
	testWord=testWord.replace(/"/g,"&#34;");
	testWord=testWord.replace(/'/g,"&#39;");
	return testWord;
	//for (i=0; i<testWord.length; i++){
	//switch (testWord.substr(i,1)){
	//	case '"':newWord=newWord+'&#34;';   break
	//	case quot:newWord=newWord+'&#39;';  break
	//	default:newWord=newWord+testWord.substr(i,1)
	//}}
	//return newWord;
}
function replaceQuoteLong(testWord){var pos=-1; var newWord="";
	// need the extra ampersand for the tooltip alts.
	testWord=testWord.replace(/"/g,"&amp#34;");
	testWord=testWord.replace(/'/g,"&amp#39;");
	return testWord;
	//for (i=0; i<testWord.length; i++){
	//switch (testWord.substr(i,1)){
	//	case '"':newWord=newWord+'&amp#34;';   break
	//	case quot:newWord=newWord+'&amp#39;';  break
	//	default:newWord=newWord+testWord.substr(i,1)
	//}}
	//return newWord;
}

function pausecomp(millis) {
	// pause specified milliseconds.
	// since this delay merely churns cpu cycles, 
	// it may not actually help the preloader if the 
	// HTML can't execute until the /script closer.
	// May need human intervention for the preloader.
	date = new Date();
	var curDate = null;
	do { var curDate = new Date(); }
	while(curDate-date < millis);
}

function Preview(thecodetoshow) {
  	  var ww = window.open("","popupwindow","width=600,height=350,directories=no,menubar=yes,status=yes,toolbar=yes,resizable=yes,scrollbars=yes,screenY=0,top=0,screenX=80,left=80,modal=yes" );
    	  ww.document.writeln("<html><head><title>Preview</title></head><body>" );
  	  ww.document.writeln(thecodetoshow);
  	  ww.document.writeln("<br clear=both><hr><form><center><input type=\"submit\" value=\"Close Window\" onClick=\"window.close();return false; \"></center></form>" );
  	  ww.document.writeln("</body></html>" );
  	  ww.document.close() ;
  	  if(document.focus){ ww.document.focus(true)}
}

//--------------------------
//  Auction Extraction routines
//--------------------------
/*
The address string will be read for country, sellerid, storeid, and search string.
The country, sellerid, and storeid will reset the input fields when returning to the page.
Only the search string is used to parse out the auction details. 
The other values are simply duplicated.
So if there is no search string, then we can assume it is a first time entry.

It would be nice to pass the gallery appearance as well.
There are about 13 parameters associated with the appearance.

If the search is used, the input fields could be bypassed (hidden).
But for now, they will be populated for user revision.
The image preview would also be unnecessary because the thumbs should appear in the search results.
However, it is possible that they would need to be refreshed to pick up any that were missed.
So the program will for a thumb preview and will create the first gallery.
*/

/*

---sample Display options ----
sorted newest first
  http://us.ebid.net/perl/main.cgi?mo=search&words=partsanthings&type=user&sort=-1
link
  http://us.four.ebid.net/perl/auction.cgi?auction=1186620444-26554-0&mo=auction
thumbnail
   http://six.ebid.net/upload_small/8/1186620430-8420-0.jpg
or http://uk.six.ebid.net/icons/camera.gif
or no image
*/



function spacetrim(word){ // remove pre and post spaces and tabs.
	word=escape(word)
	word=word.replace(/%09/g,"%20")
	word=word.replace(/%0A/g,"%20")
	word=word.replace(/%0D/g,"%20")
	word=unescape(word)
	while (word.substr(0,1)==" ") {
		word=word.substring(1,word.length)
	}
	while (word.substr(word.length-1,1)==" ") {
		word=word.substring(0,word.length-1)
	}
	return word
}

    var founditem = new Array()
    var founddesc = new Array()
    var foundthumb= new Array()
	
function fetchPage(which){
	// this routine is only called when the user clicks the button to start a search.
	// it will result in a page reload.
	var country=$('country').value.toLowerCase()+"."
	if ($('srch0').checked==true || which=="seller"){
	    $('sellerid').value=spacetrim($('sellerid').value)
	    newAddress='http://'+country+'ebid.net/perl/main.cgi?mo=search&words='+$('sellerid').value.replace(/ /g,"")+'&type=user&sort=-1'   //--75 (one page) listings, newest first
	//} else if ($('srch1').checked==true || which=="store"){
	//    storename=spacetrim($('storeid').value)
	//    storename=storename.replace(/'/g,"")
	//    storename=storename.replace(/[ .&\/;,*$@_]/g,"-")
	//    $('storeid').value=storename
        //    newAddress='http://stores.'+country+'/'+storename+'_W0QQcolZ4QQdirZQ2d1QQdptZ0QQfclZ3QQftidZ2QQtZkm' //--store example, newest first, row format
	} else {
	    newAddress= $('searchurl').value // user-generated search
	}

	var settings=MakeBookmark(false)
	document.location=page2+"?pg="+escape(newAddress)+"&cntry="+$('country').value+"&seller="+$('sellerid').value.replace(/ /g,"")+"&store="+$('storeid').value.replace(/ /g,"-")+settings
}

function extract(){
	// this is called at the end of page load or reload to act on any PHP settings.
	$('showAuctions').style.display="block"
 	restoreSettings()
	var searchlist=$('searchpage').value
	extractAuctions()

	// restore the gallery appearance selections
    	// select the first 20 listings and build a gallery
	for (var i=1; i<founditem.length; i++){if (i<=20){$('chk'+i).checked=true} }
	build()
	// because this will create a gallery from images that may not have fully loaded, 
	// we should probably notify the user to remake the gallery after images have loaded.

	
}


function extractAuctions(){ 	// same string appears twice (or more), so test for duplication
	//"http://us.four.ebid.net/perl/auction.cgi?auction=1186620444-26554-0&mo=auction"
	var searchlist=$('searchpage').value
	//var searchHTML=$('searchpage').innerHTML
	var findthis  ='<td id="photo">'
	var descroot  =''          //  'http://cgi.'+$('country').value+'/' 
	var searchsplit=searchlist.split(findthis)


/* ***********************************  */
	/*
	//2010 sample//
	<tr id="list" >
	  <td id="photo"><A HREF="http://us.ebid.net/for-sale/0330348760-m-is-for-malice-by-sue-grafton-hardcover-25123350.htm"><img src="http://im1.ebidst.com/upload_small/0/7/6/1265941098-6146-0.jpg" style="width:77px;height:77px;" border=0 ALT="M is for Malice by Sue Grafton (1996) hardcover" title="M is for Malice by Sue Grafton (1996) hardcover"></a></td>
	  <td id="main">
		<div class="title f4"><A class="under" HREF="http://us.ebid.net/for-sale/0330348760-m-is-for-malice-by-sue-grafton-hardcover-25123350.htm">M is for Malice by Sue Grafton (1996) hardcover</a></div>
		<div class="user"><A HREF="http://us.ebid.net/perl/normal.cgi?user=794677&mo=their-all-about">ednaedna</A> [<A HREF="http://us.ebid.net/perl/normal.cgi?user=794677&mo=user-rating&type=feed">+65</A>]<img src = 'http://www.ebid.net/icons/space.gif' title='Feedback Tier 3 (51 -> 100 rating)' alt='Feedback Tier 3 (51 -> 100 rating)' width=1 height=1 hspace=1 align=center  border=0><img src=http://www.ebid.net/icons/pc_match.gif hspace=2 height=14 width=14 align="absmiddle" alt="Address Verified. eBid Account Postcode matches their Credit/Debit Card Account Postcode" title="Address Verified. eBid Account Postcode matches their Credit/Debit Card Account Postcode"></div>
		<div class="accept"><h6>Accepted Payment: <img align="absmiddle" src="http://www.ebid.net/icons/accept_paypal.gif" width="16" height="16" alt="PayPal Payment Accepted" title="PayPal Payment Accepted"></h6></div>
	  </td>
	  <td id="qty">1</td>
	  <td id="view"> 28 </td>
	  <td id="bid"> <span class="bi"></span> <span class="bu">Buy<br /><strong class="orange">&#36;2.00</strong>
	  </span> </td>
	  <td id="ship"><b>&#36;3.50</b></td>
	  <td id="time"> 81 days 12 hrs Ago </td>
	</tr>
	*/
	

	// look downstream to pick up href, src, and title.

	var a=0; var results=""
	results=results+'<table style="font-family:arial; font-size:12px;"><tbody>'
	//http://www.ebid.net/icons/logos/logo_83x68.png
	var eBidIcon='http://www.ebid.net/icons/logos/logo_blackcurrant.png'

var link1
var img1
var title1
	for (var i=1; i<searchsplit.length-1; i++) {
		searchsplit[i]=searchsplit[i].split("</td>")[0];
		//document.getElementById('testresults').value+=searchsplit[i]+'\n';
		//alert(searchsplit[i]);
		//  new search
		var link1=searchsplit[i].match(/href\=".+\.htm/i)[0].replace('HREF="',"");
		var img1 =searchsplit[i].match(/src\=".+\.(jpg|gif)/i)[0].replace('src="',"");
		if (img1.toLowerCase().search('icons/camera.gif')>-1){
			var d=link1.split("/");
			f=d[d.length-1].split("-");
			f.pop();
			var title1=f.join(" ");
			img1=eBidIcon;
		}else{
		  	var title1=searchsplit[i].match(/title\=".+/i)[0].replace('title="',"").replace('"></a>',"");
		}


/* ***********************************  */


		
		startdesc=0; enddesc=0;
		if (link1!="" ){
			a++; 
			founditem[a]=link1
			foundthumb[a]=img1
			founddesc[a]=title1
			if (a%3==1) {results=results+'<tr height=100>'}
			results=results+'<td><input id=chk'+a+' type=checkbox name=selectItem align=left></td>'
			results=results+'<td><a href="'+founditem[a]+'" target="_blank">';
			results=results+'<img src="'+foundthumb[a]+'" align=left vspace=2 hspace=2 border=0></a></td>';
			//results=results+'<td id=itm'+a+'><big>'+founditem[a]+'</big><br>';
			results=results+'<td id=itm'+a+'><big>'+a+'</big><br>'+founddesc[a]+'</td>'; 
			if (a%3==0) {results=results+'</tr>\n'}

	    	}
		
	}
	if (a%3!=0) {results=results+'</tr>'}
	results=results+'</tbody></table>'
	if (founditem.length==0){
		if (searchlist.toLowerCase().indexOf("warning")>0 && searchlist.toLowerCase().indexOf("warning")<100){
		  results=results+'<center><br>Server is busy</br>Please try again in a few minutes.<br><br></center>';
		}else{
		  results=results+'<center><br>No listings were found</br>If listings exist, please check <br>spelling and country code.<br><br></center>';
		}
	}
	$('showListings').innerHTML=results
}



function build(){
	// this can be called when the users clicks the Build button
	// or when the page reloads and automatically builds a gallery
	ClearGallery(1,10)
	ClearGallery(11,20)
	var a=0
	a=buildlist(a)
	if (a<8){buildlist(a)} //make a short gallery longer by repeating.
	// This width negates that value passed by a bookmark
	// but also prevents a oneframe image that could appear with nul search results.
	if ($("CustomGalWid").value<450) {$("CustomGalWid").value=450}
	preloader()
	// the picture preloading is still a problem if there are a lot of thumbs in the search.
	setTimeout("MakeGallery()",1000)
}

function buildlist(a){
	for (var i=1; i<founditem.length; i++){
		if ($('chk'+i).checked==true){
			a++
			if (a<=20){
			//$('auction'+a).value=founditem[i]
			$('thumb'+a    ).value=foundthumb[i]
			$('link'+a    ).value=founditem[i]
			$('cap'+a    ).value=founddesc[i]    //.replace(/-/g," ")
			}
		}
	}
	return a
}

function setAll(){
	for (var i=1; i<founditem.length; i++){$('chk'+i).checked=true}
}
function setNone(){
	for (var i=1; i<founditem.length; i++){$('chk'+i).checked=false}
}

function restoreSettings(){
	if ($('ss').value){
	  $('BorderColor').value=unescape($('bc').value)
	  $('BorderColor').style.backgroundColor=unescape($('bc').value)
	  $('GalleryColor').value=unescape($('gc').value)
	  $('GalleryColor').style.backgroundColor=unescape($('gc').value)
	  $('TextColor').value=unescape($('tc').value)
	  $('TextColor').style.backgroundColor=unescape($('tc').value)
	  $('BorderSize').value=unescape($('bs').value)
	  $('groupborders').checked=eval($('gb').value)
	  $('fontFace').value=unescape($('ff').value)
	  $('FontSize').value=unescape($('fs').value)
	  $('Bold').checked=eval($('fb').value)
	  $('defaultCaption').value=unescape($('dc').value)
	  $('CustomHeight').value=unescape($('ch').value)
	  $('CustomRatio').value=unescape($('cr').value)
	  $('CustomGalWid').value=unescape($('cw').value)
	  $('ScrollerSpeed').value=unescape($('ss').value)
	}
	// the default gallery width is affected by the build routine
	// chackmark the search options on a return 
	for (var i=0; i<3; i++) {$('srch'+i).checked==false}
	if ($('searchurl').value!=""){$('srch2').checked=true}
	else if ($('sellerid').value!=""){$('srch0').checked=true}
	//else if ($('storeid').value!=""){$('srch1').checked=true}
	else {$('srch0').checked=true}
}



/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
//function bookmarksite(title,url){
function bookmarksite(){
    var title='Customized X*sell Scrolling Gallery'
    var url=MakeBookmark(true)
    var desc="Make a scrolling thumbnail gallery for your page"
    if (window.sidebar) {//-firefox
	window.sidebar.addPanel(title, url, "");
	alert ('The Firefox bookmark will open in the sidebar.\n That is currently the only way to add to FireFox.\n\n'+
	' After adding, you can edit the bookmark properties to uncheck that option.')
	}
    else if(window.opera && window.print){ //-opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
    } 
    else if(document.all)//-ie
	window.external.AddFavorite(url, title);
}

function MakeBookmark(all){
	// bookmark these settings
	var dd=new Array()
	var bmURL=""

	dd[0]="http://www.isdntek.com"+location.pathname
	dd[1]="?pg="+$('searchurl').value
	dd[2]="&cntry="+$('country').value
	dd[3]="&seller="+$('sellerid').value.replace(/ /g,"")
	dd[4]="&store="+$('storeid').value.replace(/ /g,"-")

	dd[5]="&bc="+escape($('BorderColor').value)
	dd[6]="&gc="+escape($('GalleryColor').value)
	dd[7]="&tc="+escape($('TextColor').value)
	dd[8]="&bs="+escape($('BorderSize').value)
	dd[9]="&gb="+escape($('groupborders').checked)
	dd[10]="&ff="+escape($('fontFace').value)
	dd[11]="&fs="+escape($('FontSize').value)
	dd[12]="&fb="+escape($('Bold').checked)
	dd[13]="&dc="+escape($('defaultCaption').value)
	dd[14]="&ch="+escape($('CustomHeight').value)
	dd[15]="&cr="+escape($('CustomRatio').value)
	dd[16]="&cw="+escape($('CustomGalWid').value)
	dd[17]="&ss="+escape($('ScrollerSpeed').value)
	if (all==true){s=0}else {s=5}
	for (var i=s; i<dd.length; i++){bmURL=bmURL+dd[i]}
	return bmURL
}


//--------------------------
//  gallery routines
//--------------------------

// in order to use the variable sizes, we are going to need to preload the images
// and read the dimensions. The gallery code is then going to need both width and 
// height for each image. If a fixed height is used, then only the width will need
// to be carried with each thumb field. So add a width array to the user code.
// It may be possible to forego the width array if it is determined that all images
// are the same width. This would simulate the original gallery where every image 
// is the same size.
// The user is probably going to need to verify that all of the images have arrived.
// So add some sort of previewer where the user can say OK to all the images or 
// can hit a reload until the rest of the images arrive. [ok] [reload] [cancel to fix]
// probably a popup window or popopen block with an array of all thumbnails.
// Tell the user to click ok after they all appear. Of course, the user is probably 
// going to have all their own images in their cache anyway.


function MakeGallery() {
	makeSample()
	if (compressscript==false) {MakeCodes()} else {CompressCodes()}
}


function makeSample(){
	//importImages() //at top of form
  	importInputs()
	fetchAuctionArray() //ok to repeat because of possible text changes
	buildSlider()

     //function reconfigureGallery(){
	//$('slidewrap1').style.background="url('http://www.isdntek.com/tagbot/backgrounds/texture_palegold.gif')"
	$('slidewrap1').style.backgroundColor=slidebgcolor
	$('slidewrap1').style.borderColor=slideborder
	$('slidewrap1').style.borderWidth=borderWidth+"px"
	$('slidewrap1').style.width=(borderWidth+parseInt(gallerywidth))+"px"
	$('slidewrap1').style.height=(lgHt+(vSpc*2)+ borderWidth)+"px"

	$('slidewrap2').style.width =gallerywidth+"px"
	$('slidewrap3').style.width =gallerywidth+"px"
	$('slidewrap2').style.height=(lgHt+(vSpc*2)+borderWidth/2)+"px"
	$('slidewrap3').style.height=(lgHt+(vSpc*2)+borderWidth/2)+"px"
	$('slidegroup1').style.bottom=Math.round(((lgHt+borderWidth)-thHt)/2-vSpc+thBorderWid)+"px"
	$('slidegroup2').style.bottom=Math.round(((lgHt+borderWidth)-thHt)/2-vSpc+thBorderWid)+"px" 

	$('blowup').style.borderColor=slideborder
	$('blowup').style.borderWidth=(borderWidth/2)+"px"
	$('blowup').style.visibility="hidden"
	$('blowup').style.bottom=(thBorderWid*2)+"px"

	$('slidelabel').style.fontSize=slideFontSize
	$('slidelabel').style.fontFamily=slideFontFace
	$('slidelabel').style.fontWeight=slideFontBolded
	$('slidelabel').style.color=textcolor
	$('slidelabel').innerHTML=$('defaultCaption').value
	$('slidelabel').title=$('defaultCaption').value
	clearInterval(startaction) // turn off slider
	startaction=setInterval("slideleft()",parseInt(scrollspeed))

}


function fetchAuctionArray() {//--page must load first
	//--move all of the image/auction fields into array variables.
	//--clear the arrays first
	for (var i=1; i<=20; i++){AuctionDescrp[i]=""; AuctionThumb[i]=""; AuctionLink[i]=""; CrossSellimages[i]="";}	
	//for (var i=1; i<=thumb.length; i++){
	for (var i=1; i<=20; i++){
	  //if(thumb[i]){
	  if($('thumb'+(i)).value!="" && $('thumb'+(i)).value!="http://"){
  	    AuctionThumb[i] =spacetrim($('thumb'+(i)).value)
  	    AuctionLink[i]  =spacetrim($('link'+(i)).value)
  	    AuctionDescrp[i]=$('cap'+(i)).value.replace('"','&amp;#34;').replace("'",'&amp;#39;')
	  
	    if (!AuctionDescrp[i]){if ($('defaultCaption')){AuctionDescrp[i]=$('defaultCaption').value}}
		// if the page is too slow loading, the default caption field wont be built on first visit here
  	    }
	}

}

function preloader() {
 	//importImages();
	fetchAuctionArray();
	$('showsampleimages').innerHTML=""

    	for (var i=1; i<AuctionThumb.length; i++){
	  if (AuctionThumb[i]){
	    $('showsampleimages').innerHTML=$('showsampleimages').innerHTML+
	    ' <img id="preview'+i+'" src="'+AuctionThumb[i]+'" alt='+i+' >'
    	  }
	}
}


	

function readDim(){
	sliderWidthRatio=0; maxThRatio=0; sameRatio=true; var tempRatio=0
	for (var i=1; i<=20; i++){
	if ($('preview'+i)){
	    thRat[i]=(Math.round(1000*$('preview'+i).offsetWidth/$('preview'+i).offsetHeight))/1000
	    sliderWidthRatio=sliderWidthRatio+thRat[i]
	    if (thRat[i]>maxThRatio){maxThRatio=thRat[i]}
	    //-- use this flag to determine if images are all the same size
	    if (tempRatio==0) {tempRatio=thRat[i]} else {if (thRat[i]!=tempRatio){sameRatio=false} }
	}}
}

function buildSlider() { 
	readDim()
	j=0; 

  	for (var i=1; i<AuctionThumb.length; i++){
	    if (AuctionThumb[i]!=""){j++;
		CrossSellimages[j]='<a href="'+AuctionLink[i]+'" target=_blank>'+
		'<img src="'+AuctionThumb[i]+'"  height="'+thHt+'" hspace="'+hSpc+'"  width="'+Math.round(thHt*thRat[i])+'" vspace="'+vSpc+'" border="0" '+
		' style="border:'+thBorderWid+'px '+thBorderColor+' solid;"'+
		' onmouseover="thumbwow( this.alt, this.offsetLeft, this.offsetWidth,  this.title)" '+
		' title="'+AuctionDescrp[i]+'" alt="'+i+'" ></a>'
	    } 
	    thCnt=j
	}

    CrossSellStrip='<nobr>'+CrossSellimages.join("")+'</nobr>'

  //loadSliders
	slider1=$("slidegroup1")
	slider2=$("slidegroup2")
	slider1.innerHTML=CrossSellStrip	
	slider2.innerHTML=CrossSellStrip


  //resizeSlider
	sliderwidth=Math.round(sliderWidthRatio*thHt+(thCnt*(hSpc+thBorderWid)*2))
	if ((sliderwidth-(maxThRatio*thHt)-hSpc*2)<parseInt(gallerywidth)){gallerywidth=""+Math.round(Math.abs(sliderwidth-(maxThRatio*thHt)-hSpc*2))}
	$('CustomGalWid').value=gallerywidth
	slider1.style.left="0px"  	
	slider2.style.left=sliderwidth+"px" 
}

function slideleft(){
	if (parseInt(slider1.style.left)>(sliderwidth*(-1)))  //not yet offscreen so still go left
	  {slider1.style.left=(parseInt(slider1.style.left)+scrollamount)+"px"} //so move left
	else
	  {slider1.style.left=(parseInt(slider2.style.left)+sliderwidth+scrollamount)+"px"} //else move to caboose
	if (parseInt(slider2.style.left)>(sliderwidth*(-1)))  
	  {slider2.style.left=(parseInt(slider2.style.left)+scrollamount)+"px"}
	else
	  {slider2.style.left=(parseInt(slider1.style.left)+sliderwidth)+"px"}
}


function thumbwow(num,thumOffset,thumSize, label){
	//--- use the image offset to locate the blowup
	if (parseInt(slider1.style.left)<=0) {
	    if (thumOffset+parseInt(slider1.style.left)>0-thumSize) {leftstart=thumOffset+parseInt(slider1.style.left)}
	    else{leftstart=thumOffset+parseInt(slider2.style.left)}
	}
	else{
	    if (thumOffset+parseInt(slider2.style.left)>0-thumSize) {leftstart=thumOffset+parseInt(slider2.style.left)}
	    else{leftstart=thumOffset+parseInt(slider1.style.left)}
	}
	$("blowup").style.left=leftstart+thBorderWid+Math.round((thumSize-thumSize/thRatio-borderWidth)/2 )  

	var innercode='<a href="'+AuctionLink[num]+'" title="'+label+'" target=_blank>'+
		'<img src="'+AuctionThumb[num]+'"  height="'+lgHt+'" border="0" ></a>'

	$("blowup").innerHTML=innercode
	$("blowup").style.visibility="visible"
	$("slidelabel").innerHTML=label
}

function unwow(){
	$("blowup").style.visibility="hidden"
	$('slidelabel').innerHTML=$('slidelabel').title
}



var langComment = new Array(10) // add language specific text strings for the output code
function initXsell(languagetext){
	// read in langComment[0] thru 9
}

function MakeCodes(){
  // if variable images, then add the array to the list
  // if fixed widths, then don't add the array, but the code that looks for the 
  // variable should be told to use a fixed width if the arrayed variable is not present.
  // Had to break the img tag and table tag for blogger/blogspot

  if ($("Multi").checked){key="_"+Math.round(1000*Math.random());var multi=true} else{key=""; var multi=false}
  galleryCode=""	
  galleryCode=galleryCode+'\n <!--   BEGIN SLIDE SHOW  -->'
  galleryCode=galleryCode+'\n <div style="font-family:arial;font-size:2px;color:#808080;text-align:center;"><'+'script language="javascript1.2">/*<!--;*/'
  galleryCode=galleryCode+'\n /* ===========================================	*/'
  if (multi==true) 
  {galleryCode=galleryCode+'\n /*     Free multi-copy cross-sell gallery from	*/'}
  else
  {galleryCode=galleryCode+'\n /*     Free cross-sell gallery from      	*/'}
  galleryCode=galleryCode+'\n /*     http://www.isdntek.com/etools.htm  	*/'
  galleryCode=galleryCode+'\n /*     copyright © 2005 ISDN*tek           	*/'
  galleryCode=galleryCode+'\n /*     Do not remove this notice.          	*/'
  galleryCode=galleryCode+'\n /* ===========================================	*/'
  galleryCode=galleryCode+'\n /*     This code has been tested in       	*/'
  galleryCode=galleryCode+'\n /*     Internet Explorer 6, FireFox 1,    	*/'
  galleryCode=galleryCode+'\n /*     Netscape 7, Opera 7, and eBay      	*/'
  galleryCode=galleryCode+'\n /* ===========================================	*/'

  galleryCode=galleryCode+'\n; var AuctionThum'+key+'=new Array() '
  galleryCode=galleryCode+'\n; var AuctionLink'+key+'=new Array() '
  galleryCode=galleryCode+'\n; var AuctionDesc'+key+'=new Array() '

  galleryCode=galleryCode+'\n; var ImgWidRatio'+key+'=new Array() '
  if (sameRatio==true) {galleryCode=galleryCode+'\n;     ImgWidRatio'+key+'[0]="'+thRat[1]+'" '}
  		  else {galleryCode=galleryCode+'\n;     ImgWidRatio'+key+'[0]="1" '}
  galleryCode=galleryCode+'\n;'
  galleryCode=galleryCode+'\n /* ===========================================	*/'
  galleryCode=galleryCode+'\n /*  ADD AUCTION NUMBERS AND DESCRIPTIONS   	*/'
  galleryCode=galleryCode+'\n /* ===========================================	*/'
  galleryCode=galleryCode+'\n /*  Change the values below to add           	*/'
 
  galleryCode=galleryCode+'\n /*  each thumbnail image, link, and description.	*/'

  galleryCode=galleryCode+'\n /*  Extra sets should be deleted. More can be added.	*/'
  galleryCode=galleryCode+'\n /*  Apostrophes and Quotes should be avoided, or else	*/'
  galleryCode=galleryCode+'\n /*  the following substitutions should be made:	*/'
  galleryCode=galleryCode+'\n /*  Apostrophe should be replaced with &amp;#39; 	*/'
  galleryCode=galleryCode+'\n /*  Quote should be replaced with &amp;#34;      	*/'

  galleryCode=galleryCode+'\n /* ==========================================	*/'


  for (var i=1; i<AuctionThumb.length; i++){
     if(AuctionThumb[i]!=""){
  	galleryCode=galleryCode+'\n; AuctionThum'+key+'['+i+']="'+AuctionThumb[i]+'" '
  	galleryCode=galleryCode+'\n; AuctionLink'+key+'['+i+']="'+AuctionLink[i]+'" '
  	galleryCode=galleryCode+'\n; AuctionDesc'+key+'['+i+']="'+AuctionDescrp[i]+'" '
  	if (sameRatio==false) {galleryCode=galleryCode+'\n; ImgWidRatio'+key+'['+i+']="'+thRat[i]+'" '}
      }
  }

  galleryCode=galleryCode+'\n; '  
  galleryCode=galleryCode+'\n /* ===========================================	*/'
  galleryCode=galleryCode+'\n /*          SET UP APPEARANCE    		*/'
  galleryCode=galleryCode+'\n /* ===========================================	*/'
  galleryCode=galleryCode+'\n; var scrollspeed'+key+' ="'+scrollspeed+ '" '
  galleryCode=galleryCode+'\n; var slideborder'+key+' ="'+slideborder+ '" '
  galleryCode=galleryCode+'\n; var slidebgcolor'+key+'="'+slidebgcolor+'" '
  galleryCode=galleryCode+'\n; var textcolor'+key+'   ="'+textcolor+   '" '
  galleryCode=galleryCode+'\n; var gallerywidth'+key+'="'+gallerywidth+'" '
  galleryCode=galleryCode+'\n; '  
  galleryCode=galleryCode+'\n /* ===========================================	*/'
  galleryCode=galleryCode+'\n /*     DO NOT EDIT BELOW THIS LINE 		*/'
  galleryCode=galleryCode+'\n /* ===========================================	*/'
  //galleryCode=galleryCode+'\n /*     '+langComment[0]+'      */'
  galleryCode=galleryCode+'\n var slider1'+key+', slider2'+key+', maxWid'+key+'=0; var sliderwidth'+key+'=0; '
  galleryCode=galleryCode+'\n var quot="'+quot+'"; var scrollamount'+key+'=-1; var thCnt'+key+'=0; '
  galleryCode=galleryCode+'\n var CrossSellimages'+key+'=new Array();'
  galleryCode=galleryCode+'\n function $(v){return document.getElementById(v)};' 

  galleryCode=galleryCode+'\n for (var i=1; i<=AuctionThum'+key+'.length; i++){if (AuctionThum'+key+'[i]){thCnt'+key+'++;'
  galleryCode=galleryCode+'\n	if (!ImgWidRatio'+key+'[i]) {ImgWidRatio'+key+'[i]=ImgWidRatio'+key+'[0]};'
  galleryCode=galleryCode+'\n	CrossSellimages'+key+'[thCnt'+key+']='+quot+'<a href="'+quot+'+AuctionLink'+key+'[i]+'+quot+'" target="_blank">'+quot+'+'
  galleryCode=galleryCode+'\n	'+quot+'<img src="'+quot+'+AuctionThum'+key+'[i]+'+quot+'"  width="'+quot+'+Math.round('+thHt+'*ImgWidRatio'+key+'[i])+'+quot+'" height="'+thHt+'" hspace="'+hSpc+'" vspace="'+vSpc+'" border="0" '+quot+'+'
  if (thBorderWid){  		galleryCode=galleryCode+'\n	'+quot+' style="border:'+thBorderWid+'px '+quot+'+slideborder'+key+'+'+quot+' solid;"'+quot+'+'    }
  galleryCode=galleryCode+'\n	'+quot+' onmouseover="thumbwow'+key+'(this.alt,this.offsetLeft,this.offsetWidth,'+quot+'+quot+AuctionDesc'+key+'[i]+quot+'+quot+')" '+quot+'+'
  galleryCode=galleryCode+'\n	'+quot+' title="" alt="'+quot+'+i+'+quot+'" /></a>'+quot+';'
  galleryCode=galleryCode+'\n	sliderwidth'+key+'=sliderwidth'+key+'+Math.round(('+thHt+'*ImgWidRatio'+key+'[i])+'+(hSpc+thBorderWid)*2+');'
  galleryCode=galleryCode+'\n	if (ImgWidRatio'+key+'[i]>maxWid'+key+'){maxWid'+key+'=ImgWidRatio'+key+'[i]}' 
  galleryCode=galleryCode+'\n }};'

  galleryCode=galleryCode+'\n var sliderheight'+key+'="'+(lgHt+(vSpc*2))+'"; '
  galleryCode=galleryCode+'\n var CrossSellStrip'+key+'='+quot+'<span style="white-space:nowrap">'+quot+'+CrossSellimages'+key+'.join("")+'+quot+'</span>'+quot+';' 
  galleryCode=galleryCode+'\n if (sliderwidth'+key+'-maxWid'+key+'*'+thHt+'<parseInt(gallerywidth'+key+')){gallerywidth'+key+'=Math.abs(sliderwidth'+key+'-maxWid'+key+'*'+thHt+')};'


  galleryCode=galleryCode+'\n function setupGallery'+key+'(){'
  galleryCode=galleryCode+'\n	document.write('+quot+'<table align="center" border="0" cellspacing="0" cellpadding="0" style="position:relative; border:'+borderWidth+'px '+quot+'+slideborder'+key+'+'+quot+' solid; background-color:'+quot+'+slidebgcolor'+key+'+'+quot+'; width:'+quot+'+(parseInt(gallerywidth'+key+')+'+borderWidth+')+'+quot+'px; height:'+(lgHt+(vSpc*2)+borderWidth+thBorderWid*2)+'px;"><tr><td valign="top" align="center">'+quot+');'
  galleryCode=galleryCode+'\n	document.write('+quot+'<div style="position:relative;width:'+quot+'+gallerywidth'+key+'+'+quot+'px;height:'+Math.round(lgHt+(vSpc+thBorderWid)*2+borderWidth/2)+'px;overflow:hidden;">'+quot+');'
  galleryCode=galleryCode+'\n	document.write('+quot+'<div style="position:absolute;left:0px;bottom:0px;width:'+quot+'+gallerywidth'+key+'+'+quot+'px;height:'+Math.round(lgHt+(vSpc+thBorderWid)*2+borderWidth/2)+'px;" onMouseover="scrollamount'+key+'=0" onMouseout="scrollamount'+key+'=-1">'+quot+');'
  galleryCode=galleryCode+'\n	document.write('+quot+'<div id="slidegroup1'+key+'" style="position:absolute;left:0px;bottom:'+Math.round(((lgHt+borderWidth)-thHt)/2-vSpc+thBorderWid)+'px;"></div>'+quot+');'
  galleryCode=galleryCode+'\n	document.write('+quot+'<div id="slidegroup2'+key+'" style="position:absolute;left:-1000px;bottom:'+Math.round(((lgHt+borderWidth)-thHt)/2-vSpc+thBorderWid)+'px;"></div>'+quot+');'
  galleryCode=galleryCode+'\n	document.write('+quot+'<div id="blowup'+key+'" style="position:absolute;left:0px;bottom:'+(thBorderWid*2)+'px;visibility:hidden;border:'+(borderWidth/2)+'px '+quot+'+slideborder'+key+'+'+quot+' solid;" onmouseout="unwow'+key+'()"></div>'+quot+');'
  galleryCode=galleryCode+'\n	document.write('+quot+'</div></div>'+quot+');'
  galleryCode=galleryCode+'\n	document.write('+quot+'</td></tr><tr><td align="center" id="slidelabel'+key+'" style="padding:2px; font-family:'+slideFontFace+'; font-size:'+slideFontSize+'; font-weight:'+slideFontBolded+'; color:'+quot+'+textcolor'+key+'+'+quot+'" title="'+replaceQuote($('defaultCaption').value)+'">'+quot+');'
  galleryCode=galleryCode+'\n	document.write('+quot+replaceQuote($('defaultCaption').value)+quot+');'
  galleryCode=galleryCode+'\n	document.write('+quot+'</td></tr></table>'+quot+');'
  galleryCode=galleryCode+'\n	document.write('+quot+xsell+quot+')'
  galleryCode=galleryCode+'\n };'

  galleryCode=galleryCode+'\n function loadimages'+key+'(){'
  galleryCode=galleryCode+'\n	slider1'+key+'=$("slidegroup1'+key+'");'
  galleryCode=galleryCode+'\n	slider2'+key+'=$("slidegroup2'+key+'");'
  galleryCode=galleryCode+'\n	slider1'+key+'.innerHTML=CrossSellStrip'+key+';	'
  galleryCode=galleryCode+'\n	slider2'+key+'.innerHTML=CrossSellStrip'+key+';	'
  galleryCode=galleryCode+'\n	slider2'+key+'.style.left=""+sliderwidth'+key+'+"px";  	'
  galleryCode=galleryCode+'\n	startaction'+key+'=setInterval("slideleft'+key+'()",parseInt(scrollspeed'+key+'));'
  galleryCode=galleryCode+'\n };'

  galleryCode=galleryCode+'\n function slideleft'+key+'(){'
  galleryCode=galleryCode+'\n	if (parseInt(slider1'+key+'.style.left)>(sliderwidth'+key+'*(-1)))  '
  galleryCode=galleryCode+'\n	  {slider1'+key+'.style.left=(parseInt(slider1'+key+'.style.left)+scrollamount'+key+')+"px"}'
  galleryCode=galleryCode+'\n	else'
  galleryCode=galleryCode+'\n	  {slider1'+key+'.style.left=(parseInt(slider2'+key+'.style.left)+sliderwidth'+key+'+scrollamount'+key+')+"px"}'
  
  galleryCode=galleryCode+'\n	if (parseInt(slider2'+key+'.style.left)>(sliderwidth'+key+'*(-1)))  '
  galleryCode=galleryCode+'\n	  {slider2'+key+'.style.left=(parseInt(slider2'+key+'.style.left)+scrollamount'+key+')+"px"}'
  galleryCode=galleryCode+'\n	else'
  galleryCode=galleryCode+'\n	  {slider2'+key+'.style.left=(parseInt(slider1'+key+'.style.left)+sliderwidth'+key+')+"px"}'
  galleryCode=galleryCode+'\n };'
  
 
  galleryCode=galleryCode+'\n function thumbwow'+key+'(num,thumOffset,thumSize,label){'
  galleryCode=galleryCode+'\n	if (parseInt(slider1'+key+'.style.left)<=0){'
  galleryCode=galleryCode+'\n	  if (thumOffset+parseInt(slider1'+key+'.style.left)>0-thumSize){leftstart=thumOffset+parseInt(slider1'+key+'.style.left)}else{leftstart=thumOffset+parseInt(slider2'+key+'.style.left)}'
  galleryCode=galleryCode+'\n	}'
  galleryCode=galleryCode+'\n	else {'
  galleryCode=galleryCode+'\n	  if (thumOffset+parseInt(slider2'+key+'.style.left)>0-thumSize){leftstart=thumOffset+parseInt(slider2'+key+'.style.left)}else{leftstart=thumOffset+parseInt(slider1'+key+'.style.left)}'
  galleryCode=galleryCode+'\n	};'
  galleryCode=galleryCode+'\n	$("blowup'+key+'").style.left=leftstart+'+thBorderWid+'+(Math.round((thumSize-thumSize/'+thRatio+'-'+borderWidth+')/2))+"px";'

  galleryCode=galleryCode+'\n	$("blowup'+key+'").innerHTML='+quot+'<a href="'+quot+'+AuctionLink'+key+'[num]+'+quot+'" title="'+quot+'+label+'+quot+'" target="_blank">'+quot+'+'
  galleryCode=galleryCode+'\n		'+quot+'<img src="'+quot+'+AuctionThum'+key+'[num]+'+quot+'" height="'+lgHt+'" border="0" /></a>'+quot+';'

  galleryCode=galleryCode+'\n	$("blowup'+key+'").style.visibility="visible";'
  galleryCode=galleryCode+'\n	$("slidelabel'+key+'").innerHTML=label;'
  galleryCode=galleryCode+'\n };'
 
  galleryCode=galleryCode+'\n function unwow'+key+'(){$("blowup'+key+'").style.visibility="hidden";'
  galleryCode=galleryCode+'\n	$("slidelabel'+key+'").innerHTML=$("slidelabel'+key+'").title'
  galleryCode=galleryCode+'\n };'
 
  galleryCode=galleryCode+'\n setupGallery'+key+'();'
  galleryCode=galleryCode+'\n loadimages'+key+'();'
  galleryCode=galleryCode+'\n /* ===========================================	*/'
  galleryCode=galleryCode+'\n /*     End cross-sell gallery			*/'
  galleryCode=galleryCode+'\n /*     http://www.isdntek.com/etools.htm 	*/'
  galleryCode=galleryCode+'\n /*     copyright © 2005 ISDN*tek	    	*/'
  galleryCode=galleryCode+'\n /* ===========================================	*/'
  galleryCode=galleryCode+'\n //--><'+'/script>xsellx</div>'
  galleryCode=galleryCode+'\n <!--  END SLIDE SHOW -->'
	
  $('HtmlCode').value=galleryCode
  $('codesize').innerHTML=galleryCode.length
}


function CompressCodes(){

  if ($("Multi").checked){key="_"+Math.round(1000*Math.random()); var multi=true} else{key="";var multi=false}
  galleryCode=""	
  galleryCode=galleryCode+'\n <!--   BEGIN SLIDE SHOW  -->'
  galleryCode=galleryCode+'\n <div style="font-family:arial;font-size:2px;color:#808080; text-align:center;"><'+'script language="javascript1.2">/*<!--;*/'
  galleryCode=galleryCode+'\n /* ===========================================	*/'
  if (multi==true) 
  {galleryCode=galleryCode+'\n /*     Free multi-copy cross-sell gallery from	*/'}
  else
  {galleryCode=galleryCode+'\n /*     Free cross-sell gallery from 		*/'}
  galleryCode=galleryCode+'\n /*     http://www.isdntek.com/etools.htm  	*/'
  galleryCode=galleryCode+'\n /*     copyright © 2005 ISDN*tek	      	*/'
  galleryCode=galleryCode+'\n /*     Do not remove this notice.	      	*/'
  galleryCode=galleryCode+'\n /* ===========================================	*/'

  	galleryCode=galleryCode+'\n var XaT'+key+'=new Array(""'
    for (var i=1; i<AuctionThumb.length; i++){if(AuctionThumb[i]!=""){
  	galleryCode=galleryCode+',"'+AuctionThumb[i]+'"'
  	}
      }
	galleryCode=galleryCode+');'
  	galleryCode=galleryCode+'\n var XaL'+key+'=new Array(""'
    for (var i=1; i<AuctionThumb.length; i++){if(AuctionThumb[i]){
  	galleryCode=galleryCode+',"'+AuctionLink[i]+'"'
  	}
      }
	galleryCode=galleryCode+');'
  	galleryCode=galleryCode+'\n var XaD'+key+'=new Array(""'
    for (var i=1; i<AuctionThumb.length; i++){if(AuctionThumb[i]){
  	galleryCode=galleryCode+',"'+AuctionDescrp[i]+'"'
  	}
      }
	galleryCode=galleryCode+');'
    if (sameRatio==false) {
  	galleryCode=galleryCode+'\n var XaW'+key+'=new Array(""'
      for (var i=1; i<AuctionThumb.length; i++){if(AuctionThumb[i]){
  	galleryCode=galleryCode+',"'+thRat[i]+'"'
  	}
       } 
	galleryCode=galleryCode+');'
      } else {galleryCode=galleryCode+'\n var XaW'+key+'=new Array("'+maxThRatio+'");'}


 
  galleryCode=galleryCode+'\n /* ===========================================	*/'

  galleryCode=galleryCode+'\n var Xsl1'+key+', Xsl2'+key+';'
  galleryCode=galleryCode+' var quot="'+quot+'"; var Xsc'+key+'=-1; var XsI'+key+'=new Array();	'
  galleryCode=galleryCode+'\n function $'+key+'(v){return document.getElementById(v)};' 

  galleryCode=galleryCode+'\n for (var i=1; i<XaT'+key+'.length; i++){if (XaT'+key+'[i]){'
    if (sameRatio==true) {ThumbWidth=Math.round(thHt*maxThRatio)}else {
  ThumbWidth=quot+'+Math.round('+thHt+'*XaW'+key+'[i])+'+quot
  galleryCode=galleryCode+'\n	if (!XaW'+key+'[i]) {XaW'+key+'[i]=XaW'+key+'[0]};'
    }
  galleryCode=galleryCode+'\n	XsI'+key+'[i]='+quot+'<a href="'+quot+'+XaL'+key+'[i]+'+quot+'" target="_blank">'+quot+'+'
  galleryCode=galleryCode+'\n	'+quot+'<img src="'+quot+'+XaT'+key+'[i]+'+quot+'" width="'+ThumbWidth+'" height="'+thHt+'" hspace="'+hSpc+'" vspace="'+vSpc+'" border="0" '+quot+'+'
  if (thBorderWid){  		galleryCode=galleryCode+'\n	'+quot+' style="border:'+thBorderWid+'px '+slideborder+' solid;"'+quot+'+'    }
  galleryCode=galleryCode+'\n	'+quot+' onmouseover="Xwow'+key+'(this.alt,this.offsetLeft,this.offsetWidth,'+quot+'+quot+XaD'+key+'[i]+quot+'+quot+')" '+quot+'+'
  galleryCode=galleryCode+'\n	'+quot+' title="" alt="'+quot+'+i+'+quot+'" /></a>'+quot
  galleryCode=galleryCode+'\n }};'

  galleryCode=galleryCode+'\n var Xgp'+key+'='+quot+'<span style="white-space:nowrap">'+quot+'+XsI'+key+'.join("")+'+quot+'</span>'+quot+';' 


  galleryCode=galleryCode+'\n function setupGallery'+key+'(){'
  galleryCode=galleryCode+'\n	document.write('+quot+'<table align="center" border="0" cellspacing="0" cellpadding="0" style="position:relative; border:'+borderWidth+'px '+slideborder+' solid; background-color:'+slidebgcolor+'; width:'+(parseInt(gallerywidth)+borderWidth)+'px; height:'+(lgHt+(vSpc*2)+borderWidth+thBorderWid*2)+'px;"><tr><td valign="top" align="center">'+quot+'+'
  galleryCode=galleryCode+'\n	'+quot+'<div style="position:relative;width:'+gallerywidth+'px;height:'+Math.round(lgHt+(vSpc+thBorderWid)*2+borderWidth/2)+'px;overflow:hidden;">'+quot+'+'
  galleryCode=galleryCode+'\n	'+quot+'<div style="position:absolute;left:0px;bottom:0px;width:'+gallerywidth+'px;height:'+Math.round(lgHt+(vSpc+thBorderWid)*2+borderWidth/2)+'px;" onMouseover="Xsc'+key+'=0" onMouseout="Xsc'+key+'=-1">'+quot+'+'
  galleryCode=galleryCode+'\n	'+quot+'<div id="sGp1'+key+'" style="position:absolute;width:'+sliderwidth+';left:0px;bottom:'+Math.round(((lgHt+borderWidth)-thHt)/2-vSpc+thBorderWid)+'px;"></div>'+quot+'+'
  galleryCode=galleryCode+'\n	'+quot+'<div id="sGp2'+key+'" style="position:absolute;width:'+sliderwidth+';left:-1000px;bottom:'+Math.round(((lgHt+borderWidth)-thHt)/2-vSpc+thBorderWid)+'px;"></div>'+quot+'+'
  galleryCode=galleryCode+'\n	'+quot+'<div id="blowup'+key+'" style="position:absolute;left:0px;bottom:'+(thBorderWid*2)+'px; visibility:hidden; border:'+(borderWidth/2)+'px '+slideborder+' solid;" onmouseout="unwow'+key+'()"></div>'+quot+'+'
  galleryCode=galleryCode+'\n	'+quot+'</div></div></td></tr><tr><td align="center" id="sLbl'+key+'" style="padding:2px; font-family:'+slideFontFace+'; font-size:'+slideFontSize+'; font-weight:'+slideFontBolded+'; color:'+textcolor+'" title="'+replaceQuote($('defaultCaption').value)+'">'+quot+'+'
  galleryCode=galleryCode+'\n	'+quot+replaceQuote($('defaultCaption').value)+quot+'+'
  galleryCode=galleryCode+'\n	'+quot+'</td></tr></table>'+xsell+quot+')'
  galleryCode=galleryCode+'\n };'

  galleryCode=galleryCode+'\n function loadimages'+key+'(){'
  galleryCode=galleryCode+'\n	Xsl1'+key+'=$'+key+'("sGp1'+key+'");'
  galleryCode=galleryCode+    ' Xsl2'+key+'=$'+key+'("sGp2'+key+'");'
  galleryCode=galleryCode+'\n	Xsl1'+key+'.innerHTML=Xgp'+key+';'
  galleryCode=galleryCode+    ' Xsl2'+key+'.innerHTML=Xgp'+key+';'
  galleryCode=galleryCode+'\n	Xsl2'+key+'.style.left="'+sliderwidth+'px";'
  galleryCode=galleryCode+    ' startaction'+key+'=setInterval("Xmov'+key+'()",'+parseInt(scrollspeed)+');'
  galleryCode=galleryCode+'\n };'
  galleryCode=galleryCode+'\n function XsLt(n){n==1?a=parseInt(Xsl1'+key+'.style.left):a=parseInt(Xsl2'+key+'.style.left);return a};'

  galleryCode=galleryCode+'\n function Xmov'+key+'(){'
  galleryCode=galleryCode+'\n	if (XsLt(1)>('+sliderwidth*(-1)+'))  '
  galleryCode=galleryCode+'\n	  {Xsl1'+key+'.style.left=(XsLt(1)+Xsc'+key+')+"px"}'
  galleryCode=galleryCode+'\n	else{Xsl1'+key+'.style.left=(XsLt(2)+'+sliderwidth+'+Xsc'+key+')+"px"};'
  
  galleryCode=galleryCode+'\n	if (XsLt(2)>('+sliderwidth*(-1)+'))  '
  galleryCode=galleryCode+'\n	  {Xsl2'+key+'.style.left=(XsLt(2)+Xsc'+key+')+"px"}'
  galleryCode=galleryCode+'\n	else{Xsl2'+key+'.style.left=(XsLt(1)+'+sliderwidth+')+"px"}'
  galleryCode=galleryCode+'\n };'
  
 
  galleryCode=galleryCode+'\n function Xwow'+key+'(num,Xto,Xtw,label){'
  galleryCode=galleryCode+'\n	if (XsLt(1)<=0){ if (Xto+XsLt(1)>0-Xtw){xlt=Xto+XsLt(1)}else{xlt=Xto+XsLt(2)}}'
  galleryCode=galleryCode+'\n	else {if (Xto+XsLt(2)>0-Xtw){xlt=Xto+XsLt(2)}else{xlt=Xto+XsLt(1)}}'
  galleryCode=galleryCode+'\n	$'+key+'("blowup'+key+'").style.left=xlt+'+thBorderWid+'+(Math.round((Xtw-Xtw/'+thRatio+'-'+borderWidth+')/2))+"px";'

  galleryCode=galleryCode+'\n	$'+key+'("blowup'+key+'").innerHTML='+quot+'<a href="'+quot+'+XaL'+key+'[num]+'+quot+'" title="'+quot+'+label+'+quot+'" target="_blank">'+quot+'+'
  galleryCode=galleryCode+'\n		'+quot+'<img src="'+quot+'+XaT'+key+'[num]+'+quot+'" height="'+lgHt+'" border="0" /></a>'+quot+';'

  galleryCode=galleryCode+'\n	$'+key+'("blowup'+key+'").style.visibility="visible";'
  galleryCode=galleryCode+'\n	$'+key+'("sLbl'+key+'").innerHTML=label;'
  galleryCode=galleryCode+'\n };'
 
  galleryCode=galleryCode+'\n function unwow'+key+'(){$'+key+'("blowup'+key+'").style.visibility="hidden";'
  galleryCode=galleryCode+'\n	$'+key+'("sLbl'+key+'").innerHTML=$'+key+'("sLbl'+key+'").title'
  galleryCode=galleryCode+'\n };'
 
  galleryCode=galleryCode+'\n setupGallery'+key+'();loadimages'+key+'();'
  galleryCode=galleryCode+'\n /* ===========================================	*/'
  galleryCode=galleryCode+'\n /*     End cross-sell gallery		   	*/'
  galleryCode=galleryCode+'\n /* ===========================================	*/'
  galleryCode=galleryCode+'\n //--><'+'/script>xsellx</div>'
  galleryCode=galleryCode+'\n <!--  END SLIDE SHOW -->'
	
  $('HtmlCode').value=galleryCode
  $('codesize').innerHTML=galleryCode.length
}



//--end
