// returns false is null reference is passed, true otherwise
function checkReference(obj)
{
	if (null == obj || 'undefined' == obj)
	{
		return false;
	}
	
	return true;
}

// returns false if null reference is passed or string is empty, true otherwise
function checkString(str)
{
	if (false == checkReference(str) || '' == str )
	{
		return false;
	}

	return true;
}

// returns false if null reference is passed or the number is invalid, true otherwise
function checkInteger(nr)
{
	if ( false == checkReference(nr) || true == isNaN(parseInt(nr, 10)) )
	{
		return false;
	}
	
	return true;
}


/****************************** Objects ********************************/

// ImageInfo object
function ImageInfo(src)
{
	this.src	= src;
}


// ColorInfo object
function ColorInfo(color)
{
	this.color = color;
}


// TextInfo object
function TextInfo(text)
{
	this.text = text;
}

/*************************** END - Objects *****************************/


function clearAllChildren(element)
{
	// test
	if (null == element)
	{
		return;
	}

	// remove container previous nodes
	if (element.hasChildNodes())
	{
		while (element.childNodes.length >= 1)
		{
			element.removeChild(element.firstChild);
		} 
	}
}

function verifyString(str)
{
    try
    {
        if (str + '' == '' || str + '' == 'undefined' || 0 == str.length)
        {
            throw 'Not a valid string';
        }
    }
    catch (err)
    {
        return false;
    }
    
    // ok
    return true;
}

function trimString(value)
{
	var newValue = value;
	
	// test
	if (null == newValue || 0 == newValue.length)
	{
		return newValue;
	}

	// trim
	newValue = newValue.replace( /^\s+/g, "" ); // strip leading
	newValue = newValue.replace( /\s+$/g, "" ); // strip trailing
	
	// ok
	return newValue;
}

function loadHomeLoadingImage(container)
{
	if (null == container)
	{
		return;
	}
	
	// create new img
    var imgTag = document.createElement('img');
	imgTag.src = '/IMG/Default/loading.gif';
	imgTag.className = 'home_loading_image';
	
	// create new div
	var dv = document.createElement('div');
	dv.className = 'product_summary_listing';
	
	// create new div
	var dv2 = document.createElement('div');
	dv2.style.position = 'relative';
	dv2.style.left = '300px';
	dv2.style.top = '100px';
	
	dv2.appendChild(imgTag);
	dv.appendChild(dv2);
	
	// add div with image
	container.appendChild(dv);
}