
// popup window
function popWin(cUrl,width,height) {

	aWin = window.open(cUrl,'popWin','resizable=yes,width=' + width + 'px,height=' + height + 'px,menubar=no,scrollbars=yes');
	aWin.focus();
}	

// click event in menu causes contextgroup to show it's children
function handleTreeClick(e) {

	// w3c
	if(e.target) { 
	
		showHide(e.target);
	}
	// IE
	else { 
		showHide(e.srcElement);
	}

	// 'Private' inner function	
	// Expands or collapses subitems
	function showHide(oEl) {
	
		var oEl = getParentByTagName(oEl,"LI")
	
		//alert("class="+oEl.className)
	
		if (oEl.className == "ctxgroup") {
		
			oUl = oEl.getElementsByTagName("UL")[0];
			
			if (oUl.style.display == "block") {
				oUl.style.display = "none";
			}
			else {
				oUl.style.display = "block";
			}
		}
	}	
	
	return;
}

/* Expand current context's contextgroup by default. Default cId is available
for any non-cms page. */
function initMenu(cId,cFuseaction) {

	var oMenu = document.getElementById('menu');
	colLi = oMenu.getElementsByTagName("LI");
	
	/* first collapse all. This style is added dynamically and not
	in css, so that non JS browsers will always display the fully
	expanded menu! */
	for (var i = 0; i < colLi.length; i++) {
	
		if (colLi[i].getElementsByTagName("UL").length > 0) {
			colLi[i].getElementsByTagName("UL")[0].style.display="none";
		}
	}	
		
	for (var i = 0; i < colLi.length; i++) {

		if (colLi[i].id == cId) {
			
			colLi[i].getElementsByTagName("A")[0].className = "highlight";
			var oUl = getParentByTagName(colLi[i],"UL");
			oUl.style.display = "block";
		}	
	}	
}

// handy...
function getParentByTagName(oEl,cTagname) {

	oParEl = oEl;
	
	while (oParEl.parentNode && oParEl.tagName != cTagname) {
	
		oParEl = oParEl.parentNode;
	}
	
	return oParEl;
}


/* =======================================================================
						zebra tabel
========================================================================*/
function zebra(id) {

	var even = false;
	
	var table = document.getElementById(id);
	if (! table)  return; 
	
	var tbodies = table.getElementsByTagName("tbody");
	
	for (var h = 0; h < tbodies.length; h++) {
	
		var trs = tbodies[h].getElementsByTagName("tr");
		
		for (var i = 0; i < trs.length; i++) {
		
			trs[i].className = even ? 'even' : 'odd';
			  
			// flip from odd to even, or vice-versa
			even =  !even;
		}
	}
}	

/* =======================================================================
						clear a form
========================================================================*/
function clearForm(oForm) {

	colInput = document.getElementsByTagName("INPUT");
		
	for (i=0; i< colInput.length; i++) {
		if (colInput[i].type == 'text') {
			colInput[i].value = '';
		}
		if (colInput[i].type == 'checkbox') {
			colInput[i].checked = false;
		}
		if (colInput[i].type == 'radio') {
			colInput[i].checked = false;
		}
	}
	
	selInput = document.getElementsByTagName("SELECT");
		
	for (i=0; i< selInput.length; i++) {
		selInput[i].selectedIndex = 0;
	}
	
}

