var OtherNames = new Array();
var SortingDone=0;
var TempName="";
var nPlacehold=0;
var nNextPlace=0;
var NewGraphic="http://www.calstatela.edu/library/image/newdatabase.gif"
var Limiters=window.location.search;
Limiters=Limiters.substring(1,Limiters.length);
Limiters=CharSubstitute(Limiters,"+"," ");
document.write("<table cellpadding=\"5\" cellspacing=\"0\" width=\"660\" class=\"white-b\" border=\"1\"><tr><td width=\"100%\" colspan=\"3\">");
document.write("<img src=\"/library/image/symbols2.gif\" alt=\"symbol table\" border=\"1\" align=\"right\"><big><big><b style=\"color: #336666;\">&nbsp;" + PageTitle + "</b></big></big>");

var SectCount=0;
for (i=1;i<=NumDbs;i++)
	{
	if (DbNum[i]==0)
		{
		SectCount++;
		TempName=TempName + "<span style='white-space:nowrap;'>&nbsp;&nbsp;&nbsp;&nbsp;<a href='#" + SectCount + "'>" + altDescr[i] + "</a></span> ";
		}
	}
var MaxSects=SectCount;
if (SectCount>0)
	{
	document.write("<div style=\"width:400;margin:10px;padding:5px;background-color:#FAF0E6;border-width:thin; border-color:#660000; border-style:solid;\">" + TempName + "</div></td></tr>");
	}
document.write("<tr><td colspan='3' align='center' class='offwhite-b'>Use <img src='/library/image/v-sfx.gif' border='0' alt='SFX' align='absmiddle'></a> links in the databases to find full text articles.</td></tr>")
if (Limiters.length>5)
	{
	document.write("<tr class=\"offwhite-b\"><th colspan=\"3\" class=\"burgundy\">Limited by: " + CharSubstitute(Limiters,"&"," or ") + "</th>");
	}
SectCount=0;
DescrHold="";
var CountHold=0;
TempName="<tr class = \"offwhite-b\"><th>Type</th><th>Name</th><th>Description</th></tr>";
PrintDescr=false;
NumWritten=0;
for (i=1;i<=NumDbs;i++)
	{
	switch (DbNum[i])
		{
		case 0:
		SectCount++;
		DescrHold=altDescr[i];
		PrintDescr=true;
		break;
		case -1:
		if (PrintDescr)
			{
			PrintDescr=false;
			WriteHead(DescrHold);
			document.write(TempName);
			}
		for (q=1;q<=NumAllDbs;q++)
			{
			if (CheckType(q,altDescr[i]))
				{
				MakeRecord(q,"");
				NumWritten++;
				}
			}
		break;
		case -2:
		if (PrintDescr)
			{
			PrintDescr=false;
			WriteHead(DescrHold);
			}
		NumWritten++;
		document.write("<tr><td colspan=\"3\">" + altDescr[i] + "</td></tr>");
		break;
		default:
		if (Name[DbNum[i]]!="")
			{
			if (Limiters=="" || CheckType(DbNum[i],Limiters))
				{
				if (PrintDescr)
					{
					PrintDescr=false;
					WriteHead(DescrHold);
					document.write(TempName);
					}
				NumWritten++;
				MakeRecord(DbNum[i],altDescr[i]);
				}
			}
		}
	}
if (NumWritten==0)
	{
		document.write("<tr><th colspan=\"3\" class=\"red\">No Matching Databases Found</th></tr>");
	}
if (OurPicks!="")
	{
	document.write("<tr class = \"sand-b\"><th colspan=\"3\"><a href = \"" + OurPicks + "\" class=\"bur\">Recomended Web Sites</a></td></tr>");
	}
document.write("</table>");
for (c=(CountHold+1);c<=MaxSects;c++)
	{
	document.write("<a name=\"" + c + "\"> </a>");
	}

function WriteHead(Descrip)
	{
	document.write("<tr class = \"sand-b\"><th colspan=\"3\" class=\"burgundy\">");
	for (c=(CountHold+1);c<=SectCount;c++)
		{
		document.write("<a name=\"" + c + "\">");
		}
	document.write("<big>" + Descrip + "</big></th></tr>");
	CountHold=SectCount;
	}

function CheckType(y,Params)
	{
	nPlacehold=0;
	nNextPlace=0;
	TempNames="";
	Resultant=false;
	Params=CharSubstitute(Params,"+"," ");
	do
		{
		nNextPlace=Params.indexOf("&", nPlacehold);
		if (nNextPlace> -1)
			{
			TempNames= Params.substring(nPlacehold, nNextPlace);
			nPlacehold = nNextPlace + 1;
			}
		else
			{
			TempNames= Params.substring(nPlacehold, Params.length);
			}
		posit=TempNames.indexOf("=");
		if (posit > 0)
			{
			srch=TempNames.substring(0,posit);
			content=TempNames.substring(posit+1, Params.length);
			content=CharacterChange(content)
			if (srch.toUpperCase()=="TYPE" && content.length>1)
				{
				if (Type[y].indexOf(content)>-1)
					{
					Resultant=true
					}
				}
			}				

		}
	while (nNextPlace != -1)
	return Resultant
	}


function MakeRecord(iNum,AltDes)
	{
	switch (Index[iNum])
		{
		case "part":
		ImgName="/library/image/partfull.gif";
		ImgAlt="Some Full-Text";
		break;
		case "full":
		ImgName="/library/image/fulltext.gif";
		ImgAlt="Full-Text";
		break;
		case "audio":
		ImgName="/library/image/Audio.gif";
		ImgAlt="Audible Article";
		break;
		default:
		ImgName="/library/image/abstract.gif";
		ImgAlt="Citation/Abstract Only";
		}
	nPlacehold=0;
	nNextPlace=0;
	TempNames=""
	do
		{
		nNextPlace=Type[iNum].indexOf("|", nPlacehold);
		if (nNextPlace> -1)
			{
			TempNames=TempNames + Type[iNum].substring(nPlacehold, nNextPlace) + "<br>";
			nPlacehold = nNextPlace + 1;
			}
		else
			{
			TempNames=TempNames + Type[iNum].substring(nPlacehold, Type[iNum].length);
			}
		}
	while (nNextPlace != -1)

	document.write("<tr><td align=\"center\"><img src=\"" + ImgName + "\" alt=\"" + ImgAlt + "\"><br>" + TempNames + "</td>");
	if (Proxy[iNum].toUpperCase()=="Y")
		{
		Site=ProxyAddress + URL[iNum];
		}
	else
		{
		Site=URL[iNum];
		}
	document.write("<td><a href=\'" + Site + "\'>" + Name[iNum] + "</a></td>");
	if (AltDes == "")
		{
		Description = Descr[iNum];
		}
		else
		{
		Description = AltDes;
		}
	if (Description.substring(0,4).toUpperCase()=="NEW!")
		{
		document.write("<td><img src=" + NewGraphic + "> " + Description.substring(4,Description.length) + " <b class=\"black\">Coverage: </b>" + Coverage[iNum]);
		}
		else
		{
		document.write("<td>" + Description + " <b class=\"black\">Coverage: </b>" + Coverage[iNum]);
		}
	var indices=0;
	nPlacehold=0;
	nNextPlace=0;
	do
		{
		nNextPlace=AltName[iNum].indexOf("|", nPlacehold);
		if (nNextPlace> -1)
			{
			indices++;
			OtherNames[indices]=AltName[iNum].substring(nPlacehold, nNextPlace);
			TempChar=OtherNames[indices].substring(0,1);
			if (TempChar!="^" && TempChar!="~" && TempChar!="*")
		{
		OtherNames[indices]="`" + OtherNames[indices];
		}
			nPlacehold = nNextPlace + 1;
			}
		else
			{
			if (nPlacehold < AltName[iNum].length)
		{
		indices++;
		OtherNames[indices]=AltName[iNum].substring(nPlacehold, AltName[iNum].length);
		TempChar=OtherNames[indices].substring(0,1);
		if (TempChar!="^" && TempChar!="~" && TempChar!="*")
			{
			OtherNames[indices]="`" + OtherNames[indices];
			}
		}
			}
		}
	while (nNextPlace != -1)
	LastTempChar="";
	for (z=1;z<=indices;z++)
		{
		TempChar=OtherNames[z].substring(0,1);
		Remainder=OtherNames[z].substring(1,OtherNames[z].length)
		if (LastTempChar==TempChar)
			{
			document.write("&nbsp;<b class=\"burgundy\">&amp;</b>&nbsp;");
			if (TempChar=="*"){Remainder=Name[parseInt(Remainder)];}
			}
		else
			{
			LastTempChar=TempChar;
			switch (TempChar)
		{
		case "`":
		document.write("&nbsp;&nbsp;<b class=\"burgundy\">Also Called</b> ");
		break;
		case "~":
		document.write("&nbsp;&nbsp;<b class=\"burgundy\">Formerly Called</b> ");
		break;
		case "*":
		Remainder=Name[parseInt(Remainder)];
		document.write("&nbsp;&nbsp;<b class=\"burgundy\">Contains</b> ");
		break;
		default:
		document.write("&nbsp;&nbsp;<b class=\"burgundy\">Contains</b> ");
		}
			}
		document.write(Remainder);
		}
		document.write("&nbsp;&nbsp;<a href=\"" + Help[iNum] + "\"><img src=\"/library/image/info_small.gif\" alt=\"More Information\" align=\"middle\" border=\"0\"></a></td></tr>");
	}

function CharacterChange(sSpaced1)
	{
	sSpaced1=CharSubstitute(sSpaced1,"+"," ")
	sSpaced1=CharSubstitute(sSpaced1,"%20"," ")
	sSpaced1=CharSubstitute(sSpaced1,"%2B","+")
	sSpaced1=CharSubstitute(sSpaced1,"%2F","/")
	sSpaced1=CharSubstitute(sSpaced1,"%3A",":")
	sSpaced1=CharSubstitute(sSpaced1,"%28","(")
	sSpaced1=CharSubstitute(sSpaced1,"%29",")")
	sSpaced1=CharSubstitute(sSpaced1,"%3B",";")
	//alert(sSpaced1)
	return sSpaced1
	}

function CharSubstitute(sSpaced,sChar,sSub)
	{
	var sSubstituted=""
	var nRawLength=sSpaced.length
	var nSpacing=sChar.length
	var nPlacehold=0
	var nNextPlace=0
	do
		{
		nNextPlace=sSpaced.indexOf(sChar, nPlacehold)
		if (nNextPlace== -1)
			{
			sSubstituted=sSubstituted+ sSpaced.substring(nPlacehold, nRawLength)
			}
		else
			{
			sSubstituted=sSubstituted+ sSpaced.substring(nPlacehold, nNextPlace) + sSub
			nPlacehold = nNextPlace + nSpacing
			}
		}
	while (nNextPlace != -1)
	return sSubstituted
	}

