function ViewTicked(formName, checkboxName)
{
	// get the ticked item ids
	var itemIds = GetCheckboxItemsToCsv(formName, checkboxName, true);
	
	// check if any items have been ticked
	if (itemIds == '') 
	{
		alert('No ticked Items to View');
	}
	else 
	{
		window.location = '../../Articles/Article.aspx?liArticleID=' + itemIds;
	}
}

function ViewAll(formName, checkboxName)
{
	// submit the form to allow all items to be displayed
	
	// get all the item ids
	var itemIds = GetCheckboxItemsToCsv(formName, checkboxName, false);
	window.location = '../../Articles/Article.aspx?liArticleID=' + itemIds;
}

function PrintTicked(formName, checkboxName)
{
	// display a window to allow ticked items to be printed

	// get the ticked item ids
	var itemIds = GetCheckboxItemsToCsv(formName, checkboxName, true);
	
	// check if any items have been ticked
	if (itemIds == '') 
	{
		alert('No ticked Items to Print');
	}
	else 
	{
		// display the print window
		var sFeatures = 'left=40,top=40,width=950,height=330,resizable,scrollbars,toolbar';
		var winWindow = window.open('../../Articles/Article.aspx?liArticleID=' + itemIds + '&PrinterFriendly=true', 'winPrint', sFeatures);
		winWindow.focus();
	}
}

function PrintAll(formName, checkboxName)
{
	// display a window to allow all items to be printed

	// get all the item ids
	var itemIds = GetCheckboxItemsToCsv(formName, checkboxName, false);
	
	// display the print window
	var sFeatures = 'left=40,top=40,width=950,height=330,resizable,scrollbars,toolbar';
	var winWindow = window.open('../../Articles/Article.aspx?liArticleID=' + itemIds + '&PrinterFriendly=true', 'winPrint', sFeatures);
	winWindow.focus();
}

function GetCheckboxItemsToCsv(formName, checkboxName, onlyTickedItems)
{
	// return a comma seprated list of ticked items
	
	var checkbox = document.forms[formName].elements[checkboxName];
	var itemIds   = '';
	var i;
	
	if (checkbox != null) //no items 
	{
	    // get checkbox values
	    if (checkbox.length == null)	// single checkbox
	    {
		    if (onlyTickedItems)
		    {
			    if (checkbox.checked)
			    {
				    itemIds = checkbox.value + ',';
			    }
		    }
		    else
		    {
			    itemIds = checkbox.value + ',';
		    }
	    }
	    else
	    {
		    for (i = 0; i < checkbox.length; i++)
		    {
			    if (onlyTickedItems)
			    {
				    if (checkbox[i].checked)
				    {
					    itemIds += checkbox[i].value + ',';
				    }
			    }
			    else
			    {
				    itemIds += checkbox[i].value + ',';
			    }
		    }
	    }
    	
	    itemIds = itemIds.substring(0, itemIds.length - 1);
	}	
	// return csv list of selected items
	return itemIds;
}

