
window.onload = Initialize;

windowLoaded = false;
function Initialize()
{ 
   windowLoaded = true;
}

function GelSparks(id,title,subject,image)
{
	this.id = id;
	this.title = title;
	this.subject = subject;
	this.image = image;
}
	
function CreateCollectionList()
{
	var theTitle="";
	collectionString = "";
	if (theGelSparks.length!=0)
	{
		collectionString += ("<table width=190 border=0 cellpadding=0 cellspacing=0><tr><td background='images/collection/bg.gif'><table width=190 border=0 cellpadding=0 cellspacing=0><tr><td colspan=2 align=left><img src='images/collection/showPrivate.gif' align=absmiddle border=0></td>")
	
		if (!collector)
			collectionString += ("<td  align=right><img src='images/collection/deletePrivate.gif' align=absmiddle border=0></td>")
		else
			collectionString += ("<td >&nbsp;</td>")
		collectionString += ("</tr>");	
		for(i=0; i<theGelSparks.length; i++)
		{
			collectionString += ("<tr><td width=22 align=left><input type=radio onclick='javascript:Show("+i+")' name=showGelSparks")
			if (myId=="")
			{ 
				if (i==0)
				{
					collectionString +=(" checked");
					theLink="viewCollectionBoard.pl?id="+theGelSparks[0].id+"&myPrivateCollection=1&collector="+collector+"&hideLink="+hideLink;
					parent.collectionBoard.location.replace(theLink);
				}	
			}
			else
			{
				numID =  theGelSparks[i].id;
				if (numID==myId)
				{
					collectionString +=(" checked");
				}
			}	
			//if (theGelSparks.length==1)
//				collectionString +=("></td><td width=140><a href='javascript:Show()'>" + theGelSparks[i].title + "</a></td>")
//			else			
				//collectionString +=("></td><td width=140><a href='javascript:document.forms.theForm.showGelSparks["+i+"].checked=true;javascript:Show()'>" + theGelSparks[i].title + "</a></td>")
				collectionString +=("></td><td width=140><a href='javascript:Show("+i+")'>" + theGelSparks[i].title + "</a></td>")
			if (!collector)
				collectionString += ("<td align=right><input type=checkbox name=delete" + i + "></td>")
			else
				collectionString += ("<td width=22>&nbsp;</td>")
		}
		collectionString += ("</tr><tr><td >&nbsp;</td><td>&nbsp;</td>")
		if (!collector)
			collectionString += ("<td align=right ><a href='javascript:Delete()'><img src='images/collection/ok.gif' align=absmiddle border=0></a></td>")
		else
			collectionString += ("<td >&nbsp;</td>")
			
			collectionString += ("</tr></table></tr></td></table>");
	}
	else
		parent.collectionBoard.location.replace("viewCollectionBoard.pl?myPrivateCollection=1"+"&collector="+collector+"&hideLink="+hideLink);
	document.write(collectionString);

}
function Show(num)
{
	if (theGelSparks.length==1)
 	   document.forms.theForm.showGelSparks.checked=true;
	else   
 	   document.forms.theForm.showGelSparks[num].checked=true;
	   
	image=theGelSparks[num].image;
	subject=theGelSparks[num].subject;
	theTitle=theGelSparks[num].title;
	theLink="viewCollectionBoard.pl?id="+theGelSparks[num].id+"&myPrivateCollection=1&collector="+collector+"&hideLink="+hideLink;
	parent.collectionBoard.location.replace(theLink);
}

function Delete()
{
	deleteString = "";
	for(i=0; i<theGelSparks.length; i++)
	{
		isChecked = false;
		eval("isChecked = document.forms.theForm.delete" + i + ".checked");
		if(isChecked)
		{
			orString = (deleteString == "")?'':' OR ';
			deleteString += (' ' + orString + 'id=' + theGelSparks[i].id) 
		}
	}
	if(deleteString != '')
	{
		ret=confirm("Are you sure?")
	}
	if(ret)
	{
		document.forms.theForm.deleteString.value=deleteString;
		document.forms.theForm.submit();
	}
}


