/*
	General functions

*/
function $get(el) {

	var obj = document.getElementById(el);
	if (obj) {
		return obj;		
	} else {
		return null;
	}
} 


function charCounter(f,maxlength) {
	if(f.value.length > maxlength) {
		f.value = f.value.substring(0,maxlength);
		alert("This field can only contain "+maxlength+" characters");
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  w = window.open(theURL,winName,features);
	if (w.focus) w.focus();
}


function showSet(s) {
	var fld = $get('grp-' + s);
	var tab = $get('tab_' + s);
	var tbl = tab.parentNode;
	var frm = fld.parentNode;
	
	var flds = frm.getElementsByTagName('fieldset');
	var tabs = tbl.getElementsByTagName('td');
	
	for (t=0;t<=(tabs.length-1);t++) {
		tabs[t].className='off';	
	}
	
	for (i=0;i<=(flds.length-1);i++) {
		if (flds[i].className!='btn' && flds[i].className!='foreign') {
			flds[i].style.display = 'none';	
		}
	}
	
	fld.style.display = 'block';
	tab.className = 'on';
	return false;
}
	
function addEvent(elm, evType, fn, useCapture) {
	if (elm.addEventListener) {
		elm.addEventListener(evType, fn, useCapture);
		return true;
	}
	else if (elm.attachEvent) {
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	}
	else {
		elm['on' + evType] = fn;
	}
}

function newWin(u) {
		window.open(u);	
}	

