//Copyright © 2003 PAULGRANT.CA
//http://actionfigurechecklist.com

function Ok_Picker()
{
	var oSelect		= document.frmPick.selPick;
	if((!oSelect) || (oSelect.selectedIndex < 0))
		return false;

	var i			= 0;
	var oOption		= null;
	var sGroups		= "";

	for(i = 0; i < oSelect.length; i++)
	{
		oOption = oSelect.options[ i ];
		if(!oOption)
			break;

		if(oOption.selected == true)
		{
			if(sGroups.length > 0)
				sGroups += ",";

			sGroups += oOption.value;
		}
	}

	if(!sGroups)
		return false;

	var sQueryString = QS_ex("Group");

	window.location.search = "?" + ((sQueryString.length > 1) ? (sQueryString + "&") : "") + "Group=" + sGroups;

	this.Hide();

	return true;
}

function Cancel_Picker()
{
	this.Hide();

	return true;
}

function Hide_Picker()
{
	var oGroups = document.getElementById("layerGroups");

	if(oGroups)
		oGroups.style.visibility = "hidden";

	return true;
}

function Open_Picker()
{
	var oProp = document.getElementById("layerGroups");
	if(!oProp)
		return false;

	//var iWinWidth	= ((window.innerWidth)	? window.innerWidth		: ((document.body.clientWidth) ? document.body.clientWidth : document.documentElement.clientWidth));
	iWinWidth = "800";
	var oContent = document.getElementById("main_content");
	if(oContent)
	{
		if(oContent.width)
			iWinWidth = oContent.width;
	}

	var iWinHeight	= ((window.innerHeight)	? window.innerHeight	: 480);

	var iOffsetLeft	= ((window.scrollX)	? window.scrollX : ((document.body.scrollLeft) ? document.body.scrollTop : document.documentElement.scrollLeft));
	var iOffsetTop	= ((window.scrollY)	? window.scrollY : ((document.body.scrollTop) ? document.body.scrollTop : document.documentElement.scrollTop));

	oProp.style.width		= this.iWidth + "px";
	oProp.style.height		= this.iHeight + "px";
	oProp.style.left		= (((iWinWidth - this.iWidth) / 2) + iOffsetLeft) + "px";
	oProp.style.top			= (((iWinHeight - this.iHeight) / 2) + iOffsetTop) + "px";
	oProp.style.visibility	= "visible";

	return true;
}

function AddGroup_Picker(iGroup, sGroup)
{
	this.aGroups[ this.aGroups.length ] = new Array(iGroup, sGroup);

	return true;
}

function HtmlBaseTag_Picker()
{
	var i		= 0;
	var oGroup	= null;

	var sString =
	  "<div name='layerGroups' id='layerGroups' style='position:absolute;visibility:hidden;'>\n"
	+ "<form name='frmPick' id='frmPick' onSubmit='return false;'>\n"
	+ "<table border='0' cellpadding='2' cellspacing='0' bgcolor='black'><tr><td>\n"
	+ "<table border='0' cellpadding='0' cellspacing='0' width='" + this.iWidth + "' height='" + this.iHeight + "' bgcolor='" + gsBgColor + "'>\n"
	+ "<tr><td align='right' valign='bottom' height='15'>\n"
	+ "<img src='./Images/Checkbox/Checkbox12x12close.gif' width='12' height='12' onClick='oGPick.Cancel();'>\n"
	+ "</td><td width='3'></td></tr>\n"
	+ "<tr><td align='center' valign='middle'>\n"
	+ "<table border='0' cellpadding='0' cellspacing='1'>\n"
	+ "<tr><td align='center' valign='top'>\n"
	+ "<select class='fontInput' style='width:225px;' name='selPick' size='6' multiple='multiple'>\n";

	for(i = 0; i < this.aGroups.length; i++)
	{
		oGroup = this.aGroups[ i ];
		if(!oGroup)
			break;

		sString += "<option value='" + oGroup[ 0 ] + "'> &nbsp; &nbsp; " + oGroup[ 1 ] + " &nbsp; &nbsp; </option>\n";
	}

	sString +=
	  "</select>"
	+ "</td></tr><tr><td align='right' valign='middle'>\n"
	+ "<input class='fontInputButton' type='submit' value=' Ok ' onClick='oGPick.Ok();'>&nbsp;\n"
	+ "<input class='fontInputButton' type='button' value=' Cancel ' onClick='oGPick.Cancel();'>\n"
	+ "</td></tr></table>\n"
	+ "</td></tr><tr><td height='12'>\n"
	+ "</td></tr></table>\n"
	+ "</td></tr></table>\n"
	+ "</form></div>\n";

	document.write(sString);

	return true;
}

function GroupPickerClass()
{
	this.aGroups		= new Array();

	this.iWidth			= 290;
	this.iHeight		= 140;

	this.Ok				= Ok_Picker;
	this.Cancel			= Cancel_Picker;
	this.Hide			= Hide_Picker;
	this.Open			= Open_Picker;
	this.AddGroup		= AddGroup_Picker;
	this.HtmlBaseTag	= HtmlBaseTag_Picker;

	return this;
}

var oGPick	= new GroupPickerClass();

//End.

