//***************************************************************
//  Security Validation
//***************************************************************
function isValidEmail(s) {
	var regexp = /^((([a-z]|[A-Z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|\/|=|\?|\^|_|`|\{|\||\}|~)+(\.([a-z]|[A-Z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|\/|=|\?|\^|_|`|\{|\||\}|~)+)*)@((((([a-z]|[A-Z]|[0-9])([a-z]|[A-Z]|[0-9]|\-){0,61}([a-z]|[A-Z]|[0-9])\.))*([a-z]|[A-Z]|[0-9])([a-z]|[A-Z]|[0-9]|\-){0,61}([a-z]|[A-Z]|[0-9])\.)[\w]{2,4}|(((([0-9]){1,3}\.){3}([0-9]){1,3}))|(\[((([0-9]){1,3}\.){3}([0-9]){1,3})\])))$/
	return regexp.test(s);}
//***************************************************************
//  SBMX First Time User Error Checking
//***************************************************************
function chkSBMXRegForm(frmObj){
  var frm = frmObj;
  var chk = false;
    msg1 = "Please enter all of the required fields."
    msg2 = "Please enter a numeric telephone number."
    msg3 = "Please select a business unit."
    msg4 = "Please select a user type."
    msg5 = "Your email address is not valid. Please make sure it is correct."

  if ((frm.fName.value=="")||(frm.lName.value=="")||(frm.street.value=="")||(frm.city.value=="")||(frm.country.value=="")||
     (eval("frm.province.options[frm.province.selectedIndex].value") == 0)||
     (frm.postalCode.value=="")||(frm.busTelephone.value=="")||(frm.email.value=="")||(frm.loginName.value=="")||(frm.pssw.value==""))
      alert(msg1);
  else if (!isValidEmail(frm.email.value))
	  alert(msg5);
  else
    chk=true;
  
  if (chk)
  { 
   frm.sendform.value=true;   
     
    frm.submit();
  }
}
//***************************************************************
//  SBMX First Time User Error Checking
//***************************************************************
function chkSBMXUpdateForm(frmObj){
  var frm = frmObj;
  var chk = false;
    msg1 = "Please enter all of the required fields."
    msg2 = "Please enter a numeric telephone number."
    msg3 = "Please select a business unit."
    msg4 = "Please select a user type."
    msg5 = "Your email address is not valid. Please make sure it is correct."

  if ((frm.fName.value=="")||(frm.lName.value=="")||(frm.street.value=="")||(frm.city.value=="")||(frm.country.value=="")||
     (eval("frm.province.options[frm.province.selectedIndex].value") == 0)||
     (frm.postalCode.value=="")||(frm.busTelephone.value=="")||(frm.email.value==""))
      alert(msg1);
  else if (!isValidEmail(frm.email.value))
	  alert(msg5);
  else
    chk=true;
  
  if (chk)
  { 
   frm.sendform.value=true;   
     
    frm.submit();
  }
}
//*****************************************************************************
function chkFrm()
{
	if (trim(document.forms['frmLogin'].uname.value) == "" )
	{
		alert('Please enter your user name before continuing.');
		return -1;
	}
	if	(trim(document.forms['frmLogin'].pass.value) == "" )
	{
		alert('Please enter your password before continuing.');
		return -1;
	}
	document.forms['frmLogin'].submit();
}
//*****************************************************************************
function chkFrmPassword()
{
	if (trim(document.forms['frmLogin'].uname.value) == "" )
	{
		alert('Please enter your user name before continuing.');
		return -1;
	}
	document.forms['frmLogin'].submit();
}
//*****************************************************************************
function trim(s)  
{ 
	return ltrim(rtrim(s)); 
}
//*****************************************************************************
function ltrim(s) 
{ 
	return s.replace(/^\s+/g, "");
}
//*****************************************************************************
function rtrim(s) 
{ 
	return s.replace(/\s+$/g, "");
}
//*****************************************************************************
 function Mid(str, start, len)
/***
		IN: str - the string we are LEFTing
			start - our string's starting position (0 based!!)
			len - how many characters from start we want to get

		RETVAL: The substring from start to start+len
***/
{
		// Make sure start and len are within proper bounds
		if (start < 0 || len < 0) return "";

		var iEnd, iLen = String(str).length;
		if (start + len > iLen)
				iEnd = iLen;
		else
				iEnd = start + len;

		return String(str).substring(start,iEnd);
}
//*****************************************************************************
function Left(str, n)
/***
		IN: str - the string we are LEFTing
			n - the number of characters we want to return

		RETVAL: n characters from the left side of the string
***/
{
		if (n <= 0)     // Invalid bound, return blank string
				return "";
		else if (n > String(str).length)   // Invalid bound, return
				return str;                // entire string
		else // Valid bound, return appropriate substring
				return String(str).substring(0,n);
}
//*****************************************************************************
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//*****************************************************************************
if(screen){
topPos=0
leftPos=0
}
function getPage(thePage,wt,ht){
leftPos= (screen.width-wt)/2
topPos = (screen.height-ht)/2
newWin1 = window.open(thePage,'aWin','toolbars=no,resizeable=no,scrollbars=no,left='+leftPos+',top='+topPos+',width='+wt+',height='+ht)
}