/*
##################################################################
# PJP CONTENT SWITCHER
# Written by Phil Peters (PJP)
# Date: September 1st 2009
# Last Update: September 18th 2009 (PJP)
#
# USAGE INSTRUCTIONS:
# DIVS you wish to enable switching on must have DIV id labelled "PJPCS[number]" (numbers must start from 1)
# Call the function within page from a link: onclick="javascript:content_switcher('DIV id (e.g. PJPCS1)', 'total number of DIVs to be switched (e.g. 10)');return false;"
# Set default DIV to display with javascript line after all DIVs: window.onload = content_switcher('PJPCS2', '5');
##################################################################
*/

function content_switcher(id, totalitems){

// Set the selected item variable
var itemselected = document.getElementById(arguments[0]);

// Set the total items variable
var totalitems = arguments[1];

// Set separate variable value for DIV ids starting from 1 as it will confuse people otherwise
var j = 1;

// Set DIV array dynamically
var listcontents = new Array();
for (i = 0;i < totalitems;i++)
{
 listcontents[i] = document.getElementById('PJPCS'+j+'');
 listcontents[i].disabled = true; 
 listcontents[i].className = 'hidden';
 j++
}
 
// Show selected DIV
if (itemselected != '')
{
 itemselected.disabled = false;
 itemselected.className = '';
 // Optional - you can add scriptaculous effects in here eg:
 // new Effect.Grow(e); return false; 
}
}
