/**
 * Start page utulity
 */



/**
* LexLiveStartPageUtility object declaration.
* Contains methods for different purposes.
*/
LexLiveStartPageUtility = function() { };

LexLiveStartPageUtility.ParseUrl = function(url)
{
	var res = { 'Location': null, 'QueryString': null };

	var parts = url.split("?");
	if (parts.length < 2 || parts[1].length < 1)
	{
		res.Location = url;
		return res;
	}

	res.Location = parts[0];
	res.QueryString = {};

	var qs = parts[1];
	var qsItems = qs.split("&");
	for (var i = 0; i < qsItems.length; i++)
	{
		var ip = qsItems[i].split("=");
		if (ip.length == 2)
			res.QueryString[String.trim(ip[0])] = String.trim(ip[1]);
	}

	return res;
};


/**
* Extends String class
*
* @returns {string} Returns empty srting.
*/
String.Empty = '';

/**
* Extends String class. Checks if the string is null or empty.
*
* @param {string} s String to check.
*
* @returns {bool} Returns true if the string is null or empty; false otherwise.
*/
String.isNullOrEmpty = function String$isNullOrEmpty(s)
{
	return !s || !s.length;
};

/**
* Extends String class. Removes spaces on both sides of a string.
*
* @param {string} str String to trim.
*
* @returns {string} Returns trimmed string.
*/
String.trim = function(str)
{
	if (!str)
		return str;

	var str = str.replace(/^\s\s*/, ''), ws = /\s/, i = str.length;
	while (ws.test(str.charAt(--i)));
	return str.slice(0, i + 1);
};

/**
* Extends String class. Adds 'px' to the end.
*
* @param {int} pxValue Pixels.
*
* @returns {string} Returns string in pixel format.
*/
String.formatPixel = function(pxValue)
{
	return String.format('{0}px', pxValue);
};
