/**
* adds an event to the body onload event
*/
function addEvent( obj, type, fn ) {
  if ( obj.attachEvent ) {
    obj['e'+type+fn] = fn;
    obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
    obj.attachEvent( 'on'+type, obj[type+fn] );
  } else
    obj.addEventListener( type, fn, false );
}

/**
* removes an event from the body onload event
*/
function removeEvent( obj, type, fn ) {
  if ( obj.detachEvent ) {
    obj.detachEvent( 'on'+type, obj[type+fn] );
    obj[type+fn] = null;
  } else
    obj.removeEventListener( type, fn, false );
}

function getCookie(c_name) {
	if (document.cookie.length > 0) {
		c_start = document.cookie.indexOf(c_name + "=");
		if (c_start != -1) { 
			c_start = c_start + c_name.length + 1; 
		
			c_end	= document.cookie.indexOf(";",c_start);
			if (c_end == -1)
				c_end = document.cookie.length;
			
			return unescape(document.cookie.substring(c_start,c_end));
    	} 
	}
	return "";
}

function setCookie(cookieName, cookieValue, nDays) {
	var today	= new Date();
 	var expire	= new Date();
 	if (nDays == null || nDays == 0)
 		nDays = 1;
 	expire.setTime(today.getTime() + 1000*3600000*24*nDays);
 	document.cookie	= cookieName + "="+escape(cookieValue)+ ";expires="+expire.toGMTString();
}

/** creates and handles a new XMLHttpRequest */
function xmlhttpGet(strURL, strFunc) {
	var xmlHttpReq = false;
	if (window.XMLHttpRequest) {
		/* Mozilla/Safari */
		xmlHttpReq = new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {
		/* Internet Explorer */
		try {
			xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) {
			try {
				xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e) {
		      alert("Sorry but your browser does not support AJAX so this site may not load correctly for you.");
		      return false;
		    }
		}
	}
	xmlHttpReq.open('GET', strURL, true);
	xmlHttpReq.onreadystatechange = function() {
	  if (xmlHttpReq.readyState == 4) {
	     // only if "OK"
			if (xmlHttpReq.status == 200) {
				strFunc(xmlHttpReq);
			}
	  } //state=4
	} //function
	xmlHttpReq.send(null);
}

String.prototype.ltrim	= function () { return this.replace(/^\s+/,""); };
String.prototype.rtrim	= function () { return this.replace(/\s+$/,""); };
String.prototype.trim	= function () { return this.ltrim().rtrim(); };

