/**
 * @description: Remove all extra whitespaces and remove spaces at the beginning and ending of a string
 * @params: string 
 * @return: string
 */
function trimAll (str){
	return str.replace(/^\s+|\s+$/g,'').replace(/\s+/g,' ');
}

/**
 * @description: Checks if the param string or array is empty
 * @params: string / array
 * @return: true or false
 */
function isEmail (str) {
	return /\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/.test(trimAll(str));
}

/**
 * @description: Detect mobile devices
 * @params: string 
 * @return: boolean
 */
function isMobileClient(userAgent) {
	var mobileClients = [
		"midp",
		"240x320",
		"blackberry",
		"netfront",
		"nokia",
		"panasonic",
		"portalmmm",
		"sharp",
		"sie-",
		"sonyericsson",
		"symbian",
		"windows ce",
		"benq",
		"mda",
		"mot-",
		"opera mini",
		"philips",
		"pocket pc",
		"sagem",
		"samsung",
		"sda",
		"sgh-",
		"vodafone",
		"xda",
		"android",
		"ipad"
	];
	userAgent = userAgent.toLowerCase();
	for (var i in mobileClients) {
		if (userAgent.indexOf(mobileClients[i]) != -1) {
			return true;
		}
	}
    return false;
};
