var srvurl = "http://www.myloc8ion.com/index.php/";
var srvurlbase = "http://www.myloc8ion.com/";

function roundToOneDecimal(v) {return Math.floor(0.5 + v * 10.0) / 10.0;}
function roundTo(v, decimals) {var p = Math.pow(10,decimals);return Math.floor(0.5 + v * p) / p;}
function pausefor(millis) {
	var date = new Date();
	var curDate = null;
	do { curDate = new Date(); }
	while(curDate-date < millis);
}
function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function trim(text) {  //remove leading and trailing blanks and CR
	var nl="\n";var nch=1;
	if(text.indexOf("\r\n") >= 0) {
		nl="\r\n";nch=2;//alert("found r n");
	}
	while (text.substr(text.length-nch, nch)==nl) {
		text=text.substr(0,text.length-nch);
	}
	while (text.substr(0,nch)==nl) {
		text=text.substr(nch);
	}
	while (text.substr(text.length-1)==" ") {
		text=text.substr(0,text.length-1);
	}
	while (text.substr(0,1)==" ") {
		text=text.substr(1);
	}
	return text;
}
function removeExtraSpaces(text,delim){
	if (delim == null) delim =" ";
	var tp = text.split(delim);
	var s = tp[0];
	for (var i=1; i<tp.length; i++) {
		if(tp[i].length>0) s+=delim+tp[i];
	}
	return s; 
}
