
/************************************************************************
** _showArray(a):
** 	Array a;
** 	Returns String;
************************************************************************/
function _showArray(a){
	var s="";
	for (var prop in a){
		s += "["+prop+"]\t=\t"+a[prop]+"\n<br>";
	}
	return s;
}

/************************************************************************
** _splitOn(s,sep):
** 	String s;
** 	String sep;
** 	Returns Array();
************************************************************************/
function _splitOn(s,sep){
	if (s == null || s == "") { return "";}
	if (sep == null || sep == ""){ sep = " ";}
	var ax=0;
	var bx=0;
	var ix=0;
	var temp = new Array();
	while ( (bx=s.indexOf(sep,ax)) != -1 ) {
		temp[ix++] = s.substring(ax,bx);
		ax = bx + 1;
	}
	temp[ix] = s.substring(ax);
	return temp;
}

/************************************************************************
** _iswhite(c):
** 	Char c;
** 	Returns Boolean;
************************************************************************/
function _iswhite(c){
	var firstchar=c.charAt(0);
	if (c =="\t" || c==" " || c=="\n") {
		return true;
	} else {
		return false;
	}
}

/************************************************************************
** _noWhite(s):
** 	String s;
** 	Returns String;
** 	Removes ALL whitespace form string;
************************************************************************/
function _noWhite(s){
	var newS="";
	if (s == null || s == "") { return "";}
	for (i=0; i<s.length; i++){
		newS += ( _iswhite(s.charAt(i)) )? "":s.charAt(i);
	}
	return newS;
}


/************************************************************************
** _trim(s):
** 	String s;
** 	Returns String;
************************************************************************/
function _trim(s){
	if (s == null || s == "") { return "";}
	var lastidx=0;
	var c="";
	var buf="";
	var trimmed="";
	while ( lastidx < s.length && _iswhite(c=s.charAt(lastidx++)) ){
		continue;
	}
	lastidx--;
	while (lastidx < s.length) {
		c = s.charAt(lastidx++);
		if ( _iswhite(c) ) {
			buf += c;
		} else {
			trimmed += buf + c;
			buf = "";
		}
	}
	return trimmed;					
}

/************************************************************************
** _cookies2Array():
** 	Returns Array;
************************************************************************/
function _cookies2Array(){
	var temparr = new Array();
	var assocArray = new Array();
	var names="";
	var values="";
	var cookieString = document.cookie;
	temparr = _splitOn(cookieString,";");
	for (var idx=0; idx < temparr.length; idx++) {
		names = temparr[idx].substring(0,(temparr[idx]+"=").indexOf("="));
		values = temparr[idx].substring((temparr[idx]+"=").indexOf("=")+1);
		assocArray[_trim(unescape(names))]=unescape(values);
	}
	return assocArray;
}

/************************************************************************
** _setCookie():
** 	Returns true;
************************************************************************/
function _setCookie(name, value, expire) {
	document.cookie = name + "=" + escape(value) + "; path=/"
	+ ((expire == null) ? "" : ("; expires=" + expire.toGMTString()));
	return true;
}

/************************************************************************
** _getCookie():
** 	Wrapper for _cookies2Array();
** 	Returns unescaped string.
************************************************************************/
function _getCookie(name) {
	var val = _cookies2Array()[name];
	return (val == null) ? "":val;
}



