/*******************************************************************************
' Function Name		ClearText
'
' Description		This function is used to clear the text in text box
'*******************************************************************************/
function ClearText(txtControl)
{
	if (document.getElementById(txtControl)!= null)
	{ 
		document.getElementById(txtControl).value = "";
		document.getElementById(txtControl).focus();
	}
}


/*******************************************************************************
' Function Name		OpenTestLink
'
' Description		This function is used to open a given url link
'*******************************************************************************/
function OpenTestLink(id)
{
	var txtUrl = fnTrim(document.getElementById(id).value);
	
	if (txtUrl != '' && fnIsValidUrl(txtUrl))
	{	
		if (txtUrl.substr(0,4).toLowerCase() == 'www.')
			txtUrl = 'http://' + txtUrl;
		window.open(txtUrl,'_blank');
	}
}


/*******************************************************************************
' Function Name		fnIsValidUrl
'
' Description		This function is used to check a given url link is valid or not
'*******************************************************************************/
function fnIsValidUrl(url)
{
	var str = url.replace('http://','');
	
	if (str == '' || (url.indexOf('http://') > -1 && str.substr(0,1) == '/'))
		return false;
	else
		return true;
	
}


/*******************************************************************************
' Function Name		fnOpenNewWindow				
'
' Description		This function opens a new window
'*******************************************************************************/
function fnOpenNewWindow(sUrl)
{
	window.open(sUrl);
}


/*******************************************************************************
' Function Name		fnMailLink			
'
' Description		This function mails a provided link
'*******************************************************************************/
function fnMailLink(sUrl)
{
	window.open(sUrl, 'OFTMessage', 'RESIZABLE=1,SCROLLBARS=YES,STATUS=0,TOOLBAR=0,width=50,height=20,top=50,left=50');
}


/*******************************************************************************
' Function Name		fnTrim			
'
' Description		This function trims a selected string
'*******************************************************************************/
function fnTrim(str)
{
	return str.replace(/^\s+|\s+$/g, '');
}
