// loads a dynamic script file
// param url: the url of the script: src='/scripts' + url
function loadScript(url, type)
{
	// create new string variable
	var sUrl = new String(url);

	// test value
	if (null == sUrl || 0 == sUrl.length)
	{
		return false;
	}

	// create script src
	var scriptSrc = '/scripts' + sUrl;

	// get head tags
	var headTags = document.getElementsByTagName('head');
	if (null == headTags || 0 == headTags.length)
	{
		return false;
	}

	// get first head tag
	var headTag = headTags[0];

	// create new script element
	var tempScript = document.createElement('script');
	tempScript.src = scriptSrc;

	var loaded = false;

	// get script tags
	var scripts = headTag.getElementsByTagName('script');
	if (null != scripts)
	{
		for (var i = 0; i < scripts.length; ++i)
		{
			if (tempScript.src == scripts[i].src)
			{
				loaded = true;
				break;
			}
		}
	}

	// load script
	if (false == loaded)
	{
		// create script tag string
		var sScript = new String();
		sScript += "<script type=\"" + (null == type ? 'text/javascript' : type) + "\" src=\"";
		sScript += scriptSrc;
		sScript += "\"></script>";

		// write the script
		document.write(sScript);
	}

	// done
	return true;
}

function getElementObj(frm, elemId)
{
	if (null != frm && null != elemId && elemId.length > 0)
	{
		return frm.elements[elemId];
	}
	
	return null;
}

function showMessage(msg)
{
	alert(msg);
}


function addHost(path)
{
	if (document.location.pathname.toLowerCase().indexOf('whizz4') > 0)
	{
		return location.host + '/whizz4' + path; 
	}
	
	return location.host + path; 
}

function verifyString(str)
{
	try
	{
		if (str + '' == '' || str + '' == 'undefined' || 0 == str.length)
		{
			throw 'Not a valid string';
		}
	}
	catch (err)
	{
		return false;
	}
	
	// ok
	return true;
}