/***********************************************************************
*
* genRow -	Generates a row in the Age/Time/Num Players table
*
* Input: sName	 -	Name of element
*        sVal	 -	value
*
* Returns: null
*
************************************************************************/
function genRow(sName, sVal) 
{
    document.write("<tr>");
	document.write("<td align=\"left\"><span class=\"actxsmall\">" + sName + "</span></td>");
	document.write("<td align=\"left\"><span class=\"actxsmall\">");
	if ((sVal == "") || (sVal == " / 5"))
		document.write("&nbsp;");
	else
		document.write(sVal);
	document.write("</span></td>");
	document.write("</tr>");
    return null;
}

/***********************************************************************
*
* genRequires -	Generates the "Requires ... to play" text
*
* Input: sName	 -	Name of required components
*
* Returns: null
*
************************************************************************/
function genRequires(sName) 
{
	if (sName != "")
	{
	  document.write("<span class=\"actxsmall\"> <br>");
	  document.write("<p>Requires: <b>" + sName + "</b> to play<br>");
	  document.write("</span>");
	}
    return null;
}

/***********************************************************************
*
* genBigImageLink -	Generates the "Click to enlarge image" link
*
* Input: sName	 -	Name of 'large' image
*
* Returns: null
*
************************************************************************/
function genBigImageLink(sName) 
{
	if (sName != "")
	{
	  document.write("<A HREF=\"javascript:ShowPopUp(\'../acatalog/" + sName + "\', 800, 800)\"><span class=\"actxsmall\">Click to enlarge image</span></A>");
	}
    return null;
}

/***********************************************************************
*
* genDesigner -	Generates the Designer 
*
* Input: sText	 -	Designer name
*
* Returns: null
*
************************************************************************/
function genDesigner(sText) 
{
	if (sText != "")
	{
	  document.write("<span class=\"actxsmall\"> <br>");
	  document.write("<br><b>Designer&#58; </b>");
	  document.write(sText + "<br>")
	  document.write("</span>");
	}
    return null;
}

/***********************************************************************
*
* genPublisher -	Generates the Publisher 
*
* Input: sText	 -	Publisher name
*
* Returns: null
*
************************************************************************/
function genPublisher(sText) 
{
	if (sText != "")
	{
	  document.write("<span class=\"actxsmall\"> <br>");
	  document.write("<br><b>Publisher&#58; </b>");
	  document.write(sText + "<br>")
	  document.write("</span>");
	}
    return null;
}

/***********************************************************************
*
* genContents -	Generates the contents list by replacing commas with <BR>
*
* Input: sList1	 -	comma-separated list
*        sList2	 -	comma-separated list
*
* Returns: null
*
************************************************************************/
function genContents(sList1, sList2) 
{
	if (sList1 != "")
	{
	  var a = new Array();
	  var s2 = new String();
	  a = sList1.split(',');
	  s2 = a.join("<br>");
	  if (sList2 != "")
	  {
		a = sList2.split(',');
		s2 = s2 + "<br>" + a.join("<br>");
	  }
	  document.write("<span class=\"actxsmall\"> <br>");
	  document.write("<b>Contents&#58; </b><br>");
	  document.write(s2)
	  document.write("</span>");
	}
    return null;
}

/***********************************************************************
*
* genSize -	Generates the size 
*
* Input: sText	 -	size text
*
* Returns: null
*
************************************************************************/
function genSize(sText) 
{
	if (sText != "")
	{
	  document.write("<span class=\"actxsmall\"> <br>");
	  document.write("<br><b>Box Size (in millimetres)&#58; </b><br>");
	  document.write(sText)
	  document.write("</span>");
	}
    return null;
}

/***********************************************************************
*
* genStockLevel -	Generates the stock level text
*
* Input: nCount	 -	number in stock
*
* Returns: null
*
************************************************************************/
function genStockLevel(nCount) 
{
    document.write("<span class=\"actxsmall\">");
	if (nCount > 0)
	{
	  document.write("<b>" + nCount.toString() + " in stock</b>");
	}
    document.write("</span>");
    return null;
}

/***********************************************************************
*
* genPrevNext -	Generates the previous/next href for sections 
*
* Input: sSection	 - section name
*        sGroupName  - group name
*        bPrev       - true = previous
*
* Returns: null
*
************************************************************************/
function genPrevNext(sSection, sGroupName, sUrl, bPrev) 
{
	if (sSection.substring(0, sGroupName.length) == sGroupName)
	{
	  var sText = new String();
	  if (bPrev == true)
	  { 
		sText = "&#60;&#60; Previous";
	  }
	  else
	  { 
	    sText = "Next &#62;&#62;";
	  }
	  document.write("<a href=\"");
	  document.write(sUrl);
	  document.write("\"><span class=\"actxsmall\">");
	  document.write(sText);
	  document.write("</span></a>");
	}
    return null;
}

/***********************************************************************
*
* genBGGReview -	Generates the "Click here for review on BGG" text
*
* Input: sId	 -	Review Id
*
* Returns: null
*
************************************************************************/
function genBGGReview(sId) 
{
	if (sId != "")
	{
	  document.write("<br>");
	  document.write("<A HREF=\"http://www.boardgamegeek.com/thread/" + sId + "\" TARGET=\"_blank\"><span class=\"actxsmall\">Click here for a review on BoardGameGeek</span></A>");
	}
    return null;
}

/***********************************************************************
*
* ajaxGetPage -	
*
************************************************************************/
function ajaxGetPage(pageUrl,divID)
{
var d = new Date();
var time = d.getTime();
pageUrl=pageUrl+'&t='+time;

  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
			document.getElementById(divID).innerHTML = xmlHttp.responseText;
        }
      }
    xmlHttp.open("GET",pageUrl,true);
    xmlHttp.send(null);

}
