﻿// JScript File

String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}


function altRow(classN, color){
    var tables = document.getElementsByTagName("table");

    for (i = 0; i < tables.length; i++)
    {
        if (tables[i].className == classN || tables[i].id == classN)
        {
            var rows = tables[i].childNodes;

            if (rows[0].nodeName.toLowerCase() != "tr")
            {
                for (k = 0; k < rows.length; k++)
                {
                    if (rows[k].nodeName.toLowerCase() =="tr")
                    {
                        break;
                    }
                    else if (rows[k].nodeName.toLowerCase() =="tbody")
                    {
                        rows = rows[k].childNodes;
                        break;
                    }
                }
            }

            for (j = 0; j < rows.length; j++)
            {
                if (rows[j].nodeName.toLowerCase() =="tr")
                {
                    if (j % 2 == 0)
                    {
                        rows[j].className += "even";
                        if (color != '')
                        {
                            rows[j].style.backgroundColor = "#FFFFFF";
                        }
                    }
                    else
                    {
                        rows[j].className += "odd";
                        if (color != '')
                        {
                            rows[j].style.backgroundColor = color;
                        }
                    }
                }
            }
        }
    }
}

function ValidatePassword(source, arguments)
{
  if (arguments.Value != '' && arguments.Value.length < 7)
  {
    arguments.IsValid = false;
  }
  else
  {
    arguments.IsValid = true;
  }
}

function ValidateNotEmpty(source, arguments)
{
  if (arguments.Value == '' || arguments.Value == '- Please Select -')
  {
    arguments.IsValid = false;
  }
  else
  {
    arguments.IsValid = true;
  }
}

function ValidateEmail(source, arguments){
  validRegExp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  strEmail = arguments.Value;

   // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1) 
    {
        arguments.IsValid = false;
    } 
    else
    {
        arguments.IsValid = true;
    }
}

//Call the notifyScriptLoaded to indicate to the ScriptManager object that referenced script has finished loading.
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded(); 