function trim(str) {
     str = this != window? this : str;
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

/*
browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);
var msie4 = (browserName == "Microsoft Internet Explorer" && browserVer >= 4);
if ((browserName == "Netscape" && browserVer >= 3) || msie4 || browserName=="Konqueror") {version = "n3";} else {version = "n2";}
// Blurring links:
function blurLink(theObject)	{	//
	if (msie4)	{theObject.blur();}
} */

sfHover = function() {
	if (document.getElementById("dropdown")) { 
		var sfEls = document.getElementById("dropdown").getElementsByTagName("ul")[0].getElementsByTagName("li");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		} 
	}
} 
if (window.attachEvent) window.attachEvent("onload", sfHover);

function addEvent(elm, evType, fn, useCapture)
// addEvent and removeEvent
// cross-browser event handling for IE5+,  NS6 and Mozilla
// By Scott Andrew
{
  if (elm.addEventListener){
    elm.addEventListener(evType, fn, useCapture);
    return true;
  } else if (elm.attachEvent){
    var r = elm.attachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be removed");
  }
} 


var elemToFocus = null;

function focusElementHelper()
{
	elemToFocus.focus();
}

function focusElement(elementID) 
// focuses the specified element on window load
{
	elemToFocus = document.getElementById(elementID);
	addEvent(window, "load", focusElementHelper);
}


function popUp(url,x,y)
// opens a small pop-up with the specified dimensions
{
	if (!x) x = 700;
	if (!y) y = 600;
	var w = window.open(url,"pkal_pop","location=0,status=0,scrollbars=1,width="+x+",height="+y+",resizable=1");
	w.focus();
	return w;
}



/* XMLHTTP functions 0.2 */

/* Revisions */
/* 0.1 - 24 Jan 2005 - Written by Peter Cooper (coops) */
/* 0.2 - 26 Jan 2005 - ixXMLHTTPRequestSupported and success object checking supplied 
			by Jakob of http://Mentalized.net/ */

/* The licence is simple, use however you want, but leave attribution to any authors
   listed above, including yourself :-) */

function xmlHTTPRequest(url, method, data) {
  if (!method) method = "GET";
  if (!data) data = null;
  req = xmlHTTPRequestObject();
  if (req) {
	  req.open (method, url, false);
	  req.send (data);
	  return req.responseText;
  }
  return false;
}

function xmlHTTPAsyncRequest(url, method, data, callbackr) {
  if (!method) method = "GET";
  if (!data) data = null;
  req = xmlHTTPRequestObject();
  if (req) {
  	eval ('req.onreadystatechange = ' + callbackr + ';');
	req.open (method, url, true);
	req.send (data);
	return req
  }
}

function xmlHTTPRequestObject() {
	var obj = false;
	var objectIDs = new Array(
		"Microsoft.XMLHTTP",
		"Msxml2.XMLHTTP",
		"MSXML2.XMLHTTP.3.0",
		"MSXML2.XMLHTTP.4.0"
	);
	var success = false;

	for (i=0; !success && i < objectIDs.length; i++) {
		try {
			obj = new ActiveXObject(objectIDs[i]);
			success = true;
		} catch (e) { obj = false; }
	}

	if (!obj)
		obj = new XMLHttpRequest();

	return obj;
}

function isXMLHTTPRequestSupported() {
	return xmlHTTPRequestObject != null;
}
/* End XMLHTTPRequest functions */