// -------------------------- DECLARE ------------------------- //
// Global variable for appending
var strGlobal;
// ------------------------------------------------------------ //


// --------------------------- INIT --------------------------- //
// ------------------------------------------------------------ //


// ------------------------- FUNCTION ------------------------- //
/**
 * This function allow to initialize or reset the global string.
 */
function initializeGlobal()
{
	strGlobal = "";
}

/**
 * This function allow to append a string with the global string.
 * @param str is a string.
 */
function appendGlobal(str)
{
	strGlobal += str;
}

/**
 * 
 * @param param is the param markup that we want to add the attribute.
 * @param nameAttribute is the attribute's name.
 * @param valueAttribute is the attribute's value.
 */
 function addAttribute(param, nameAttribute, valueAttribute)
 {
 	param.setAttribute("name", nameAttribute);
	param.setAttribute("value", valueAttribute);
 }

/**
 * Get the relative position of an object compared with the top left corner of the browser.
 * @param nameObject is the object's name that we want to know the relative position.
 * @param offset is the type of position: Top, Left, Right, Bottom
 */
function obtainAbsoluteObjectPosition(nameObject, offset)
{
	var val;
	var obj;
	// --------------------------- INIT --------------------------- //
	
	val = 0;
	obj = document.getElementById(nameObject);
	
	// Get the oldest parent (So, the browser) in order to have the absolute position of the object.
	while (obj && (obj.tagName != 'BODY'))
	{
		val += eval('obj.' + offset);
		obj = obj.offsetParent;
	}
	
	return val;
}

/**
 * Returns class of argument.
 * @param p_object is the object to obtain the class.
 * @return Returns class of argument otherwise undefined if it's not a valid JavaScript object.
 */
function obtainClass(p_object)
{
	var res;
	// -------------------------- DECLARE --------------------------//

	res = "undefined";
    if (p_object && p_object.constructor && p_object.constructor.toString)
    {
        var arr = p_object.constructor.toString().match(/function\s*(\w+)/);
		if (arr && arr.length == 2)
		{
			res = arr[1];
		}
    }
    
    return res.toString();
}
// ------------------------------------------------------------ //
