//<![CDATA[

var loadmodule = null;


function isUsername(string,minlength,maxlength)
{
	var valid = '/^[a-z][-a-z0-9_]{'+(minlength-1)+','+(maxlength-1)+'}$/';
	
	if (!minlength) minlength = 1;
	if (!maxlength) maxlength = 255;
	
	var result = (valid.test(string) && (string.length >= minlength) && (string.length <= maxlength));
	
	return result;
}

function isEmail(string)
{
	if (!string) return false;
	
	tfld = trim(string);
	
	var email = /^[^@]+@[^@.]+\.[^@]*\w\w$/  ;
	if (!email.test(tfld))
	{
		return false;
	}

	var email2 = /^[A-Za-z][\w.-]+@\w[\w.-]+\.[\w.-]*[A-Za-z][A-Za-z]$/  ;
	if (!email2.test(tfld)) 
	{
		return false;
	}
	
	return true;
}

function isAlphaNumeric(string)
{
   if (!string) return false;
   if (string == " ") return false;
   
   var iChars = "*|,\":<>[]{}`\';()@&$#%";

   for (var i = 0; i < string.length; i++) {
      if (iChars.indexOf(string.charAt(i)) != -1)
         return false;
   }
   return true;
}

function trim(str)
{
	return str.replace(/^\s+|\s+$/g, '');
}

function formatcurrency(st)
{
	st += "";
	var theValue = st;
	var finalString = '';
	
	if(theValue.length < 4)
	{
		finalString = theValue;
	}
	else
	{
		if(theValue.indexOf(".")==-1)
		{
			theValueEx = "";
		}
		else
		{
			temp = theValue.split(".");
			theValue=temp[0];
			theValueEx= "." + temp[1];
		}
		
		var modulus = theValue.length % 3
		var count = 0
		finalString = theValue.substring(0, modulus)
		
		if(modulus != 0) finalString += ','
		for(i = modulus; i < theValue.length; i++)
		{
			if(count == 3)
			{
				finalString += ',';
				count = 0;
			}
			finalString += theValue.charAt(i);
			count++;
		}
		finalString = finalString + theValueEx;
	}
	
	return finalString;
}


//	layout functions
function getURL(url) {
	window.location.href = url;
}

function popWin(mypage,myname,w,h,s,r) {
	var win = null;
	
	if ((h == 0) || (h == null)) h = screen.availHeight;
	if ((w == 0) || (w == null)) w = 986;
	
	LeftPosition = ((screen.width) && (w > 0)) ? (screen.width-w)/2 : 0;
	TopPosition = ((screen.height) && (h > 0)) ? (screen.height-h)/2 : screen.height - screen.availHeight;
	Scrollable = ((s == null) || (s == '1') || (s == 'yes') || (s == 'YES')) ? 'yes' : 'no';
	Resizable =  ((r == null) || (r == '1') || (r == 'yes') || (r == 'YES')) ? 'yes' : 'no';
	
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+Scrollable+',resizable='+Resizable;

	win = window.open(mypage,myname,settings);
	return false;
}

function copy_to_parent(s_elm, s_val) {
  eval('window.opener.frm.' + s_elm + ".value = '" + s_val + "'");
}

function confirm_action(target, vs_dialog, vs_href)
{
	if (confirm(vs_dialog))
	{
		target.window.location.href = vs_href;
	}
	return true;
}
//]]>