famedescriptions=new Array("Not famous at all -- just randomly turned up on my computer","Tiny name celeb: Couldn't bump Phil from marketing on a restaurant reservation list","Small name celeb: Might actually not snub invitation to SAG Awards<br>Possibilities:<br>1. In a profession where few are very famous, like a female athlete<br>2. Was medium to big name but faded in recent years<br>3. Still working her way up -- give her time", "Medium or medium-big name celeb: Wouldn't be caught dead endorsing your discount camel store", "Big name celeb: A household name like Bounce, but not as good at preventing static cling", "Huge name celeb: If you don't know who this is, it's time to come out of your Unabomber-style shack")

clothingdescriptions=new Array("Margaret Thatcher called her uptight","Even men's magazines basically have her in a parka","Doesn't really strip for publicity, but does for her work","Occasionally takes something off, maybe caught by paparazzi too","Pretty easy to find hot magazine shots of","Impossible to find with clothes on","More famous as a nude or nearly nude pin-up than for her actual work")

function forcedigits(picnumber,digits) {
	picnumber=picnumber+""
	while (picnumber.length<digits) {
		picnumber="0"+picnumber
	}
	return picnumber
}

function findbestresult(styleWI, styleDD, styleDB) {
	var combination = styleWI ? styleWI : 0;
	if (styleDD && (!combination || (combination > styleDD)))
		combination = styleDD;
	return styleDB && (!combination || (combination > styleDB)) ? styleDB : combination;
}

function getbrowserwidth() {
	return findbestresult (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}

function formatlink(girlcode) {
	var fullpage=haspage(girlcode)
	var gletter=girlletter(girlcode)
	var ending = fullpage ? girlcode+".html" : "#"+girlcode
	var fulllink = gletter+"/"+ending
	return fulllink
}

function mainpagethumbs(allcodes) {
	var windwidth=getbrowserwidth() 
	var numofcolumns=2
	if (windwidth>=600) {numofcolumns=Math.floor(windwidth/200)};
	var girlcode
	var girlinfo
	var girladdress
	var girlnumber
	var numofgirls=allcodes.length
	var numofrows=Math.ceil(numofgirls/numofcolumns)
	document.write("<table align=center>")
	for (var rownumber=0;rownumber<numofrows;rownumber++) {
		document.write("<tr>")
		for (var columnnumber=0;columnnumber<numofcolumns;columnnumber++) {
			girlnumber=numofcolumns*rownumber+columnnumber
			if (girlnumber<numofgirls) {
				girlcode=allcodes[girlnumber]
				girlinfo=getinfo(girlcode)
				girladdress=formatlink(girlcode,girlinfo[1],girlinfo[2])
				document.write("<td><a href='",girladdress,"'><img src='images/",girlcode,".jpg'></a>")
				document.write("</td><td width=100 valign=center><a href='",girladdress,"'>",girlinfo[0],"</a></td>")
			};
		};
		document.write("</tr>")
	};
	document.write("</table>")
}

function onoff(numon,outof,otext) {
	document.write("<table cellpadding=0 cellspacing=0><tr><td><b>"+otext+"</b>&nbsp;&nbsp;</td>");
	for (var ocount=1;ocount<=outof;ocount++) {
		if (ocount<=numon) {
			document.write("<td><img src='../on.jpg'></td>");
		} else {
			document.write("<td><img src='../off.jpg'></td>");
		};
	};
	document.write("</tr></table>");
};

function intro(gname,gcode,gdesc,fame,clothing) {
	document.write("<a name='"+gcode+"'></a>")
	document.write("<font size=4><b>"+gname+"</b></font><br>")
	if (fame>=0) {
		onoff(fame,5,"Fame Level (U.S.):")
		document.write(famedescriptions[fame],"<br>")
		document.write("<b>Clothing Level:</b> ",clothingdescriptions[clothing],"<br>")
	}
	document.write("<b>Comments:</b> "+gdesc+"<br>")
};

function typelist(bhlns,numpics) {
	bikini=Math.floor(bhlns/10000);
	bhlns-=bikini*10000;
	hbreasts=Math.floor(bhlns/1000);
	bhlns-=hbreasts*1000;
	lingerie=Math.floor(bhlns/100);
	bhlns-=lingerie*100;
	naked=Math.floor(bhlns/10);
	swimsuit=bhlns-naked*10;
	maxtype=0;
	if (bikini>0) {maxtype=1;};
	if (hbreasts>0) {maxtype=2;};
	if (lingerie>0) {maxtype=3;};
	if (naked>0) {maxtype=4;};
	if (swimsuit>0) {maxtype=5;};
	if (maxtype>0) {document.write(" - ");};
	if (bikini>0) {
		document.write("bikini");
		if (maxtype>1) {document.write(", ");};
	};
	if (hbreasts>0) {
		document.write("handbra");
		if (maxtype>2) {document.write(", ");};
	};
	if (lingerie>0) {
		document.write("lingerie");
		if (maxtype>3) {document.write(", ");};
	};
	if (naked>0) {
		document.write("naked");
		if (maxtype>4) {document.write(", ");};
	};
	if (swimsuit>0) {document.write("swimsuit");};
	if (numpics<1) {document.write(" (follow link)");};
	document.write("<br>");
};

function isnumber(character) {
	var numbers="1234567890"
	var findcharacter=numbers.indexOf(character)
	var testifnumber=(findcharacter<0)? 0 : 1
	return testifnumber
}

function getpagenumber() {
	var urlsplit=location.href.split(".html")
	var urlpieces=urlsplit.length
	if (urlpieces<2) {return 0}
	else {
		var urlstart=urlsplit[0]
		var urlstartlength=urlstart.length
		var lastfive=urlstart.substring(urlstartlength-5,urlstartlength)
		if (lastfive=="index") {return 0}
		else {
			var lastone=urlstart.substring(urlstartlength-1,urlstartlength)
			var testifnumber=isnumber(lastone)
			if (testifnumber<1) {return 1}
			else {return lastone*1}
		}
	}
}

function thumbs(girlcode,digits) {
	var pagenumber=getpagenumber()
	var gname=girlname(girlcode)
	var gletter=girlletter(girlcode)
	var numofpics=numberofpics(girlcode)
	var threshold= (pagenumber>0) ? 60 : 9
	var startnum=(pagenumber-1)*threshold+1
	startnum=(startnum<1) ? 1 : startnum
	var possibleend=startnum+threshold-1
	var endnum = (numofpics<possibleend) ? numofpics : possibleend
	var picnumformatted
	for(var picnumber=startnum;picnumber<=endnum;picnumber++) {
		picnumformatted=forcedigits(picnumber,digits)
		var linkaddress="../display.html?"+girlcode+","+gletter+","+picnumber+","+numofpics+","+digits
		document.write("<a href='",linkaddress,"'><img alt='",gname,"' src='thumbnails/")
		document.write(girlcode,picnumformatted,".jpg' hspace=3 vspace=3 border=1></a>");
	};
	// write link to other galleries
	if ((pagenumber>0)&&(numofpics>threshold)) {
		document.write("<br><table cellpadding=5 align=center><tr><td>")
		if (endnum<numofpics) {
			document.write("<a href='",girlcode,pagenumber+1,".html'>")
			document.write("<img src='../more.jpg'></a>")
		}
		document.write("</td><td>")
		var numofpages=Math.ceil(numofpics/threshold)
		var galleryarray=new Array()
		for (gallerynum=1;gallerynum<=numofpages;gallerynum++) {
			var filename=(gallerynum>1)? gallerynum : ""
			var filename=girlcode+filename+".html"
			var linktag="<a href='"+filename+"'>"
			var linktag=(gallerynum==pagenumber)? gallerynum : linktag+gallerynum+"</a>"
			galleryarray.push(linktag)
		}
		var gallerylist=galleryarray.join("&nbsp;&nbsp;")
		document.write(gallerylist)
		document.write("</td></tr></table>")
	}
	if (numofpics>0) {document.write("<br>")}
	document.write("<br>")
};

function thumbsnew(gname,gcode,gnum) {
	for(var gcount=1;gcount<=gnum;gcount++) {
		if (
			gcount<10) {var gpicnum="00"+gcount;
		} else if (gcount<100) {
			var gpicnum="0"+gcount;
		} else {var gpicnum=gcount;};
		document.write("<a href='"+gcode+gpicnum+".jpg' target='Picture'><img alt='"+gname+"' src='thumbnails/"+gcode+gpicnum+".jpg' hspace=3 vspace=3 border=1></a>");
	};
	if (gnum>0) {document.write("<br>");};
	document.write("<br>");
};

function link(gname,gcode) {
	document.write("<a href='#"+gcode+"'>"+gname+"</a><br>");
};

function output(gletter,digits) {
	var justletter=filterbyletter(allgirls,gletter)
	var justletter=sortcodesbylast(justletter)
	var numgirls=justletter.length
	var capletter=gletter.toUpperCase()
	document.write("<center><b><h3>",capletter,"</h3>")
	var gcode
	var gname
	var gfame
	var gclothing
	var gpics
	var fullphrase
	for (var girlnumber=0;girlnumber<numgirls;girlnumber++) {
		gcode=justletter[girlnumber]
		gname=girlname(gcode)
		document.write("<a href='#",gcode,"'>",gname,"</a><br>");
	}
	document.write("</b></center><br>")
	for(girlnumber=0;girlnumber<numgirls;girlnumber++) {
		gcode=justletter[girlnumber]
		document.write("<a name='"+gcode+"'></a>")
		gname=girlname(gcode)
		document.write("<font size=4><b>"+gname+"</b></font><br>")
		gfame=famelevel(gcode)
		if (gfame>=0) {
			document.write(famedescriptions[gfame],"<br>")
			gclothing=clothinglevel(gcode)
			document.write("<b>Clothing Level:</b> ",clothingdescriptions[gclothing],"<br>")
		}
		writedescription(gcode)
		gpics=numberofpics(gcode)
		if (gpics>9) {
			fullphrase="For more info on "+gname+" and her full gallery of "
			fullphrase=fullphrase+gpics+" pictures, follow link: <a href='"
			fullphrase=fullphrase+gcode+".html'>full "+gname+" page</a><br>"
			document.write(fullphrase)
		}
		thumbs(gcode,digits)
	}
	document.write("Pictures on this page (might have to visit full page):<br>")
	for(girlnumber=0;girlnumber<numgirls;girlnumber++) {
		gcode=justletter[girlnumber]
		clothingtypes(gcode)
	}
}

function outputnew() {
	numgirls=data.length/7;
	document.write("<center><b><h3>"+letter+"</h3>");
	for(var i=0;i<numgirls;i++) {link(data[7*i],data[7*i+1])};
	document.write("</b></center><br>");
	for(var i=0;i<numgirls;i++) {
		intro(data[7*i],data[7*i+1],data[7*i+3],data[7*i+5],data[7*i+6]);
		if (data[7*i+2]>9) {
			document.write("For more info on "+data[7*i]+" and her full gallery of "+data[7*i+2]+" pictures, follow link: <a href='"+data[7*i+1]+".html'>full "+data[7*i]+" page</a><br>");
			thumbsnew(data[7*i],data[7*i+1],9);
		} else {
			thumbsnew(data[7*i],data[7*i+1],data[7*i+2]);
		};
	};
	document.write("Pictures on this page (might have to visit full page):<br>");
	for(var i=0;i<numgirls;i++) {
		document.write(data[7*i]);
		typelist(data[7*i+4],data[7*i+2]);
	};
};
