// global javascript file to contain functions that may be used multiple times throughout the site
// July 18th, 2008


function popUp(strURL, strOptions) {
	var x=window.open(strURL, "BLM", strOptions);
	x.focus();
	return false;
}

function toggleItem(strDivId) {
	if (strDivId+'x' != 'x') {
		if (document.getElementById(strDivId) != null) {
			if (document.getElementById(strDivId).style.display == "none") {
				document.getElementById(strDivId).style.display = "block";	} 
			else {
				document.getElementById(strDivId).style.display = "none";}
		}
	}
}

function togglePDF(strDivId) {
	if (strDivId+'x' != 'x') {
		if (document.getElementById(strDivId) != null) {
			if (document.getElementById(strDivId).style.display == "inline") {
				document.getElementById(strDivId).style.display = "none";	} 
			else {
				document.getElementById(strDivId).style.display = "inline";}
		}
	}
}


function toggleTableRows(strDivId) {
	if (strDivId+'x' != 'x') {
		if (document.getElementById(strDivId) != null) {
			if (document.getElementById(strDivId).style.display == "none") {
				document.getElementById(strDivId).style.display = "table-row-group";	} 
			else {
				document.getElementById(strDivId).style.display = "none";}
		}
	}
}
function toggleTableRowsOn(strDivId) {
	if (strDivId+'x' != 'x') {
		//document.getElementById(strDivId).style.display = "table-row-group";
		//Set the visible class
		var x = document.getElementById(strDivId);
		x.className = "ShowTableBody";
		}
}

function toggleTableRowsOff(strDivId) {
	if (strDivId+'x' != 'x') {
		//document.getElementById(strDivId).style.display = "none";
		//Set the invisible class
		var x = document.getElementById(strDivId);
		x.className = "HideTableBody";
		
		}
}


/*******************************************
 toggleGroupItem('span', 'SafetyLink_', 'SafetyLink_1') 
 hides all spans on page with prefex SafetyLink_ opens up element w/ id SafetyLink_1

 toggleGroupItem('span', 'SafetyLink_', 'SafetyLink_1', true) 
 shows all spans on page with prefix SafetyLink_ closes SafetyLink_1
 
 toggleGroupItem('span', 'SafetyLink_' ) 
 hides all spans on page with prefex SafetyLink_ 
 
 toggleGroupItem('span', 'SafetyLink_', '', true) 
 shows  all spans on page with prefex SafetyLink_ 
  
*******************************************/

function toggleGroupItem(strTagRef, strIdPrefix, strId, blnSetVisible) {
    var blnMakeVisible = (blnSetVisible == null) ? false : true;
    var strSelectedId = (strId == null) ? "" : strId;	
	var blnDoIt = true;
	var strAction1 = 'none';
	var strAction2 = 'block';
	
	if (strTagRef.replace(/ /g, "") +'x' == 'x') { blnDoIt = false; }
	if (strTagRef.length > 100) { blnDoIt = false; }	
	if (strIdPrefix.replace(/ /g, "") +'x' == 'x') { blnDoIt = false; }	
	if (strIdPrefix.length > 100) { blnDoIt = false; }	
	if (strSelectedId.length > 100) { blnDoIt = false; }	

	if (blnDoIt) {
		if (blnSetVisible) { // hides the one selected but displayes all not selected // opposite of default
			strAction1 = 'block';
			strAction2 = 'none';			
		}
		
		// loop through valid tags (html) looking for provided prefix
		var doc = document.getElementsByTagName(strTagRef);
		for (var i = 0; i < doc.length; i++){
			//Do Work on doc[i], this sets the border of the Div black
			var currentTagID=doc[i].id;
			if ( (currentTagID.match(strIdPrefix) != null)) {
				document.getElementById(currentTagID).style.display = strAction1;
				}
			}
		// hide/show according to strSelectedId passed in by user	
		if (strSelectedId != "") {
			if (document.getElementById(strSelectedId) != null) {
				document.getElementById(strSelectedId).style.display = strAction2;}
			}
	}
}