
function SwitchContent(src, target)
{
 var obj = document.getElementById(target); 
 var obj2 = document.getElementById(src);
 if (obj2) obj.innerHTML = obj2.innerHTML;
}

function SwitchClass(src, cl_on, cl_off, state)
{
  var obj;
  if (obj = document.getElementById(src)) {
    if (state) obj.className = cl_on;
	else obj.className = cl_off;
  }
}

function CheckAll(form_name, arr_name)
{
 if (document.getElementById(form_name)) {
  var checks = document.getElementById(form_name).getElementsByTagName('input');
  var len = arr_name.length;
  for (i=0; i<checks.length; i++) 
   if ((checks[i].type=='checkbox') && (checks[i].name.substring(0,len)==arr_name))
    checks[i].click();
 }
}

function ToolTip(target, showtip)
{
 obj = document.getElementById(target); 
 obj.style.display = (showtip>0)? 'block' : 'none';
}

function Popup(target, name, width, height, params) {
	var swidth; var sheight; var xpos; var ypos; var tw;
	if( typeof( window.innerWidth ) == 'number' ) { swidth = window.innerWidth; sheight = window.innerHeight; } 
	else if( document.documentElement && document.documentElement.clientWidth ) {
	swidth = document.documentElement.clientWidth; sheight = document.documentElement.clientHeight; } 
	else { swidth = document.body.clientWidth; sheight = document.body.clientHeight; } 
	//window.alert(target+" "+name+" "+width +'x'+height+" "+swidth+"x"+sheight+" ("+xpos+","+ypos+")");
	tw = window.open (target, name, "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0,width="+width+",height="+height+params, true);
	tw.resizeTo(width+32, height+96);
	tw.moveTo(parseInt((swidth-width)/2), parseInt((sheight-height)/2));
	tw.focus();
	return true;//false;
}

function addEvent(obj, evType, fn, useCapture){
  if (obj.addEventListener){
    obj.addEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be attached");
  }
}

function removeEvent(obj, evType, fn, useCapture){
  if (obj.removeEventListener){
    obj.removeEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.detachEvent){
    var r = obj.detachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be removed");
  }
} 
