/************************************************************************************************************
(C) www.dhtmlgoodies.com, June 2006
************************************************************************************************************/

var dynamicContent_ajaxObjects = new Array(); 
var jsCache = new Array();
var enableCache = true; 

function ajax_loadContent(divId,pathToFile)
{
  if(enableCache && jsCache[pathToFile]){
    document.getElementById(divId).innerHTML = jsCache[pathToFile];
    return;
  }
  
  var ajaxIndex = dynamicContent_ajaxObjects.length;
  document.getElementById(divId).innerHTML = 'Loading content...';
  dynamicContent_ajaxObjects[ajaxIndex] = new sack(pathToFile);
  dynamicContent_ajaxObjects[ajaxIndex].requestFile = pathToFile;

  dynamicContent_ajaxObjects[ajaxIndex].onCompletion = 
  function(){ ajax_showContent(divId,ajaxIndex,pathToFile); };  

  dynamicContent_ajaxObjects[ajaxIndex].runAJAX();  
  
  
} 

function ajax_showContent(divId,ajaxIndex,pathToFile)
{
  document.getElementById(divId).innerHTML =
    dynamicContent_ajaxObjects[ajaxIndex].response;
  if(enableCache){
    jsCache[pathToFile] = 
    dynamicContent_ajaxObjects[ajaxIndex].response;
  }
  dynamicContent_ajaxObjects[ajaxIndex] = false;
}

/*      Sean Loving     */
function hide(x) {
	if(document.getElementById(x))
	{
		document.getElementById(x).style.display='none';
	}
}
function show(x) {
	if(document.getElementById(x))
	{
		document.getElementById(x).style.display='';
	}
}

function preload_value(x) {
var island = document.getElementsByName('alert').options[selectedIndex].value;
document.getElementsByName(x).value = island;
}

var count = 1;
function scrollz(dir) {
	var formNum = 'form_' + count + '_6';
	//alert(formNum);
	hide(formNum);
	if(dir=='next'){count++;}
	if(dir=='prev'){count--;}
	if(count==0){count=1;}
	formNum = 'form_' + count + '_6';
	show(formNum);
}

function showItem(thisa) {
	var i;
	var item;
	// when an item is clicked, first toggle its state...
	if(document.getElementById(thisa).style.display=='none')
	{
		show(thisa);
		document.getElementById(thisa).style.color='#00AA00';
	}
	else
	{
		hide(thisa);
	}
	
	// ... then collapse all other items
	for(i=0; i<30; i++)
	{
		item = 'a' + i;
		if( document.getElementById(item) )
		{
			if(item != thisa)
			{
				hide(item);
			}
		}
	}
	
}
function showList1(codetype) {
	// when codetype changes, display the corresponding list of codes...
	// hide all, then display the one
	hide('colors1');
	hide('states1');
	hide('letters1');
	hide('numbers1');
	show(codetype);
}

function showList2(codetype) {
	// when codetype changes, display the corresponding list of codes...
	// hide all, then display the one
	hide('colors2');
	hide('states2');
	hide('letters2');
	hide('numbers2');
	show(codetype);
}

function changeFont(thisa) {
	var i;
	var item;
	for(i=0; i<15; i++)
	{
		item = 'q' + i;
		if(document.getElementById(item))
		{
			document.getElementById(item).style.fontWeight='normal';
			document.getElementById(item).style.fontColor='#FFFFFF';
		}
	}
	document.getElementById(thisa).style.fontWeight='bold';
	document.getElementById(thisa).style.fontColor='#00AA00';

}

function changeBackground(thid, newcolor) 
{
	var i;
	var item;
	for(i=0; i<6; i++)
	{
		item = 'fb' + i;
		if(document.getElementById(item))
		{
			document.getElementById(item).style.backgroundColor='#FFFFFF';
		}
	}
	document.getElementById(thid).style.backgroundColor=newcolor;
}

function toggleDisabledProperty( id )
{
	//toggle the disable property of control element id
	if( document.getElementById('code2_box').checked == true)
	{
		document.getElementById(id).disabled = false; 
	}
	else
	{
		document.getElementById(id).disabled = true; 
	}
}

