
NN4=((parseInt(navigator.appVersion)>=4 && parseInt(navigator.appVersion)<5)&&(navigator.appName.indexOf("Netscape")!=-1))?1:0
NN6=((parseInt(navigator.appVersion)>=5)&&(navigator.appName.indexOf("Netscape")!=-1))?1:0
MS4=((parseInt(navigator.appVersion)>=4)&&(navigator.appName.indexOf("Microsoft")!=-1))?1:0

function f_get_elem(i)
{
if(NN6)			return(document.getElementById(i));
else if(NN4)	return(document.layers[i]);
else			return(document.all[i]);
}

function f_set_bg_col(d,sCol)
{
if(NN6)			d.style.backgroundColor = sCol;
else if(NN4)	d.style.bgColor = sCol;
else			d.style.backgroundColor = sCol;
}

function f_show_elem(i)
{
obj=f_get_elem(i);
obj.style.visibility="visible";
obj.style.display="inline";
}

function f_hide_elem(i)
{
obj=f_get_elem(i);
obj.style.visibility="hidden";
obj.style.display="none";
}

function f_print_pg()
{
if(MS4) {
	document.images["imgp"].style.visibility = "hidden";
	document.images["imgp"].style.display = "none";
	//alert("ok");
	window.print();
	document.images["imgp"].style.visibility = "visible";
	document.images["imgp"].style.display = "inline";
	}
else {
	window.print();
	}
}

function f_validate_date(obj)
{
var today=new Date();
v=obj.value;
p=v.split("/");
if(p.length==1) {
	obj.value="";
	return(0);
	}
else if(p.length==2) { 
	m=p[0];
	d=p[1];
	y=today.getFullYear();
	}
else if(p.length==3) {
	m=p[0];
	d=p[1];
	y=parseInt(p[2]);
	if(y<=99) { y+=2000; }
	}
if(isNaN(m) || isNaN(d) || isNaN(y)) {
	obj.value="";
	return(0);
	}
else if(m<1 || m>12 || d<1 || d>31 || y<0) {
	obj.value="";
	return(0);
	}
s=m+"/"+d+"/"+y;
obj.value = s;
}

function f_validate_num(obj)
{
v=obj.value;
if(isNaN(v)) {
	s="";
	}
else {
	s = parseInt(v);
	}
obj.value = s;
}


function makeRequest(url,func,v) {
    var httpRequest;

    if (window.XMLHttpRequest) { // Mozilla, Safari, ...
        httpRequest = new XMLHttpRequest();
        if (httpRequest.overrideMimeType) {
            httpRequest.overrideMimeType('text/xml');
            // See note below about this line
        }
    } 
    else if (window.ActiveXObject) { // IE
        try {
            httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
            } 
            catch (e) {
                       try {
                            httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                           } 
                         catch (e) {}
                      }
                                   }

    if (!httpRequest) {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
    httpRequest.onreadystatechange = function() { alertContents(httpRequest,func); };
		var postdata= "foo=bar&baz=hey";
    httpRequest.open('POST', url, true);
		httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		httpRequest.setRequestHeader("Content-length", v.length);
    httpRequest.send(v);
}



function trim(s)
{
return( s.replace(/^\s+|\s+$/g, '') );
}


function alertContents(httpRequest,ctrl) {

	var htm;

  if (httpRequest.readyState == 4) {
      if (httpRequest.status == 200) {
          htm = httpRequest.responseText;
      } else {
          htm = "There was a problem with the request.  status code=" + httpRequest.status;
      }

	if(ctrl!="") {
		//alert(htm);
		document.all[ctrl].innerHTML = htm;
		}

  }

}


