
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_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];}
}

function checkNumeric(objName,minval, maxval,comma,period,hyphen)
{
	var numberfield = objName;
	if (chkNumeric(objName,minval,maxval,comma,period,hyphen) == false)
	{
		numberfield.select();
		numberfield.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function chkNumeric(objName,minval,maxval,comma,period,hyphen)
{
var checkOK = "0123456789" + comma + period + hyphen;
var checkStr = objName;
var allValid = true;
var decPoints = 0;
var allNum = "";

for (i = 0;  i < checkStr.value.length;  i++)
{
ch = checkStr.value.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
if (ch != ",")
allNum += ch;
}
if (!allValid)
{	
alertsay = "Please enter only enter a numeric value";
alert(alertsay);
return (false);
}

// set the minimum and maximum
var chkVal = allNum;
var prsVal = parseInt(allNum);
if (chkVal != "" && !(prsVal >= minval && prsVal <= maxval))
{
alertsay = "Please enter a value greater than or "
alertsay = alertsay + "equal to \"" + minval + "\" and less than or "
alertsay = alertsay + "equal to \"" + maxval + "\" in the \"" + checkStr.name + "\" field."
alert(alertsay);
return (false);
}

return true;
}

function ValidateFreeEmail()

{
	    var em = document.getElementById('Item_2').value;
            em = em.toLowerCase();

            var foundmatch = false;
            if(!foundmatch) foundmatch = em.match(/yahoo.com$/);
            if(!foundmatch) foundmatch = em.match(/msn.com$/);
            if(!foundmatch) foundmatch = em.match(/hotmail.com$/);
            if(!foundmatch) foundmatch = em.match(/gmail.com$/);
            if(!foundmatch) foundmatch = em.match(/roadrunner.com$/);
            if(!foundmatch) foundmatch = em.match(/aol.com$/);
            if(!foundmatch) foundmatch = em.match(/comcast.net$/);
            if(!foundmatch) foundmatch = em.match(/mail.com$/);
            if(!foundmatch) foundmatch = em.match(/inbox.com$/);
            if(!foundmatch) foundmatch = em.match(/fastmail.com$/);
            if (foundmatch){

     //frmvalidator.AppendError(errormessage);
     alert("You are using a free email account, please provide a work email address");
     document.getElementById('Item_2').value = "";
     return false;

     }

else

     {

     return true;

     }

}

function getParameter( Parameter, URL )
{
  var Value = '';
	if ( !URL ) URL = document.location.search.substring(1);
  
  var Parameters = URL.split( '&' );

	for ( var i = 0; i < Parameters.length; i++ )
  {
		if ( Parameters[i].indexOf( Parameter + '=' ) > -1 )
    {
			Value = Parameters[i].substring( Parameters[i].indexOf( '=' ) + 1 );
      if ( Value == 'undefined' ) Value = '';
		}
	}
	return Value;
}

function Message_Box()
{
  var Msg_Text = '';
  if ( typeof( Page_Msg_Text ) != 'undefined' && Page_Msg_Text ) Msg_Text = Page_Msg_Text;

  if ( !Msg_Text && getParameter( 'ErrorMsg' ) ) Msg_Text = unescape( getParameter( 'ErrorMsg' ) );
  if ( !Msg_Text && getParameter( 'Msg_Text' ) ) Msg_Text = unescape( getParameter( 'Msg_Text' ) );

  if ( Msg_Text )
  {
    var Icon = '';
    if ( typeof( Page_Msg_Icon ) != 'undefined' && Page_Msg_Icon ) Icon = Page_Msg_Icon;
    if ( getParameter( 'Icon' ) ) Icon = getParameter( 'Icon' );
    if ( !Icon && ( Msg_Text.indexOf( 'ERROR' ) > -1 || Msg_Text.indexOf( 'not found' ) > -1 || 
         Msg_Text.indexOf( 'locked' ) > -1 ) ) Icon = 'problem';
    if ( !Icon && Msg_Text.indexOf( 'WARNING' ) > -1 ) Icon = 'warning';
    if ( !Icon ) Icon = 'training';
    if ( Msg_Text.indexOf( '%20' ) ) Msg_Text = unescape( Msg_Text );
    
    if ( Msg_Text.indexOf( '/'+'pages/wlp/index.html?ErrorMsg=' ) > -1 )
      Msg_Text = Msg_Text.replace( '/'+'pages/wlp/index.html?ErrorMsg=', '' );

    if ( Msg_Text.indexOf( 'Maximum_Invalid_Logins' ) > -1 || Msg_Text.indexOf( 'Account_Timeout' ) > -1 )
    {
      if ( Msg_Text.indexOf( 'Account_Timeout' ) > -1 )
        Msg_Text = 'You have exceed the number failed login attempts allowed by the system.  Your account has temporarily been locked.';
      else
        Msg_Text = 'You have exceed the number failed login attempts allowed by the system.  Your account has permenantly locked, please contact your system administrator.';
    }      
    else if ( Msg_Text.indexOf( 'Password_Invalid' ) > -1 )
      Msg_Text = 'Sorry, the email account and password conbination you used was not valid, please try again.';
    else if ( Msg_Text.indexOf( 'Invalid_Password_Reminder' ) > -1 )
      Msg_Text = Msg_Text.replace( 'ERROR: Invalid_Password_Reminder', 'Sorry, the password reminder email link can only be used once, please request another reminder.' );
    else if ( Msg_Text.indexOf( 'SUCCESS: Password_Updated' ) > -1 )
      Msg_Text = 'Your password has been successfully updated.';
    else 
      Msg_Text = Msg_Text.replace( 'ERROR: ', 'An error has occurred, please try again - <br>ERROR: ' );

    if ( Msg_Text.indexOf( '<' ) > -1 || Msg_Text.indexOf( '>' ) > -1 || Msg_Text.toLowerCase().indexOf( 'script' ) > -1  )
      Msg_Text = Msg_Text.replace( /\>/g, '&gt;' ).replace( /\</g, '&lt;' ).replace( /script/gi, 'scr<!-- -->ipt' );

    if ( Msg_Text.indexOf( '&lt;b&gt;' ) > -1 || Msg_Text.indexOf( '&lt;/b&gt;' ) > -1 )
      Msg_Text = Msg_Text.replace( /\&lt\;b\&gt\;/g, '<b>' ).replace( /\&lt\;\/b\&gt\;/g, '</b>' );
    if ( Msg_Text.indexOf( '&lt;br&gt;' ) > -1 )
      Msg_Text = Msg_Text.replace( /\&lt\;br\&gt\;/g, '<br>' );
/*
User_Not_Found, User_Update_Failed, User_Not_Group_Authorized, Password_Not_Alpha_Numeric, Password_Used_Before, Password_Is_Repetitive
Password_Can_Be_Guessed, Password_Contains_Name, Password_Contains_Email, Password_Too_Short, Password_Has_Not_Changed
*/
    
    var Str = '<IMG src="/admin-marketbright/images/icons/dot.gif" height=5><br>';
    Str += '<TABLE width="95%" border="0" cellspacing="0" cellpadding="0"><TR><TD>';
    Str += '<TABLE width="100%" border="0" style="border: 2px solid black" cellspacing="10" cellpadding="0">';
    Str += '<TR><TD width="30" align="center" id="Msg_Icon"><IMG src="/admin-marketbright/images/icons/'+Icon+'.gif"></TD>';
    Str += '<TD class="HelpText" id="Msg_Text">'+Msg_Text+'</TD></TR></TABLE></TD></TR></TABLE>';
    Str += '<IMG src="/admin-marketbright/images/icons/dot.gif" height=13><br>';

    document.write( Str );
    document.close();
  }
}
