
function showXBRLTerms(div_id, button_id, pnum, objId, pnormId, trid, isGlossaryTerm, section_trid){

	document.body.style.cursor = 'progress';

	showXBRLDiv(div_id, button_id, pnum, objId, pnormId, isGlossaryTerm);	
	
	var url = 'http://' + window.location.hostname + '/showxbrlterms';

	var showTermsReq = newHttpRequest();

	var handlerFunction = getReadyStateHandler(showTermsReq, div_id, replaceXBRLDivText);
	showTermsReq.open("POST", url, true);
	showTermsReq.onreadystatechange = handlerFunction;
	showTermsReq.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
	var query = 'ov_obj_id=' + objId + '&pnorm_id=' + pnormId + '&trid=' + trid + '&section_trid='+section_trid;
	if (isGlossaryTerm)
		query += '&is_glossary=true';
	showTermsReq.send(query);

}

function hideXBRLDiv(div_id, button_id, pnum, objId, pnormId, isGlossaryTerm){
	if (!isGlossaryTerm) var isGlossaryTerm = false;
	var element = document.getElementById(div_id);
	if(element){
		element.style.position = 'absolute';
		element.style.zIndex = -1;
		element.style.display = 'none';
		toggleXBRLButton(div_id, button_id, pnum, objId, pnormId, 'show', isGlossaryTerm);
	}
}

function showXBRLDiv(div_id, button_id, pnum, objId, pnormId, isGlossaryTerm){
	if (!isGlossaryTerm) var isGlossaryTerm = false;
	var element = document.getElementById(div_id);
	if(element){
		element.style.zIndex = 15;
		element.style.position = 'static';
		element.style.display = 'inline';
		toggleXBRLButton(div_id, button_id, pnum, objId, pnormId, 'hide', isGlossaryTerm);
	}
}

function replaceXBRLDivText(tagID,rptext) {
	var elt=document.getElementById(tagID);
	if(elt){
		elt.innerHTML=unescape(rptext);
		if(rptext.replace(/^\s+|\s+$/, '') == ''){
			hideDiv(tagID);
		}
	}
	document.body.style.cursor = 'auto';
}

function toggleXBRLButton(div_id, button_id, pnum, objId, pnormId, value, isGlossaryTerm){
	var button = document.getElementById(button_id);
	if(button){
		if(value == 'hide'){
			if(document.all){
				document.getElementById(button_id).innerText = " Hide XBRL Elements ";
			}
			else{
				document.getElementById(button_id).textContent = " Hide XBRL Elements ";
			}
			button.setAttribute("href", "javascript:hideXBRLDiv('" + div_id + "','" + button_id + "','" + pnum + "','" + objId + "','" + pnormId + "',"+isGlossaryTerm+");");
		}
		else{
			if(document.all){
				document.getElementById(button_id).innerText = " XBRL Elements ";
			}
			else{
				document.getElementById(button_id).textContent = " XBRL Elements ";
			}
			button.setAttribute("href", "javascript:showXBRLDiv('" + div_id + "','" + button_id + "','" + pnum + "','" + objId + "','" + pnormId + "',"+isGlossaryTerm+");");
		}
	}
}
