// JavaScript Document

var numClasses = 8; // this number determines how many table classes

function switchClass (strid) {
	if (strid == '0') {
		expandAll(numClasses);
	}
	else {
		showOnly(strid);	
	}
}

function showOnly(id) {
	for (i=1;i<=numClasses;i++) {
	  	objectHead = "divHead" + i;
	  	objectTable = "divTable" + i;
	  	temp = document.getElementById(objectHead);
	  	if (i!=id) {
			if(temp.src.match("contract")) {
				temp.src='/images/icons/expand.png';
				hideClass(objectTable);
			}
		}
		else {
			if(temp.src.match("expand")) {
				temp.src='/images/icons/contract.png';
				showClass(objectTable);
			}	
		}
   	}
	if (id==1) {
		objectHead2 = "divHead2" ;
	  	objectTable2 = "divTable2" ;
		temp2 = document.getElementById(objectHead2);
		if(temp2.src.match("contract")) {
			temp2.src='/images/icons/expand.png';
			hideClass(objectTable2);
		}
		if(temp2.src.match("expand")) {
			temp2.src='/images/icons/contract.png';
			showClass(objectTable2);
		}	
	}
}

function hideClass(id) {
	temp = document.getElementById(id).style;
	if (temp.visibility == 'visible') {
		temp.visibility = 'hidden';
		temp.display = 'none';
		temp.height= 'auto';
	}
}

function showClass(id) {
	temp = document.getElementById(id).style;
	if (temp.visibility == 'hidden') {
		temp.visibility = 'visible';
		temp.display = 'block';
		temp.height = 'auto';
	}
}

function switchCross(id,table) {
	temp = document.getElementById(id);
	if(temp.src.match("contract")) {
		temp.src='/images/icons/expand.png';
		toggleDiv(table, false);
	}
	else {
		temp.src= '/images/icons/contract.png';
		toggleDiv(table, false);
	}
}

function toggleDiv(id, boolAll) {
	temp = document.getElementById(id).style;
	if (boolAll) {
		temp.visibility = 'visible';
		temp.display = 'block';
		temp.height = 'auto';
	} else {
		if (temp.visibility == 'visible') {
			temp.visibility = 'hidden';
			temp.display = 'none';
			temp.height= 'auto';
		}
		else {
			temp.visibility = 'visible';
			temp.display = 'block';
			temp.height = 'auto';
		}	
	}
}

function expandAll(numDivs) {
	for (i=1;i<=numDivs;i++) {
	  	objectHead = "divHead" + i;
		//alert(objectHead);
	  	objectTable = "divTable" + i;
	  	temp = document.getElementById(objectHead);
	  	if(temp.src.match("expand")) {
			temp.src='/images/icons/contract.png';
			toggleDiv(objectTable, true);
	  	}
   	}
}

