function isAgentBlocked() {
	//log(navigator.userAgent);
	/* 1D array */
	var white = ['MSIE 7', 'MSIE 8', 'MSIE 9'];//, 'Windows Phone 6.5'
	/* 2D array */
	var black = [
	              ['MSIE 5.5'],
	              ['MSIE 6.0'],
	              ['MIDP-1'],
	              ['Opera Mini'],
	              ['SymbianOS'],
	              ['webOS/1'],
	              ['CLDC-1']
	             ];
	for (var i = 0; i < white.length; i++) {
		if (navigator.userAgent.indexOf(white[i]) != -1) {
			return false;
		}
	}
	for (var i = 0; i < black.length; i++) {
		if (black[i] != null) {
			var c = black[i].length;
			for (var j = 0; j < black[i].length; j++) {
				if (navigator.userAgent.indexOf(black[i][j]) != -1) {
					c--;
				}
			}
			if (c == 0) return true;
		}
	}
	return false;
}

function innerLines(str) {
	var c = 0;
	var st = str.toLowerCase();
	var x = -1;
	while ((x = st.indexOf('<br>')) != -1) {
		c++;
		st = st.substring(x + 1);
	}
	return c + 1;
}

function log(msg) {
	document.getElementById('log').innerHTML += msg + '<br>';
}

function clearLog() {
	document.getElementById('log').innerHTML = '';
}

function now() {
	return (new Date()).getTime();
}

function getPostfix(filename) {
	if (!(MSIE || IPHONE) || MSIE9) {
		return filename;
	}
	/*
	if (filename.indexOf('circle') != -1) {
		/* exception for smoother animation *
		return filename;
	}
	*/
	var st = "";
	if (MSIE) st = '-mask';
	if (IPHONE) st = '-small';
	var i = filename.indexOf('.');
	var post = filename.substring(i);
	var fn = filename.substring(0, i);
	return fn + st + post;
}

function getOpacity(img) {
	if (img.style.opacity != null) {
		return img.style.opacity;
	}
	var tmp = img.style.filter;
	tmp = tmp.substring(tmp.indexOf('=') + 1);
	tmp = tmp.substring(0, tmp.length - 1);
	return parseInt(tmp)/100;
}

function setElemOpacity(element, opacity) {
	if (element.style.opacity != null) {
		element.style.opacity = Math.round(opacity * 100) / 100;
	} else {
		element.style.filter = 'alpha(opacity=' + Math.round(opacity * 100) + ')';
	}
}

String.prototype.endsWith = function(arg) {
	return (this.match(arg + "$") == arg);
};

String.prototype.startsWith = function(arg) {
	return (this.match("^" + arg) == arg);
};

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
};
