// get browser
var agent       = navigator.userAgent.toLowerCase(); 
var isIE        = (navigator.appName == "Microsoft Internet Explorer") ? true : false;
var isNetscape6 = (!document.all && !document.layers && navigator.appName == "Netscape" && parseInt(navigator.appVersion) >=5) ? true : false;
var isMac       = (agent.indexOf("mac") != -1) ? true : false;
var isIE4       = (agent.indexOf("msie") != -1 && agent.indexOf("4.0;") != -1) ? true : false;
var isNetscape  = (agent.indexOf("mozilla") != -1 && agent.indexOf("4.") != -1) ? true : false;
var win2000     = ((agent.indexOf("winnt") != -1) || (agent.indexOf("windows nt 5.0") != -1)) ? true : false; 
var winXP       = ((agent.indexOf("winnt") != -1) || (agent.indexOf("windows nt 5.1") != -1)) ? true : false; 
var isWin       = (agent.indexOf("windows") != -1) ? true : false;
var isMoz       = (agent.indexOf("gecko") != -1) ? true : false;

function toggle_showhide(id) {

	var e = document.getElementById(id);
	toggle_showhide_e(e);
}

function toggle_showhide_e(e) {
	
	if(e.style.display != 'none')
		e.style.display = 'none';
	else
		e.style.display = '';	
}

function gen_show(id)
{
	var e = document.getElementById(id);
	e.style.display = '';
}

function gen_hide(id)
{
	var e = document.getElementById(id);
	e.style.display = 'none';
}

function trim(str)
{
	var trimmed = str.replace(/^\s+|\s+$/g, '') ;
	return trimmed;
}

/**
 * tells us if a variable has been defined
   example isdefined('window','my_var')
 */
function isdefined(object, variable)
{
	return (typeof(eval(object)[variable]) == "undefined")? false: true;
}


function is_numeric(n)
{

	return !isNaN(parseFloat(n)) && isFinite(n);

}
/* js message shown to user to confirm they want to delete a record */
function confirm_delete() {
	str='are you sure you want to delete this record';
	return confirm_delete_str(str) ;
}
function confirm_delete_str(str) {
   if (confirm(str)) {
    return true;
  } else {
    return false;
  }
}

function copyToClipboard(s)
{	

	if( window.clipboardData && clipboardData.setData )
	{
		
		clipboardData.setData("Text", s);
		alert('Email on clipboard now.');
	}
	else{
		alert('sorry only works in IE');
	}
	
}
