function nl2br (str, is_xhtml) 
{
    breakTag = '<br />';
    if (typeof is_xhtml != 'undefined' && !is_xhtml) {
        breakTag = '<br>';
    }
    return (str + '').replace(/([^>]?)\n/g, '$1'+ breakTag +'\n');
}
function echeck(str)
{
	//var str=document.getElementById(x).value;
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	
	if (str.indexOf(at)==-1) return false;
	else if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) return false;
	else if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) return false;
	else if (str.indexOf(at,(lat+1))!=-1) return false;
	else if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) return false;
	else if (str.indexOf(dot,(lat+2))==-1) return false;
	else if (str.indexOf(" ")!=-1) return false;
	else return true;
}
function hidediv(div_id) 
{
	if (document.getElementById) 
	{ // DOM3 = IE5, NS6
		document.getElementById(div_id).style.visibility = 'hidden';
		document.getElementById(div_id).style.display = 'none';
	}
	else 
	{
		if (document.layers) 
		{ // Netscape 4
			document.div_id.visibility = 'hidden';
			document.div_id.display = 'none';
		}
		else 
		{ // IE 4
			document.all.div_id.style.visibility = 'hidden';
			document.all.div_id.style.display = 'none';
		}
	}
}
function showdiv(div_id) 
{
	if (document.getElementById) 
	{ // DOM3 = IE5, NS6
		document.getElementById(div_id).style.visibility = 'visible';
		document.getElementById(div_id).style.display = 'block';
	}
	else 
	{
		if (document.layers) 
		{ // Netscape 4
			document.div_id.visibility = 'visible';
			document.div_id.display = 'none';
		}
		else 
		{ // IE 4
			document.all.div_id.style.visibility = 'visible';
			document.all.div_id.style.display = 'none';
		}
	}
}
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function convert_html_entities(string)
{
	string = string.replace(/&amp;/g, '&'); //encode ampersand
	string = string.replace(/&quot;/g, '"'); //encode quote
	string = string.replace(/&apos;/g, "'"); //encode apostrophe
	string = string.replace(/&lt;/g, '<'); //encode less than
	string = string.replace(/&gt;/g, '>'); //encode greater than
	return string;
}