/******************************************************************************************************************************************************************
** Title: General javascript segédfv -ek
** Ver: 1.0
** Create: 2009.10.06
** Last mod: 2009.12.01
** Good for: ff, ie
** Description:	Általános segéd javascript fv -ek, főleg string műveletekhez
** Created by Zogmund
** E-mail: zogmund@freemail.hu
******************************************************************************************************************************************************************/

// String műveletek

function nl2br(text)
{
		return (text + '').replace(/([^>]?)\n/g, '$1'+ "<br />" +'\n');
}

function trim(stringToTrim)
{
		return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function getUrlGetParams()
{
	var getparams = window.location.href.slice(window.location.href.indexOf('?') + 1);
	var hashes = new Array();
	var vars = new Array();
	if (getparams.search('&') == -1) {
		hashes = getparams.split('&amp;');
	} else {
		hashes = getparams.split('&');
	}
	for (var i = 0; i < hashes.length; ++i)
	{
		hash = hashes[i].split('=');
		vars[hash[0]] = hash[1];
	}
	return vars;
}

// Típus eldöntő fv -ek
// by Matt Sinder: http://mattsnider.com/javascript/type-detection/

/* True when 'o' is not a member of a function. */
function isAlien(o) {return isObject(o) && ! isFunction(o.constructor);}

/* True when 'o' is a native JavaScript array */
function isArray(o) {return isObject(o) && o.constructor == Array;}

/* True when 'o' is the meta-type 'boolean' */
function isBoolean(o) {return 'boolean' === typeof o;}

/* True when 'o' is an object having the 'getMonth' method */
function isDate(o) {return isObject(o) && o.getMonth;}

/* True when 'o' is set and has children nodes or a node type */
function isDomElement(o) {return o && ("undefined" !== typeof o.childNodes || o.nodeType);}

/* True when 'o' is set, the native JavaScript event is defined, and 'o' has an event phase */
function isEvent(o){return o && "undefined" != typeof Event && o.eventPhase;}

/* True when 'o' is exactly equal to 'null' */
function isNull(o) {return null === o;}

/* True when 'o' is the meta-type 'function' */
function isFunction(o) {return 'function' == typeof o;}

/* True when 'o' is the meta-type 'number' and is finite */
function isNumber(o) {return "number" == typeof o && isFinite(o);}

/* True when 'o' is the meta-type 'object' or 'function' */
function isObject(o) {return (o && "object" == typeof o) || isFunction(o);}

/* True when 'o' has any value, including 0 and false, both of which are normally falsy */
function isSet(o) {return ((o || false === o || 0 === o) && ! isNull(o) && '' !== o && ! isUndefined(o));}

/* True when 'o' is of the meta-type 'string' */
function isString(o) {return 'string' == typeof o;}

/* True when 'o' is of the meta-type 'undefined' */
function isUndefined(o) {return 'undefined' == typeof o;}

/* True when 'o' does not have any member values set that are not functions */
function isEmpty(o) {
	var i, v;
	if (isObject(o)) {
		for (i in o) {
			v = o[i];
			if (! isUndefined(v) && ! isFunction(v)) {
				return false;
			}
		}
	}
	return true;
}


